The Z-80 has a 4-bit ALU

“The 8-bit Z-80 processor is famed for use in many early personal computers such the Osborne 1, TRS-80, and Sinclair ZX Spectrum, and it is still used in embedded systems and TI graphing calculators. I had always assumed that the ALU (arithmetic-logic unit) in the Z-80 was 8 bits wide, like just about every other 8-bit processor. But while reverse-engineering the Z-80, I was shocked to discover the ALU is only 4 bits wide! The founders of Zilog mentioned the 4-bit ALU in a very interesting discussion at the Computer History Museum, so it’s not exactly a secret, but it’s not well-known either.”

7 Likes

You can explore the implementation at visualz80

Edit: see also the improved z80 remix by floooh aka flohofwoe

Edit: see also Goran Devic’s work

and video demonstration

Here’s visualz80 as a screenshot:

2 Likes

(I made a couple of updates to my previous)

Masatoshi Shima notes in an oral history that the ALU was one of the things specifically done differently from the 8080 - I assume to avoid legal challenge from Intel.

And secondarily, in order to differentiate Z80 logic from 8080 logic, I introduced many unique design technologies as follows. One-phase clock instead of two-phase clock, and 4-bit arithmetic instead of 8-bit arithmetic unit. The storage of both accumulator and flags into the register file. Those were more than enough to differentiate Z80 logic from 8080 logic. At first I introduced the pipeline 4-bit ALU. Next, I introduced the pipeline among the instruction set and the instruction executions, and minimum number of the clock for instruction was four clocks. And I use a four clock for instruction execution. But still there was some overlap between execution and instruction fetching. Also that was quite different logic from 8080’s.

1 Like

And because it’s clocked both halves it actually performs the same as the 8bit one on the 8080.

It’s well known hence the 8bit cpu with a 4bit alu from a 2bit company line.

2 Likes

See also the earlier topic, somewhat related
The z80’s incrementer/decrementer circut is a whole register file away from the ALU

More links within.

It would be interesting to compare the data paths from the 4004, the 8008, 8080/8085 and the Z80.
Where did all the transistors go? The 8080 logic worked fine, so why change it, on the z80. A bigger
register file made sense as you had the transistor budget over the 8080. The cleaner bus interface over the 8080 and 5 volt operation were more important than any new software features the z80 had other than interrupt service changes,when it first came out. 4 Mhz operation was important when memory could handle the speed.

The bit-serial ALU in the RCA 1802 would like a word with the author (eventually).

1 Like

The Z80 added very little useful in instruction sets, and didn’t fix the gaping holes in the 8080 design so I agree entirely. Intel on the other hand added only a few instructions to the 8085 to fix most of the real issues (except short relative branches) but then undocumented it for reasons never entirely explained (variously so you had to buy an 8086, because their 8080 auto translator couldn’t help and some others but afaik nothing ever formally stated).

1 Like

The lack of indexing off the stack or a stack frame pointer, is a problem for the 8085 or z80.
Did they not think of high level languages in the hardware design?

The 8085 fixed this. In the bits they added and then hid you have

LDSI n DE = SP + n
LDHI n DE = HL + n
LHLX HL = (DE)
SHLX (DE) = HL

which with a compiler that knows how to use them works really well although not as well as 6803/6809/HC11.

int foo(int a, int b) { return a + b; }

on a 6803 is TSX LDD 2,X ADDD 4,X RTS. On 8085 it’s a bit messier and on Z80 it’s a short essay

1 Like