LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What does call and ret actually do internally?

call pushes the address of the next instruction onto the stack and jumps to the target; ret pops that address and jumps back to it.

call pushes the return address (address of the next instruction) onto the stack and jumps to the target; ret pops that address into %rip and jumps back, restoring %rsp.

* call ≡ push return-addr ; jmp target (%rsp −= 8). ret ≡ pop → %rip ; %rsp += 8. The value at (%rsp) on entry to a callee is its return address. *

call <function>

is equivalent to:

push %rip
jmp  <function>

(Pushes the address of the instruction after call, then jumps)

ret

is equivalent to:

pop %rip

(Pops the return address from the stack into the program counter)

Key consequence: After call, %rsp is 8 bytes lower. The value at (%rsp) inside the called function is the return address.

Note: This is why functions that call other functions must keep the stack 16-byte aligned — call pushes 8 bytes, so the function prologue often does sub $8, %rsp or push %rbx to re-align.

Go deeper:

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 14, 2026