
CS485G Spring 2015 22
(b) parameters
(c) local variables
(d) temporary locations (that don’t fit in registers)
6. On the x86, the %epb register points to the start of the frame, and the
%esp register points to the current top of the stack.
7. The stack (for Unix, at least), grows downward.
(a) pushl src subtracts 4 from %esp and writes the operand at the
new address.
(b) popl dest puts (%esp) in the destination and then adds 4 to
%esp.
(c) call label pushes the return address and then jumps to the la-
bel. The return address is the address of the instruction after
the call.
(d) ret pops the return address and then jumps to it.
8. Example:
804854e: e8 3d 06 00 00 call 8048b90 <main>
8048553: 50 pushl %eax
...
8048591: c3 ret
when %esp %eip
before call 0x108 0x804854e
after call 0x104 0x8048b90
before return 0x104 0x8048591
after return 0x108 0x8048553
9. Linux C frame contents, starting at bottom (right after caller’s frame)
(a) return address (placed by call)
(b) old %ebp
(c) saved registers and local variables
(d) parameters for the next call (“argument build”), last parameter
first
(e) %esp points to the last parameter.
10. Lecture 13, 2/13/2015
Kommentare zu diesen Handbüchern