I've been using nestest.nes quite frequently and discovered that my emulator behaved wierd when using the (indirect),y test.
I traced the code and found the problem, nestest actually jumps to a wierd address that causes my emulator to go crazy, look at the code below:
It's the JMP that causes the problem, but as you can see, $300 is written too twice (see below) and "corrupts" the address that is being jumped to.
Anyone knows why nestest does this? I've removed some "uninteresting" parts of the code that wasn't affecting the JMP....
0000DB7E: A9 00 lda #$00
0000DB80: 8D FF 02 sta $02FF
0000DB83: A9 01 lda #$01
0000DB85: 8D 00 03 sta $0300
----
0000DB9C: A9 A9 lda #$A9
0000DB9E: 8D 00 03 sta $0300
---
0000DBAB: 20 B5 DB jsr $DBB5
--
0000DBB4: 60 rts
--
0000DBB5: 6C FF 02 jmp ($02FF)
---
Nestest.nes wierd-stuff(?)
Moderator: Moderators
Re: Nestest.nes wierd-stuff(?)
On a 6502 (not a 65C02 or 65C816), the instruction JMP ($02FF) has absolutely nothing to do with address $0300. It reads from $02FF and $0200.oRBIT2002 wrote:but as you can see, $300 is written too twice (see below) and "corrupts" the address that is being jumped to.
[snip]
0000DBB5: 6C FF 02 jmp ($02FF)
---
Re: Nestest.nes wierd-stuff(?)
As you say, this "jmp $xxFF bug" exists on older NMOS 6502 (such as the NES cpu) but not newer CMOS 65C02, and the bug is also fixed in the 65C816 (which the SNES cpu core is based on). A while ago someone (anomie?) verified that the bug is definitely fixed on an SNES (even in emulation mode it would read $02FF and $0300).tepples wrote:On a 6502 (not a 65C02 or 65C816), the instruction JMP ($02FF) has absolutely nothing to do with address $0300. It reads from $02FF and $0200.
"Table 8-1: Caveats" in the 65C816 datasheet (http://www.westerndesigncenter.com/wdc/ ... 5c816s.pdf) has this to say:
Compatibility issue: B. Jump Indirect Operand=XXFF
NMOS 6502: 5 cycles and invalid page crossing
W65C02/W65C02S: 6 cycles
W65C816S: 5 cycles
So it is consistent with the "invalid page crossing" occuring only on the original NMOS 6502.