Advertisement
Terrys

askisi 3.1 a)

Apr 28th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. .text
  2. .globl __start
  3. __start:
  4. read_num: li $v0,5
  5. syscall #read number
  6. move $t0,$v0
  7.  
  8. print_endl1: la $a0,endl #newline
  9. li $v0,4
  10. syscall
  11.  
  12. load_divs: li $s0,2
  13. li $s1,3
  14. li $s2,5
  15.  
  16. div2: div $t0,$s0
  17. store_remainder_div2: mfhi $t1 #storing the remainder to
  18. if_Not_div2_avoid_message: bne $t1,$zero,div3
  19. if_div2_print_message: la $a0,by2
  20. li $v0,4
  21. syscall
  22. addi $t3,$t3,1
  23.  
  24.  
  25. print_endl2: la $a0,endl
  26. li $v0,4
  27. syscall
  28.  
  29.  
  30.  
  31. div3: div $t0,$s1
  32. store_remainder_div3: mfhi $t1 #storing the remainder to
  33. if_Not_div3_avoid_message: bne $t1,$zero,div5
  34. if_div3_print_message: la $a0,by3
  35. li $v0,4
  36. syscall
  37. addi $t3,$t3,1
  38.  
  39.  
  40. print_endl3: la $a0,endl
  41. li $v0,4
  42. syscall
  43.  
  44. div5: div $t0,$s2
  45. store_remainder_div5: mfhi $t1 #storing the remainder to
  46. if_Not_div5_avoid_message: bne $t1,$zero,div3
  47. if_div5_print_message: la $a0,by5
  48. li $v0,4
  49. syscall
  50. addi $t3,$t3,1
  51. print_endl4: la $a0,endl
  52. li $v0,4
  53. syscall
  54.  
  55. nothing: bne $t3,$zero,Exit
  56.  
  57. print_Not_divi_by2_3_5: la $a0,noth
  58. li $v0,4
  59. syscall
  60. Exit: li $v0,10
  61. syscall
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. .data
  70. by2: .asciiz "Divided by 2"
  71. by3: .asciiz "Divided by 3"
  72. endl: .asciiz "\n"
  73. by5: .asciiz "Divided by 5"
  74. noth: .asciiz "It is not divided by any of the 2,3,5 "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement