Hello,
I have a bug in my CPU where JMP Indirect reads the wrong address. I used the Nintendulator debugger to find out what it's supposed to be, and I think that the Indirect JMP instruction needs to wrap around at the end of a page.
The instruction is JMP($02FF) which is supposed to end up jumping to address 0300. I looked at the NES CPU memory in Nintendulator, and indeed the memory location 02FF has 00, and 0200 has 03 in it, which would result in 0300. This leads me to think the Indirect mode requires page wrap around.
However, I am unable to find anything about this in the MOS6502 documentation or the 6502 reference site.
So does anyone know if Indirect mode requires page wrap around or not?
Thanks!
Does the Indirect JMP instruction wrap around?
Moderator: Moderators
Re: Does the Indirect JMP instruction wrap around?
Yes, that's how JMP indirect works. I won't go through the trouble of looking for references now, but this is not a secret or an obscure behaviour by any means, it's mentioned fairly frequently in documents about the 6502. Maybe it's not mentioned along with the JMP instruction itself, but there's usually a section of observations somewhere that mentions this behavior.
Re: Does the Indirect JMP instruction wrap around?
Okay thanks!tokumaru wrote:Yes, that's how JMP indirect works. I won't go through the trouble of looking for references now, but this is not a secret or an obscure behaviour by any means, it's mentioned fairly frequently in documents about the 6502. Maybe it's not mentioned along with the JMP instruction itself, but there's usually a section of observations somewhere that mentions this behavior.
I did look for it in here:
http://archive.6502.org/datasheets/mos_ ... g_1975.pdf
and here:
http://www.obelisk.me.uk/6502/reference.html
and here:
http://www.obelisk.me.uk/6502/addressing.html
But couldn't find it anywhere.
Re: Does the Indirect JMP instruction wrap around?
This one mentions it very clearly in the section about the JMP instruction:timl132 wrote:http://www.obelisk.me.uk/6502/reference.html
NB:
An original 6502 has does not correctly fetch the target address if the indirect vector falls on a page boundary (e.g. $xxFF where xx is any value from $00 to $FF). In this case fetches the LSB from $xxFF as expected but takes the MSB from $xx00. This is fixed in some later chips like the 65SC02 so for compatibility always ensure the indirect vector is not at the end of the page.
Re: Does the Indirect JMP instruction wrap around?
Oh sorry, wow. I even remember reading that, but completely forgot about it.tokumaru wrote:This one mentions it very clearly in the section about the JMP instruction:timl132 wrote:http://www.obelisk.me.uk/6502/reference.html
NB:
An original 6502 has does not correctly fetch the target address if the indirect vector falls on a page boundary (e.g. $xxFF where xx is any value from $00 to $FF). In this case fetches the LSB from $xxFF as expected but takes the MSB from $xx00. This is fixed in some later chips like the 65SC02 so for compatibility always ensure the indirect vector is not at the end of the page.
Thanks for pointing out.