Skip to main content

push/pushf/pop/popf

The push instructions push the value of the given register onto the stack. pushf pushes the flags.
The pop instructions pop an 8 bit value from the stack and write it to the given register. popf pops the flags.

The flags are encoded in an 8 bit value as follows: 0000CVZS (the sign flag is the least significant bit).

Prefixing these instructions with prefix_a16 results in undefined behavior. (The values would be written to or read from IO devices.)

InstructionEncodingSemanticsCycles
push reg8100 rrr 100spsp1;mem[sp]reg8\mathit{sp} \gets \mathit{sp} - 1; \mathit{mem}[\mathit{sp}] \gets \mathit{reg8}4
pushf00 110 100spsp1;mem[sp]flags\mathit{sp} \gets \mathit{sp} - 1; \mathit{mem}[\mathit{sp}] \gets \mathit{flags}4
pop reg8100 rrr 101reg8mem[sp];spsp+1\mathit{reg8} \gets \mathit{mem}[\mathit{sp}]; \mathit{sp} \gets \mathit{sp} + 14
popf00 110 101flagsmem[sp];spsp+1\mathit{flags} \gets \mathit{mem}[\mathit{sp}]; \mathit{sp} \gets \mathit{sp} + 14
  1. reg8 may not be [pi] (rrr = 110).