10 - Procedure Call 1 Outline Stackframe Callingconventions Recursive Suggestedreading Chap3.7 2 Example int int int g)cfw_return1 f)cfw_returng

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

View Full Document Right Arrow Icon
1 Procedure Call
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Outline Stack frame Calling conventions Recursive Suggested reading Chap 3.7
Background 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 
Background image of page 3

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

View Full DocumentRight 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?
Background 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
Background image of page 5

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

View Full DocumentRight 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
Background image of page 6
7 Example int g()  {  return 1 ; } int f()  { return g() ; } int main()  {  g();  return f(); } Main g Stack Main g
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Example int g()  {  return 1 ; } int f()   { return g() ; } int main()  { g(); return  f();  } Main g f Stack Main f
Background 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
Background image of page 9

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

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

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

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

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 34

10 - Procedure Call 1 Outline Stackframe Callingconventions Recursive Suggestedreading Chap3.7 2 Example int int int g)cfw_return1 f)cfw_returng

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online