Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LAB clr R3
- clr R4
- clr R5
- clr R6
- clr R7
- clr R8
- clr R9
- clr R10
- clr R11
- mov.b #0xFF, &P1DIR
- mov.b #0x00, &P2DIR
- CHECK mov.b &P2IN, R4
- mov.b R4,R8 ;preserve the input for other checks
- and.b #0x38, R4 ;mask the pattern at start
- mov.b R4, R7 ;move it to R7
- mov.b R8, R4 ;put the raw input back into R4
- and.b #0x01, R4 ;mask it for P2.0
- cmp.b #1, R4
- jz READ
- mov.b R8, R4 ;get the raw input again
- and.b #0x02, R4 ;mask it for P2.1
- cmp.b #2, R4
- jz LEFT
- jmp RIGHT
- LEFT mov.b R8, R4 ;get the raw input again
- and.b #0x04, R4 ;mask it for P2.2
- cmp.b #4, R4
- clrc
- jz ROTLF
- jmp ROTLS
- RIGHT mov.b R8, R4 ;get the raw input again
- and.b #0x04, R4 ;mask it for P2.2
- cmp.b #4, R4
- clrc
- jz ROTRF
- jmp ROTRS
- READ mov.b &P2IN, R5
- mov.b R5, R6 ;R6 will be a duplicate
- and.b #0x38, R5 ;masking 00111000 (P2.3-P2.5
- mov.b R5, &P1OUT
- and.b #0x01, R6
- cmp.b #1, R6
- jz READ
- jmp CHECK
- ROTRF mov.b R5, R7 ;move the pattern to the rotate register (rot right fast)
- ROTRF1 cmp.b #1, R11
- jz RFHNDL
- jmp RRF
- RFHNDL call #CFLAG
- RRF rrc.b R7 ;rotate right
- jc RFCARRY
- jmp CRRF
- RFCARRY call #CMOVR
- CRRF mov.b R7,&P1OUT ;send to LED
- mov.b &P2IN, R5 ;check if the user wants to read a new pattern
- mov.b R5, R8
- and.b #0x01, R5
- cmp.b #1, R5
- jz READ
- mov.b R8, R5 ;get the raw input again
- and.b #0x02, R5 ;mask it for P2.1
- cmp.b #2, R5
- mov.b R7, R5
- jz LEFT
- mov.b R8, R5 ;get the raw input again
- and.b #0x04, R5 ;mask it for P2.2
- cmp.b #4, R5
- mov.b R7,R5
- jne ROTRS
- call #DELAYF ;otherwise delay and rotate again
- jmp ROTRF1
- ROTLS mov.b R5, R7 ;move the pattern to the rotate register (rot left slow)
- ROTLS1 cmp.b #1, R11
- jz LSHNDL
- jmp RLS
- LSHNDL call #CFLAG
- RLS rlc.b R7 ;rotate left
- jc LSCARRY
- jmp CRLS
- LSCARRY call #CMOVL
- CRLS mov.b R7,&P1OUT ;send to LED
- mov.b &P2IN, R5 ;check if the user wants to read a new pattern
- mov.b R5, R8
- and.b #0x01, R5
- cmp.b #1, R5
- jz READ
- mov.b R8, R5 ;get the raw input again
- and.b #0x02, R5 ;mask it for P2.1
- cmp.b #2, R5
- mov.b R7, R5
- jne RIGHT
- mov.b R8, R5 ;get the raw input again
- and.b #0x04, R5 ;mask it for P2.2
- cmp.b #4, R5
- mov.b R7,R5
- jz ROTLF
- call #DELAYS ;otherwise delay and rotate again
- jmp ROTLS1
- ROTRS mov.b R5, R7 ;move the pattern to the rotate register (rot right slow)
- ROTRS1 cmp.b #1, R11 ;see if we have a carry to bring in
- jz RSHNDL ;handle the case, otherwise continue
- jmp RRS
- RSHNDL call #CFLAG
- RRS rrc.b R7 ;rotate right
- jc RSCARRY ;preserve the carry if there is one
- jmp CRRS
- RSCARRY call #CMOVR
- CRRS mov.b R7,&P1OUT ;send to LED
- mov.b &P2IN, R5 ;check if the user wants to read a new pattern
- mov.b R5, R8
- and.b #0x01, R5
- cmp.b #1, R5
- jz READ
- mov.b R8, R5 ;get the raw input again
- and.b #0x02, R5 ;mask it for P2.1
- cmp.b #2, R5
- mov.b R7, R5
- jz LEFT
- mov.b R8, R5 ;get the raw input again
- and.b #0x04, R5 ;mask it for P2.2
- cmp.b #4, R5
- mov.b R7,R5
- jz ROTRF
- call #DELAYS ;otherwise delay and rotate again
- clrc
- jmp ROTRS1
- ROTLF mov.b R5, R7 ;move the pattern to the rotate register (rot left fast)
- ROTLF1 cmp.b #1, R11
- jz LFHNDL
- jmp RLF
- LFHNDL call #CFLAG
- RLF rlc.b R7 ;rotate right
- jc LFCARRY
- jmp CRLF
- LFCARRY call #CMOVL
- CRLF mov.b R7,&P1OUT ;send to LED
- mov.b &P2IN, R5 ;check if the user wants to read a new pattern
- mov.b R5, R8
- and.b #0x01, R5
- cmp.b #1, R5
- jz READ
- mov.b R8, R5 ;get the raw input again
- and.b #0x02, R5 ;mask it for P2.1
- cmp.b #2, R5
- mov.b R7, R5
- jne RIGHT
- mov.b R8, R5 ;get the raw input again
- and.b #0x04, R5 ;mask it for P2.2
- cmp.b #4, R5
- mov.b R7,R5
- jne ROTLS
- call #DELAYF ;otherwise delay and rotate again
- clrc
- jmp ROTLF1
- DELAYF mov.w #3, R9
- OUTERF mov.w #10000,R8
- INNERF dec.w R8
- cmp.w #0, R8
- jne INNERF
- dec.w R9
- cmp.w #0, R9
- jne OUTERF
- ret
- DELAYS mov.w #6, R9
- OUTERS mov.w #10000,R8
- INNERS dec.w R8
- cmp.w #0, R8
- jne INNERS
- dec.w R9
- cmp.w #0, R9
- jne OUTERS
- ret
- CFLAG mov.b #1, R11 ;R11 will be our flag
- ret
- CMOVR add.b #0x80, R7 ;put the carry into R7
- mov.b #0, R11
- ret
- CMOVL add.b #0x01, R7 ;put the carry into R7
- mov.b #0, R11
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement