[AVR] about Stack pointer

Thread Starter

roberto k.

Joined Apr 25, 2018
7
Hi,
Since the size of the stack pointer depends on the amount of data memory a microntroller contains
I want to understand what happens when stack pointer meets user's data in SRAM :eek:
If it's true that SP points to next available location, in the event that no memory location were available , what happens ?


Edit:
is that called overflow Stack ?
what is the underflow stack ?
Thanks
 

OBW0549

Joined Mar 2, 2015
3,566
Since the size of the stack pointer depends on the amount of data memory a microntroller contains I want to understand what happens when stack pointer meets user's data in SRAM :eek:
If the stack pointer ends up (e.g., through too many subroutine calls, too many pending interrupts, pushing too much data onto the stack, etc.) pointing to a memory location that is already being used to store a variable, the variable gets clobbered.

If it's true that SP points to next available location, in the event that no memory location were available , what happens ?
In this usage, "available" has nothing to do with whether or not the memory location is being used for something else, like holding a variable. The stack pointer simply points to the next memory location that will be used in the event something is pushed onto the stack.

[/QUOTE]is that called overflow Stack ?[/QUOTE]
Yes.

[/QUOTE]what is the underflow stack ?[/QUOTE]
Once everything has been pulled off the stack (i.e., the stack is empty and the stack pointer is pointing back to the stack's starting location), and you attempt to pull anything more off the stack, that's called "stack underflow."
 
Top