Question: For the following MIPS code: stuff: . word 1 4 , 0 , 9 , - 4 , 5 , - 7 , 1 2

For the following MIPS code:
stuff: .word 14,0,9,-4,5,-7,122,0,9,0
# code to make this program load and such
move $s0, $zero
la $s2, stuff
addi $s3, $zero, 10
move $t8, $zero
top:
beq $s3, $zero, done2
lw $t1,0($s2)
beq $t1, $zero, p1
addi $t8, $t8,1
j p2
p1:
move $t7, $t8
move $t8, $zero
slt $t2, $s0, $t7
beq $t2, $zero, p2
move $s0, $t7
p2:
addi $s2, $s2,4
addi $s3, $s3,-1
j top
done2:
What value will be in register s0 after the code has completed executing and what task does the function perform.
Question 3 options:
s0=122: Finds the largest element in the array.
s0=5: This program computes the length of the longest sequence of numbers between occurences of 0.
s0=17: Finds the largest element in the list, and then computes the sum of all the values prior to that element.
s0=3: This program computes the number of 0's in the array.
s0=1: This program computes the shortest substring in the string.
s0=159: Computes the sum of the array elements with positive values.

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!