It is currently Tue Dec 11, 2018 5:36 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Aug 23, 2006 7:59 pm 
Offline

Joined: Sat Aug 19, 2006 2:03 pm
Posts: 34
in "Assembly in one step" (which is a great 6502 teacher, humbly i think) they list the two addressing modes like this:


Indexed Indirect (aa, X)
Indirect Indexed (aa), Y

Does that mean that these can only work with zero page addresses?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:20 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20853
Location: NE Indiana, USA (NTSC)
The indirect indexed modes read a pointer that has to be stored in zero page, but this pointer can point anywhere.
Code:
; Load address $FACE into a 16-bit pointer variable stored at zero page $B6
lda #$FA
sta $B7
lda #$CE
sta $B6

ldy #$10
lda ($B6),y

The last instruction reads from $FACE + $10 = $FADE.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 10:42 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2150
Location: Minneapolis, Minnesota, United States
I often use Indexed Indirect Addressing when I have a couple of addresses in RAM that are grouped together, like AI addresses to go to and stuff. But if you're just doing something like loading a NAM file, or doing CHR RAM stuff, or just loading from one particular address, use Indirect Indexed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 1:58 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7601
Location: Chexbres, VD, Switzerland
I'm unsure about the name of the adressing mode because they are confusing.
But you should retain the following :
lda [BlahBlah,X]
Will have the effect to load what is in the pointer found by adding the adress of [BlahBlah] and X, so X helps to determine wich pointer you use.
This instruction is usefull if you have several consecutives pointers in Z-Page RAM. However, you have to manually increment each pointer if they point to a table (wich they are likely to do).
Alternativly, the pointers doesn't need to be consecutive. You could also use the trick to read from either one pointer or the other in zero page RAM, have your [BlahBlah] set to zero, and just load the adres of the desired pointer in X.

lda [BlahBlah],Y
Will have the effect to read the adress of [BlahBlah], add the value of Y to it and finally use the final result as a pointer. This is used much more often than the other one (at least from my personnal experience), because it allow random acess to a pointed table, and you only need to keep the base adress of your table in [BlahBlah], and the Y register does the rest. If the pointed data may be more than 256 bytes, then you have to manually add the high part of the pointer to the high byte of BlahBlah, but you can still avoid to monkey with the low byte.

In summary, [BlahBlah,X] is one opcode that could be easily replaced by others, and is here mainly for code optimisation, but [BlahBlah],Y is really a important adressing mode, and you cannot go too far without using it.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 7:02 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20853
Location: NE Indiana, USA (NTSC)
Bregalad wrote:
I'm unsure about the name of the adressing mode because they are confusing.

Which is why I usually call them (d,x) and (d),y after how they appear in WDC's 65C816 opcode matrix. (I learned 6502 assembly on an Apple IIGS.)

Quote:
But you should retain the following :
lda [BlahBlah,X]
Will have the effect to load what is in the pointer found by adding the adress of [BlahBlah] and X, so X helps to determine wich pointer you use.
This instruction is usefull if you have several consecutives pointers in Z-Page RAM. However, you have to manually increment each pointer if they point to a table (wich they are likely to do).

I don't think I have ever used this addressing mode. But last night I brainstormed about places to use this, and then it hit me: it'd be ideal for fetching the pattern bytestream in a music playback engine. Here, the pointers would be stored at base+0, base+4, base+8, base+12, and base+16, for each of the 2A03's five channels.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 7:16 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7601
Location: Chexbres, VD, Switzerland
I use this adressing mode in both music engine I've written so far, but I think it is the only place I used it up now.
This is very usefull for data pointer that come up for each channel.

_________________
Life is complex: it has both real and imaginary components.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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