Calling longjmp restores the stack pointer, which because the function returned would point to a non-existent and potentially overwritten or corrupted stack frame.
22.
A weakness of this approach is that operating systems necessarily need to call lower-level code to, for instance, move the stack pointer.
23.
Through the use of the Stack Pointer ( R6 ) and Program Counter ( R7 ) as referenceable registers, there were 10 conceptual addressing modes available.
24.
A " stack pointer " register tracks the top of the stack; it is adjusted each time a value is " pushed " onto the stack.
25.
Additionally, a third index register ( Z ) was included, the stack pointer was widened to 16 bits, and the direct page addressing mode.
26.
If a pop operation on the stack causes the stack pointer to move past the origin of the stack, a " stack underflow " occurs.
27.
If a push operation causes the stack pointer to increment or decrement beyond the maximum extent of the stack, a " stack overflow " occurs.
28.
The stack area traditionally adjoined the heap area and they grew towards each other; when the stack pointer met the heap pointer, free memory was exhausted.
29.
If an interrupt is called, the current instruction pointer ( IP ) is saved on the stack, and the stack pointer ( SP ) is decremented.
30.
As data items are added to the stack, the stack pointer is displaced to indicate the current extent of the stack, which expands away from the origin.