Advertisement
LegoDrifter

MIPS - Zadaca 3

Apr 18th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. .data
  2. b1: .asciiz "Vnesi broj1:"
  3. b2: .asciiz "Vnesi broj2:"
  4. x: .word 4
  5. y: .word 0
  6. .text
  7. lw $s0, y
  8. lw $s1, x
  9. li $v0, 4
  10. la $a0, b1
  11. syscall
  12.  
  13. li $v0, 5 #scanf za broj1
  14. syscall
  15. move $t0, $v0
  16.  
  17. li $v0, 5
  18. syscall
  19. move $t1, $v0
  20.  
  21. ciklus:
  22. beq $t0, $t1 kraj
  23. div $t0, $s1 # gi delime t0 i 4
  24. mfhi $t3
  25. beq $t3, 1 sumiranje #ako ostatokot e eden odi vo sumiranje labelata
  26. addi $t0,$t0 1 #go inkrementirame t0 ako ne vazi uslovot
  27. j ciklus
  28.  
  29. sumiranje:
  30. addu $s0,$s0,$t0 #na t4 mu go dodavame momentalniot t0 # MORA I MOMENTALNOTO S0 DA GO DODADEME INACE PREBRISUVANJE IMAME
  31. addi $t0,$t0,1 #go inkrementirame t0
  32. j ciklus
  33.  
  34. kraj:
  35. li $v0, 1
  36. move $a0, $s0
  37. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement