The following article was printed in June 1979 of the magazine „BYTE".
A tricky routine generating an ASCII-character from a four bit hex value.

5 Byte Hexadecimal to ASCII Converter

Ashwin L Doshi
5830 Green Valley Cir 105
Culver City CA 90230

I was recently challenged by a colleague to find the most efficient 8080 code to translate hexadecimal 0 thru F (stored in the accumulator) into ASCII 0 thru 9 and A thru F (also in the accumulator). After I came up with a 5 byte translation, he showed me a well-published 6 byte translation (of which I was unaware) which is as follows:

          ADI     90H
          DAA
          ACI     40H
          DAA.

The 5 byte code that does the same translation is as follows:

          DAA
          ADI     F0H
          ACI     40H.

The latter assumes that the carry and the auxiliary carry are reset, which is the case in all applications that I could find of this translation.

Scanned by Werner Cirsovius
September 2002
© BYTE Publications Inc.