LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the purpose of the %rsp register?

%rsp is the stack pointer — it always points at the top (lowest in-use address) of the runtime stack.

The stack is the scratch area where functions keep return addresses, saved registers, and local variables, and %rsp is the single register that tracks its current top. A defining quirk of the x86 stack is that it grows downward: pushing data decreases %rsp. It's modified automatically by push, pop, call, and ret, and the calling convention requires it to be 16-byte aligned just before a call.

push %rax    # %rsp -= 8, then store %rax at (%rsp)
pop  %rbx    # load (%rsp) into %rbx, then %rsp += 8
call func    # push return address, then jump to func
ret          # pop return address into %rip and jump there

Warning: never rely on data stored below %rsp (at addresses smaller than it) unless you're using the System V red zone deliberately — signals, interrupts, and called functions are free to overwrite that space.

Go deeper:

From Quiz: REVE1 / The Processor Interface | Updated: Jul 14, 2026