; uncomment following two lines if using 16f627 or 16f628. config uses internal oscillator
LIST p=16F628 ;tell assembler what chip we are using
include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)


; IMPORTANT : The following is very important
; Recall: there is user RAM available starting at location 0x20 upto 0x77 in each bank
; Instead of referring to these locations by NUMBER, why not refer to them by NAME
; In the example below, count1 ia an alias for location 0x20, counta is an alias for
; location 0x21, countb is an alias for location 0x22. HIGHLY RECOMMENDED


cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc


; Filename : FlashLED.asm
;




; list p=16f84a
; __config h'3ff1'

; We'll turn on an LED on pin B8 (or any PORTB pin)



;un-comment the following two lines if using 16f627 or 16f628

movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)

; set b port for output, a port for input

bsf STATUS,RP0
movlw 0x00
movwf TRISB ; portb is output
movlw 0xff
movwf TRISA ;porta is input
bcf STATUS,RP0 ;return to bank 0

top_o_loop

;start with led off
movlw 0x00
movwf PORTB
call delay_100_milli
; turn led on
movlw 0xff
movwf PORTB
call delay_100_milli

; let do it again
goto top_o_loop


delay_100_milli
movwl 0x64
movwf countb ; careful!! don't use counta
delay_100_loop
call delay_1_milli
decfsz countb
goto delay_100_loop
return

delay_1_milli
movwl 0xf9
movwf counta
delay_1_loop
nop
decfsz counta
goto delay_1_loop
return

end