Question: CS3723 Homework#2 Scope (28 pts) Use the provided blank answer sheet for your answers. Consider the following C-like code: void main () { int m

CS3723 Homework#2 Scope (28 pts)

Use the provided blank answer sheet for your answers. Consider the following C-like code:

void main()

{

int m = 100;

int i = 101;

int c = 102;

int k = 103;

int e = 104;

int y = 105;

subA();

print("main", "m=", m, "i=", i, "c=", c, "k=", k, "e=", e, "y=", y);

void subA()

{

int m = 200;

int x = 1;

subB();

print("subA", "m=", m, "i=", i, "c=", c, "k=", k, "e=", e, "y=", y);

void subB()

{

int i = 311;

int c = 312;

m += 20;

x += 5;

k += 10;

subC();

print("subB", "m=", m, "i=", i, "c=", c, "k=", k, "e=", e, "y=", y);

void subC()

{

int c = 402;

int k = 403;

int e = 404;

m += 30;

i += x;

if (x

subB();

else

subD();

print("subC", "m=", m, "i=", i, "c=", c, "k=", k, "e=", e, "y=", y);

}

}

}

void subD()

{

int y = 505;

m += 50;

i += 50;

k += 50;

e += 50;

print("subD", "m=", m, "i=", i, "c=", c, "k=", k, "e=", e, "y=", y);

}

}

#1 Assume the C-like code uses static scope and main is initially called.

Solve each of the following:

1.1 Show the symbol table for each of the functions Assume int is 4 bytes.

1.2 Trace the code showing the runtime memory stack including environment vectors.

It isn't necessary to show separate copies of the RTMS on each call.

Use these symbols for the activation record addresses in this order:

1.3 What is the output? Make certain you show the output in the correct order.

#2 Assume the C-like code uses dynamic scope and main is initially called.

Solve each of the following:

2.1 Trace the code using dynamic scope. Show the runtime memory stack (it isn't necessary to show separate copies of the RTMS on each call). Do not include an environment vector.

2.2 What is the output? Make certain you show the output in the correct order.

CS3723 Homework#2 Scope (28 pts) Use the provided blank answer sheet for

your answers. Consider the following C-like code: void main() { int m

= 100; int i = 101; int c = 102; int k

1.1. Symbol tables main subA BA Offset/Address BA Offset/Address subA subD subB subB subC subC subB subD subD 1.1. Symbol tables main subA BA Offset/Address BA Offset/Address subA subD subB subB subC subC subB subD subD

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!