{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

10 - Procedure Call 1 Outline Stackframe Callingconventions...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Procedure Call
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Outline Stack frame Calling conventions Recursive Suggested reading Chap 3.7
Image of page 2
3 Example int g()  {  return 1 ; } int f()  { return g() ; } int main() { g(); return f(); } Main f g g activation tree 
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Example 2 int g()  { return 1 ;} int f(int x)  {  if (x == 0)  return g() ;  else  return f(x - 1) ;  } int main() { f(3); } What is the activation tree for this example?
Image of page 4
5 Notes The activation tree depends on run-time behavior The activation tree may be different for every program input Since activations are properly nested, a stack can track  currently active procedures
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Using Stack to Trace the Activations int g()  {  return 1 ; } int f()  { return g() ; } int main()  { g(); return f(); } Main Stack Main
Image of page 6
7 Example int g()  {  return 1 ; } int f()  { return g() ; } int main()  {  g();  return f(); } Main g Stack Main g
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
8 Example int g()  {  return 1 ; } int f()   { return g() ; } int main()  { g(); return  f();  } Main g f Stack Main f
Image of page 8
9 Example int g()  {  return 1 ;  } int f()  { return g() ;  } int main()  { g(); return  f();  } Main f g g Stack Main f g
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
10 Memory Layout Low Address High Address Memory Code Stack
Image of page 10
11 Activation Records On many machine the stack starts at high-addresses and 
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern