Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. blt $s1, 0x80, Case1
  2. ble $s1, 0x7FF, Case2
  3. ble $s1, 0xFFFF, Case3
  4. ble $s1, 0x10FFFF, Case4
  5. li $s2, 0xFFFFFFFF # n = 0xFFFFFFFF
  6. j continue
  7.  
  8. Case1:
  9. la $s2, 0x00000000 # n = 00000000
  10. or $s2, $s2, $s1 # n = n | j
  11. j continue
  12.  
  13.  
  14.  
  15. Case2:
  16. and $t1, $s1, 0x3F # b = low 6 bits
  17. srl $t3, $s1, 6 # shift j right 6 bits
  18. and $t2, $t3, 0x3F # a = next 5 bits
  19. la $s2, 0xC080
  20. sll $t2, $t2, 8
  21. or $s2, $s2, $t2
  22. or $s2, $s2, $t1
  23. j continue
  24.  
  25. Case3:
  26. and $t1, $s1, 0x3F # c = low 6 bits
  27. srl $t4, $s1, 6 # j >> 6
  28. and $t2, $t4, 0x3F # b = next 6 bits
  29. srl $t4, $s1, 12 # j >> 6
  30. and $t3, $t4, 0xF #a = next 4 bits
  31. la $s2, 0xE08080
  32. sll $t3, $t3, 16
  33. sll $t2, $t2, 8
  34. or $s2, $s2, $t1
  35. or $s2, $s2, $t2
  36. or $s2, $s2, $t3
  37. j continue
  38.  
  39. Case4:
  40. and $t1, $s1, 0x3F
  41. srl $t5, $s1, 6
  42. and $t2, $t5, 0x3F
  43. srl $t5, $s1, 12
  44. and $t3, $t5, 0x3F
  45. srl $t5, $s1, 18
  46. and $t4, $t5, 0x7
  47. la $s2, 0xF0808080
  48. sll $t4, $t4, 24
  49. sll $t3, $t3, 16
  50. sll $t2, $t2, 8
  51. or $s2, $s2, $t1
  52. or $s2, $s2, $t2
  53. or $s2, $s2, $t3
  54. or $s2, $s2, $t4
  55. j continue
  56.  
  57. continue:
  58. # Your part ends here
  59.  
  60. # print i, j and n
  61. move $a0, $s0 # i
  62. jal Print_integer
  63. la $a0, sp # space
  64. jal Print_string
  65. move $a0, $s1 # j
  66. jal Print_hex
  67. la $a0, sp # space
  68. jal Print_string
  69. move $a0, $s2 # n
  70. jal Print_hex
  71. la $a0, sp # space
  72. jal Print_string
  73. move $a0, $s1 # j
  74. jal Print_bin
  75. la $a0, sp # space
  76. jal Print_string
  77. move $a0, $s2 # n
  78. jal Print_bin
  79. la $a0, nl # newline
  80. jal Print_string
  81.  
  82. # for (i = 0; i <= 16; i++)
  83. addi $s0, $s0, 1 # i++
  84. addi $t0, $t0, 4 # address of testcase[i]
  85. ble $s0, 16, top # i <= 16
  86. bottom:
  87.  
  88. la $a0, done # mark the end of the program
  89. jal Print_string
  90.  
  91. jal Exit0 # end the program, default return status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement