---
title: "Short note: stack memory"
subject: "Microprocessor"
chapter: 2
key: "semester_4/microprocessor:short-note-stack-memory"
source: https://www.bctengineer.com/q/semester_4/microprocessor/short-note-stack-memory
site: BCT Engineering
---

# Short note: stack memory

Microprocessor · Chapter 2: Programming with 8085 Microprocessor

- Asked in: 2068 Bhadra, 4 marks
- Video: [Stack Organization | Register Stack | Memory stack | COA | Lec-65 | Bhanu Priya](https://www.youtube.com/watch?v=5t_BIROKkLw) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/short-note-stack-memory
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-2

## Question

Write a short note on stack memory.

## Short answer

Stack memory is a LIFO RAM area addressed by the stack pointer (SP) that grows downward. PUSH decrements SP twice and stores a register pair; POP does the reverse. It handles CALL/RET, interrupts, and temporary register saving.

## Answer

A **stack** is a block of read/write memory used as a last-in first-out (LIFO) store: the last item pushed is the first one popped. In the 8085 the stack lies in RAM and is addressed by the 16-bit **stack pointer (SP)**, which always holds the address of the top of stack.

**Operation**
- The programmer loads SP at the start, e.g. `LXI SP,0FFFFH`.
- The stack grows **downward** (towards lower addresses).
- `PUSH rp`: SP ← SP−1, store high byte of the register pair; SP ← SP−1, store low byte.
- `POP rp`: low byte ← [SP], SP ← SP+1; high byte ← [SP], SP ← SP+1.

```text
 PUSH B  (B=12H, C=34H, SP=FFFFH)
 Address   Before   After
 FFFEH      --       12H   (B)
 FFFDH      --       34H   (C)  <- SP = FFFDH
```

**Uses**
1. Saving register contents temporarily (PUSH/POP) when a subroutine needs the registers.
2. `CALL` saves the return address on the stack; `RET` pops it into the PC.
3. Interrupts and `RST` instructions store the PC on the stack automatically.
4. Passing parameters to subroutines.

**Points to remember:** PUSH and POP work on register pairs (B, D, H, PSW) only; PUSH/POP must be balanced, and the stack must not overlap program or data area. Nested subroutines are possible because the stack stores return addresses in order. Stack depth is limited only by available memory.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which statement about the 8085 stack is correct?
   A. It is a FIFO area in ROM addressed by the program counter
   B. It is a set of internal registers inside the CPU
   C. It is a LIFO area in RAM, and SP holds the address of the top of the stack
   D. It is a LIFO area whose top is pointed to by the HL pair
   Answer: C. The stack is read/write memory used last-in first-out, and the 16-bit SP always holds the top-of-stack address. (Key point: Stack is LIFO in RAM; SP holds the top-of-stack address)

2. SP = FFFFH, B = 12H, C = 34H. After PUSH B, what is the state?
   A. FFFEH = 12H, FFFDH = 34H, SP = FFFDH
   B. FFFFH = 34H, 0000H = 12H, SP = 0001H
   C. FFFEH = 34H, FFFDH = 12H, SP = FFFDH
   D. FFFEH = 12H, FFFDH = 34H, SP = FFFFH
   Answer: A. PUSH decrements SP and stores the high byte (B) at FFFEH, then decrements again and stores the low byte (C) at FFFDH, leaving SP = FFFDH. (Key point: Stack grows downward: PUSH decrements SP, high byte stored first)

3. How does the stack allow a subroutine to return to the right place?
   A. RET reloads PC from the HL pair
   B. CALL saves the return address on the stack, and RET pops it back into the PC
   C. CALL stores the return address in the W and Z registers only
   D. The stack stores the subroutine's code so it can be re-run
   Answer: B. CALL pushes the return address onto the stack and RET pops it into PC; because addresses are stored in order, nested subroutines also work. (Key point: CALL saves the return address on the stack; RET pops it into PC)
