; 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 movlw b'00000001' movwf TRISA ; set ra0 as a input, the rest are output 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 scanbut btfsc PORTA,0 ; test porta for button press - clear means pressed goto rainbow ; continue present pattern goto patchn ; pattern change rainbow 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 LEDs off rlf shift,f ; next LED on goto scanbut patchn movlw b'00000001' ; all blue movwf PORTB call pause clrf PORTB rlf shift,f bcf PORTA,0 ; clear out porta,0 goto scanbut pause movlw 0xff movwf mcount loadn movlw 0xff movwf ncount deco nop nop nop nop nop nop nop nop decfsz ocount,f goto deco decfsz mcount,f goto loadn return end