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.