Some times ago, Andrew W. gave me these. It works really fine, I am using this to send 16bit number to LCD. Don't forget to add 0x30 (ASCII '0') to each number before sending to the LCD (don't use table read). I have got the code to drive LCD if you need. David ------------------------------------------------------------------- ; ; Binary-to-BCD. Written by John Payson. ; ; Enter with 16-bit binary number in NumH:NumL. ; Exits with BCD equivalent in TenK:Thou:Hund:Tens:Ones. ; org $0010 ;Start of user files for 16c84 NumH: ds 1 NumL: ds 1 TenK: ds 1 Thou: ds 1 Hund: ds 1 Tens: ds 1 Ones: ds 1 Convert: ; Takes number in NumH:NumL ; Returns decimal in ; TenK:Thou:Hund:Tens:Ones swapf NumH,w andlw $0F ;*** PERSONALLY, I'D REPLACE THESE 2 addlw $F0 ;*** LINES WITH "IORLW 11110000B" -AW movwf Thou addwf Thou,f addlw $E2 movwf Hund addlw $32 movwf Ones movf NumH,w andlw $0F addwf Hund,f addwf Hund,f addwf Ones,f addlw $E9 movwf Tens addwf Tens,f addwf Tens,f swapf NumL,w andlw $0F addwf Tens,f addwf Ones,f rlf Tens,f rlf Ones,f comf Ones,f rlf Ones,f movf NumL,w andlw $0F addwf Ones,f rlf Thou,f movlw $07 movwf TenK ; At this point, the original number is ; equal to ; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones ; if those entities are regarded as two's ; complement binary. To be precise, all of ; them are negative except TenK. Now the number ; needs to be normalized, but this can all be ;done with simple byte arithmetic. movlw $0A ; Ten Lb1: addwf Ones,f decf Tens,f btfss 3,0 goto Lb1 Lb2: addwf Tens,f decf Hund,f btfss 3,0 goto Lb2 Lb3: addwf Hund,f decf Thou,f btfss 3,0 goto Lb3 Lb4: addwf Thou,f decf TenK,f btfss 3,0 goto Lb4 retlw 0