Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- .word 0
- newline:
- .asciiz "\n"
- datalen:
- .word 0x0015 # 16
- data:
- .word 0xffff7e81
- .word 0x00000001
- .word 0x00000002
- .word 0xffff0001
- .word 0x00000000
- .word 0x00000001
- .word 0xffffffff
- .word 0x00000000
- .word 0xe3456687
- .word 0xa001aa88
- .word 0xf0e159ea
- .word 0x9152137b
- .word 0xaab385a1
- .word 0x31093c54
- .word 0x42102f37
- .word 0x00ee655b
- .word 0x42102f37
- .word 0x00ee655b
- .word 0x00000001
- .word 0x00000002
- .word 0xffff0001
- .text
- li $s5, 0
- li $s0, 1
- li $s1, 2
- lw $s3, datalen
- la $s4, data
- while:
- beq $s3, $s0, print
- nop
- sll $s6, $s0, 2
- add $s6, $s6, $s4
- sub $s7, $s6, 4
- lw $t5, 0($s6)
- lw $t6, 0($s7)
- # If (a[i - 1] <= a[i])
- bge $t5, $t6, endelse
- nop
- sw $t5, 0($s7)
- sw $t6, 0($s6)
- sub $s0, $s0, 1
- bne $s0, $zero, while
- nop
- li $s0, 1
- li $s1, 2
- j while
- nop
- endelse:
- la $s0, ($s1)
- add $s1, $s1, 1
- j while
- nop
- print:
- beq $s5, $s3, exit
- nop
- sll $t3, $s5, 2 # Multiply the iterator times 4 (2 because its the power of 2)
- addu $t3, $t3, $s4 # Gets the momoryaddress of the array
- li $v0, 1 #Prepare for printing an int
- lw $a0, 0($t3) # Load the value of the int that is going to print
- syscall
- li $v0, 4 # Prepare to print a string
- la $a0, newline # Load the string
- syscall
- addi $s5, $s5, 1 # Increase the iterator by one for the loop functionality
- j print #Jump to the top of the loop
- nop
- exit:
- li $v0, 10
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement