4 ; Author: George Gallant
7 ; $Id: cvtdec.S 3718 2005-04-06 06:06:20Z vrokas $
9 ; This routine is based on the code and algorithm by
10 ; Nikolai Golovchenko and Scott Dattalo presented in
11 ; the piclist webb site on radix conversion methods.
12 ; Modified to support integers from 0 to 65535 and coded
13 ; for the pic18 chip set.
16 ; BIT Weight 4 3 2 1 0
17 ; --- ------ --- --- --- --- ---
55 ; Convert a 16-bit binary word to 5 BCD bytes
59 ; FSR0 pointer to ascii buffer
62 ; digits[4:0] contain the BCD integers
64 ; Notes: 1. strip leading zeros
65 ; 2. only positive integers on input
66 ; 3. FSR0, PROD & W are modified and not preserved
69 cvt_dec_word: clrw ;calculate digit 0 - lsd
119 clrf digits+1 ;setup for carry in 10's
168 clrf digits+2 ;setup for carry into 100's
199 clrf digits+3 ;setup for carry into 1000's
230 clrf digits+4 ;setup for carry into 10000's