PUSH

By Vesper Vei
2 minutes read

Table of Contents

  1. PUSH (push)
    1. Basic purpose
    2. Instruction execution process
    3. Instruction format
    4. Behavioral characteristics
    5. Equivalent expansion example
    6. ASCII stack change illustration
    7. Common uses

PUSH (push)

Basic purpose

The PUSH instruction pushes an operand onto the stack and updates the stack pointer.
In x86/x64, the stack grows toward lower addresses, so PUSH decreases the value of ESP/RSP first, then writes the data to the new top of the stack.

Instruction execution process

Using 64-bit as an example:

rsp = rsp - 8
[rsp] = 操作数

For 32-bit:

esp = esp - 4
[esp] = 操作数

Instruction format

The following operands are allowed:

The sign extension of immediate pushes is a unique behavior of PUSH.

Behavioral characteristics

Equivalent expansion example

push rax
; 等价于
sub rsp, 8
mov [rsp], rax
push 0x1234
sub rsp, 8
mov qword ptr [rsp], 0x0000000000001234

ASCII stack change illustration

Before execution:

rsp → +------------------+
| (旧栈数据) |
+------------------+

After executing push rax:

+------------------+
rsp → | rax 的值 |
+------------------+
| (旧栈数据) |

image.png

Common uses



Relationship Graph

Loading graph...