Guest User

Untitled

a guest
Nov 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. #load the ASCII needed
  2. li $t1, ' '
  3. li $t2, '0'
  4. li $t3, ':'
  5. li $t4, 'A'
  6. li $t5, '['
  7. li $t6, '`'
  8. li $t7, '{'
  9. li $t8, 'z'
  10.  
  11.  
  12. #load keystrokeCounter
  13. la $s5, keystrokeCounter
  14.  
  15. #promt message for user input
  16. la $a0, userInput
  17. li $v0, 4
  18. syscall
  19.  
  20. #take user input and store it in register t0
  21. li $v0, 8
  22. la $a0, userString
  23. li $a1, 400
  24. move $t0, $a0
  25. syscall
  26.  
  27. #counter
  28. la $s0, initial
  29.  
  30.  
  31. #time to make this loop :(
  32.  
  33. #exit at end of string
  34. beq $s0, 400, exit
  35.  
  36. lb $t0,($s0)
  37. #check for null
  38. beq $t0,$zero,exit
  39. #branch if character is a space
  40. beq $t1, $t0 space
  41. #branch if less than 0 (special char)
  42. blt $t0, $t2, special
  43. #branch if less than : (digit)
  44. blt $t0, $t3, digit
  45. #branch if less than A (special)
  46. blt $t0, $t4, special
  47. #branch if less than [ (letter)
  48. blt $t0, $t5, letter
  49. #branch if less than ' (special)
  50. blt $t0, $t6, special
  51. #branch if less than { (letter)
  52. blt $t0, $t7, letter
  53. #branch if greater than z (special
  54. bgt $t0, $t8, special
  55.  
  56.  
  57.  
  58.  
  59. #end of label
  60. li $v0, 10
  61. syscall
  62.  
  63. #return back to main while loop
  64. j while
  65.  
  66. #end of label
  67. li $v0, 10
  68. syscall
  69.  
  70. #return back to main while loop
  71. j while
  72.  
  73. #end of label
  74. li $v0, 10
  75. syscall
  76.  
  77. #return back to main while loop
  78. j while
  79.  
  80. #end of label
  81. li $v0, 10
  82. syscall
  83.  
  84. #return back to main while loop
  85. j while
  86.  
  87. #end of label
  88. li $v0, 10
  89. syscall
  90.  
  91. #print spaces
  92. li $v0, 4
  93. la $a0, spaceInfo
  94. syscall
  95.  
  96. lbu $s5,($s1) #load desired index to print
  97. li $v0, 1 #tell mips to print int
  98. move $s5, $a0 #move print target to a0 (where it will be printed)
  99. syscall #print
  100.  
  101. li $v0, 4
  102. la $a0, newLine
  103. syscall
  104.  
  105.  
  106. #print letters
  107. li $v0, 4
  108. la $a0, letterInfo
  109. syscall
  110.  
  111. lbu $s5,($s2) #load desired index to print
  112. li $v0, 1 #tell mips to print int
  113. move $s5, $a0 #move print target to a0 (where it will be printed)
  114. syscall #print
  115.  
  116. li $v0, 4
  117. la $a0, newLine
  118. syscall
  119.  
  120. #print digits
  121. li $v0, 4
  122. la $a0, digitInfo
  123. syscall
  124.  
  125. lbu $s5,($s3) #load desired index to print
  126. li $v0, 1 #tell mips to print int
  127. move $s5, $a0 #move print target to a0 (where it will be printed)
  128. syscall #print
  129.  
  130. li $v0, 4
  131. la $a0, newLine
  132. syscall
  133.  
  134. #print special chars
  135. li $v0, 4
  136. la $a0, specialInfo
  137. syscall
  138.  
  139. lbu $s5,($s4) #load desired index to print
  140. li $v0, 1 #tell mips to print int
  141. move $s5, $a0 #move print target to a0 (where it will be printed)
  142. syscall #print
  143.  
  144. #end of program
  145. li $v0, 10
  146. syscall
Add Comment
Please, Sign In to add comment