.data array0: .float 0.6, 0.7, 0.9, 0.1, -0.8 array1: .float 0.8, 1.9, 11.2, -0.19, 0.7 array2: .space 20 msg_newline: .asciiz "\n" .text .globl main main: la $a0, array0 # Get starting addresses of the 3 arrays la $a1, array1 la $a2, array2 li $a3, 5 # array size jal floatArray # Call floatArray subroutine done: addi $t0, $a2, 0 # Load starting address of Array2 again for printing addi $t1, $0, 0 loop: li $v0, 2 # print elements of Array2 l.s $f12, 0($t0) syscall li $v0, 4 # newline after each element la $a0, msg_newline syscall addi $t0, $t0, 4 # Next i addi $t1, $t1, 1 blt $t1, $a3, loop # if t1 = a3, we're done printing exit: li $v0,10 syscall floatArray: addi $sp, $sp, -12 # store data in stack swc1 $f0, 8($sp) swc1 $f1, 4($sp) swc1 $f2, 0($sp) addi $t0, $a0, 0 # Load starting addresses for indexing addi $t1, $a1, 0 addi $t2, $a2, 0 addi $t9, $0, 0 # counter floatArrayloop: l.s $f0, 0($t0) # Load values of array[i] l.s $f1, 0($t1) c.lt.s $f0, $f1 # Check which element is the smaller one bc1t floatArrayskip # f0 is the lesser element mov.s $f0, $f1 # if f1 is the lesser element, move it into f0 (we're going to copy from f0 later) floatArrayskip: s.s $f0, 0($t2) # store f0 (smaller element) into array2 addi $t0, $t0, 4 # next i addi $t1, $t1, 4 addi $t2, $t2, 4 addi $t9, $t9, 1 blt $t9, $a3, floatArrayloop # if counter =5, we're done here, otherwise, go back into the loop lwc1 $f0, 8($sp) # restore the data in these registers from stack lwc1 $f1, 4($sp) lwc1 $f2, 0($sp) addi $sp, $sp, 12 jr $ra # return