How can I then tell avr-gcc that all registers but "r0" are clobbered?
In particular how do I tell it that X,Y,Z are clobbered?
For any register other than Y
, __tmp_reg__
and __zero_reg_
, add respective registers to the clobber list. For example, in order to clobber r30, you would
___asm ("..." ::: "r30");
// or
___asm ("..." ::: "30");
For the ramaining registers:
__tmp_reg__
and __zero_reg_
(R16, R17 on AVRrc; R0, R1 on all the other AVRs) has no effect since they are fixed registers (not allocated or handled by GCC's register allocator).__zero_reg__
by means of a MUL
instruction, you have to clr __zero_reg__
at the end of the asm template since otherwise, the following code will malfunction since avr-gcc expects __zero_reg__
to always contain 0
.