; 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.)


cblock     0x20             ;start of general purpose registers
        count1             ;  count1 is symbolic name for location 0x20
        counta             ;  counta is symbolic name for location 0x21
        countb             ;  countb is symbolic name for location 0x22
    endc



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

    org 0x00
    goto main

    org 0x04
    goto isr

main
    movlw    0x07
    movwf    CMCON                ;turn comparators off (make it like a 16F84)
   
    ; get ready for interrupts
    bsf        INTCON, GIE        ;enable interrupts
    bsf        INTCON,INTE      ;B0 is the interrupt line

    ; set b port for output
    bsf        STATUS,RP0       ;goto bank 1
    bcf        0x81,INTEDG     ;falling edge interrupts
    movlw    0x01                   ; B0 is an interrupt? Indicate it as input!!!
    movwf    TRISB                ; portb is output
    bcf        STATUS,RP0     ;go back to bank 0
   
;start with led on
    movlw    0xff
    movwf    PORTB
cycle
    bsf        PORTB,1
    call    delay_1_milli
    bcf        PORTB,1
    movlw    d'19'
    movwf    counta
whoop_it
    call    delay_1_milli
    decfsz    counta
    goto     whoop_it
    goto    cycle            ; loop here and wait for interrupt

isr
    btfsc    PORTB,2
    goto    turn_on
    bsf        PORTB,2
    goto    end_int
turn_on
    bcf        PORTB,2
end_int
    bcf        INTCON,INTF        ; the most important line in the program!
    retfie

delay_1_milli
    movlw    d'249'
    movwf    count1
delay_loop
    nop
    decfsz    count1
    goto    delay_loop
    return  
    end