It is currently Fri Aug 23, 2019 2:43 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Jul 28, 2019 7:33 am 
Offline

Joined: Tue Jul 23, 2019 10:41 am
Posts: 31
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!


Top
 Profile  
 
PostPosted: Sun Jul 28, 2019 8:16 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11399
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Sun Jul 28, 2019 8:29 am 
Offline

Joined: Tue Jul 23, 2019 10:41 am
Posts: 31
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.

Okay thanks!
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.


Top
 Profile  
 
PostPosted: Sun Jul 28, 2019 9:26 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11399
Location: Rio de Janeiro - Brazil
timl132 wrote:
http://www.obelisk.me.uk/6502/reference.html

This one mentions it very clearly in the section about the JMP instruction:

Quote:
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.


Top
 Profile  
 
PostPosted: Sun Jul 28, 2019 10:47 am 
Offline

Joined: Tue Jul 23, 2019 10:41 am
Posts: 31
tokumaru wrote:
timl132 wrote:
http://www.obelisk.me.uk/6502/reference.html

This one mentions it very clearly in the section about the JMP instruction:

Quote:
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.

Oh sorry, wow. I even remember reading that, but completely forgot about it.
Thanks for pointing out.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 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