Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!nexus.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@swell.actrix.gen.nz (David Empson) Subject: Re: 65816, obscure details Organization: Actrix Information Exchange Date: Sun, 2 Jan 1994 12:15:47 GMT Message-ID: References: Sender: dempson@actrix.gen.nz (David Empson) Lines: 105 In article jmk3@crux3.cit.cornell.edu (Jay Krell) writes: > > For what addressing modes can the effective address (or > intermediate effective address, for indirect modes) wrap > to the next bank? I looked in Eyes & Lichty's book, but couldn't find any totally clear information on this, so I've tried out each addressing mode to see how they behave. These are all full native mode (e=0, m=0, x=0). Emulation mode may be different in some cases. Addressing Mode Conditions Example Absolute LDA $FFFF Fetches high byte from next bank (DBR+1/$0000). Absolute long LDA $01FFFF Fetches high byte from next bank ($02/$0000). Direct DPR=$FF00 LDA $FF Fetches high byte from bank zero ($00/$0000). (Direct),Y DPR=$FF00 LDA ($FF),Y Fetches high byte of pointer from bank zero ($00/$0000). Data lookup wraps to next bank if pointer+Y >= $10000 (DBR+1). Fetches high byte of data from next bank if pointer+Y = $FFFF. [Direct],Y DPR=$FF00 LDA [$FF],Y Fetches high byte of pointer from bank zero ($00/$0000). Data lookup wraps to next bank if pointer+Y >= $10000. Fetches high byte of data from next bank if pointer+Y = $FFFF. (Direct,X) DPR=$FF00, X=$00FF LDA ($00,X) Fetches high byte of pointer from bank zero ($00/$0000). If resulting pointer is $FFFF, fetches high byte from next bank (DBR+1/$0000). Direct,X DPR=$FF00, X=$00FF LDA $00,X Fetches high byte from bank zero ($00/$0000). Direct,Y DPR=$FF00, Y=$00FF LDX $00,Y Fetches high byte from bank zero ($00/$0000). Absolute,X X=$00FF LDA $FF00,X Fetches high byte from next bank (DBR+1/$0000). If pointer+X >= $10000, fetches whole word from next bank. Abs Long,X X=$00FF LDA $04FF00,X Fetches high byte from next bank ($05/$0000). Pointer+X will wrap to following bank. Absolute,Y Y=$00FF LDA $FF00,Y Fetches high byte from next bank (DBR+1/$0000). If pointer+Y >= $10000, fetches whole word from next bank. (Absolute) JMP ($FFFF) Fetches high byte of pointer from bank zero ($00/$0000). NOTE: this addressing mode always gets the pointer from bank zero, not from the current data bank. (Absolute,X) X=$00FF JMP ($FF00,X) Fetches high byte of pointer from same bank (PBR/$0000). NOTE: this addressing mode always gets the pointer from the program bank, not from the current data bank. (Direct) DPR=$FF00 LDA ($FF) Fetches high byte of pointer from bank zero ($00/$0000). If pointer is $FFFF, fetches high byte from next bank (DBR+1/$0000). [Direct] DPR=$FF00 LDA [$FF] Fetches high byte of pointer from bank zero ($00/$0000). If pointer is $xxFFFF, fetches high byte from next bank (xx+1/$0000). Offset,S SP=$FF80 LDA $7F,S Fetches high byte from bank zero ($00/$0000). (Offset,S),Y SP=$FF80, Y=$0000 LDA ($7F,S),Y Fetches high byte of pointer from bank zero ($00/$0000). Data lookup wraps to next bank if pointer+Y >= $10000 (DBR+1). Fetches high byte of data from next bank if pointer+Y = $FFFF. I think that about covers it. If anyone can spot any errors or omissions in the above, let me know and I'll post an update. -- David Empson dempson@swell.actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!nexus.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@swell.actrix.gen.nz (David Empson) Subject: Re: 65816, obscure details Organization: Actrix Information Exchange Date: Sun, 2 Jan 1994 12:23:20 GMT Message-ID: References: Sender: dempson@actrix.gen.nz (David Empson) Lines: 36 In article jmk3@crux3.cit.cornell.edu (Jay Krell) writes: > Well, I looked through the Lichty/Eyes IIGS book > and found that besides [dp],y, (s),y wraps banks. > Non-indexed [] might too, but only by 1 byte. > I think absolute long indexed by X also wraps banks > > Indexing into the direct page apparently wraps within bank 0. Yep. The rules seem pretty simple. Any reference to the direct page will wrap within bank zero. This includes indexing from a direct page base address, as in LDA $xx,X and LDA ($xx,X). Two-byte lookups based on a direct-page mode will wrap within bank zero (i.e. if the direct page address calculation results in $FFFF). Any reference to the data bank or to an absolute long bank will wrap to the next bank. Note in particular that indirect modes on direct page have two stages: the pointer fetch is done using "direct" (i.e. bank zero only) but the pointer lookup (and indexing, if appropriate) is done using "absolute" or "absolute long", i.e. can wrap to the next bank. e.g. LDA ($xx),Y will fetch its pointer from $00FFFF and $00000 if the direct page address calculates to $FFFF, but the resulting pointer refers to the data bank, and can index into the following bank. Stack indexing works just like direct page indexing - the stack offset and value lookup will always occur within bank zero, but pointer lookup and indexing for LDA ($xx,S),Y can wrap into other banks, since it is dealing with the data bank. -- David Empson dempson@swell.actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand