Can you please provide the solution for number 2 12:06 ? mail-attachment.googleu
ID: 3698403 • Letter: C
Question
Can you please provide the solution for number 2
12:06 ? mail-attachment.googleusercontent.com 11 of 13 Scanned by CamScanner IIIMIPS Structures Translate the following into MIPS, assuming the reglster assignments below. You may use as necessary 130 pts, 15pts eachl. temporaries able hreshold g addressof a at this pain 2. while (threshold> aly eyo xaY: 3 Scanned by CamScanner v. Functions: Part Below is a Java function that takes an array of ta elements and computes their sum publia int aun(int arr, int 2) int total ·01?$So for (int i-0; ? 8; i++)-1 totaltotalarri return total Translate this code into equivalent MIPS code (20 pts. You may use temporaries as necessary. arr contains the address o HintExplanation / Answer
2)
given:-
x = $s0
y = $s1
diff = $s2
threshold = $s3
starting address of a = $s4
MIPS PROGRAM:-
li $t4,4
while_loop:
mult $t0,$s1,$t4 #creating offset value
add $t0,$s4,$s1 #calculating logical address of a[y]
lw $t1,0($t0) #fetching the value at address
slt $t2,$t1,$s3 #checks for $s3 > $t1 i.e threshold > a[y]
beq $t2,$zero,end_while_loop
move $s0,$t1 # x = a[y]
addi $s1,$s1,1 # y = y + 1
j while_loop
end_while_loop: