Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the following problems, consider the following program: void main) int x; double y; float f; //some computations f = foo(x y) ; f +-
For the following problems, consider the following program: void main) int x; double y; float f; //some computations f = foo(x y) ; f +- bar(x, y); //some computations float foo(int a) 0 double g; g bar (a, a) ; return g; double bar(int r, int s) t float h; h=1.0 * (r + s); if (r == s) { double q = 2.0; return h; 1. Assume your program is running on a machine with 4 registers, using callee saves Assume addresses (i.e., pointers) are 8 bytes, floats are 4 bytes, ints are 4 bytes, and doubles are 8 bytes. Draw the complete stack (i.e., the stack including all active activation records) for the program right after foo has called bar, and before bar returns. For each slot in the stack, indicate what is stored there, and how much space that slot takes up 2. Now assume that the call signature for bar is double bar (int &r, int &s) (in other words, bar is now a pass-by-reference call). Draw the call stack right after main calls bar, and before bar returns For the following problems, consider the following program: void main) int x; double y; float f; //some computations f = foo(x y) ; f +- bar(x, y); //some computations float foo(int a) 0 double g; g bar (a, a) ; return g; double bar(int r, int s) t float h; h=1.0 * (r + s); if (r == s) { double q = 2.0; return h; 1. Assume your program is running on a machine with 4 registers, using callee saves Assume addresses (i.e., pointers) are 8 bytes, floats are 4 bytes, ints are 4 bytes, and doubles are 8 bytes. Draw the complete stack (i.e., the stack including all active activation records) for the program right after foo has called bar, and before bar returns. For each slot in the stack, indicate what is stored there, and how much space that slot takes up 2. Now assume that the call signature for bar is double bar (int &r, int &s) (in other words, bar is now a pass-by-reference call). Draw the call stack right after main calls bar, and before bar returns
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started