Ithaca College Machine-Level Programming IV: IA32 Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2013 * Modified slides.

Slides:



Advertisements
Similar presentations
Machine-Level Programming III: Procedures Feb. 8, 2000 Topics IA32 stack Stack-based languages Stack frames Register saving conventions Creating pointers.
Advertisements

University of Washington Procedures and Stacks II The Hardware/Software Interface CSE351 Winter 2013.
Machine Programming – Procedures and IA32 Stack CENG334: Introduction to Operating Systems Instructor: Erol Sahin Acknowledgement: Most of the slides are.
Carnegie Mellon Instructors: Randy Bryant and Dave O’Hallaron Machine-Level Programming III: Switch Statements and IA32 Procedures : Introduction.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
Accessing parameters from the stack and calling functions.
Machine-Level Programming III: Procedures Sept. 17, 2007 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
Machine-Level Programming III: Procedures Jan 30, 2003
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Machine-Level Programming III: Procedures Sept. 15, 2006 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
September 22, 2014 Pengju (Jimmy) Jin Section E
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
Introduction to x86 Assembly or “How does someone hack my laptop?”
Y86 Processor State Program Registers
Carnegie Mellon Introduction to Computer Systems /18-243, spring 2009 Recitation, Jan. 14 th.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
Lee CSCE 312 TAMU 1 Based on slides provided by Randy Bryant and Dave O’Hallaron Machine-Level Programming III: Switch Statements and IA32 Procedures Instructor:
Machine-Level Programming III: Switch Statements and IA32 Procedures Seoul National University.
University of Washington Today More on procedures, stack etc. Lab 2 due today!  We hope it was fun! What is a stack?  And how about a stack frame? 1.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
Assembly Programmer’s View
Carnegie Mellon 1 Introduction to x86 Assembly or “What does my laptop actually do?” Ymir Vigfusson Some slides gracefully borrowed from
Recitation 2 – 2/11/02 Outline Stacks & Procedures Homogenous Data –Arrays –Nested Arrays Mengzhi Wang Office Hours: Thursday.
Machine-Level Programming: X86-64 Topics Registers Stack Function Calls Local Storage X86-64.ppt CS 105 Tour of Black Holes of Computing.
Machine-Level Programming III: Procedures Topics IA32 stack discipline Register-saving conventions Creating pointers to local variables CS 105 “Tour of.
Carnegie Mellon Machine-Level Programming III: Switch Statements, 1-D Array and IA32 Procedures Lecture, Mar. 7, 2013 These slides are from
Machine-level Programming III: Procedures Topics –IA32 stack discipline –Register saving conventions –Creating pointers to local variables.
1 Procedure Call and Array. 2 Outline Data manipulation Control structure Suggested reading –Chap 3.7, 3.8.
Carnegie Mellon 1 Machine-Level Programming I: Basics Lecture, Feb. 21, 2013 These slides are from website which accompanies the.
F’08 Stack Discipline Aug. 27, 2008 Nathaniel Wesley Filardo Slides stolen from CMU , whence they were stolen from CMU CS 438.
Compiler Construction Code Generation Activation Records
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Instructor: San Skulrattanakulchai Machine-Level Programming.
MACHINE-LEVEL PROGRAMMING III: SWITCH STATEMENTS AND IA32 PROCEDURES.
1 Assembly Language: Function Calls Jennifer Rexford.
IA32 Stack –Region of memory managed with stack discipline –Grows toward lower addresses –Register %esp indicates lowest stack address address of top element.
Section 5: Procedures & Stacks
A job ad at a game programming company
Reading Condition Codes (Cont.)
C function call conventions and the stack
CSCE 212 Computer Architecture
The Stack & Procedures CSE 351 Spring 2017
Machine-Level Programming III: Procedures
Carnegie Mellon Machine-Level Programming III: Switch Statements and IA32 Procedures / : Introduction to Computer Systems 7th Lecture, Sep.
Chapter 3 Machine-Level Representation of Programs
Machine-Level Programming 1 Introduction
Machine-Level Programming III: Switch Statements and IA32 Procedures
Y86 Processor State Program Registers
Instructors: Majd Sakr and Khaled Harras
Machine-Level Programming 4 Procedures
Machine-Level Programming III: Procedures /18-213/14-513/15-513: Introduction to Computer Systems 7th Lecture, September 18, 2018.
Carnegie Mellon Machine-Level Programming III: Procedures : Introduction to Computer Systems October 22, 2015 Instructor: Rabi Mahapatra Authors:
Condition Codes Single Bit Registers
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Assembly Language Programming II: C Compiler Calling Sequences
Machine-Level Programming III: Procedures Sept 18, 2001
Machine-Level Programming: Introduction
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Ithaca College Machine-Level Programming VII: Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2017.
Chapter 3 Machine-Level Representation of Programs
Machine-Level Representation of Programs (x86-64)
Ithaca College Machine-Level Programming VII: Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2017.
“Way easier than when we were students”
Ithaca College Machine-Level Programming VII: Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2017.
Presentation transcript:

Ithaca College Machine-Level Programming IV: IA32 Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2013 * Modified slides from the book “Computer Systems: a Programmer’s Perspective”, Randy Bryant & David O’Hallaron, 2011

2 Summarizing C Control  if-then-else  do-while  while, for  switch Assembler Control  Conditional jump  Conditional move  Indirect jump  Compiler generates code sequence to implement more complex control Standard Techniques  Loops converted to do-while form  Large switch statements use jump tables  Sparse switch statements may use decision trees

3 Ithaca College Today Switch statements IA 32 Procedures  Stack Structure  Calling Conventions  Illustrations of Recursion & Pointers

4 Ithaca College IA32 Stack Region of memory managed with stack discipline Grows toward lower addresses Register %esp contains lowest stack address  address of “top” element Stack Pointer: %esp Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom”

5 IA32 Stack: Push pushl Src  Fetch operand at Src  Decrement %esp by 4  Write operand at address given by %esp -4 Stack Grows Down Increasing Addresses Stack “Bottom” Stack Pointer: %esp Stack “Top” %esp points at the top of the stack, i.e., at the last entry in the stack.

6 Stack Pointer: %esp Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom” IA32 Stack: Pop +4 popl Dest Read operand at address given by %esp Increment %esp by 4 Write to Dest

7 %esp %eax %edx %esp %eax %edx %esp %eax %edx 0x x108 0x10c 0x110 0x Stack Operation Examples 0x108 0x10c 0x x1080x104 pushl %eax 0x108 0x10c 0x x popl %edx 0x top

8 Ithaca College Procedure Control Flow Use stack to support procedure call and return Procedure call: call label  Push return address on stack  Jump to label Return address:  Address of the next instruction right after call  Example from disassembly e:e8 3d call 8048b :50 pushl %eax  Return address = 0x Procedure return: ret  Pop address from stack  Jump to address

9 Ithaca College 0x x104 %esp %eip %esp %eip 0x8048b90 0x108 0x10c 0x110 0x104 0x804854e 123 Procedure Call Example 0x108 0x10c 0x x108 call 8048b e:e8 3d call 8048b :50 pushl %eax e:e8 3d call 8048b :50 pushl %eax %eip: program counter

10 Ithaca College %esp %eip 0x104 %esp %eip 0x x104 0x108 0x10c 0x110 0x Procedure Return Example 0x108 0x10c 0x ret :c3 ret 0x108 0x %eip: program counter

11 Ithaca College Stack-Based Languages Languages that support recursion  e.g., C, C++, Pascal, Java  Code must be “Reentrant”  Multiple simultaneous instantiations of single procedure  Need some place to store state of each instantiation  Arguments  Local variables  Return pointer Stack discipline  State for given procedure needed for limited time  From when called to when return  Callee returns before caller does Stack allocated in Frames  state for single procedure instantiation

12 Ithaca College Call Chain Example yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); } yoo who amI Example Call Chain amI Procedure amI() is recursive

13 Ithaca College Frame Pointer: %ebp Stack Frames Contents  Parameters  Local variables  Return information  Temporary space Management  Space allocated when enter procedure  “Set-up” code  Deallocated when return  “Finish” code Stack Pointer: %esp Stack “Top” Previous Frame Frame for proc Stack pointer %esp indicates stack top Frame pointer %ebp indicates start of current frame

14 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo yoo(…) { who(); } yoo(…) { who(); }

15 Ithaca College yoo(…) { who(); } yoo(…) { who(); } Example yoo who amI yoo %ebp %esp Stack yoo who who(…) { amI(); amI(); } who(…) { amI(); amI(); }

16 Ithaca College yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } Example yoo who amI yoo %ebp %esp Stack yoo who amI amI(…) { amI(); } amI(…) { amI(); }

17 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who amI yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); }

18 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who amI yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); }

19 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who amI yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); } amI(…) { amI(); }

20 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who amI yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); }

21 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); }

22 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who amI yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); } amI(…) { amI(); } amI(…) { amI(); }

23 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo who yoo(…) { who(); } yoo(…) { who(); } who(…) { amI(); amI(); } who(…) { amI(); amI(); }

24 Ithaca College Example yoo who amI yoo %ebp %esp Stack yoo yoo(…) { who(); } yoo(…) { who(); }

25 Ithaca College IA32/Linux Stack Frame Current Stack Frame (“Top” to Bottom)  “Argument build:” Parameters for function about to call  Local variables If can’t keep in registers  Saved register context  Old frame pointer Caller Stack Frame  Return address  Pushed by call instruction  Arguments for this call Return Addr Saved Registers + Local Variables Argument Build Old %ebp Arguments Caller Frame Frame pointer %ebp Stack pointer %esp

26 Ithaca College Revisiting swap void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } int course1 = 15213; int course2 = 18243; void call_swap() { swap(&course1, &course2); } int course1 = 15213; int course2 = 18243; void call_swap() { swap(&course1, &course2); } call_swap: subl$8, %esp movl$course2, 4(%esp) movl$course1, (%esp) callswap call_swap: subl$8, %esp movl$course2, 4(%esp) movl$course1, (%esp) callswap &course2 &course1 Rtn adr %esp Resulting Stack Calling swap from call_swap %esp subl call

27 Ithaca College Revisiting swap void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: pushl%ebp movl%esp, %ebp pushl%ebx movl8(%ebp), %edx movl12(%ebp), %ecx movl(%edx), %ebx movl(%ecx), %eax movl%eax, (%edx) movl%ebx, (%ecx) popl%ebx popl%ebp ret Body Set Up Finish

28 Ithaca College swap Setup #1 swap: pushl %ebp movl %esp,%ebp pushl %ebx Resulting Stack &course2 &course1 Rtn adr %esp Entering Stack %ebp yp xp Rtn adr Old %ebp %ebp %esp

29 Ithaca College swap Setup #2 swap: pushl %ebp movl %esp,%ebp pushl %ebx Resulting Stack &course2 &course1 Rtn adr %esp Entering Stack %ebp yp xp Rtn adr Old %ebp %ebp %esp

30 Ithaca College swap Setup #3 swap: pushl %ebp movl %esp,%ebp pushl %ebx Resulting Stack &course2 &course1 Rtn adr %esp Entering Stack %ebp yp xp Rtn adr Old %ebp %ebp %esp Old %ebx

31 Ithaca College swap Body movl 8(%ebp),%edx # get xp movl 12(%ebp),%ecx # get yp... Resulting Stack &course2 &course1 Rtn adr %esp Entering Stack %ebp yp xp Rtn adr Old %ebp %ebp %esp Old %ebx Offset relative to %ebp

32 Ithaca College swap Finish Stack Before Finish popl%ebx popl%ebp yp xp Rtn adr Old %ebp %ebp %esp Old %ebx Resulting Stack yp xp Rtn adr %ebp %esp Observation  Saved and restored register %ebx  Not so for %eax, %ecx, %edx

33 Ithaca College Disassembled swap : :55 push %ebp :89 e5 mov %esp,%ebp :53 push %ebx :8b mov 0x8(%ebp),%edx b:8b 4d 0c mov 0xc(%ebp),%ecx e:8b 1a mov (%edx),%ebx :8b 01 mov (%ecx),%eax :89 02 mov %eax,(%edx) :89 19 mov %ebx,(%ecx) :5b pop %ebx :5d pop %ebp :c3 ret 80483b4:movl $0x ,0x4(%esp)# Copy &course bc:movl $0x ,(%esp)# Copy &course c3:call # Call swap 80483c8:leave # Prepare to return 80483c9:ret # Return Calling Code

34 Ithaca College Today Switch statements IA 32 Procedures  Stack Structure  Calling Conventions  Illustrations of Recursion & Pointers

35 Ithaca College Register Saving Conventions When procedure yoo calls who :  yoo is the caller  who is the callee Can register be used for temporary storage?  Contents of register %edx overwritten by who  This could be trouble ➙ something should be done!  Need some coordination yoo: movl $15213, %edx call who addl %edx, %eax ret yoo: movl $15213, %edx call who addl %edx, %eax ret who: movl 8(%ebp), %edx addl $18243, %edx ret who: movl 8(%ebp), %edx addl $18243, %edx ret

36 Ithaca College Register Saving Conventions When procedure yoo calls who :  yoo is the caller  who is the callee Can register be used for temporary storage? Conventions  “Caller Save”  Caller saves temporary values in its frame before the call  “Callee Save”  Callee saves temporary values in its frame before using

37 Ithaca College IA32/Linux+Windows Register Usage %eax, %edx, %ecx  Caller saves prior to call if values are used later %eax  also used to return integer value %ebx, %esi, %edi  Callee saves if wants to use them %esp, %ebp  special form of callee save  Restored to original values upon exit from procedure %eax %edx %ecx %ebx %esi %edi %esp %ebp Caller-Save Temporaries Callee-Save Temporaries Special

38 Ithaca College Today Switch statements IA 32 Procedures  Stack Structure  Calling Conventions  Illustrations of Recursion & Pointers

39 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Function Registers  %eax, %edx used without first saving  %ebx used, but saved at beginning & restored at end pcount_r: pushl%ebp movl%esp, %ebp pushl%ebx subl$4, %esp movl8(%ebp), %ebx movl$0, %eax testl%ebx, %ebx je.L3 movl%ebx, %eax shrl%eax movl%eax, (%esp) callpcount_r movl%ebx, %edx andl$1, %edx leal(%edx,%eax), %eax.L3: addl$4, %esp popl%ebx popl%ebp ret

40 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Call #1 Actions  Save old value of %ebx on stack  Allocate space for argument to recursive call  Store x in %ebx pcount_r: pushl%ebp movl%esp, %ebp pushl%ebx subl$4, %esp movl8(%ebp), %ebx x Rtn adr Old %ebp %ebp %esp Old %ebx x %ebx

41 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Call #2 Actions  If x == 0, return  with %eax set to 0 movl $0, %eax testl %ebx, %ebx je.L3.L3: ret x %ebx

42 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Call #3 Actions  Store x >> 1 on stack  Make recursive call Effect  %eax set to function result  %ebx still has value of x movl %ebx, %eax shrl %eax movl %eax, (%esp) call pcount_r Rtn adr Old %ebp %ebp %esp Old %ebx x >> 1 x %ebx

43 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Call #4 Assume  %eax holds value from recursive call  %ebx holds x Actions  Compute (x & 1) + computed value Effect  %eax set to function result movl %ebx, %edx andl $1, %edx leal (%edx,%eax), %eax x %ebx

44 Ithaca College /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } /* Recursive popcount */ int pcount_r(unsigned x) { if (x == 0) return 0; else return (x & 1) + pcount_r(x >> 1); } Recursive Call #5 Actions  Restore values of %ebx and %ebp  Restore %esp L3: addl$4, %esp popl%ebx popl%ebp ret Rtn adr Old %ebp %ebp %esp Old %ebx %ebx %ebp %esp

45 Ithaca College Observations About Recursion Handled Without Special Consideration  Stack frames mean that each function call has private storage  Saved registers & local variables  Saved return pointer  Register saving conventions prevent one function call from corrupting another’s data  Stack discipline follows call / return pattern  If P calls Q, then Q returns before P  Last-In, First-Out Also works for mutual recursion  P calls Q; Q calls P

46 Ithaca College Pointer Code /* Compute x + 3 */ int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } /* Compute x + 3 */ int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } Generating Pointer add3 creates pointer and passes it to incrk /* Increment value by k */ void incrk(int *ip, int k) { *ip += k; } /* Increment value by k */ void incrk(int *ip, int k) { *ip += k; } Referencing Pointer

47 Ithaca College %esp Creating and Initializing Local Variable int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } Variable localx must be stored on stack  Because: Need to create pointer to it Compute pointer as -4(%ebp) First part of add3 x Rtn adr Old %ebp %ebp localx = x Unused add3: pushl%ebp movl%esp, %ebp subl$24, %esp# Alloc. 24 bytes movl8(%ebp), %eax movl%eax, -4(%ebp)# Set localx to x add3: pushl%ebp movl%esp, %ebp subl$24, %esp# Alloc. 24 bytes movl8(%ebp), %eax movl%eax, -4(%ebp)# Set localx to x

48 Ithaca College %esp Creating Pointer as Argument int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } Use leal instruction to compute address of localx Middle part of add3 x Rtn adr Old %ebp %ebp localx Unused movl$3, 4(%esp)# 2 nd arg = 3 leal-4(%ebp), %eax# &localx movl%eax, (%esp) # 1 st arg = &localx callincrk movl$3, 4(%esp)# 2 nd arg = 3 leal-4(%ebp), %eax# &localx movl%eax, (%esp) # 1 st arg = &localx callincrk %esp+4

49 Ithaca College %esp Retrieving local variable int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } int add3(int x) { int localx = x; incrk(&localx, 3); return localx; } Retrieve localx from stack as return value Final part of add3 x Rtn adr Old %ebp %ebp localx Unused movl-4(%ebp), %eax # Return val= localx leave ret movl-4(%ebp), %eax # Return val= localx leave ret

50 Ithaca College IA 32 Procedure Summary Important Points  Stack is the right data structure for procedure call / return  If P calls Q, then Q returns before P Recursion (& mutual recursion) handled by normal calling conventions  Can safely store values in local stack frame and in callee-saved registers  Put function arguments at top of stack  Result return in %eax Pointers are addresses of values  On stack or global Return Addr Saved Registers + Local Variables Argument Build Old %ebp Arguments Caller Frame %ebp %esp