Rutgers University Abhishek Bhattacharjee 85 Stack Pointer esp yoo who Frame

Rutgers university abhishek bhattacharjee 85 stack

This preview shows page 85 - 98 out of 137 pages.

Rutgers University Abhishek Bhattacharjee 85 Stack Pointer %esp yoo who Frame Pointer %ebp Stack Operation yoo who Call Chain who(…) { • • • amI(); • • • amI(); • • • }
Image of page 85
Rutgers University Abhishek Bhattacharjee 86 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who amI Call Chain amI(…) { amI(); }
Image of page 86
Rutgers University Abhishek Bhattacharjee 87 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who amI Call Chain amI(…) { amI(); } amI amI
Image of page 87
Rutgers University Abhishek Bhattacharjee 88 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who amI Call Chain amI(…) { amI(); } amI amI amI amI
Image of page 88
Rutgers University Abhishek Bhattacharjee 89 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who amI Call Chain amI(…) { amI(); } amI amI amI
Image of page 89
Rutgers University Abhishek Bhattacharjee 90 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who amI Call Chain amI(…) { amI(); } amI amI
Image of page 90
Rutgers University Abhishek Bhattacharjee 91 Stack Pointer %esp yoo who Frame Pointer %ebp Stack Operation yoo who Call Chain who(…) { • • • amI(); • • • amI(); • • • } amI amI amI
Image of page 91
Rutgers University Abhishek Bhattacharjee 92 Stack Pointer %esp yoo who amI Frame Pointer %ebp Stack Operation yoo who Call Chain amI(…) { } amI amI amI amI
Image of page 92
Rutgers University Abhishek Bhattacharjee 93 Stack Pointer %esp yoo who Frame Pointer %ebp Stack Operation yoo who Call Chain who(…) { • • • amI(); • • • amI(); • • • } amI amI amI amI
Image of page 93
Rutgers University Abhishek Bhattacharjee 94 yoo(…) { who(); } Stack Pointer %esp yoo Frame Pointer %ebp Stack Operation yoo who Call Chain amI amI amI amI
Image of page 94
Rutgers University Abhishek Bhattacharjee 95 IA32/Linux Stack Frame Current Stack Frame (“Top” to  Bottom) Parameters for function  about to call “Argument build” 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 Stack Pointer ( %esp ) Frame Pointer ( %ebp ) Return Addr Saved Registers + Local Variables Argument Build Old %ebp Arguments Caller Frame
Image of page 95
Rutgers University Abhishek Bhattacharjee 96 Revisiting  swap void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } int zip1 = 15213; int zip2 = 91125; void call_swap() { swap(&zip1, &zip2); } call_swap: • • • pushl $zip2 # Global Var pushl $zip1 # Global Var call swap • • • &zip2 &zip1 Rtn adr %esp Resulting Stack Calling  swap  from  call_swap
Image of page 96
Rutgers University Abhishek Bhattacharjee 97 Revisiting  swap void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: pushl %ebp movl %esp,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx movl %eax,(%edx) movl %ebx,(%ecx) movl -4(%ebp),%ebx movl %ebp,%esp popl %ebp ret Body Set Up Finish
Image of page 97
Image of page 98

You've reached the end of your free preview.

Want to read all 137 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture