4-21
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
In Figure 4-7, an ENTER instruction at the beginning of the MAIN procedure creates three
doublewords of dynamic storage for MAIN, but copies no pointers from other stack frames. The
first doubleword in the display holds a copy of the last value in the EBP register before the
ENTER instruction was executed. The second doubleword holds a copy of the contents of the
EBP register following the ENTER instruction. After the instruction is executed, the EBP
register points to the first doubleword pushed on the stack, and the ESP register points to the last
doubleword in the stack frame.
When MAIN calls procedure A, the ENTER instruction creates a new display (refer to Figure
4-8). The first doubleword is the last value held in MAINs EBP register. The second double-
word is a pointer to MAINs stack frame which is copied from the second doubleword in MAINs
display. This happens to be another copy of the last value held in MAINs EBP register. Proce-
dure A can access variables in MAIN because MAIN is at level 1. 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 MAINs EBP register. All dynamic variables for MAIN are
at fixed, positive offsets from this value.
Figure 4-7. Stack Frame after Entering the MAIN Procedure
EBP
Display
Old EBP
ESP
Mains EBP
Dynamic
Storage