add $s2,$a0,$zero (there are other solutions too) addi $t4,$zero,-1 (there are other solutions too)
$t1 = 0xd02 $t2 = 0xff9c0f4d
la $t0,info # load address of beginning of array loop: lw $t1,0($t0) # load next element of info blt $t1,$zero,neg # out of loop if negative addi $t1,$t1,4 # advance to next element b loop # check next element neg: la $t1,info # get address of beginning of array sub $s0,$t0,$t1 # subtract address of negative element sra $s0,$s0,2 # divide by 4 # at this point $s0 has the value
# Parameter values are in $a0, $a1 and $a2, return value goes into $v0. # Since no $s registers are used and there are no jal's in the code, no # registers need to be saved. which: # assume $a0 is the largest move $t0,$a0 li $v0,0 # if $a1 is larger, record it bge $a0,$a1,skip1 move $t0,$a1 li $v0,1 skip1: # if $a2 is larger yet, record it bge $t0,$a2,skip2 move $t0,$a2 li $v0,2 skip2: # return jr $ra
000000 10100 00010 00111 00000 100000000100 00100 00101 1111111111111011
sll $a2,$t1,16lw $t9,17($sp)