list p=16f877A ; list directive to define processor
#include <p16f877A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
cblock 0x20 ;start of general purpose registers
count ;used in looping routines
endc
;**********************************************************************
ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
main:
BANKSEL ADCON1 ;disable analogue inputs
movlw 0x06
movwf ADCON1
BANKSEL PORTA
banksel TRISA
movlw b'00000001' ;Set port data directions, data output
movwf TRISA
banksel TRISB
movlw b'00000000'
movwf TRISB
banksel PORTB
clrf PORTB
loop
btfsc PORTA,0 ; if input gos high
incf PORTB,f ; count it out to leds on PORTB
goto loop ; repeat forever
END ; directive 'end of program'