Xref: utzoo comp.lang.misc:6650 comp.sys.ibm.pc.misc:6658 comp.sources.wanted:15334 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!uklirb!kirchner From: kirchner@informatik.uni-kl.de (Reinhard Kirchner) Newsgroups: comp.lang.misc,comp.sys.ibm.pc.misc,comp.sources.wanted Subject: Re: Multiple-Precision Binary to ASCII Decimal Machine Languae Routine Message-ID: <7565@uklirb.informatik.uni-kl.de> Date: 19 Feb 91 11:39:07 GMT References: <1991Feb18.155207.24378@ux1.cso.uiuc.edu> Sender: news@uklirb.informatik.uni-kl.de Lines: 33 From article <1991Feb18.155207.24378@ux1.cso.uiuc.edu>, by gwang@ncsa.uiuc.edu (George Wang): > Does anyone know of a 8088 Machine Language routine that will > convert a multiple-byte array containing a VERY large (64 bit, 8 bytes) > number to ASCII? I know how to write a routine for 16 bit signed There is a very simple algorithm to convert binaries of arbitrary length to decimal WITHOUT division. I post it here since it may be of general interest. You need to arrays in storage, one for the decimal ( bcd ) number and one for the binary. |---------------------------|-------------| bcd binary Then you simply shift this whole thing to the left bitwise. So the bits from the binary cross the border to the bcd-part. And now the conversion-trick: if the rightmost digit in the bcd-part, the one where the binary bits go in, is >= 5, then add 3 to this digit. On the next shift this will result in a higher next digit. So you shift and perhaps add 64 times in the above case. To convert not to bcd but ASCII should be possible by adding not 3 but another constant, or by crossing the not needed 4 bits in every byte during the shift with additional operations. I once did this bin -> bcd cinversion on a Z80 and it was very effective. Reinhard Kirchner Univ. Kaiserslautern, Germany kirchner@uklirb.informatik.uni-kl.de