Question: Part 1 Write MIPSzy assembly code to accomplish the tasks specified by the following high - level language ( Java or C + + )

Part 1
Write MIPSzy assembly code to accomplish the tasks specified by the following high-level language (Java or C++) statement.
System.out.print((1000-200+30)*2); // Java
cout <<(1000-200+30)*2; // C++
//(both do the same thing)
Essentially, your program needs to do three things:
Compute (1000-200+30).
Multiply the result of step 1 by 2.
Display the result of step 2(by storing this result to memory address 8200).
Write code that does all of these steps, in order.
Test your code in the "MIPSzy simulator with input and output". Once you're convinced that it works correctly, copy it out of the simulator and paste it into a text editor (e.g., Notepad++, TextPad, Atom, or mousepad). Save it as a file named part1.asm. You will submit this file as part of your project.
Part 2
Write MIPSzy assembly code to accomplish the tasks specified by the following code in a high-level language (Java or C++).
int w1=60; // use a register for this variable
int w2=20; // use a register for this variable
int total; // use a register for this variable
int result[3]; // note: int =1 word =4 bytes (on this machine)
total = w1;
for (int i =0; i <3; i++){
total = total + w2;
result[i]= total;
System.out.println(total); // C++: cout << total <<'
';
}
Hints
Begin by deciding which registers you will use for the variables w1, w2, and total. You may want to write comments (which begin with # in MIPSzy assembly) or make a separate file or note sheet to keep track of the register you are using for each variable.
Then decide which registers you will use (or reuse?) to store other values used in the program:
the loop counter variable
the memory address of the current element in the result array (starts at 5000 in base-10)
the memory address that you use to display output (8200 in base-10)
Now move into writing the code. The following zyBook sections might be especially helpful for you.
Section 5.6: tips for writing assembly programs, plus examples
Sections 5.8 and 5.9: conditional branch instructions; the MIPSzy simulator does accept the branch pseudoinstructions in section 5.9
Section 7.6: construct a for loop using conditional branch instructions
Section 7.8: access different elements of an array as your code moves through a loop (but there is a simpler way than what they show you...)
The newline will be automatically added by the MIPSzy simulator. You do not need to print the newline character.
Test your code in the "MIPSzy simulator with input and output". Once you're convinced that it works correctly, copy it out of the simulator and paste it into a text editor (e.g., Notepad++, TextPad, Atom, or mousepad). Save it as a file named part2.asm. You will submit this file as part of your project.

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 Programming Questions!