LockerGnomeTech news and nostalgia for today's technology professionals
Subscribe

Search

HardwareZ-80reverse engineeringretro computing

The Z-80 is an 8-bit chip with a 4-bit ALU, and Ken Shirriff's silicon teardown shows how

Reverse-engineering the die photos shows the Z-80 does every 8-bit operation in two passes through four one-bit slices.

On a giant chip die Chris pushes a wheelbarrow of four cubes across a narrow bridge while four more wait
Illustration: LockerGnome

The Z-80 powered the Osborne 1, the TRS-80 and the Sinclair ZX Spectrum, and it’s still found in embedded systems and TI graphing calculators. It is an 8-bit processor, so of course its ALU is 8 bits wide. Except it isn’t.

Shirriff, who writes about restoring vintage computers and reverse-engineering chips, discovered this while working from Visual 6502 team images of the die. In his words, “I was shocked to discover the ALU is only 4 bits wide!” He notes it’s not a secret: the founders of Zilog mentioned it in a discussion at the Computer History Museum.

His block diagram, drawn from the silicon rather than from published diagrams, shows four single-bit units stacked into a 4-bit ALU. The sequence for an 8-bit add runs like this: load two 8-bit operands from registers into internal latches, compute the low 4 bits and store that result, compute the high 4 bits using the carry from the first step, then write all 8 result bits back. Two passes cover a full byte. Two internal 4-bit buses, one for bits 0 to 3 and one for bits 4 to 7, connect to the 8-bit register bus.

The details are the fun part. The second operand goes through a multiplexer that can pass its value inverted, which is how subtraction, negation and comparison work. The core of each bit position handles addition, AND, OR and XOR in one multi-level gate controlled by three lines. The shifter is also unusual: where the 6502 and 8085 have a separate shift-right operation, the Z-80 shifts while loading a value into the ALU. Bit-addressed set, reset and test operations, which the 6502 and 8085 lack, are decoded right at the ALU, and extra paths between the low and high halves support the 4-bit BCD rotates RRD and RLD.

Shirriff’s conclusion is a comparison. The 6502 and 8085 use 8-bit ALUs, he writes, and the Z-80’s decimal support beats the 8085’s, since it handles subtraction as well as addition, while the 6502’s decimal mode is more advanced still. His closing line: “You didn’t get ripped off on your old TRS-80.”

The article dates from 2013, and the comment thread is as instructive as the post. One reader implemented the ALU in Minecraft redstone and reported two mistakes in the diagram (the last gate should be an OR, and the OR operation needs a different control setting), and another noted the 6502’s ALU is itself a pair of 4-bit units chained together. Treat the post as a good start rather than the final word.

If you’ve only met ALUs in a class, a real chip is a lesson in trade-offs. Shirriff says it directly: it’s interesting to see the shortcuts real chips take compared with an academic design.

Even the TRS-80 was doing its math in two bites.

More Hardware

Every Hardware story →