[En-Nut-Discussion] Not fixed!!!: Re: confirmed!!! Re: NutOS 4.4.0 on ARM7: possibly bug in NutEnterCritical / NutExitCritical

Nathan Moore nategoose at gmail.com
Fri Feb 22 20:18:55 CET 2008


>
> In this case, A is withing the stack frame (I think it's called like
> this).
> Push would use unallocated space. Although, I just got a bigger
> question.
> is there both a stack frame pointer AND a stack pointer?

On x86 there's a base pointer (bp or ebp) that can be used as a frame
pointer (theres instructions
that assume that it is) but there is a common optimization to use it as a
general purpose register
instead and do stack address calculations as StackPointer - offset rather
than FramePointer + offset.
On AVR if you compile with gcc without any optimizations it will try to
store a base pointer, using up
two registers.  If you do -O3 or -Os (not sure about others) it won't use
the frame pointer.  You can force
it by using -fno-omit-frame-pointer or in functions that use alloca() the
compiler will have to use it.



>
> If no, then either accessing local variables after pushing a value on
> the stack
> would access the wrong memory, or, the compiler has to keep track, how
> many values it already pushed on the stack. possible but tough. not
> sure if anybody does understand this - it's not important really, if
> NutEnterCritical is to change.


There's only so much info that compilers can figure out from inline asm.

Nathan



More information about the En-Nut-Discussion mailing list