Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. LAB clr R3
  2. clr R4
  3. clr R5
  4. clr R6
  5. clr R7
  6. clr R8
  7. clr R9
  8. clr R10
  9. clr R11
  10. mov.b #0xFF, &P1DIR
  11. mov.b #0x00, &P2DIR
  12. CHECK mov.b &P2IN, R4
  13. mov.b R4,R8 ;preserve the input for other checks
  14. and.b #0x38, R4 ;mask the pattern at start
  15. mov.b R4, R7 ;move it to R7
  16. mov.b R8, R4 ;put the raw input back into R4
  17. and.b #0x01, R4 ;mask it for P2.0
  18. cmp.b #1, R4
  19. jz READ
  20. mov.b R8, R4 ;get the raw input again
  21. and.b #0x02, R4 ;mask it for P2.1
  22. cmp.b #2, R4
  23. jz LEFT
  24. jmp RIGHT
  25.  
  26. LEFT mov.b R8, R4 ;get the raw input again
  27. and.b #0x04, R4 ;mask it for P2.2
  28. cmp.b #4, R4
  29. clrc
  30. jz ROTLF
  31. jmp ROTLS
  32.  
  33. RIGHT mov.b R8, R4 ;get the raw input again
  34. and.b #0x04, R4 ;mask it for P2.2
  35. cmp.b #4, R4
  36. clrc
  37. jz ROTRF
  38. jmp ROTRS
  39.  
  40. READ mov.b &P2IN, R5
  41. mov.b R5, R6 ;R6 will be a duplicate
  42. and.b #0x38, R5 ;masking 00111000 (P2.3-P2.5
  43. mov.b R5, &P1OUT
  44. and.b #0x01, R6
  45. cmp.b #1, R6
  46. jz READ
  47. jmp CHECK
  48.  
  49. ROTRF mov.b R5, R7 ;move the pattern to the rotate register (rot right fast)
  50. ROTRF1 cmp.b #1, R11
  51. jz RFHNDL
  52. jmp RRF
  53. RFHNDL call #CFLAG
  54. RRF rrc.b R7 ;rotate right
  55. jc RFCARRY
  56. jmp CRRF
  57. RFCARRY call #CMOVR
  58. CRRF mov.b R7,&P1OUT ;send to LED
  59. mov.b &P2IN, R5 ;check if the user wants to read a new pattern
  60. mov.b R5, R8
  61. and.b #0x01, R5
  62. cmp.b #1, R5
  63. jz READ
  64. mov.b R8, R5 ;get the raw input again
  65. and.b #0x02, R5 ;mask it for P2.1
  66. cmp.b #2, R5
  67. mov.b R7, R5
  68. jz LEFT
  69. mov.b R8, R5 ;get the raw input again
  70. and.b #0x04, R5 ;mask it for P2.2
  71. cmp.b #4, R5
  72. mov.b R7,R5
  73. jne ROTRS
  74. call #DELAYF ;otherwise delay and rotate again
  75. jmp ROTRF1
  76.  
  77. ROTLS mov.b R5, R7 ;move the pattern to the rotate register (rot left slow)
  78. ROTLS1 cmp.b #1, R11
  79. jz LSHNDL
  80. jmp RLS
  81. LSHNDL call #CFLAG
  82. RLS rlc.b R7 ;rotate left
  83. jc LSCARRY
  84. jmp CRLS
  85. LSCARRY call #CMOVL
  86. CRLS mov.b R7,&P1OUT ;send to LED
  87. mov.b &P2IN, R5 ;check if the user wants to read a new pattern
  88. mov.b R5, R8
  89. and.b #0x01, R5
  90. cmp.b #1, R5
  91. jz READ
  92. mov.b R8, R5 ;get the raw input again
  93. and.b #0x02, R5 ;mask it for P2.1
  94. cmp.b #2, R5
  95. mov.b R7, R5
  96. jne RIGHT
  97. mov.b R8, R5 ;get the raw input again
  98. and.b #0x04, R5 ;mask it for P2.2
  99. cmp.b #4, R5
  100. mov.b R7,R5
  101. jz ROTLF
  102. call #DELAYS ;otherwise delay and rotate again
  103. jmp ROTLS1
  104.  
  105. ROTRS mov.b R5, R7 ;move the pattern to the rotate register (rot right slow)
  106. ROTRS1 cmp.b #1, R11 ;see if we have a carry to bring in
  107. jz RSHNDL ;handle the case, otherwise continue
  108. jmp RRS
  109. RSHNDL call #CFLAG
  110. RRS rrc.b R7 ;rotate right
  111. jc RSCARRY ;preserve the carry if there is one
  112. jmp CRRS
  113. RSCARRY call #CMOVR
  114. CRRS mov.b R7,&P1OUT ;send to LED
  115. mov.b &P2IN, R5 ;check if the user wants to read a new pattern
  116. mov.b R5, R8
  117. and.b #0x01, R5
  118. cmp.b #1, R5
  119. jz READ
  120. mov.b R8, R5 ;get the raw input again
  121. and.b #0x02, R5 ;mask it for P2.1
  122. cmp.b #2, R5
  123. mov.b R7, R5
  124. jz LEFT
  125. mov.b R8, R5 ;get the raw input again
  126. and.b #0x04, R5 ;mask it for P2.2
  127. cmp.b #4, R5
  128. mov.b R7,R5
  129. jz ROTRF
  130. call #DELAYS ;otherwise delay and rotate again
  131. clrc
  132. jmp ROTRS1
  133.  
  134. ROTLF mov.b R5, R7 ;move the pattern to the rotate register (rot left fast)
  135. ROTLF1 cmp.b #1, R11
  136. jz LFHNDL
  137. jmp RLF
  138. LFHNDL call #CFLAG
  139. RLF rlc.b R7 ;rotate right
  140. jc LFCARRY
  141. jmp CRLF
  142. LFCARRY call #CMOVL
  143. CRLF mov.b R7,&P1OUT ;send to LED
  144. mov.b &P2IN, R5 ;check if the user wants to read a new pattern
  145. mov.b R5, R8
  146. and.b #0x01, R5
  147. cmp.b #1, R5
  148. jz READ
  149. mov.b R8, R5 ;get the raw input again
  150. and.b #0x02, R5 ;mask it for P2.1
  151. cmp.b #2, R5
  152. mov.b R7, R5
  153. jne RIGHT
  154. mov.b R8, R5 ;get the raw input again
  155. and.b #0x04, R5 ;mask it for P2.2
  156. cmp.b #4, R5
  157. mov.b R7,R5
  158. jne ROTLS
  159. call #DELAYF ;otherwise delay and rotate again
  160. clrc
  161. jmp ROTLF1
  162.  
  163.  
  164. DELAYF mov.w #3, R9
  165. OUTERF mov.w #10000,R8
  166. INNERF dec.w R8
  167. cmp.w #0, R8
  168. jne INNERF
  169. dec.w R9
  170. cmp.w #0, R9
  171. jne OUTERF
  172. ret
  173.  
  174. DELAYS mov.w #6, R9
  175. OUTERS mov.w #10000,R8
  176. INNERS dec.w R8
  177. cmp.w #0, R8
  178. jne INNERS
  179. dec.w R9
  180. cmp.w #0, R9
  181. jne OUTERS
  182. ret
  183.  
  184. CFLAG mov.b #1, R11 ;R11 will be our flag
  185. ret
  186.  
  187. CMOVR add.b #0x80, R7 ;put the carry into R7
  188. mov.b #0, R11
  189. ret
  190.  
  191. CMOVL add.b #0x01, R7 ;put the carry into R7
  192. mov.b #0, R11
  193. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement