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 ofpush. -
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.