Question: Translate the following C++ program into MIPS assembly language. (Don't worry about what results the program should compute; just translate it faithfully.) Note that the

Translate the following C++ program into MIPS assembly language. (Don't worry about what results the program should compute; just translate it faithfully.) Note that the array initializations have been provided. Make sure your loops are efficient (i.e., they should not have unnecessary branches). Allocate i to $s0, j to $s1, sum to $s2. You may use any other MIPS registers.

int x[] = {9, -1, 2, 13, 79, 4, -87, 3};

int data[] = {1, 4, 5, -1};

int main() {

int i = 1, j = 4, sum = 0; while (sum < j) {

sum += i;

if (x[i] >= sum) {

for (i=j; i<5; i++) {

data[i] = x[i]; }

} else {

j++;

i = i*2;

}

}

}

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!