So I have to use MIPS assembly code to bubble sort an array that\'s already set
ID: 3792499 • Letter: S
Question
So I have to use MIPS assembly code to bubble sort an array that's already set and put into the program. I'm not quite sure how to work with the array and print it, this is what I have so far but I can't figure out how to print out the sorted array. Any help would be greatly appreciated.
.globl Main
.data
msg_E: .asciiz "Program Start "
msg_F: .asciiz "Program Terminated "
Size: .word 10
List: .word 5, 20, 2, 17, 18, 9, 7, 1, 4, 3
.text
Main:
li $v0, 4
la $a0, msg_E
syscall
lw $s3, Size
addi $s3, $s3, -1
Outer:
bge $zero, $s3, Outer_end
li $s0, 0
li $s1, 0
Inner:
bge $s0, $s3, Inner_end
lw $t7, List($s1)
lw $t8, List + 4($s1)
ble $t7, $t8, no_swap
sw $t8, List($s1)
sw $t7, List + 4($s1)
addi $s3, $s3, -1
j Outer
Outer_end:
no_swap:
addi $s1, $s1, 4
addi $s0, $s0, 1
j Inner
Inner_end:
Exit:
li $v0, 4
la $a0, msg_F
syscall
Exit_:
j Exit_
Explanation / Answer
After the Inner_end: label write the following code :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.