[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Not naked but "topless" functions?
From: |
Kang Tin LAI |
Subject: |
Re: [avr-gcc-list] Not naked but "topless" functions? |
Date: |
Thu, 17 Oct 2002 22:05:37 +0800 |
> > There is nothing wrong with this prolog. The CLI clears the interrupt
> > enable flag. When the OUT instruction restores the flag by restoring SREG,
> > I still use the "naked" attribute in my RTOS, but I have the restriction
> > that you can't have more than 8 bytes of automatic variables in the top
> > level routine (GCC allocates registers, then stack frame variables).
> > Fortunately, GCC is so fantastic about register recycling, I can often get
> > 10-12 bytes worth of automatics before the compiler needs to resort to the
> > frame. Unfortunately, I have to inspect the resulting assembly all the
> > time to make sure modifying the code didn't introduce frame variables
> > which, of course, would break.
>
> Only 8? Once I tested how many register variables I can have, and when I used
> 30 of them, compiler put only 5 of them on the stack!? When I used 20, none
> was on the stack. Is there an fixed number of available registers? Some are
> reserved like r0,r1. All other registers are free or not?
>
It is depended on what type of local vars, for example:
char a, b, c, d;
If in your function, no "address" operation, such as &a; then all vars should be
hold by register, another case, in your function, a function call for example,
takes a address of a vars as argument:
swap(&a, &b);
then a and b will be allocated in the stack.
I believe that number of register allocated for local vars is not a concern.
--
---
Kang Tin LAI <address@hidden>
-----
avr-gcc-list at http://avr1.org
Re: [avr-gcc-list] Not naked but "topless" functions?, Kang Tin LAI, 2002/10/23