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: Fri, 6 Feb 2009 23:11:13 +0100
User-agent: Mutt/1.5.11

As Weddington, Eric wrote:

> I created a temporary variable, and gave it the "d" constraint. The
> compiler then created assembly code to initialize that variable
> (register) to 0, and then the next line overwrote that register with
> the value read in from the I/O register. Very strange.

Strange, indeed.  This is the assembly code GCC 4.3.x generates for
the code snippet I sent in my previous message:

/* #APP */
 ;  27 "foo.c" 1
        in r24, 53
        ori r24, 96
        out 53, r24
        andi r24, -33
        out 53, r24
 ;  0 "" 2

GCC 4.2.x generates the same, modulo the line number comments.  This
generated code is completely independent of the -Ox option in effect
(well, that's been the rationale behind hacking it in inline asm
anyway).

I think that's pretty much the code you want.  No additional
initialization to 0 (no need for that anyway, local variables are
never initialized).

> Besides why would I need to create a temporary, named "variable"
> when that variable doesn't really do anything.

It's just an auxiliary construct so the register allocator gets
something to chew on.  By adding your "d" constraint for it, if top
registers (>= r16) gets scarce, it can weigh out which one to free up,
and pass on into your assembly snippet.  Implicitly, your code
essentially does the same, it's only that I'm not sure whether your
code snippet will always generate the code you want while I'm pretty
sure my suggestion will do (because the actual OUT handling there is
completely explicit).

-- 
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]