Using the MARS simulator, write and execute the MIPS assembly code that will per
ID: 3845185 • Letter: U
Question
Using the MARS simulator, write and execute the MIPS assembly code that will perform the C statements. Find the value of the C variable on the LHS of indicated C instruction. Use comment hash #### to identify and separate the problems. Identify the C variables as A = exists0, B=exists1, C=exists2, D=existS3, E=exists4, F=exists5, G=exists6 and H=exists7. The register existt0 can be used for temporary storage. Submit a copy of the MARS MIPS code for these exercises and complete the table at the bottom with calculated values from the MARS simulator. The target variable (register) is the variable (register) on the LHS of the C arithmetic statement. Run this C code segment by using the branch instruction bne (see Appendix B-62) and find F. A=3, B=50:F=0: for (H=0:H!= B:H++) F = F + A:Explanation / Answer
1. A=5; B=12;
MIPS: add $s2,$s0,$s1
2. A = -15, B = -26
MIPS: sub $s3,$s0,$s1
3. MIPS:
sub $t0,$s3,$s4 ; $t0 = D - E
add $t1,$s0,$s1 ; $t1 = A + B
sub $t1,$t1,$s2 ; $t1 = A+B-C
sub $s5,$t1,$t0 ; F = (A+B-C) - (D-E)
4. MIPS:
add $t0,$s0,$s1 ; get A+B
sub $s5,$s5,$t0 ; F = F - A+B
5. MIPS:
sub $s6,$s1,$s0.
Likewise try for other instructions, and let me know if you
face any problems.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.