ON 20070306@3:48:51 PM at page: http://www.piclist.com/techref/microchip/math/radix/b2bhp-8b3d.htm#39147.6589236111 James Newton[JMN-EFP-786] archive reference /techref/postbot.asp?by=time&id=piclist/2007/03/06/160835a List post "seperate num into tens+units" ON 20070315@9:35:43 AM at page: http://www.piclist.com/microchip/math/radix/b2bu-24b9d-xx.htm#39155.0249652778 James Newton[JMN-EFP-786] published post 39155.0249652778 Hi guys,
I modified the 24 bit binary to BCD code for PIC18Fxxx.
It works well without error. Good luck. - YBL


bin24dec
call clrdig
movlw 24 ;24 bits to do
movwf bitcnt
bitlp

rlcf count0 ;Shift msb into carry
rlcf count1
rlcf count2

lfsr FSR0,digit1 ; load FSR0 with digit1


movlw d'8' ;8 digits to do
movwf digcnt
adjlp
rlcf INDF0 ;Shift digit 1 bit left
movlw -d'10'
addwf INDF0,w,0 ;Check and adjust for decimal overflow
btfsc STATUS,0

;skpnc
movwf INDF0
movf POSTINC0,w


decfsz digcnt
goto adjlp
decfsz bitcnt ;Next bit
goto bitlp
return

clrdig:

clrf digit1
clrf digit2
clrf digit3
clrf digit4
clrf digit5
clrf digit6
clrf digit7
clrf digit8
return

|Delete 'P-' before: '' but after: '