; tuta4.asm ; using aliases, bit names and conditional loops list p=p16f84 radix hex include "p16f84.inc" ; high speed >4mhz osc ; disable watchdog timer __config _HS_OSC & _WDT_OFF #define page0 bcf STATUS,5 #define page1 bsf STATUS,5 count equ 0x0c ; counter storage ncount equ 0x0d ; count down storage register mcount equ 0x0e ; count down storage register ocount equ 0x0f ; count down storage register shift equ 0x24 ; temporary pattern register w equ 0 ; working register flag f equ 1 ; file register flag c equ 0 ; carry flag org 0 ; reset vector call 5 ; call start of program org 4 ; interrupt vector call 5 ; call start of program org 5 ; start of program memory clrf PORTA ; clear port a data register clrf PORTB ; clear port b data register page1 ; page1 clrf TRISA ; disable port A inputs clrf TRISB ; set all port b as output (clear direction reg) page0 ; page0 bcf STATUS,C ; disable carry flag movlw b'00000001' ; initial bit pattern movwf shift ; store pattern ; ; Clockwise Rotation ; clockw movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,000 clrf PORTB ; all EL off rlf shift,f ; next EL on btfss STATUS,0 ; test carry flag goto clockw ; re-run until carry flag set ; ; Setup bit for reverse function ; revs movlw b'10000000' ; initial bit pattern movwf shift ; store pattern ; ; Counter Clockwise Rotation ; reverse movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,000 clrf PORTB ; all EL off rrf shift,f ; start from highest bit in portb btfss STATUS,0 ; test carry flag goto reverse ; re-run until carry flag set movwf PORTB ; puts the contents of W into portb call pause ; count to 65,000 clrf PORTB ; all EL off ; ; Setup bit for skipen function ; skipse movlw b'00000001' ; initial bit pattern movwf shift ; store pattern ; ; Rotate every even bit including zero in portb ; skipen movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off rlf shift,f ; skipping a wire with two instructions (1) rlf shift,f ; skipping a wire with two instructions (2) btfss STATUS,0 ; test carry flag goto skipen ; re-run until carry flag set movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off ; ; Rotate every odd bit including zero in portb ; skipod movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off rlf shift,f ; skipping a wire with two instructions (1) rlf shift,f ; skipping a wire with two instructions (2) btfss STATUS,0 ; test carry flag goto skipod ; re-run until carry flag set movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off ; ; Initialize across bit ; acrossi movlw b'00010001' ; initial bit pattern movwf shift ; store pattern ; ; Flash each piece of EL directly across from each other ; across movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off rlf shift,f ; skipping a wire with two instructions (2) btfss STATUS,0 ; test carry flag goto across ; re-run until carry flag set movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off ; ; flash setup ; flashs movlw b'01010101' ; initial bit pattern movwf shift ; store pattern ; ; Flash all of each color ; flash movf shift,w ; puts the contents of shift into W movwf PORTB ; puts the contents of W into portb call pause ; count to 65,0000 clrf PORTB ; all EL off rlf shift,f ; skipping a wire with two instructions (2) btfss STATUS,0 ; test carry flag goto flash ; re-run until carry flag set goto clockw ; back to the first function pause movlw 0xff movwf mcount loadn movlw 0xff movwf ncount deco nop nop nop nop nop decfsz ocount,f goto deco decfsz mcount,f goto loadn return end