Guest User

Untitled

a guest
Jun 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. .globl main
  2. .text
  3.  
  4. li $v0, 5 #system call for read integer
  5. syscall #read integer
  6.  
  7. bltu $v0, 50, else #if $v0 < 50 branch to else (failing grade)
  8. sw $v0, 0($t1) #store word in pass array
  9. addi $t1, $t1, 4 #t1 = t1 + 4 (increment pass pointer)
  10. addi $t0, $t0, 1 #t0 = t0 + 1 (increment pass counter)
  11. b l_end #branch over else statement
  12.  
  13. li $v0, 4 #system call for print string
  14. la $a0, o_pasc #load string
  15. syscall #output "Number of Passing Scores:
  16.  
  17. la $v0, 1 #system call for print integer
  18. add $a0, $t0, 0 #load value of pass counter into $a0
  19. syscall #output value
  20.  
  21. li $v0, 4 #system call for print string
  22. la $a0, o_fasc #load string
  23. syscall #output "Number of Failing Scores: "
  24.  
  25. la $v0, 1 #system call for print string
  26. add $a0, $t2, 0 #load value of fail counter into $a0
  27. syscall #output value
  28.  
  29. li $v0, 4 #setup output
  30. la $a0, o_pass #setup text
  31. syscall #output string o_pass
  32.  
  33. la $t1, pass #load address of pass pointer to t1
  34. lw $a0, 0($t1) #load word at $t1 into $a0
  35. li $v0, 1 #system call for print integer
  36.  
  37. li $v0, 4 #system call for print string
  38. la $a0, o_coma #load string
  39. syscall #ouput comma and space
  40.  
  41. li $v0, 1 #setup output
  42. addi $t1, $t1, 4 #move pointer down by 1 word
  43. lw $a0, 0($t1) #move word at pointer into $a0
  44. addi $t5, $t5, 1 #add 1 to counter
  45.  
  46. b loop_a #branch to top
  47.  
  48. la $t5, 0 #clear t5 (counter)
  49. li $v0, 4 #setup output
  50. la $a0, o_fail #setup text
  51. syscall #output string o_fail
  52.  
  53. la $t3, fail #load address for fail pointer into $t3
  54. lw $a0, 0($t3) #load word at mem addy $t3 into $a0
  55. li $v0, 1 #system call for print integer
  56.  
  57. li $v0, 4 #system call for print string
  58. la $a0, o_coma #load string
  59. syscall #output comma and space
  60.  
  61. li $v0, 1 #setup output
  62. addi $t3, $t3, 4 #move pointer down by 1 word
  63. lw $a0, 0($t3) #load word from mem addy $t3 to $a0
  64. addi $t5, $t5, 1 #add 1 to counter
  65.  
  66. b loop_b #branch to top
  67.  
  68. li $v0, 4 #setup output
  69. la $a0, o_brk #setup text
  70. syscall #output line break
  71.  
  72. li $v0, 10 #loads 10 to $v0
  73. syscall #ends program
  74.  
  75. bleu $t0,$t5,lp_a_end #if t0 <= t5 branch to lp_a_end
  76.  
  77. bleu $t0,$zero,lp_a_end
  78.  
  79. li $t5,50
  80. bltu $v0,$t5,else
  81.  
  82. la $t3, fail #load address for fail pointer into $t3
  83. lw $a0, 0($t3) #load word at mem addy $t3 into $a0
  84. li $v0, 1
  85. loop_b: bleu $t2, $t5, lp_b_end #if t2 <= t5 branch to lp_a_end
  86. syscall #output single score
  87.  
  88. #Is there anything to print in the array? If not, goto lp_b_end
  89. bleu $t2,$zero,lp_b_end
  90.  
  91. #Ok, we know we are not pointing at an invalid position of the array.
  92. la $t3, fail #load address for fail pointer into $t3
  93. lw $a0, 0($t3) #load word at mem addy $t3 into $a0
  94. li $v0, 1
  95. syscall
Add Comment
Please, Sign In to add comment