The model
A function call transfers control while preserving enough state for the caller to resume. A calling convention defines how arguments, return values, registers, and stack alignment are handled. A stack frame commonly holds saved registers, local storage, and bookkeeping, though optimizers can keep values in registers or remove frames.
A concrete walk-through
When function A calls B, the machine records a return location and passes arguments according to the platform ABI. B may reserve stack space and save registers it must preserve. On return, it places the result where the caller expects and restores the control state required by the convention.
Costs and failure cases
Recursion creates nested activation state and can exhaust a finite stack. Tail-call elimination can reuse a frame when language and compiler rules permit it, but should not be assumed across every runtime. Stack layout and calling conventions vary by architecture and compiler.
Check your understanding
Trace a recursive function with input depth three. At each call, list the values that must remain available for the suspended caller after the deeper call returns.