# Maura Dailey CSE 331 .data .align 0 #turn off automatic alignment str1: .asciiz "Please enter 3 distinct integers: " #create a null terminated string str2: .asciiz "The smallest integer is: " #create another one str3: .asciiz "The sum of the largest two is: " #and another one str4: .asciiz "\n" #and another one .text .align 2 .globl main #following is global main: li $v0, 4 #prepare $v0 with syscall instruction 4 la $a0, str1 #store the addr of str1 in $a0 syscall #print str1 to the console li $v0, 5 #prepare $v0 with syscall instruction 5 syscall #retrieve an int from the console add $t0, $v0, $zero #store the retrieved int in $t0 li $v0, 5 #prepare $v0 with syscall instruction 5 syscall #retrieve an int from the console add $t1, $v0, $zero #store the retrieved int in $t1 li $v0, 5 #prepare $v0 with syscall instruction 5 syscall #retrieve an int from the console add $t2, $v0, $zero #store the retrieved int in $t2 test1: slt $t4, $t0, $t1 #test if $t0 is less than $t1 bne $t4, $zero, test3 #if it is, skip ahead to test3 test2: slt $t4, $t1, $t2 #test if $t1 is less than $t2 beq $t4, $zero, test4 #if it isn't, skip ahead to test4 add $s0, $t1, $zero #if it is, then $t1 is the smallest, put in $s0 add $s1, $t0, $t2 #add the other inputs together and store in $s1 j output #jump to output test3: slt $t4, $t0, $t2 #test if $t0 is less than $t2 beq $t4, $zero, test4 #if it isn't, skip ahead to test4 add $s0, $t0, $zero #if it is, then $t0 is the smallest, put in $s0 add $s1, $t1, $t2 #add the other inputs together and store in $s1 j output #jump to output test4: add $s0, $t2, $zero #if $t0 and $t1 are not the smallest, then $t2 must be add $s1, $t0, $t1 #add the other inputs together and store in $s1 output: li $v0, 4 #prepare $v0 with syscall instruction 4 la $a0, str2 #store the addr of str2 into $a0 syscall #print str2 to the console li $v0, 1 #prepare $v0 with syscall instruction 1 add $a0, $s0, $zero #store the smallest number ($s0) in $a0 syscall #print the smallest number to the console li $v0, 4 #prepare $v0 with syscall instruction 4 la $a0, str4 #store the addr of str4 in $a0 syscall #print str4 to the console li $v0, 4 #prepare $v0 with syscall instruction 4 la $a0, str3 #store the addr of str3 into $a0 syscall #print str3 to the console li $v0, 1 #prepare $v0 with syscall instruction 1 add $a0, $s1, $zero #store the sum of the largest two integers in $a0 syscall #print the sum of the largest two integers to the console li $v0, 4 #perpare $v0 with syscall instruction 4 la $a0, str4 #store the addr of str4 in $a0 syscall #print str4 to the console