#include "P18F4455.INC" LIGHTS_ON_OUT EQU 30H LIGHTS_OFF_OUT EQU 00H CONST_BUTTON_PRESSED EQU 0EH ; when button is pressed CBLOCK 0X00 VAR_BUTTON_PRESSED TEMP INC_VAR ENDC ORG 0x00 GOTO MAIN_PROGRAM #include "increment_proc.inc" MAIN_PROGRAM: CALL INCREMENT_PROC ;;;;;;;;;;;;;; CONFIGURE PORTA ;;;;;;;;;;;; CLRF PORTA CLRF LATA MOVLW 0Fh MOVWF ADCON1 MOVLW 07h MOVWF CMCON MOVLW 0CFh MOVWF TRISA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOVLW CONST_BUTTON_PRESSED MOVWF VAR_BUTTON_PRESSED MOVLW 0FH MOVWF TEMP MAIN_LOOP: MOVF PORTA, W ANDWF TEMP, W CPFSEQ VAR_BUTTON_PRESSED GOTO ON_BUTTON_NOT_PRESSED ; if button is pressed MOVLW LIGHTS_ON_OUT MOVWF PORTA GOTO MAIN_LOOP ON_BUTTON_NOT_PRESSED: ; if button is not pressed .. output lights off MOVLW LIGHTS_OFF_OUT MOVWF PORTA GOTO MAIN_LOOP END