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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started