On Fri, 15 Sep 2000, Sam Linder wrote: > unsigned char delayU, delayL; // C code > #asm > Delay10bit // delay is 10 bit value + 7 cycles ( + call + > return, if any) > incf _delayU,f // correct for dec & test instead of test & dec > Dly10bLoop: > comf _delayL,w // invert LSBs > decfsz _delayU,f > goto Dly10bLoop // coarse delay to closest 4 cycles > andlw 3 > > // this additional code checks for the > // page boundary and sets pclath correctly > // **** > movwf _delayL > movlw low offset > addwf _delayL > movlw high offset > btfsc status,C > addlw 1 > movwf pclath > movf _delayL,w > // **** > > addwf pcl,f > offset: > nop > nop > nop > return > #endasm It's little more efficient to do this: > unsigned char delayU, delayL; // C code > #asm > Delay10bit // delay is 10 bit value + 7 cycles ( + call + > return, if any) > incf _delayU,f // correct for dec & test instead of test & dec > Dly10bLoop: > comf _delayL,w // invert LSBs > decfsz _delayU,f > goto Dly10bLoop // coarse delay to closest 4 cycles > andlw 3 addlw offset skpnc incf pclath,f movwf pcl offset: > nop > nop > nop > return > #endasm Looks like 3 more cycles than the original Scott -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics