RET

By Vesper Vei
1 minute read

Table of Contents

  1. RET (ret)
    1. Basic purpose
    2. Instruction execution process
    3. Instruction format
    4. Behavioral characteristics
    5. Common uses

RET (ret)

Basic purpose

RET pops the return address from the top of the stack and jumps to it; it is the exit instruction used when a function finishes execution. Equivalent behavior:

pop rip

Immediate version:

ret 8

Equivalent to:

pop rip
add rsp, 8

Used by calling conventions to clean up arguments.

Instruction execution process

  1. Read the return address from RSP and assign it to RIP
  2. Increase RSP by 8 (x64)

Instruction format

ret
ret imm16

Behavioral characteristics

Common uses


Relationship Graph

Loading graph...