POP
16-Bit Load Group
Expansion:
POP
Usage:
pop {rr}
The POP instruction in Z80 assembly language is used to pop the contents of the stack back into a register pair. This is useful for retreiving temporary data that was preserved on the stack from registers before calling a subroutine.
| Instruction | Description | Opcode |
|---|---|---|
| POP AF | Pop a 16-bit value back off the stack into register AF | F1 |
| POP BC | Pop a 16-bit value back off the stack into register BC | C1 |
| POP DE | Pop a 16-bit value back off the stack into register DE | D1 |
| POP HL | Pop a 16-bit value back off the stack into register HL | E1 |
| POP IX | Pop a 16-bit value back off the stack into register IX | DDE1 |
| POP IY | Pop a 16-bit value back off the stack into register IY | FDE1 |
Example
; Example
ld bc, $1234 ; load the value $1234 into register pair BC
ld de, $5678 ; load the value $5678 into register pair DE
push bc ; push the contents of BC onto the stack
push de ; push the contents of DE onto the stack
; at this point, BC and DE are saved on the stack
; other operations can be performed here
pop de ; pop the contents from the stack back into DE
pop bc ; pop the contents from the stack back into BC
; now BC and DE have their original values restored