Linked by Thom Holwerda on Sat 7th Sep 2013 09:54 UTC
Hardware, Embedded Systems

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.

I have been reverse-engineering the Z-80 processor using images from the Visual 6502 team. The image below shows the overall structure of the Z-80 chip and the location of the ALU. The remainder of this article dives into the details of the ALU: its architecture, how it works, and exactly how it is implemented.

Ken Shirrif's blog is an absolute must for fans of ultra-low-level hardware stuff. This goes way over my head, but interesting nonetheless.

Thread beginning with comment 571559
To read all comments associated with this story, please click here.
by peteo on Sat 7th Sep 2013 14:32 UTC
Member since:

"This goes way over my head..." and yet you claim the blog is a must.

It's actually pretty badly written.

Reply Score: 1

RE: Uh
by kens on Sat 7th Sep 2013 19:19 in reply to "Uh"
kens Member since:

Wow, tough crowd here. Anything specific you'd like improved in the article?

Reply Parent Score: 7

RE[2]: Uh
by viton on Sat 7th Sep 2013 20:08 in reply to "RE: Uh"
viton Member since:

Great article, Ken. But I'm just a programmer, not a literary critic :-)
I did a lot of Z80 coding and this discovery is pretty exciting for me.

Reply Parent Score: 3

RE[2]: Uh
by kokara4a on Sun 8th Sep 2013 07:11 in reply to "RE: Uh"
kokara4a Member since:

Well, I would have liked to know why they did it like that. It seems to me that the additional logic is more than what would have been needed for a full 8-but ALU. Maybe I'm wrong, but the drawback is quite significant - you get half the performance. Granted, the Z80 was running on frequencies quite a bit higher than the original 6052 but it seems the 4-bit ALU eats most of that.

Interesting article though - I like reading about such things. Never did any assembly programming on the Z80. Never had access to any. In the early 80s in Bulgaria there were mostly locally produced Apple II compatibles. We did make one - Правец-8М - which incorporates a Z80 extension card on the mainboard. I'm not familiar of anyone else doing that. But these were rare.

Reply Parent Score: 3

RE: Uh
by ferrels on Sun 8th Sep 2013 17:32 in reply to "Uh"
ferrels Member since:

What did you expect? It's a blog for goodness sakes, not a novel or hardback book that you purchased at the bookstore for $50. Technically speaking it's a darn good blog. If you want perfection go buy a James Joyce novel.

Edited 2013-09-08 17:34 UTC

Reply Parent Score: 4

RE[2]: Uh
by henderson101 on Mon 9th Sep 2013 11:51 in reply to "RE: Uh"
henderson101 Member since:

Ah yes, there's a great section on the 6502 instruction set tucked in to the middle of the Dubliners, and totally I forgot about the Z80 primer in the last chapter of Ulysses! Thanks for your extremely helpful comment!

Reply Parent Score: 4