Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. .data
  2. #array: .word 2 1 3 4 5 6 7 8 9 10 11 12 13
  3. array: .word 13 12 11 10 9 8 7 6 5 4 3 2 1
  4. arrayLen:.word 13
  5.  
  6. .text
  7. .globl main
  8.  
  9.  
  10. main:
  11. la $t6, array
  12. la $t0, array
  13. la $t1, arrayLen
  14. lw $t2, 0($t1) #array length
  15. addi $t9, $t2, 1 #array length+1
  16. li $s0, 0 #counter outer
  17. li $s1, 0 #counter inner
  18. li $t3, 0
  19. li $t4, 0
  20. j outer
  21.  
  22. outer:
  23. addi $s0, $s0, 1 #counter increment
  24. blt $s0, $t9, inner
  25. j end
  26.  
  27. inner:
  28. addi $s1, $s1, 1 #counter increment
  29. bgt $s1, $t2, outer
  30.  
  31.  
  32. add $t0, $t0, $t4
  33.  
  34. addi $t3, $t0, 4
  35.  
  36. addi $t4, $t4, 4 #offset counter
  37.  
  38.  
  39. lw $s3, 0($t0)
  40. lw $s4, 0($t3)
  41.  
  42. blt $s3, $s4, inner
  43. j swap
  44.  
  45.  
  46. swap:
  47. sw $s3, 0($t3)
  48. sw $s4, 0($t0)
  49. j inner
  50.  
  51. end:
  52. li $v0, 1
  53.  
  54. lw $a0, 0($t6)
  55. syscall
  56. lw $a0, 4($t6)
  57. syscall
  58. lw $a0, 8($t6)
  59. syscall
  60. lw $a0, 12($t6)
  61. syscall
  62. lw $a0, 16($t6)
  63. syscall
  64. lw $a0, 20($t6)
  65. syscall
  66. lw $a0, 24($t6)
  67. syscall
  68. lw $a0, 28($t6)
  69. syscall
  70. lw $a0, 32($t6)
  71. syscall
  72. lw $a0, 36($t6)
  73. syscall
  74. lw $a0, 40($t6)
  75. syscall
  76. lw $a0, 44($t6)
  77. syscall
  78. lw $a0, 48($t6)
  79. syscall
  80.  
  81.  
  82. li $v0, 10
  83. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement