#include <p12f629.inc>
__CONFIG (_MCLRE_OFF & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT)  ;Internal osc.
 
  c1 equ 20
  c2 equ 21

 org 00

Start
 BCF   STATUS,RP0  ; select bank 0
 CLRF  GPIO       ; set GPIO pins equal to 0 volts
 movlw b'00000010'
 movwf CMCON       ; set comparitor on and to output to cout
 BSF   STATUS,RP0  ; select bank 1
 movlw b'00000011' ;
 CLRF  TRISIO      ; make GPIO pins 0 and 1 input all others output
 BCF   STATUS,RP0  ; select bank 0

loop
lc2 
 btfss CMCON,6 ; check if voltage on pin 7 is larger than on pin 6
 goto lc2      ; if no, check again
 bsf GPIO, 4  ; if yes, turn on led
 call delay1  ; delay around 10 msec
 bcf GPIO, 4  ; turn off led
 goto loop

delay1
 movlw b'00010000'
 bcf STATUS,RP0
 movwf c2
lc0
 movlw b'11111111'
 movwf c1
lc1
 decfsz c1,1
 goto lc1
 decfsz c2,1
 goto lc0
 return

 end
