Hay lo llevas
Codigo:
;HEX2BDC: Transforma el código en Hexadecimal que viene en el w,
;en dos bcd, el mas alto en los 4 MSBs y el mas bajo en los 4 LSBs del registro w
hex2bcd movwf contador1
clrf contador2
comf contador1,f
h2bcd1 movf contador1,w
addlw 0x0a
btfsc status,0
goto h2bcd2
movwf contador1
incf contador2,f
goto h2bcd1
h2bcd2 comf contador1,f
movf contador2,w ;Si contador2 no es cero
btfsc status,2
goto h2bcd4
h2bcd3 movf contador1,w
addlw 0x10 ;Se le suma a contador1 tantos 0x10 como indique
movwf contador1
decfsz contador2,f
goto h2bcd3
h2bcd4 movf contador1,w
return
Aqui tienes otra de microchip que convierte un número de 16 bits a 5 dígitos BCD
Codigo:
;********************************************************************
; Binary To BCD Conversion Routine
; This routine converts a 16 Bit binary Number to a 5 Digit
; BCD Number.
; The 16 bit binary number is input in locations H_byte and
; L_byte with the high byte in H_byte.
; The 5 digit BCD number is returned in R0, R1 and R2 with R0
; containing the MSB in its right most nibble.
;
; Performance :
; Program Memory : 35
; Clock Cycles : 885
;
;*******************************************************************;
;
B2_BCD bcf status,c ;Borra el carry
movlw .16
movwf contador1
clrf R0
clrf R1
clrf R2
loop16 rlf L_byte,f
rlf H_byte,f
rlf R2,f
rlf R1,f
rlf R0,f
decfsz contador1,f
goto adjDEC
return
adjDEC movlw R2
movwf fsr
call adjBCD
movlw R1
movwf fsr
call adjBCD
movlw R0
movwf fsr
call adjBCD
goto loop16
adjBCD movlw 3
addwf indf,W
movwf temp
btfsc temp,3 ; test if result > 7
movwf indf
movlw 30
addwf indf,W
movwf temp
btfsc temp,7 ; test if result > 7
movwf indf ; save as MSD
return