Advertisement
Alhiris

Mips problem4(vector max)

Oct 22nd, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. .data
  2. v: .space 400
  3. n: .space 4
  4. sp: .asciiz " "
  5. .text
  6. main:
  7. li $v0,5
  8. syscall
  9. sw $v0,n
  10. lw $t0,n
  11. li $t1,0
  12. li $t2,0
  13. li $t3,0
  14. li $t4,0
  15. for:
  16. bge $t1,$t0,exit
  17. li $v0,5
  18. syscall
  19. sw $v0,v($t2)
  20. lw $t5,v($t2)
  21. bgt $t5,$t3,change
  22. continue:
  23. addi $t1,1
  24. addi $t2,4
  25. j for
  26. change:
  27. move $t3,$t5
  28. move $t4,$t1
  29. j continue
  30.  
  31. exit:
  32. move $a0,$t3
  33. li $v0,1
  34. syscall
  35. la $a0,sp
  36. li $v0,4
  37. syscall
  38. addi $t4,1
  39. move $a0,$t4
  40. li $v0,1
  41. syscall
  42. li $v0,10
  43. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement