EmbeddedRelated.com
Forums

Difference Between Stack Pointer and Frame Pointer

Started by Unknown July 1, 2005
On Tue, 05 Jul 2005 14:47:59 GMT, "Richard" <nospam@thanks.com> wrote:

>> Most AVR compilers have a data stack separate from the hardware stack. > >I'm interested in this statement. The IAR compiler is the only AVR compiler >I have come across that does this, and I've never been sure why. Any clues?
How many AVR compilers have you seen? The only one that _doesn't_ (AFAIK) is avr-gcc. The primary reason it that direct manipulation of the hardware stack pointer (SP) in the AVR is non-atomic (eight bits at a time, and interrupts must be disabled on writes to prevent ISRs from stomping all over memory), while the data stack pointer can be kept in a 16-bit general purpose register that supports 16-bit math. IOW, it makes code generation simpler, and the resulting code is both faster an smaller. Regards, -=Dave -- Change is inevitable, progress is not.