Skip to main content

PC and SP in CALL, RET, PUSH, POP

Short answer

PC holds the address of the next instruction; SP points to the top of stack. CALL pushes the return address and loads the subroutine address, decreasing SP by 2; RET pops it, increasing SP by 2. PUSH decrements SP and stores a register pair; POP loads a pair and increments SP.

What is the use of Program Counter and Stack Pointer registers of 8085 microprocessor? How these registers get affected during CALL, RET, PUSH and POP instructions explain with suitable examples.

Program Counter (PC)

A 16-bit register that holds the address of the next instruction to be fetched. It is incremented automatically after each byte fetched, so instructions execute in sequence. Jump, call and return load a new address into it.

Stack Pointer (SP)

A 16-bit register that holds the address of the top of the stack, a LIFO region of RAM used to save return addresses and register contents. In the 8085 the stack grows downward: SP is decremented on a push and incremented on a pop. It is initialised with LXI SP,addr.

Effect on PC and SP

CALL addr (3 bytes, 18T): Suppose CALL 4000H is at 2000H, SP = 3FFFH.

Before: PC = 2000H   SP = 3FFFH
Fetch bytes:  PC = 2003H (next instruction address)
SP-1 = 3FFEH  <- PCH = 20H
SP-2 = 3FFDH  <- PCL = 03H
After:  SP = 3FFDH     PC = 4000H

The return address is pushed on the stack, SP decreases by 2, and PC gets the subroutine address.

RET (1 byte, 10T):

PCL <- M[SP] = 03H ;  PCH <- M[SP+1] = 20H
SP  <- SP + 2 = 3FFFH
After:  PC = 2003H

SP increases by 2 and PC returns to the instruction after the CALL.

PUSH B (stores BC; 12T): PC increases only by 1 (fetching the opcode); SP changes.

Before: B = 12H, C = 34H, SP = 3FFFH
M[SP-1] = 3FFEH <- B = 12H
M[SP-2] = 3FFDH <- C = 34H
After:  SP = 3FFDH

POP D (loads DE; 10T):

E <- M[SP] ;  D <- M[SP+1] ;  SP <- SP + 2

If M[3FFDH] = 34H and M[3FFEH] = 12H: E = 34H, D = 12H, SP = 3FFFH.

PUSH/POP do not change the PC except for its normal increment, while CALL and RET load PC with a new value as well as using the stack.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 2 questions →