Search code examples
assemblyavr

Pseudo-register Z load into a single register?


I have trouble understanding the follow codes

;assume code for start of cseg
;and stack setup
.equ MAXNUM = 4
    ldi ZL, 0
    ldi ZH, 0 
    ldi r20, MAXNUM
loop_generate:
    lpm r0, Z+
    eor r0, ZL
...

First, what does it exactly mean by Z+? I google it and found "load Z and then increase Z by 1"?

Second, if the above is true, and Z is a pseudo-register, which means Z represents two registers. How can we load Z into r0?


Solution

  • lpm r0, Z+ loads r0 with the byte in program memory pointed to by the Z pseudo register, then adds 1 to Z.