Slashdot Mirror


Why the Z-80's Data Pins Are Scrambled

An anonymous reader writes "The Z-80 microprocessor has been around since 1976, and it was used in many computers at the beginning of the PC revolution. (For example, the TRS-80, Commodore 128, and ZX Spectrum.) Ken Shirriff has been working on reverse engineering the Z-80, and one of the things he noticed is that the data pins coming out of the chip are in seemingly random order: 4, 3, 5, 6, 2, 7, 0, 1. (And a +5V pin is stuck in the middle.) After careful study, he's come up with an explanation for this seemingly odd design. "The motivation behind splitting the data bus is to allow the chip to perform activities in parallel. For instance an instruction can be read from the data pins into the instruction logic at the same time that data is being copied between the ALU and registers.

[B]ecause the Z-80 splits the data bus into multiple segments, only four data lines run to the lower right corner of the chip. And because the Z-80 was very tight for space, running additional lines would be undesirable. Next, the BIT instructions use instruction bits 3, 4, and 5 to select a particular bit. This was motivated by the instruction structure the Z-80 inherited from the 8080. Finally, the Z-80's ALU requires direct access to instruction bits 3, 4, and 5 to select the particular data bit. Putting these factors together, data pins 3, 4, and 5 are constrained to be in the lower right corner of the chip next to the ALU. This forces the data pins to be out of sequence, and that's why the Z-80 has out-of-order data pins."

8 of 167 comments (clear)

  1. Re:C=128 by Ihlosi · · Score: 4, Interesting
    There was a Z-80 in the C=128 , but it wasn't used.

    Yes, I found this part of the article amusing too.

    C128s were cobbled together from too many different parts. And they appeared when the 8-bit generation was already on its way out.

    However, the C128 mode had its uses. The BASIC was had lots of additional features (commands for music, graphics, sprites), and it had a built-in sprite editor. If you didn't know the C64 inside out and could do these things in assembly (blindfolded), the C128 mode gave you much more access to the machines capabilites. Too bad no company ever came up with a killer 8-bit machine. Z80 CPU, more than 64 kB RAM, sound and graphics like SID and VIC-II.

  2. Re:Why didn't they just ask Federico Faggin? by Lord+Apathy · · Score: 3, Interesting

    This is what I came in here to say. They guy who designed the chip is still alive. Just shoot him a email, phone call, or smoke signals and just ask him.

    I'm going to go out on a limb here and say there is probably a logical reason behind the arrangement and not some conspiracy or something.

    --

    Supporting World Peace Through Nuclear Pacification

  3. i remember by acdc_rules · · Score: 3, Interesting

    Ahhh, those were the days. a whole CPU in a 40 pin DIP. you could actually do useful things with this mounted on an experimental breadboard. thanks for bringing back memories.

  4. BASIC vs. Z80 assembly language by MillionthMonkey · · Score: 4, Interesting

    Back in 1980 my parents got me a British ZX81 kit to assemble, with 1024 bytes of RAM. (I still have it buried in the closet along with my other antiques- AFAIK it still works.) It ran BASIC so slowly that you could actually read the code about as fast as it executed, so I was "forced" to learn assembly language. I was amazed by how fast it was- it ran a million operations in just a few seconds! (wow.) You had to start by writing a BASIC program:

    10 REM AAAAAAAAAAAAAAAA
    20 PRINT USR(16514)

    Then you had to POKE each assembly instruction into the comment, starting at 16514 for the first "A". The comment line would slowly turn into "10 REM x&$bL;,$_)[vU7z#AAAAAAAA". The next line was 20 PRINT USR(16514) (printing out the return value from the BC register).

    Saving any ZX81 program onto a cassette tape was excruciating- they recorded as several minutes of loud high-pitched screeching. Usually you needed to save them twice because it failed half the time. Then to load the program you had to cue the tape you had to find exactly where the start of the screeching was, rewind several seconds, play the tape, and only then could you hit enter on LOAD. (Otherwise LOAD got confused by the *click* noise when you pushed the play button on the tape player.)

    You young people don't realize what an easy life you have.

  5. Re:The story by Z00L00K · · Score: 4, Interesting

    The news what why it was that way.

    And the Z80 was a major player in computing in the early personal computers before IBM PC. Even today it's still around in variants, and many have seen a variant of it in the Nintendo Gameboy. It was popular enough to render some clones as well, however they weren't always fully compatible, mostly on the undocumented instructions - which caused for example the Sinclair ZX80 to not work unless you had a real one.

    --
    If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
  6. Definitely News For Nerds by MikeTheGreat · · Score: 3, Interesting

    It's always refreshing to see stuff like this waft across the front page of /. every now and then - I wish there was a way to re-apply the "News For Nerds... Stuff That Matters" logo to top of the page only on stories like this.

    (Pro-Tip: Please mod this "+1 Nostalgic" :) )

  7. Re:Please, you are kidding? by AaronW · · Score: 3, Interesting

    My father had built a Heathkit H89 computer built around a Z80. As a kid I earned money soldering together boards my father had designed that under software control would double the speed from 2 to 4MHz. The H89 actually had two CPUs since it was also a H19 terminal. While it didn't do color and was limited to text based graphics it was a nice machine. My father's computer had something like 4 floppy drives and a hard drive hooked up to it. It ran both CPM and HDOS which was the first microcomputer operating system with loadable device drivers.

    Later in college we used the Z80 for our microprocessor design class. The Z80 was trivial to wire up and included such things as automatic DRAM refresh support.

    --
    This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
  8. Re:C=128 by Anonymous Coward · · Score: 5, Interesting

    The Z80 was used every time the C128 was turned on. It was added specifically to work around a compatibility issue with the C64 and one single, solitary, cartridge (Magic Voice) for the C64. To make it work, Bill Herd added the Z80, It would start (at address 0x0000), run a handful of instructions that initialised the C128 hardware, and then started the 8502 proper. (The Spectacular Rise And Fall Of Commodore, pg. 368)