I'm trying to do a very specific thing which I know how to do in assembly, but I'm lost on how to accomplish it using the avr-gcc compiler. This is WinAVR 2010 01 10 on an ATtiny461A
What I want to do is have the first few instructions of my program load the last value in the program memory, and compare it to some magic value. If it's correct, continue as normal, if incorrect just loop back on itself. This would go in __init()
#define last_byte_high 0x0F #define last_byte_low 0xFF #define magic_number 0xA5 loop: ldi ZH,last_byte_high ldi ZL,last_byte_low lpm r16,Z cpi r16,magic_number brne loop
I've tried going through the different options in the user manual below, but I'm having trouble even loading the address into the z register. Any ideas?