really far of what you need but here's an example with a 12f675 i did many months ago using the internal comparator
Code:
@ __config _INTRC_OSC_NOCLKOUT & _MCLRE_OFF  ;config fuse

TRISIO = %11001111 ;GPIO.4, GPIO.5 as output
CMCON=%00000010 ;COUT=1 when Vin+(GPIO.0) > Vin- (GPIO.1)
				;comparator mode :comparator without output
ANSEL=0 ;turn off analog to digital

Clip     var   GPIO.4
Normal   var   GPIO.5
Speaker  var   byte

start:
	  speaker=CMCON.6 ;read from internal comparator
      Select case speaker
             case 0
                  clip=0
                  normal=1
             case 1
                  clip=1
                  normal=0
                  pause 100
                  Clip=0
      end select
	  goto start