.TITLE CVTBD - Convert binary to decimal. .VERSION 20 .ENABLE 7BIT / ++ / CVTBD Y2.0 / / (c) 1988, 1989 by Johnny Billquist / / History: / / 88/12/29 15:15 BQT X1.0. Initial coding. / 89/01/04 15:35 BQT X1.1. Split into PRSLIB. / 89/12/27 05:00 BQT Y2.0. Made from STRLIB. / / -- / / / CVTBD converts AC to a decimal ascii string. / .FSECT CVTBD / 0 /For return address. DCA VAL$ /Save value. TAD I CVTBD /Get arg1. ISZ CVTBD DCA DP$ /Save as dest. pointer. RDF /Get return field. TAD (CDF CIF) DCA R$ RDF /Get data field. TAD (CDF) DCA C$ CDF .FLD /Change to current field. TAD (TBL$) /Get table pointer. DCA TP$ /Save as pointer. TAD (-4) /Set loop count to 4 digits. DCA LC$ 1$: TAD I TP$ /Get value in table. DCA V$ /Save value. C$: HLT /Change to data field. TAD ("0-1) /Start from zero on each digit. DCA I DP$ TAD VAL$ /Get value to convert. 2$: CLL /Clear overflow flag. TAD V$ /Add value. ISZ I DP$ /Bump digit. SZL /Overflow? JMP 2$ /Yes. Repeat. CDF .FLD /No. Change to current field. ISZ TP$ /Bump table pointer. TAD I TP$ /Add value. DCA VAL$ /Save binary value. ISZ TP$ /Bump table pointer. ISZ DP$ /Bump dest. pointer. ISZ LC$ /Bump loop count. JMP 1$ /Repeat. R$: HLT /Done. Return field. JMP I CVTBD /Return. VAL$: 0 /Value to convert. DP$: 0 /Destination pointer. TP$: 0 /Table pointer. TBL$: -^D1000 /Table with multiples for decimal numbers. ^D1000 -^D100 ^D100 -^D10 ^D10 -^D1 ^D1 LC$: 0 /Loop count. V$: 0 /Value of current multiple. / $