Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In mips assembly Count= 0; For(i=0; I<1000; i ++) { If(A[i]<100) { Count++; } }

ID: 3826683 • Letter: I

Question

In mips assembly Count= 0; For(i=0; I<1000; i ++) { If(A[i]<100) { Count++; } }


Only values in saved registers are base adress of arrays A and variable count in $s0 and $s1 respectively the value of i is in $s0 In mips assembly Count= 0; For(i=0; I<1000; i ++) { If(A[i]<100) { Count++; } }


Only values in saved registers are base adress of arrays A and variable count in $s0 and $s1 respectively the value of i is in $s0 Count= 0; For(i=0; I<1000; i ++) { If(A[i]<100) { Count++; } }


Only values in saved registers are base adress of arrays A and variable count in $s0 and $s1 respectively the value of i is in $s0

Explanation / Answer

Note : your question has a bit confusion. Both i and base address of A, are said to be in $s0? I am assiging $s2 for i

$s0 -> base address of array A
$s1 -> count variable
$s2 -> i


# Dont forget to initialize the variables i and count to 0
# main:
#    li $s2,0   # i
#    li $s1,0   # count

loop:
   bgt $s2,999,exit   # if i<1000      
   lb $t1, 0($s0)      # load a byte from the array into $t1
   bgt $t1,100,incr   # if A[i] < 100
   addi $s0, $s0, 1   # point to next element in the array
   addi $s2, $s2, 1   # i = i + 1      
   j loop

incr:
   addi $s1,$s1,1       # count = count + 1
   addi $s0, $s0, 1   # point to next element in the array
   addi $s2, $s2, 1   # i = i + 1      
   j loop

exit:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote