POP
Pop the top value from the SP stack and assign it to the specified register.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $30 | 2 | 3 | POP B:_ | POP B:1 |
| $31 | 2 | 3 | POP P:_ | POP P:2 |
| $32 | 2 | 3 | POP I:_ | POP I:4 |
| $1A | 1 | 2 | POP FP | POP FP |
| $1B | 1 | 2 | POP GP | POP GP |
| $1C | 1 | 2 | POP IP | POP IP |
| $1D | 1 | 2 | POP FLAGS | POP FLAGS |
Notes
-
The SP stack is commonly used to store local variables and return addresses for function calls.
-
The SP stack grows forwards (pushing increases the
SPregister), whereas the GP stack grows backwards. (The "top" of the GP stack is actually the lowest memory address.) -
POPundoes the action of PUSH. -
For example, the effect of
POP P:6is to add 2 to theSPregister, becauseP:6is aPAIRregister. Then two bytes are read from the memory address indicated bySPand stored inP:6. -
POP IPundoes the action ofPUSH RETURN IP. This pair of instructions is used to call subroutines, for example Hybrix function calls. -
POP FLAGSpops the CPU flags as a single byte. -
Aside from the
POP FLAGSform, thePOPinstruction does not affect the CPU condition flags.