Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. # 2017 Vincent Åström, William Åkerman
  2.  
  3. .macro PUSH reg
  4. addi $sp, $sp, -4
  5. sw \reg, 0($sp)
  6. .endm
  7.  
  8. .macro POP reg
  9. lw \reg, 0($sp)
  10. addi $sp, $sp, 4
  11. .endm
  12.  
  13. .data
  14. .global main
  15. .global user_isr
  16. .globl loop
  17. .text
  18.  
  19. init:
  20. PUSH $t0
  21. li $t0, 0x0
  22. li $s0, 0x0 # lines = 0
  23. li $s4, 0xc0 # pixel data
  24. sb $t0, 0xbf886100 # TRISE = 0x0
  25. sb $t0, 0xbf886110 # PORTE = 0x0
  26. sw $t0, 0xbf800800 # T2CON = 0x0
  27. sw $t0, 0xbf800810 # TMR2 = 0x0
  28. li $t0, 1820
  29. sw $t0, 0xbf800820 # PR2 = 1820
  30. li $t0, 0x8000
  31. sw $t0, 0xbf800808 # T2CONSET = 0x8000
  32. li $t0, 0x100
  33. sw $t0, 0xbf881060 # IEC0 = 0x100
  34. li $t0, 0x4
  35. sw $t0, 0xbf8810b0 # IPC2 = 0x4
  36. ei # enable interrupts globally
  37. POP $t0
  38. jr $ra
  39. nop
  40.  
  41. # ----- ----- ----- ----- -----
  42. main:
  43. jal init
  44. nop
  45.  
  46. li $t1, 0x0
  47.  
  48. loop:
  49. addi $t1, $t1, 1
  50.  
  51. blt $s0, 300, cyan
  52. nop
  53.  
  54. j stuck
  55. nop
  56. cyan:
  57. blt $t1, 40, red
  58. nop
  59. li $s4, 0xfc
  60. j loop
  61. nop
  62. red:
  63. li $s4, 0xc3
  64. j stuck
  65. nop
  66.  
  67. stuck:
  68. j stuck
  69. nop
  70.  
  71. #starto: bne $s4, 0xff, incr
  72. # nop
  73. # li $t8, 0x0
  74. # loop2:
  75. # addi $t8, $t8, 0x1
  76. # bne $t8, 0x10000, loop2
  77. # nop
  78. # li $s4, 0xc0
  79. # j starto
  80. # nop
  81. #incr:
  82. # li $t8, 0x0
  83. #loop1:
  84. # addi $t8, $t8, 0x1
  85. # bne $t8, 0x10000, loop1
  86. # nop
  87.  
  88. # addi $s4, $s4, 0x1
  89. # j starto
  90. # nop
  91.  
  92. # ----- ----- ----- ----- -----
  93. user_isr:
  94. PUSH $t0
  95.  
  96. blt $s0, 480, r0
  97. nop
  98. blt $s0, 491, r1
  99. nop
  100. blt $s0, 493, r2
  101. nop
  102. blt $s0, 524, r1
  103. nop
  104.  
  105. li $t0, 0xc0
  106. sb $t0, 0xbf886110 # PORTE = 0xc0
  107. li $t0, 0x0
  108. ls40:
  109. addi $t0, 0x1
  110. bne $t0, 40, ls40
  111. nop
  112.  
  113. li $t0, 0x80
  114. sb $t0, 0xbf886110 # PORTE = 0x80
  115. li $t0, 0x0
  116. ls41:
  117. addi $t0, 0x1
  118. bne $t0, 80, ls41
  119. nop
  120. li $t0, 0xc0
  121. sb $t0, 0xbf886110 # PORTE = 0xc0
  122. li $t0, 0x0
  123. ls42:
  124. addi $t0, 0x1
  125. bne $t0, 40, ls42
  126. nop
  127. li $t0, 0xc0
  128. sb $t0, 0xbf886110 # PORTE = 0xc0
  129.  
  130. li $s0, 0 # lines = 0
  131. j endif
  132. nop
  133.  
  134. # ----- ----- ----- ----- -----
  135. r0:
  136. li $t0, 0xc0
  137. sb $t0, 0xbf886110 # PORTE = 0xc0
  138. li $t0, 0x0
  139. l00:
  140. addi $t0, 0x1
  141. bne $t0, 40, l00
  142. nop
  143. li $t0, 0x80
  144. sb $t0, 0xbf886110 # PORTE = 0x80
  145. li $t0, 0x0
  146. l01:
  147. addi $t0, 0x1
  148. bne $t0, 80, l01
  149. nop
  150. li $t0, 0xc0
  151. sb $t0, 0xbf886110 # PORTE = 0xc0
  152. li $t0, 0x0
  153. l02:
  154. addi $t0, 0x1
  155. bne $t0, 40, l02
  156. nop
  157.  
  158. li $t0, 0xf0 # 5
  159. sb $s4, 0xbf886110 # PORTE = 0xc3
  160. j endif
  161. nop
  162. # ----- ----- ----- ----- -----
  163. r1:
  164. li $t0, 0xc0
  165. sb $t0, 0xbf886110 # PORTE = 0xc0
  166. li $t0, 0x0
  167. l10:
  168. addi $t0, 0x1
  169. bne $t0, 40, l10
  170. nop
  171. li $t0, 0x80
  172. sb $t0, 0xbf886110 # PORTE = 0x80
  173. li $t0, 0x0
  174. l11:
  175. addi $t0, 0x1
  176. bne $t0, 80, l11
  177. nop
  178. li $t0, 0xc0
  179. sb $t0, 0xbf886110 # PORTE = 0xc0
  180. li $t0, 0x0
  181. l12:
  182. addi $t0, 0x1
  183. bne $t0, 40, l12
  184. nop
  185. li $t0, 0xc0
  186. sb $t0, 0xbf886110 # PORTE = 0xc0
  187. j endif
  188. nop
  189. # ----- ----- ----- ----- -----
  190. r2:
  191. li $t0, 0x40
  192. sb $t0, 0xbf886110 # PORTE = 0x0
  193. li $t0, 0x0
  194. l20:
  195. addi $t0, 0x1
  196. bne $t0, 40, l20
  197. nop
  198. li $t0, 0x0
  199. sb $t0, 0xbf886110 # PORTE = 0x0
  200. li $t0, 0x0
  201. l21:
  202. addi $t0, 0x1
  203. bne $t0, 80, l21
  204. nop
  205. li $t0, 0x40
  206. sb $t0, 0xbf886110 # PORTE 0x40
  207. li $t0, 0x0
  208. l22:
  209. addi $t0, 0x1
  210. bne $t0, 40, l22
  211. nop
  212. li $t0, 0x40
  213. sb $t0, 0xbf886110 # PORTE = 0x40
  214. j endif
  215. nop
  216. # ----- ----- ----- ----- -----
  217. endif:
  218. addi $s0, $s0, 1 # lines++
  219. li $t0, 0x0
  220. sw $t0, 0xbf800810 # clear TMR2
  221. sw $t0, 0xbf881030 # clear IFS0
  222. POP $t0
  223. jr $ra
  224. nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement