Answered step by step
Verified Expert Solution
Link Copied!

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 +-

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

If he or she did not write a plan, why not?

Answered: 1 week ago