Hi everybody,
A little introduction:
In the past (1990-1999) I used to build test equipment for a smal company here in the Netherlands using the Texas tms370 microcontrollers programmed in assembly language. Now for hobby I started programming in assembler the atmega368p microcontroller building little routines first that I can use for my projects. I needed to copy variables from program memory to some of the first 16 registers and found the solution here below. It works fine. Values from Test_Value are copied to cnt3 to cnt0. (r6,r7,r8 and r9). What I don't understand is why I need the <<1 shift to left option to load the address of table Test_Value to index pointers ZH and ZL. Does anyone know?
ldi ZH,high(Test_Value<<1)
ldi ZL,low(Test_Value<<1)
lpm cnt3,Z+ ;
lpm cnt2,Z+ ;
lpm cnt1,Z+ ;
lpm cnt0,Z+ ;
Test_Value:
; test value 12345678
.db 0x00,0xbc,0x61,0x4e