Home / Expert Answers / Computer Science / assignment-5-mips-program-2-translate-the-following-c-program-into-mips-assembly-language-allo-pa825

(Solved): Assignment \#5 MIPS Program 2 Translate the following C++ program into MIPS assembly language: Allo ...



Assignment \#5 MIPS Program 2
Translate the following \( \mathrm{C}++ \) program into MIPS assembly language:
Allocate regist
Assignment \#5 MIPS Program 2 Translate the following program into MIPS assembly language: Allocate registers as you wish, but use correct register conventions (\$t vs ) int ; int sum int while cout Final sum sum endl ; Output should be: Final sum Submit a word document including: a. A RAT (Register Allocation Table) that shows which registers used correspond to the variables in the original program. b. The MIPS code (as text). - Format carefully. - Document the code with appropriate comments. - Optional: You may wish to add a screengrab of the code c. A screenshot of the output. Unlike with the previous assignment, there will only be one final output!. Use the simulator for debugging. Go step by step to see how the values change. Steps to consider: 1. Make a RAT based off of the code. 2. Initialize 3 values: , sum , the array with values. 3. Set a label e.g. LOOP: Determine when to 'jump to the end' of the main loop 4. Determine the proper order of the operations 5. Calculate the offset (in bytes). 4 bytes per int, so offset (consider shift?) 6. Load the array entry (currently in memory) into a register 7. Perform the remaining math to update sum 8. Increment 9. jump to top of the LOOP 10. Review the SYSCALL instructions to print the string and int.


We have an Answer from Expert

View Expert Answer

Expert Answer



Answer :

a. RAT:

b. MIPS Code:

c. Output :



The given C++ program initializes an integer array A with 10 integer values and a variable sum to 0. It then enters into a while loop and repeatedly adds A[i] to sum and multiplies the result by 3 until the value of i becomes equal to or greater than 10. Finally, it prints the value of sum on the console.


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe