Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1.  
  2. # HoopStats.s
  3. # Tripp Whaley
  4.  
  5. .data
  6.  
  7. buffer: .space 256
  8.  
  9. inputName:
  10. .asciiz "Enter player's last name: "
  11.  
  12. inputPoints:
  13. .asciiz "Enter player's points per game: "
  14.  
  15. inputMinutes:
  16. .asciiz "Enter player's minutes per game: "
  17.  
  18. done:
  19. .asciiz "DONE\n"
  20.  
  21. newline:
  22. .asciiz "\n"
  23.  
  24. space:
  25. .asciiz " "
  26.  
  27.  
  28. .align 2
  29. .globl main
  30. .text
  31.  
  32.  
  33. main:
  34. li $v0, 9 # init memory
  35. li $a0, 264 # null node
  36. syscall
  37.  
  38. move $t6, $v0
  39. move $s4, $t6
  40.  
  41. sw $s4, 0($t6) #s4 is null head, #t7 is the prev pointer
  42.  
  43. #t6 is actual storage of node
  44.  
  45. loop:
  46.  
  47. move $s2, $t6
  48. move $t0, $v0
  49. li $v0, 9 # init memory
  50. li $a0, 264 # 255 string, 1 null character, 4 float, 4 pointer
  51. syscall
  52.  
  53. sw $v0, 260($t6)
  54.  
  55.  
  56. move $t6, $v0 # store string and mem. addr.
  57.  
  58. li $v0, 4
  59. la $a0, inputName #print string prompt
  60. syscall
  61.  
  62. li $v0,8 #take in input
  63. la $a0, buffer #load byte space into address
  64. li $a1, 256 # allot the byte space for string
  65. move $t0,$a0 #save string to t0
  66. syscall
  67.  
  68. move $t4, $zero
  69. move $t5, $t6
  70. strloop:
  71. lw $t7, 0($t0)
  72. sw $t7, 0($t5)
  73.  
  74. addi $t4, $t4, 4
  75. addi $t0, $t0, 4
  76. addi $t5, $t5, 4
  77.  
  78. blt $t4, 256, strloop
  79.  
  80. move $t1, $a0
  81.  
  82.  
  83.  
  84. # CHECK STRINGS
  85.  
  86. # string is in t1 from move above, load DONE\n into a1
  87. la $t2, done
  88. add $t1, $zero, $t1
  89. add $t2, $zero, $t2
  90. jal myComp
  91. beq $v0,$zero, exit #check result
  92.  
  93. # END CHECK STRINGS
  94.  
  95. li $v0, 4
  96. la $a0, inputPoints
  97. syscall
  98.  
  99. li $v0, 6
  100. syscall
  101.  
  102. mov.s $f2, $f0 # move float points to s2 mov.s and $a0 instead?
  103.  
  104.  
  105. li $v0, 4
  106. la $a0, inputMinutes
  107. syscall
  108.  
  109. li $v0, 6
  110. syscall
  111.  
  112. mov.s $f3, $f0 # move float minutes to s3
  113.  
  114.  
  115. div.s $f4, $f2, $f3 # store float and mem. addr.
  116. s.s $f4, 256($t6)
  117.  
  118.  
  119.  
  120. #sw $t7, 260($t6) # next node?
  121. #move $t6, $t7
  122.  
  123. b loop
  124.  
  125. endloop:
  126. jr $ra
  127. j exit
  128.  
  129. myComp:
  130.  
  131. lb $t3($t1)
  132. lb $t4($t2)
  133.  
  134. beqz $t3, check
  135. beqz $t4, missmatch
  136.  
  137. slt $t5, $t3, $t4
  138. bnez $t5, missmatch
  139. addi $t1, $t1, 1
  140. addi $t2, $t2, 1
  141. j myComp
  142.  
  143. check:
  144.  
  145. bnez $t4, missmatch
  146. li $v0, 0
  147. j exit
  148. jr $ra
  149.  
  150. missmatch:
  151.  
  152. addi $v0, $zero, 1
  153. jr $ra
  154.  
  155. sort:
  156.  
  157. lw $t0, 260($s4)
  158. la $t0, 0($t0)
  159.  
  160. jal loopSort
  161.  
  162. jr $ra
  163.  
  164. loopSort:
  165.  
  166.  
  167. la $a0, 0($t0)
  168. li $v0, 4
  169. syscall
  170.  
  171. la $a0, space
  172. li $v0, 4
  173. syscall
  174.  
  175. l.s $f0, 256($t0)
  176.  
  177. mov.s $f12, $f0
  178. li $v0, 2
  179. syscall
  180.  
  181. la $a0, newline
  182. li $v0, 4
  183. syscall
  184.  
  185. lw $t0, 260($t0)
  186.  
  187. beq $t0, $zero, end
  188.  
  189. la $t0, 0($t0)
  190.  
  191.  
  192. j loopSort
  193.  
  194.  
  195.  
  196. exit:
  197.  
  198. lw $zero, 260($s2) # set DONE node to 0
  199.  
  200. jal sort
  201.  
  202. li $v0, 10
  203. syscall
  204.  
  205. end :
  206.  
  207. li $v0, 10
  208. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement