Advertisement
juaniisuar

Untitled

May 27th, 2015
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. .data
  2. str1: .asciiz "Cant de numeros: "
  3. espacio: .asciiz " "
  4. array: .space 512 # 128 ints
  5.  
  6. .text
  7. main: li $v0, 4
  8. la $a0, str1
  9. syscall
  10. li $v0, 5
  11. syscall
  12.  
  13. li $s0, 0
  14. la $t0, array
  15. or $s1, $v0, $0
  16.  
  17. for1: bge $s0, $s1, seguir
  18.  
  19. li $v0, 5
  20. syscall
  21.  
  22. sw $v0, 0($t0)
  23.  
  24. addi $s0, $s0, 1
  25. addi $t0, $t0, 4
  26. j for1
  27.  
  28. seguir:
  29. li $t0, 0
  30. la $t5, array
  31.  
  32. FOR: bge $t0, $s1, finpr
  33.  
  34. li $t1, 0
  35. li $t2, 1
  36. or $t6, $t5, $0
  37.  
  38. FOR2: bge $t2, $s1, fin2
  39.  
  40. lw $t3, 0($t6)
  41. lw $t4, 4($t6)
  42.  
  43. bge $t4, $t3, noswap # si es menor hace ...
  44.  
  45. sw $t3, 4($t6)
  46. sw $t4, 0($t6)
  47.  
  48. noswap:
  49. addi $t6, $t6, 4
  50. addi $t1, $t1, 1
  51. addi $t2, $t2, 1
  52. j FOR2
  53.  
  54. fin2:
  55. addi $t0, $t0, 1
  56. j FOR
  57.  
  58. finpr: li $s0, 0
  59. la $t0, array
  60.  
  61. for2:
  62. bge $s0, $s1, ceguir
  63. li $v0, 1
  64.  
  65. lw $a0, 0($t0)
  66. syscall
  67.  
  68. li $v0, 4
  69. la $a0, espacio
  70. syscall
  71.  
  72. addi $s0, $s0, 1
  73. addi $t0, $t0, 4
  74. j for2
  75.  
  76. ceguir: li $v0, 10
  77. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement