i take this from the internet....
;PROGRAM TO CONTROL DC MOTOR SPEED
;BY MOHD ZULHILMI BIN MAT DAUD USING PIC16F873
;*****DECLARATION*****
PROCESSOR 16F873
#include "p16F873.INC"
__CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF
errorlevel -302
;*****LABEL****
speed equ d'8';8x5/256=0.156
change equ d'1'
led equ h'20'
;****PROGRAM START*****
org 0
goto init
org 4
goto int
;*****INITIAL PROCESS******
init
;*****PORT****
bsf 03h,5
movlw b'00000010'
movwf 85h ;set port A bit 0 as input
clrf 86h ;port b output
clrf 87h ;port c output
bcf 03h,5
;****A/D CONVERTER*****
movlw b'10000101'
movwf 1Fh ;adcon0
bsf 03h,5
movlw b'00001110'
movwf 9Fh ;adcon1
bcf 03h,5
;*****PWM*****
clrf 11h ;tmr2
movlw d'255'
movwf 15h ;ccpr1L
bsf 03h,5
movlw d'255'
movwf 92h ;pr2
bcf 03h,5
movlw b'00000111'
movwf 12h ;t2con
movlw b'00011100'
movwf 17h ;ccp1con
;*****COMPARE MODE*****
clrf 0Fh ;tmr1h
clrf 0Eh ;tmr1L
movlw h'61'
movwf 1Ch;ccpr2h
movlw h'A8'
movwf 1Bh;ccpr2L
movlw b'00000001'
movwf 10h;t1con
movlw b'00001011'
movwf 1Dh;ccp2con
;****INTERRUPTION CONTROL******
bsf 03h,5
movlw b'00000001'
movwf 8Dh;pie2
bcf 03h,5
movlw b'11000000'
movwf 18Bh;intcon
wait
goto $
;*****INTERRUPTION PROCESS*****
int
clrf 0Dh
ad_check
btfsc 1Fh,2;cek A/D siap x?
goto ad_check
movlw 1Eh;adresh, A/D result high register
sublw speed
btfsc 03h,0;bit test f,skip next instruction if clear
goto check1
;****LOW SPEED*****
movlw 15h;ccpr1L
addlw change
btfss 03h,0;bit test f,skip next instruction if set
movwf 15h;ccpr1L
goto led_cont
check1
btfsc 03h,2
goto led_cont
;****FAST SPEED******
movlw change
subwf 15h,1;ccpr1L-1
btfsc 03h,0
goto led_cont
clrf 15h
;******LED CONTROL******
led_cont
comf 15h,0;ccpr1L
movwf led
movlw b'00010000'
subwf led,0
btfsc 03h,0
goto led1
movlw b'00000000'
goto int_end
led1
movlw b'00100000'
subwf led,0
btfsc 03h,0
goto led2
movlw b'00000001'
goto int_end
led2
movlw b'01000000'
subwf led,0
btfsc 03h,0
goto led3
movlw b'00000011'
goto int_end
led3
movlw b'01100000'
subwf led,0
btfsc 03h,0
goto led4
movlw b'00000111'
goto int_end
led4
movlw b'10000000'
subwf led,0
btfsc 03h,0
goto led5
movlw b'00001111'
goto int_end
led5
movlw b'10100000'
subwf led,0
btfsc 03h,0
goto led6
movlw b'00011111'
goto int_end
led6
movlw b'11000000'
subwf led,0
btfsc 03h,0
goto led7
movlw b'00111111'
goto int_end
led7
movlw b'11100000'
subwf led,0
btfsc 03h,0
goto led8
movlw b'01111111'
goto int_end
led8
movlw b'11111111'
;******END INTERRUPTION******
int_end
movwf 06h
retfie
;**********END OF DC MOTOTR SPEED CONTROLLER*******
END
end