9.2: Stack Instructions
- Page ID
- 19912
A push operation puts things onto the stack, and a pop operation takes things off the stack. The format for these commands is:
push <operand64> pop <operand64>
The operand can be a register or memory, but an immediate is not allowed. In general, push and pop operations will push the architecture size. Since the architecture is 64-bit, we will push and pop quadwords.
The stack is implemented in reverse in memory. Refer to the following sections for a detailed explanation of why.
Instruction |
Explanation |
push <op64> |
Push the 64-bit operand on the stack. |
Examples: |
push rax |
pop <op64> |
Pop the 64-bit operand from the stack. Adjusts rsp accordingly (rsp+8). The operand may not be an immediate value. Operand is overwritten. |
Examples: |
pop rax pop qword [qVal] pop rsi |
If more than 64-bits must be pushed, multiple push operations would be required. While it is possible to push and pop operands less than 64-bits, it is not recommended.
A more complete list of the instructions is located in Appendix B.