As Joerg Wunsch wrote:
> As your inline asm statement cannot ensure this cannot happen because
> it is not specified in the parameter lists of the statements (even if
> not right now, who knows what will happen with it next year?), I
> cannot really understand your resistance against using a temporary
> "variable" (which actually never exists as a variable at all but is
> just a register again, but a register that is guaranteed the same for
> both instructions).
I just noticed that tempreg must be an output register (because it's
destroyed inside), so here's a corrected version of my suggestion:
#define sleep_bod_disable() \
{ \
uint8_t tempreg; \
__asm__ __volatile__("in %[tempreg], %[mcucr]" "\n\t" \
"ori %[tempreg], %[bods_bodse]" "\n\t" \
"out %[mcucr], %[tempreg]" "\n\t" \
"andi %[tempreg], %[not_bodse]" "\n\t" \
"out %[mcucr], %[tempreg]" \
: [tempreg] "=&d" (tempreg) \
: [mcucr] "I" _SFR_IO_ADDR(MCUCR), \
[bods_bodse] "i" (_BV(BODS) | _BV(BODSE)), \
[not_bodse] "i" (~_BV(BODSE))); \
}
Btw., the practice to supply a dummy variable in place of a scratch
register that way is also mentioned in the inline asm cookbook.
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev