Hello everybody. Having a look at the ATmegaBOOT_168.c source code in Arduino release 1.6.5, I have difficulties in understanding the following :
Inside the forever loop in the code part dedicated to reception of a 'd' char (write memory), I can find the following code :
"wait_spm1: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm1 \n\t" "ldi r16,0x03 \n\t" //Erase page pointed to by Z "sts %0,r16 \n\t" "spm \n\t"
As far as I understand the code and the associated comments the first part is dedicated to waiting the SPMEN bit of the SPMCSR register being 0 and the second part to setting the SPMEN and PGERS bits to 1 to erase the memory page when SPM instruction is given.
My question is : in the LDS R16,%0 and STS %0,R16 instructions %0 seems to refer to the SPMCSR register address. But I don't understand the relationship in beetween %0 and 0x37 (0x57) that is supposed to be the register address according to the ATMega328p datasheet. Is there somewhere a %0 definition I'm missing or is there any % syntax asm specifities ?
Thanks for your help.