Question: QI (60 points) Translate the following MIPS code snippets into C code a. (15 points) For the MIPS assembly instructions below, what is the corresponding
QI (60 points) Translate the following MIPS code snippets into C code a. (15 points) For the MIPS assembly instructions below, what is the corresponding statement? Assume that the variables f, g, h, i, and are assigned to registers SsO, Ssl, Ss2, S3, and $54, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and $57, respectively. sll $t0. $50. 2 # $t0 - f + 4 add $t0. $56, $t0 # $t0 = &A[f] sli $t1,$sl. 2 # $tl = g * 4 add $ti. $97. $ti # $tl &B[9] Tw $50. 0(500) # f = A[f] addi $t2. $t0.4 lw $t0. 0($t2) add $t0,$t0,$50 SW $t0. 0($t1) b. (15 points) For the MIPS assembly instructions above, rewrite the assembly code to minimize the number if MIPS instructions (if possible) needed to carry out the same function c (15 points) Translate the following MIPS code to C. Assume that the variables f, g, h, i, and jare assigned to registers Ss0, $sl, SS2, S3, and $4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and $87, respectively. addi $t0,$87. 4 add $t1. $56. $0 SW $t1, 0($t0) Tw $t0. 0($t0) add $51. $ti. $t0 d. (15 points) Translate the following code to MIPS. Assume that the variables f, g, h, i, and jare assigned to registers $50, S1, S2, S3, and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and 8s7, respectively. Assume that the elements of the arrays A and B are 4-byte words. B[8] = A[i-]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
