It is currently Mon Oct 16, 2017 9:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Mar 03, 2017 7:55 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
If a game attempts to access a location past the end of 64k address space with indirect addressing, does this wrap all the way back to ZP, or only within the last page?


Top
 Profile  
 
PostPosted: Fri Mar 03, 2017 8:04 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1768
Location: DIGDUG
WDC programming the 65816 manual, page 98

Quote:
On the 6502, 65C02, and 65802, if an index plus its base would exceed $FFFF, it wraps to continue
from the beginning of the 64K bank zero; that is, when index is added to base, any carry out of the low-order
sixteen bits lost.


The next one past ffff is 0000, yes, zero page.

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


Top
 Profile  
 
PostPosted: Fri Mar 03, 2017 8:17 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
*warns the programmer that bad things are happening*


Top
 Profile  
 
PostPosted: Fri Mar 03, 2017 8:22 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5706
Location: Canada
The same thing happens with ZP indexing too, by the way. (The relevant instructions wrap within the ZP, they won't go into $1XX) I don't think this comes up very often though.

There's also a weird wrap with indirect pointers placed at $FF, or JMP ($XXFF) where the high byte doesn't get incremented to fetch the second half of the pointer. i.e. ($FF) is the pointer at $00:$FF, not $100:$FF. (Probably comes up even less often.)


Top
 Profile  
 
PostPosted: Sat Mar 04, 2017 7:31 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7223
Location: Chexbres, VD, Switzerland
GradualGames wrote:
If a game attempts to access a location past the end of 64k address space with indirect addressing, does this wrap all the way back to ZP, or only within the last page?

I don't think there's any question to add there. The same principle of $ff + $01 = $00 applies everywhere in digital electronics, it would be totally weird to have it stick to $ff. Such a behaviour is totally unnatural and requires extra circuitery to work. Some advanced CPUs have instructions to do such calculation, which are useful for example when mixing audio. However it is always explicitely mentionned when such a saturation is implemented. There for your question is a non-question - obviously going past $ffff will roll back to $0000.


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 7 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