Z80 Assembly 84: 16-bit Binary to BCD Conversion

The Challenge of Displaying Numbers Once the Z80 has calculated a final value (e.g., a score of 4296 decimal), this number is stored as a 16-bit binary value (1000010000000000B). To display it on the screen, we need to convert it into a sequence of decimal digits (4′, 2′, 9′, 6′) that can be looked up in the font table. Goal: Convert a 16-bit binary number into a 16-bit BCD value (four decimal digits). ...

September 28, 2025

Z80 Assembly 83: 16-bit BCD to Binary Conversion

The Challenge of User Input When a user types a number (e.g., 4296), it is stored as a series of ASCII characters (or often converted immediately into Binary-Coded Decimal (BCD)). The Z80 needs this number in a single 16-bit binary value for fast calculation. Goal: Convert a 16-bit BCD value (representing a number from 0 to 9999) into a 16-bit binary value. The BCD Structure A 16-bit BCD value typically uses the entire word (two bytes) to store four decimal digits (0-9). ...

September 28, 2025

Z80 Assembly 50: Floating-Point to ASCII Conversion

The Challenge of Displaying Floats In Z80 assembly, a floating-point number is stored internally across multiple bytes (e.g., 4 or 5 bytes) in a specialized format (Part 30). The screen, however, only displays ASCII characters. Converting the binary float into a series of characters (“3”, “.”, “1”, “4”) is one of the most complex tasks in 8-bit programming. The Conversion Strategy The process is too complex for a single routine and is typically broken down into four major steps: ...

September 27, 2025