| and $s1, $zero, $zero | # initialize $s1 to 0 | |
| add $t0, $s0, $zero | # set $t0 to the start address of some array | |
| loop: | lw $t1, 0 ($t0) | # copy a word from the array into $t1 |
| add $s1, $s1, $t1 | # add the value of $t1 to the running total in $s1 | |
| addi $t0, $t0, 4 | # increment $t0 | |
| bne $t1, $zero, loop | # loop if word copied does not equal zero |
|
|
|
| dec $s0 | $s0 = $s0 - 1 |
| quad $s0 | $s0 = $s0 x 4 |
| swap $s0, $s1 | $s0 = $s1 and $s1 = $s0 |
| swinc $s0, $t0 | stores $s0 to address
$t0 in memory
and increments $t0 by 4 |
| subi $s0, $s1, big | $s0 = $s1 - big |
| bgt $s0, small, L | if ($s0 > small) go to L |