[Top][All Lists]

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

RE: [avr-gcc-list] something I don't understand with stack manipulation

From: Larry Barello
Subject: RE: [avr-gcc-list] something I don't understand with stack manipulation
Date: Wed, 24 Nov 2004 06:23:50 -0800

The interrupts are enabled *after* the instruction following the sei(), reti
or SREG update.  The order, below, was developed to minimize interrupt

Setting up stack frames and accessing the variables is expensive on the AVR.
I guess it can't be good at everything.  Fortunately one can pass a lot of
parameters before hitting the stack.  Things that force use of stack:
automatics that need to be referenced by address (&, buffers), variable call
parameters (printf), large structures.

Other C compilers (IAR, ICC, CodeVision) use a separate stack for
parameters, thus avoiding the SREG update issue.  However, with the
exception of IAR, the other compilers generate significantly more code than
GCC - GCC is wicked good at overall optimization.


-----Original Message-----
From: Bernard Fouché

Hi there.

I'm (still!) looking at the asm code produced by avr-gcc 3.4.2 with -Os.
When the compiler needs to give stack space to a local variable (for
instance a 10 bytes space), it produces:

    1d6e:       cd b7           in      r28, 0x3d       ; 61
    1d70:       de b7           in      r29, 0x3e       ; 62
    1d72:       2a 97           sbiw    r28, 0x0a       ; 10
    1d74:       0f b6           in      r0, 0x3f        ; 63
    1d76:       f8 94           cli
    1d78:       de bf           out     0x3e, r29       ; 62
    1d7a:       0f be           out     0x3f, r0        ; 63

reply via email to

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