Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- #array: .word 2 1 3 4 5 6 7 8 9 10 11 12 13
- array: .word 13 12 11 10 9 8 7 6 5 4 3 2 1
- arrayLen:.word 13
- .text
- .globl main
- main:
- la $t6, array
- la $t0, array
- la $t1, arrayLen
- lw $t2, 0($t1) #array length
- addi $t9, $t2, 1 #array length+1
- li $s0, 0 #counter outer
- li $s1, 0 #counter inner
- li $t3, 0
- li $t4, 0
- j outer
- outer:
- addi $s0, $s0, 1 #counter increment
- blt $s0, $t9, inner
- j end
- inner:
- addi $s1, $s1, 1 #counter increment
- bgt $s1, $t2, outer
- add $t0, $t0, $t4
- addi $t3, $t0, 4
- addi $t4, $t4, 4 #offset counter
- lw $s3, 0($t0)
- lw $s4, 0($t3)
- blt $s3, $s4, inner
- j swap
- swap:
- sw $s3, 0($t3)
- sw $s4, 0($t0)
- j inner
- end:
- li $v0, 1
- lw $a0, 0($t6)
- syscall
- lw $a0, 4($t6)
- syscall
- lw $a0, 8($t6)
- syscall
- lw $a0, 12($t6)
- syscall
- lw $a0, 16($t6)
- syscall
- lw $a0, 20($t6)
- syscall
- lw $a0, 24($t6)
- syscall
- lw $a0, 28($t6)
- syscall
- lw $a0, 32($t6)
- syscall
- lw $a0, 36($t6)
- syscall
- lw $a0, 40($t6)
- syscall
- lw $a0, 44($t6)
- syscall
- lw $a0, 48($t6)
- syscall
- li $v0, 10
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement