Question: C/C++ to Mips main() { x = 2*foo(4*y+4); x = x+(4*y+4); } int foo (int n) { int junk[10] = {0,1,2,3,4,5,6,7,8,9}; int junk2[16]; // Mod

C/C++ to Mips

main() {

x = 2*foo(4*y+4);

x = x+(4*y+4);

}

int foo (int n) {

int junk[10] = {0,1,2,3,4,5,6,7,8,9};

int junk2[16]; // Mod 1 (stored below (i.e.,higher address) junk on stack)

junk[4] += 2 - junk2[7]; // Mod 2

if (n

else return 2*bar(1,2,3,4,5,6+n) + junk[4] + foo(n-1); // Mod 3

}

Modify the following assembly language for this revised program. You may assume that bar is an OS function that has already been written. Of course, you have to use the procedure convention described in class. In cases where the convention was left unspecified, use the convention of the example. Also note that we need to call bar before foo as in the HLL code, since the compiler doesnt know whether bar has side effects such as [unadvisedly] playing with pointers to modify a variable in foo. Make sure to use a different ink color (or boldface font) to make your modifications clear, and label your program to indicate which changes support which mod. DO NOT change the original code, except as needed for these modifiations.

Thank you.

C/C++ to Mips main() { x = 2*foo(4*y+4); x = x+(4*y+4); }

This is the procedure convention

int foo (int n) { int junk[10] = {0,1,2,3,4,5,6,7,8,9}; int junk2[16]; //

# Allocate Registers: xS0.y-6s1 # Assume optimizing compiler avoids computing 4yt4 twice 0 # Push Sto Foo: addi Ssp,Ssp,-48 #StO 1 if n

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!