Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

This is the procedure convention

image text in transcribed

# 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

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions