© Thomas Kunz 2000
SCE 574
101
   Stack Frame Pointers
äValues and references on the stack can’t just be popped off because the SP must remain pointed at the return address
äSolution
äLoad the SP into the base pointer BP and access the parameters through the BP
äNote: BP is used by many subprograms, so it must be saved first! Where? Programmer saves it on the stack.
äDS, SS, BP are also saved/restored to original status (by the programmer) if changed by a subprogram (more calling conventions)
äBP is said to point to a stack frame
BP(L)
BP(H)
OFFSET(L)
OFFSET(H)
SEGMENT(L)
SEGMENT(H)
P2 ADDR(L)
P2 ADDR(H)
P1 ADDR(L)
P1 ADDR(H)
Original BP value placed on
stack by PUSH BP
Offset of return address pushed
by CALL
Segment of return address
pushed by call (FAR call)
Address of second parameter
Address of first parameter
BP
BP+2
BP+4
BP+6
BP+8