Question: [ 5 ] < 2 . 2 , 2 . 3 > Translate the following C code to MIPS. Assume that the variables f ,

[5]<2.2,2.3> 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 8-byte words:
B[8]= A[i]+ A[j]:The code and interpretation on the website are as follows. However, if the array elements are eight bytes in size, shouldn't the shift left instruction be like this: sll $t0, $s3,3? I believe the 2 here should be replaced with 3 because shifting left by three positions is equivalent to multiplying by eight.# Perform shift logical left operation for register s3 by 2 # Place the result in register t0
sll $t0, $s3,2
# Perform addition operation t0 with s6
# Place the result in register t0
add $t0, $t0, $s6
#Perform load word function in the register t0
# With the location 0
lw $t0,0($t0)
# Perform shift logical left operation for register s4 by 2 # Place the result in register t1
sll $t1, $s4,2
# Perform addition operation t1 with s6
# Place the result in register t1
add $t1, $t1, $s6
#Perform load word function in the register t1
# With the location 0
lw $t1,0($t1)
# Perform addition operation t0 with s1
# Place the result in register t0
add $t0,$t0,$t1
# Perform store word function with the register s7 and t0
sw $t0,32($s7)

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