avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [RFC] Sleeping BOD API


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] [RFC] Sleeping BOD API
Date: Sat, 7 Feb 2009 11:07:32 +0100
User-agent: Mutt/1.5.11

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. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]