Question
Translate the following C code to MIPS. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3,
Translate the following C code to MIPS. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. Assume that the elements of the arrays A and B are 4-byte words:
B[8] = A[i] + A[j];
List of options to choose:
1. addi $t0, $t0, 1 # $t0 <-- B[g]+1
2. add $t0, $t0, $s7 # $t0 <-- Addr(B[g])
3. lw $s0, 0($t0) # f <-- A[B[g]+1]
4. sll $t0, $t0, 2 # $t0 <-- 4*(B[g]+1) = Addr(A[B[g]+1])
5. sll $t0, $s1, 2 # $t0 <-- 4*g
6. lw $t0, 0($t0) # $t0 <-- B[g]
step 1: (choose one of the option above)
step 2: (choose one of the option above)
step 3: (choose one of the options above)
step 4: (choose one of the option above)
step 5: (choose one of the option above)
step 6: (choose one of the option above)
*There are 6 options equally distributed into 6 steps.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started