Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

Vol. 1 6-23
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
Therefore the base address for the dynamic storage used in MAIN is the current
address in the EBP register, plus four bytes to account for the saved contents of
MAIN’s EBP register. All dynamic variables for MAIN are at fixed, positive offsets from
this value.
When procedure A calls procedure B, the ENTER instruction creates a new display
(see Figure 6-9). The first doubleword holds a copy of the last value in procedure As
EBP register. The second and third doublewords are copies of the two stack frame
pointers in procedure As display. Procedure B can access variables in procedure A
and MAIN by using the stack frame pointers in its display.
Figure 6-7. Stack Frame After Entering the MAIN Procedure
Figure 6-8. Stack Frame After Entering Procedure A
EBP
Display
Old EBP
ESP
Main’s EBP
Dynamic
Storage
EBP
Display
Old EBP
ESP
Main’s EBP
Dynamic
Storage
Procedure A’s EBP
Main’s EBP
Main’s EBP