Michael Geer

MC9S08JM16 Indexed Addressing

Discussion created by Michael Geer on May 30, 2012
Latest reply on Jun 5, 2012 by bigmac

Last question for today:

 

How do I use Indexed Addressing?

 

At the top of my code, in my RAM section, starts with something like ORG RAMStart, I am "declaring" some variables/registers, and at the end I want to have an "array" of registers, which could be a few or a lot of registers.

 

VAR1DS1

VAR2DS1

...

 

ARRAY:

ARRAY1DS1

ARRAY2DS1

ARRAY3DS1

ARRAY4DS1

...

 

I think putting a colon next to the first "ARRAY" is just making it a label, not sure.

 

So when I want to store something to the 2nd ARRAY down, would I use:

 

STAARRAY, X

 

assuming the accumulator has what I want to store, and X is 2.

 

What if the "array" ends up being 15 registers:

 

LDAARRAY, X

 

X is 15 to get the data that far down?

 

Does then name of the following ARRAY1, ARRAY2 even matter?

 

Or do I just use

 

ARRAYDS16

 

knowing I'll need 4-16 registers??

 

I'm really having a hard time understanding the way Assembly uses variables/registers compared to an HLL like Java :smileysad:

 

Thanks in advance,

 

-Mike

Outcomes