Stack - Yousef's Notes
Stack

Stack

The stack is a region of data memory that is set aside by the programmer specifically for the main purpose of storing the microprocessor’s state information when it branches to a subroutine. A stack is a last-in, first-out memory structure.

The stack segment is used for managing:

  • local variables
  • function arguments
  • control information such as return addresses.
    Stack Pointer stores the address of the last element added to the stack.

#Push

Decrements the value of the stack pointer and inserts value at that position.

#Pop

Read the value pointed by SP and increments the stack pointer.