list p=16f628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT
cblock 0x20 ;start of general purpose registers
d1
d2
d3
endc
org 0x0000
init:
CLRF PORTA ;Initialize PORTA by setting output data latches
MOVLW 0x07 ;Turn comparators off and
MOVWF CMCON ;enable pins for I/O
banksel TRISA ; switch to bank1
movlw b'00000000' ; set outputs
movwf TRISA ; load value
banksel PORTA ; switch bank0
movlw b'00000000' ; set all low
movwf PORTA
start:
bsf PORTA,0 ;turn on led
call delay ; 1/2 sec delay
bcf PORTA,0 ;turn off led
call delay ;one more 1/2 sec delay
goto start ; keep doing it till you turn off power
delay ;499994 cycles
movlw 0x03
movwf d1 ; the delay
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
retlw 0x00
end