Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A sample result: -------------------------------------------- Input a Float-Poin

ID: 3820408 • Letter: A

Question

A sample result:
--------------------------------------------
Input a Float-Point #:(0 indicates the end)
1.0
Input a Float-Point #:(0 indicates the end)
-1.0
Input a Float-Point #:(0 indicates the end)
2.0
Input a Float-Point #:(0 indicates the end)
-2.0
Input a Float-Point #:(0 indicates the end)
3.0
Input a Float-Point #:(0 indicates the end)
-3.0
Input a Float-Point #:(0 indicates the end)
0
Sorting Result
-3.0, -2.0, -1.0, 1.0, 2.0, 3.0

Make a program using MIPS, using mars compiler, that takes in floating point numbers and outputs the sorted array of numbers.

Explanation / Answer

.data

array: .space 40

prompt: .asciiz "Enter a number: "

spacee: .asciiz " "

output: .asciiz "The numbers are: "

.text

main:

li $t1,10

la $a1,array

loop:

addi $t1,$t1,-1

li $v0,4

la $a0,prompt

syscall

li $v0,5

syscall

sw $v0,0($a1)

addi $a1,$a1,4

bnez $t1,loop

li $t1,9

li $t2,9

la $a1,array

loop1:

beqz $t2,here

addi $t2,$t2,-1

lw $t5,0($a1)

lw $t6,4($a1)

add $a1,$a1,4

ble $t5,$t6,loop1

sw $t5,0($a1)

sw $t6,-4($a1)

bnez $t2,loop1

here:

la $a1,array

addi $t1,$t1,-1

add $t2,$t2,$t1

bnez $t1,loop1

li $v0,4

la $a0,output

syscall

la $a1,array

li $t1,10

loop2:

li $v0,1

lw $a0,0($a1)

syscall

li $v0,4

la $a0,spacee

syscall

add $a1,$a1,4

addi $t1,$t1,-1

bnez $t1,loop2

li $v0,10 #exit

syscall

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote