Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void main) f int x; double y; float f; //some computations f foo(x + y) ; f += bar (x, y); //some computations float foo(int

image text in transcribed

void main) f int x; double y; float f; //some computations f foo(x + y) ; f += bar (x, y); //some computations float foo(int a) f double g; g-bar (a, a); return g; double bar (int r, int s) f 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 void main) f int x; double y; float f; //some computations f foo(x + y) ; f += bar (x, y); //some computations float foo(int a) f double g; g-bar (a, a); return g; double bar (int r, int s) f 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_2

Step: 3

blur-text-image_3

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

whom?

Answered: 1 week ago

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago