Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- # t0 <- min
- # a0 <- number1
- # a1 <- number2
- # a2 <- number3
- li $a0 , 100 # a number
- li $a1 , 56 # another number
- li $a2 , 99 # some other number...
- jal findMin # call findMin on them
- move $a0 , $v0 # save the return address to $a0
- li $v0 , 1 # save the print_int code to $v0
- syscall # print the min found
- j EXIT # call the exit tag
- findMin:
- move $t0 , $a0
- bge $a1 , $t0 ,ELSE # if ( number2 > = min ) check the other
- move $t0 , $a1 # else this one is the min so far
- ELSE:
- bge $a1 , $t0 , END # if (number3 >= min ) the first one is the min
- move $t0 , $a2 # else this one is the min
- END:
- move $v0 , $t0 # make the return value be the min
- jr $ra # return
- EXIT:
- li $v0 , 10 # save the exit code to v0
- syscall # exit the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement