Search code examples
assemblyavrmemory-addressatmega8-bit

Why is this array pointer shifted by 1?


I am studying for an exam in microprocessors and this example question has come up:

the question

In summary of it, there is an array in program memory after the code:

array: .db 11,12,13,14,15,16,17,18,19,20

and in the code the pointer is loaded as:

ldi ZL, low(array<<1);

My question is why that shift by 1 is present in the code I was given. In my mind the label "array" should point right at the byte of memory that contains the number 11. Shifting left by 1 would multiply by 2, if I understand it correctly. Wouldn't that throw it way off? Is the code I was given just wrong or am I not understanding something?


Solution

  • From the description of LPM:

    The program memory is organized in 16 bit words while the Z pointer is a byte address.

    So the shift is done to convert from a word address to a byte address.