LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is a stack frame and what does it contain?

A stack frame is the slice of the stack belonging to one function invocation — holding its return address, saved registers, locals, and space to build arguments for functions it calls.

The anatomy of one stack frame from high to low address down to %rsp.

* One frame stacks (high to low) caller args 7+, the return address, an optional saved %rbp, saved registers, locals, and the next call's argument-build area down to %rsp. *

Each active function owns one frame; together they stack up to mirror the chain of in-progress calls. Laid out high to low addresses:

| arguments 7+      |  ← pushed by the caller
| return address    |  ← pushed by call
| saved %rbp        |  ← optional in x86-64
| saved registers   |  ← callee-saved regs this function uses
| local variables   |
| argument build    |  ← space for the next call's stack args
|                   |  ← %rsp

The frame pointer %rbp gives a stable anchor for accessing locals even as %rsp moves during the function:

  • IA-32 almost always uses it.
  • x86-64 frequently omits it (an optimization), addressing locals from %rsp instead.

When %rbp is needed: for variable-length arrays, and for debuggers that walk the call stack by following the saved-%rbp chain.

pushq %rbp          # save caller's frame pointer
movq  %rsp, %rbp    # set this frame's base
subq  $N, %rsp      # allocate locals

Go deeper:

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