Skip to main content

POP

Pop the top value from the SP stack and assign it to the specified register.

OpcodeBytesCyclesFormExample
$3023POP B:_POP B:1
$3123POP P:_POP P:2
$3223POP I:_POP I:4
$1A12POP FPPOP FP
$1B12POP GPPOP GP
$1C12POP IPPOP IP
$1D12POP FLAGSPOP 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 SP register), whereas the GP stack grows backwards. (The "top" of the GP stack is actually the lowest memory address.)

  • POP undoes the action of PUSH.

  • For example, the effect of POP P:6 is to add 2 to the SP register, because P:6 is a PAIR register. Then two bytes are read from the memory address indicated by SP and stored in P:6.

  • POP IP undoes the action of PUSH RETURN IP. This pair of instructions is used to call subroutines, for example Hybrix function calls.

  • POP FLAGS pops the CPU flags as a single byte.

  • Aside from the POP FLAGS form, the POP instruction does not affect the CPU condition flags.