Question: The following MIPS code snippet implements a simple loop. Analyze the code and answer the questions below: li $t 0 , 0 loop: beq $t

The following MIPS code snippet implements a simple loop. Analyze the code
and answer the questions below:
li $t0,0
loop: beq $t0, $s0, end
addi $t0, $t0,1
sll $t1, $t0,2
add $t2, $s1, $t1
lw $t3,0($t2)
addi $t3, $t3,5
sw $t3,0($t2)
j loop
end:
a) Assuming $s0 holds the value 10, how many times will the loop iterate?
b) Describe in words what this code does. What is the purpose of the sll
instruction?
c) If $s1 contains the base address of an array named data, in Python, Java or
C/C++ please write the equivalent of the code inside the loop (from addi
$t0, $t0,1 to j loop)?

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