Nestest log question

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
max_sweat
Posts: 2
Joined: Thu Jul 09, 2009 7:54 pm

Nestest log question

Post by max_sweat » Thu Jul 09, 2009 7:59 pm

Hey everyone, Im just testing my CPU right now and I got a working nestest log from http://nesdev.com/bbs/viewtopic.php?p=6 ... ight=#6651 (nestest.log from Quietust).

My CPU seems to match that test log exactly except for this part:

Code: Select all

DBB5  6C FF 02  JMP ($02FF) = A900              A:60 X:07 Y:00 P:65 SP:F9 CYC:180 SL:63
0300  A9 AA     LDA #$AA                        A:60 X:07 Y:00 P:65 SP:F9 CYC:195 SL:63
0302  60        RTS                             A:AA X:07 Y:00 P:E5 SP:F9 
My CPU jumps to A900 after DBB5 instead of 0300 like this one, and for the life of my I cant figure out why it is supposed to jump to 0300. None of the registers look like they are set to make it do that, am I missing something completely obvious here? My CPU will eventually get back on track after 20 or so instructions, but this is really bugging me. Thanks!

User avatar
tokumaru
Posts: 11991
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru » Thu Jul 09, 2009 8:06 pm

Indirect jumps don't increment the high byte of the pointer to the destination address while fetching it in case the lower byte wraps around. So, if the low byte of the destination address comes from $02FF, the high one will come from $0200, not $0300.

max_sweat
Posts: 2
Joined: Thu Jul 09, 2009 7:54 pm

Post by max_sweat » Thu Jul 09, 2009 8:54 pm

That makes sense, thanks a bunch!

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu » Thu Jul 09, 2009 8:58 pm

Be sure to note this only affects JMP indirect, and only applies to the 6502. (The 65C02 doesn't have this problem). It's one of the few documented 6502 bugs. :)

Post Reply