It is currently Sun Oct 22, 2017 9:33 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Mar 18, 2016 8:53 am 
Offline
User avatar

Joined: Mon Apr 13, 2015 7:52 am
Posts: 6
http://www.thealmightyguru.com/Games/Hacking/Wiki/index.php?title=BRK
This is correct ? please tell me why. gentleman/lady thanks :mrgreen:


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 8:58 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19116
Location: NE Indiana, USA (NTSC)
In 6502 processors, BRK ($00 xx) calls the IRQ handler once. If the IRQ handler is just RTI, then it's the same as a NOP that just takes longer to run. But games may use the IRQ handler as a crash handler or to control raster splits.

So that page is incorrect. I encourage regulars of this board to do a few things:


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 10:00 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
Location: Rio de Janeiro - Brazil
xuling93 wrote:

That information is completely wrong.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 11:22 am 
Offline

Joined: Mon Nov 10, 2008 3:09 pm
Posts: 430
That BRK in Dragon Warrior 4 is probably an inline argument to the JSR before it, and not actually executed as an instruction.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 11:41 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5732
Location: Canada
AWJ wrote:
That BRK in Dragon Warrior 4 is probably an inline argument to the JSR before it, and not actually executed as an instruction.

No, it's a valid instruction. It calls the IRQ handler, if executed. (How would it be an "inline argument" to the JSR?)


Last edited by rainwarrior on Fri Mar 18, 2016 11:45 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 11:43 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
Information at said page is completely incorrect. Do not heed.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 12:27 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19116
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
AWJ wrote:
That BRK in Dragon Warrior 4 is probably an inline argument to the JSR before it, and not actually executed as an instruction.

No, it's a valid instruction. It calls the IRQ handler, if executed. (How would it be an "inline argument" to the JSR?)

I think the implication was that the $00 byte at that address is never executed. Instead, it is treated as data, and the called subroutine increases the program counter on the stack to skip the data after using it. The MLI system call interface in Apple ProDOS uses the same trick: each JSR $BF00 is followed by a syscall number and a pointer to the parameter block.

But the registration information came back fairly quickly. This leaves finding test ROMs that rely on BRK not being NOP.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 12:50 pm 
Offline

Joined: Sun Jan 31, 2016 9:55 pm
Posts: 31
I saw this page last summer when I was working on an emulator, with no prior knowledge of nes programming. It confused me quite a bit.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 12:54 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5732
Location: Canada
tepples wrote:
...the called subroutine increases the program counter on the stack to skip the data after using it.

Yeah, that makes sense. I guess that's actually the most compact way to create arguments for a function.

Of course, Dragon Warrior IV is not doing that:
Code:
1F:C52F:A9 00     LDA #$00
1F:C531:85 1F     STA $001F = #$00
1F:C533:8D 0A 05  STA $050A = #$00
1F:C536:8D 0B 05  STA $050B = #$00
1F:C539:8D 08 05  STA $0508 = #$00
1F:C53C:8D 09 05  STA $0509 = #$00
1F:C53F:8D 13 05  STA $0513 = #$02
1F:C542:60        RTS


I'm don't know if those two JSRs ever get executed, they could be vestigial code, but they do indeed look like code and not data to me. (They both point to very valid looking subroutines, like the one above.) Also it certainly does use BRK elsewhere in a functional way (seems to happen when talking text is gradually appearing).


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 1:03 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
I did a bunch of Google searches, trying to identify the source of this strange / incorrect page about BRK.

All of the 6502 (or derivative) chips have functioning BRK instructions.

I think,maybe, the misinformation comes from the fact that the B flag isn't saved...
http://nesdev.com/the%20'B'%20flag%20&% ... uction.txt

And, perhaps the author felt that without a B flag, the interrupt wouldn't trigger. ?

But. It is the i flag that triggers allows an interrupt, and that flag works fine.


Edit, also...its 7 cycles for BRK and 6 for RTI...so, not even close to 2 cycle NOP.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 1:56 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
Also...

Did anyone notice that I pointed out an error in a document on the nesdev page?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 2:00 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5732
Location: Canada
I don't know why that page still exists. There's a ton of misinformation on it. At the very least if we don't want to just get rid of it, we could shuffle all that information to a secondary page so that the nesdev.com main page primarily links to the Forum / Wiki and maybe a little less prominent link to all those legacy documents.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 2:57 pm 
Offline

Joined: Mon Nov 10, 2008 3:09 pm
Posts: 430
Hiryu no Ken Special uses BRK for inter-bank subroutine calls. Other Culture Brain games might do so as well.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 3:25 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19116
Location: NE Indiana, USA (NTSC)
I've updated the wiki page in question. Keep an eye on it to see if my change gets reverted. I need to think of a plan for the front page of nesdev.com.


Top
 Profile  
 
PostPosted: Fri Mar 18, 2016 4:33 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2963
Location: Tampere, Finland
tepples wrote:
This leaves finding test ROMs that rely on BRK not being NOP.

Blargg's NES CPU instruction tests contain a test a case for BRK: 15-brk

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group