This example shows a stack, with ESP on the left, and EBP on the right.
ESP EBP
( higher addresses ) ( i,10 )
-------------------------
( i,12 ) | ? |
-------------------------
( 1 ) | B |
-------------------------
( 2,11 ) | A |
-------------------------
( 3,10 ) | address of ADD |
-------------------------
( 4,9 ) | EBP ( used by main ) | ( 5 )
.----- -------------------------
. | automatic |
. -------------------------
nn bytes | data |
. -------------------------
. | for 'sub' |
. -------------------------
( 6 ) | ( if used ) |
----- -------------------------
| | <-- where parameters for the
------------------------- next subroutine are put
( lower addresses )
Note: The numbers in parentheses indicate where the register points immediately after the numbered instruction on the previous page completes.