Stack: The stack is a section of RAM used by the CPU to store information temporarily information could be data or an address.
- The register used to access the stack is called stack pointer register.
- Stack is used to store data temporary during any program execution.
- The 8 bit stack pointer is used to hold an internal RAM address which is called the top of stack.
- Generally 8051 used bank1 of internal RAM as the stack so the default stack pointer is 07H.
- The stack pointer in the 8051 only 8 bit wide which means that it can take value of 00 to FFH.
- When the 8051 is powered up the sp register contain value 07H.
- RAM location 08H is the first location begin used for the stack by the 8051.
- When data is retrieved from the stack the byte is read from the stack and then sp register increment.
- The stack is used during PUSH, POP, CALL, RET instruction.
- Stack pointer work on the principal of last ID first output (LIFO).