Advertisement
LegoDrifter

MIPS niza od broevi i nivna suma so ciklus

Apr 17th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. .data
  2.  
  3. x: .word 1,2,3,4,5,6,7,8,90,10
  4. i: .word 0
  5. size: .word 9
  6.  
  7. prompt: .asciiz "The total sum of the array is equal to: "
  8.  
  9. .text
  10. main:
  11.  
  12. la $s0, prompt
  13. la $t0, x
  14. lw $t1, i
  15. lw $t2, size
  16.  
  17. begin_loop:
  18. bgt $t1,$t2 exit_loop
  19.  
  20. sll $t3,$t1 2
  21.  
  22. addu $t3,$t3,$t0 #ja dodavame baznata adresa 1000 + 4
  23.  
  24. lw $t6,0($t3)
  25.  
  26. addu $s7,$s7,$t6
  27.  
  28. addi $t1,$t1,1
  29.  
  30. j begin_loop
  31.  
  32. exit_loop:
  33.  
  34. li $v0, 4
  35. la $a0, prompt
  36. syscall
  37.  
  38. li $v0, 1
  39. la $a0, ($s7)
  40. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement