Advertisement
ChrisH41

Untitled

Feb 9th, 2023
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.  
  3. .text
  4. # 1000/3 = 333 , 1000/5 = 200
  5. li $t0, 0 # This is my total sum
  6. li $t1, 1 # This is my counter
  7.  
  8. multiple_of_Three:
  9.     bgt $t1, 333, Reset_Values # If $t1 > 333 --> Reset_Values
  10.  
  11.     mul $t2, $t1, 3      # This finds my multiple t2 = 3 * counter
  12.     add $t0, $t0, $t2    # This sums my new multiple with previous ones
  13.     addi $t1, $t1, 1     # Increment Counter
  14.     j multiple_of_Three
  15.  
  16. Reset_Values:
  17. move $s0, $t0 #Save my previous sum of three multipeles
  18. li $t0, 0 # This is my total sum
  19. li $t1, 1 # This is my counter
  20.  
  21. multiple_of_Five:
  22.     bgt $t1, 199, end # If $t1 > 200 --> End
  23.  
  24.     mul $t2, $t1, 5     # This finds my multiple t2 = 5 * counter
  25.     add $t0, $t0, $t2    # This sums my new multiple with previous ones
  26.     addi $t1, $t1, 1     # Increment Counter
  27.     j multiple_of_Five
  28.    
  29. end:
  30. add $s0, $s0, $t0
  31. subi $s0, $s0, 33165
  32. li $v0, 1
  33. move $a0, $s0
  34. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement