Microprocessors and Microcontrollers: Unit III: (a) 8051 Microcontroller

Stack and Stack Pointer

8051 Microcontroller

Review Questions : 1. Explain the operation of stack in 8051. 2. Define SP.

Stack and Stack Pointer

The stack refers to an area of internal RAM that is used to store and retrieve data quickly. The stack pointer register is used by the 8051 to hold an internal RAM address that is called top of stack. The stack pointer register is 8-bit wide. It is increased before data is stored during PUSH and CALL instructions and decremented after data is restored during POP and RET instructions.

The stack array can reside anywhere in on-chip RAM. The stack pointer is initialized to 07H after a reset. This causes the stack to begin at location 08H. The operation of stack and stack pointer is illustrated in Fig. 14.7.1.


The stack may overwrite data in the register banks, bit-addressable RAM and scratch-pad RAM. Thus to avoid conflict with the register, bit-addressable RAM and scratch-pad RAM data, the stack is initialized at a higher location in the internal RAM.

Review Questions

1. Explain the operation of stack in 8051.

2. Define SP.

Microprocessors and Microcontrollers: Unit III: (a) 8051 Microcontroller : Tag: : 8051 Microcontroller - Stack and Stack Pointer