I stumbled upon some strange compiling errors when using SBIW (Subtract Immediate from Word) in inline assembly. I want to use a register pair to do some simple 16-bit arithmetic (just incrementing/decrementing). I followed the instruction reference Instruction-set, p. 119 and used the code example shown on the page for my inline assembly:
asm volatile(
"ldi r25, 0xff \n"
"ldi r24, 0xff \n"
"sbiw r25:r24,1 \n"
);
This snippet does not compile and throws the error: register r24, r26, r28 or r30 required Switching r25 and r24, I get:
asm volatile(
"ldi r25, 0xff \n"
"ldi r24, 0xff \n"
"sbiw r24:r25, 1 \n"
);
still not compiling with an error `,' required, leading to:
asm volatile(
"ldi r25, 0xff \n"
"ldi r24, 0xff \n"
"sbiw r24, 1 \n"
);
which is compiling without an error. What am I overseeing here? Might add that I am not that versatile with asm, so maybe I just got the documentation wrong.
On a sidenote: are sbiw/adiw good choices for simple 16 bit arithmetic? Thanks for your input!