Question: Write a program using MIPSzy that functions equivalently to the following C code. Be sure to conserve registers in your code. In testing your code,

Write a program using MIPSzy that functions equivalently to the following C code. Be sure to conserve registers in your code. In testing your code, I may substitute values other than those initially assigned to the variables in the following snippets to make sure your conditional statements work correctly in all cases.

A) int a = 46; int b = 62; int c = (a + 1) * (b + 2); B) int x = 2 int w = 0; if (x == 0) { w = w + 10; } C) int w = 0; int x = 0; int y = 1; int z = 0; if (x == y) { w = 1; } else if (y == z) { w = 2; } else if (x == z) { w = 3; } D) int x = 1; int y = 1; int z = 0; if (x == 0) { z = -1; } else if (y == 0) { z = -2; } else { z = -3; } E) int x = 1; int y = 1; int z = 0; if (x <= y) { z = -1; }

Use the MIPSzy compiler found in Chapter 2.6 "A small assembly program" to write, test and run your code.

Once your program is successful, copy the code to an Ascii text file named Assignment01_Lastname_Firstname.txt.

Include all five snippets but put a #comment between A, B, C, D, E to delineate the five snippets.

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!