Chip Hall of Fame: Zilog Z80 Microprocessor (2017)
spectrum.ieee.org
spectrum.ieee.org
In the 8080, most ALU operations set the "P" (parity) flag to indicate if the result had an even or odd number of 1 bits. On the Z80, that flag would be set the same way for logical operations (AND, OR, XOR), but for ADD/SUB operations it was used as an overflow flag -- not carry out, but it indicated that the 2s-complement result wasn't able to accurately represent the result.
There were also some changes in the way the half-carry (nibble carry out) flag was handled in some instructions too.
Still used in the TI range of graphing calculators. Specifically, the TI-84 CE range[0]. I can't speak for other countries, but graphing calculators are mandatory in Dutch high schools, and the TI series is the default choice for many (I got a TI 83+ Silver Edition when I was 14, which was "new" at the time - guess my age). I suspect because it's low-powered enough to still require that students Learn The Material too (instead of doing the symbolic calculus through the calculator). Texas Instruments must be having quite a large mark-up on such a dirt-cheap piece of electronic hardware though.
Anyway, because of that, Z80 assembly was my second programming language TI Basic being the first[1]. It really is quite accessible - I mean you basically memorise the entire instruction set after a while because it's so small and simple[2].
Funny enough, I remember when moving to higher level languages that almost every tutorial that I read on warned me that pointers were really, really hard, and I couldn't see why at that point. I guess that if you start from the ground up instead from the top down, some things get easier.
[0] https://en.wikipedia.org/wiki/TI-84_Plus_series
[1] https://www.ticalc.org/archives/files/fileinfo/328/32816.htm...
[2] http://wikiti.brandonw.net/index.php?title=Z80_Instruction_S...
I didn't have the cable you needed to transfer binaries from a desktop computer to the calculator, and I never finished the cable I tried to build myself from scrap parts. Hence, I never got past the TI Basic, which you could program on the calculator itself. :-)
Here's a TI Basic rendering of a sphere (the Moon seen from Earth, say): https://i.imgur.com/xWb1xk2.jpg
It was lame as crap. Just used the PRNG to multiply one of 5 variables by 10 and then draw them on the screen. Longest number won the race.
If you were clever enough you could reseed the RNG and pick a winner every time.
Started coding with a Timex 2068 back in the day, and went through Z80, 8086, 68000, Basic and Pascal dialects before getting to learn C, nothing special about C pointers.
Pointers are pretty easy when drawing boxes and arrows. Sometimes I wonder if they don't teach them anymore.
The Z80 had two hardware features that made it possible, and that nobody here has mentioned yet:
1: two sets of working registers, with a one byte instruction to toggle between them. I instruction cyclke to context switch between application and interrupt handlers. Only the TI 9900 came close with its in-RAM working register sets.
2: hardware vectored interrupt dispatch, fully suppported by theor accompanying peripheral line. Just a few clocks from raising an interrupt to executing the first line of code (typically switch context then ...) of not only the device but it's reason for interrupt code. No code wasted interrogating bitfields and scanning registers. 2 usecs interrupt response time. Faster than an Intel i960 with its 50MHz clock, that came along later.
The ironic bit is that the emulation experience is fundamentally flawed because the TI-83+SE has a lower resolution display than an original Gameboy. The original TI-83 launched in 1996, the Gameboy in 1989.
"Access cheap DRAM just like you do SRAM" must have been an effective sales pitch at the time.
Yes, yes it was
The Z80 was also a big deal in Europe, where it powered two (major) brands of micros in UK alone, and was cloned extensively in the USSR.
It was very rare to meet someone whose parents had bought another 8 bit machine.
I only knew other 8 bit systems from magazines.
One model post-purchase Spectrum even included the same kind of oddball 3 inch floppy drive that Amstrad had been using (another had a built in cassette player, similar to what the first Amstrad CPC had).
I'm going to repair it though, even if I have to replace every single chip. :)
Mine is happily running; it's a 464 w/ green phosphor monitor. I'm on the lookout for a reasonably priced colour monitor but they're rare as hen's teeth in Australia.
I wrote an emulator which covers most of the East German 8-bit machines, some had quite interesting ideas implemented: http://floooh.github.io/virtualkc/ (needs WebAssembly)
This does make the Z80 sound much worse than it is. A 6502 instruction takes at least 2 cycles, which for certain types of instruction means a cycle wasted. TXA and ASL A take 2 cycles, for example, even though both are one byte. It's 1 cycle to read the byte for the instruction, and then 1 cycle effectively wasted. The equivalent Z80 operations take 4 T-states, on the other hand: just the cost of reading the byte for that instruction.
The Z80 also has the upper hand with some more general instructions. LDIR is 21 T-states per byte for the equivalent of a memcpy, where the equivalent 6502 loop might approach 9 cycles per byte only with multiple unrolls, while being far less general. The Z80 also has 16-bit operations, which the 6502 lacks entirely. It's 11 T-states to add one register pair to HL, which is the sort of thing the 6502 will take 15-18 cycles over, and that only in the best case.
But it's not entirely a wash - in fact, quite the opposite. The Z80 has no analogue of the 6502's X-/Y-indexed addressing modes, and with only 3 register pairs (IX and IY being uselessly slow) you'll struggle to keep the necessary addresses live - a pain for anything that's table-driven. (It's 10 T-states to load the address, then 4 to replace the low byte with the index, then 7 to fetch the value there. The 6502 can do that whole lot in 4 cycles. You can also load the other index register this way, then use that to load the accumulator: 8 cycles for a table-indexed table lookup.) The 16-bit operations are annoyingly specific, and for many types of operation you need to shuffle data through the accumulator and back again. In practice this stuff typically negates the Z80's apparent register count advantage.
When I first read through the Z80 data sheet, the thing seemed basically magical by comparison to the 6502! But once I tried to actually write any code, I found there'd typically turn out to be this fairly consistent 4:1 T-state:cycle ratio. You can engineer situations where the Z80 is hilariously better... but they'd be engineered. For typical code, you can expect 4:1. You'll need a lot better than double the clock rate for the Z80 to win.
(Interesting and possibly relevant interview with Sophie Wilson, ARM designer and formerly with UK's Acorn, that touches on how memory bandwidth can influence CPU effectivness: http://www.computerhistory.org/collections/catalog/102746190)
I'm curious, as a way to compare progress with todays 500 GFLOPS phone GPUs, and 10 TFLOPS PC GPU cards.
But neither Z80 nor 6502 have native 32 bit, nor fp, nor multiply, so a program is needed... this must have been done, for some applications.
You’d be lucky to get KFLOPs on an 8-bit processor.
Do you know what they were, or is that secret information? It wasn't the BBC micro, was it the ZX Spectrum and Amstrad?
In high school one of our teachers made us program a Z80 board by hand.
And when I say "by hand" I mean it quite literally: first a flow-chart, then a conversion to z80 assembly (two passes: pencil first, pen later), then datasheet at hand a conversion into z80 opcodes (this time it was three passes, the third one was to recalculate all jumps, absolute and relative ones).
Last step was to input each opcode into memory by hand using an hexadecimal keypad. Then go to address 1800h, hold breath and press RUN.
In retrospect, it was a very enlightening experience considering I and my school mates were like 16-17.
But keep in mind, if a 17 years old can do this with relative ease (it was a technical high school, after all) that should tell you something about the simplicity and effectiveness of the Z80 instruction set.
Z80 <3
6502 had more addressing modes, but some of them, if not all, could have used Z80 style syntax. After all, it would just be a different the assember (i.e. compiler) frontend, generating the same target machine code.
8008 bits 8080
A 000 B
B 001 C
C 010 D
D 011 E
E 100 H
H 101 L
L 110 (HL)
(HL) 111 A
Datapoint did not want Intel's future processors to be able to execute Datapoint machine code. They had a lot invested in their software.
Datapoint also had a 5500 processor which was more powerful than the 2200. It was microprogrammed rather than the simpler logic decode of the 2200. It was compatible with the 2200 but had many more instructions (think Z80). Yes it was that instruction set. The engineers at Intel who worked on the 5500 design left to form Zilog.
I worked as an electronics technician at Datapoint and performed test and repair of many 2200 and 5500 processor boards including writing short machine code routines to exercise the hardware.
After I left Datapoint (1977) I worked for Tandy where I repaired thousands of TRS-80 Model 1 computer boards which used the Z80. When the Tandy engineers came into the repair area with the programmers who had written Level 2 BASIC for the TRS-80 with the first masked ROMs, they tried the ROMs on a board and it didn't work. I told them that all the boards in the area needed repair but I had one that I had just repaired. I was introduced to Bill Gates and Paul Allen and the ROMs were put on my repaired board. I typed in a one line program to count and print numbers on the screen and it worked. Bill Gates offered me a job at Microsoft which had about a dozen employees but I turned him down and stayed at Tandy. I wrote more test programs and transitioned into full-time programming.
Motorola broke compatibility completely when they transitioned from 8-bits (6800, 6809) to 16/32 bits (68000) [1].
[1] From a hardware perspective, the 68000 is a 16-bit system; from a software perspective, it's a 32-bit system.
https://en.wikipedia.org/wiki/Z-80_SoftCard
My Apple II had one for basically the sole purpose of running Wordstar under CP/M (I don't recall why we didn't just use Apple Writer).
Anybody got a graph of historical 6502 vs Z80 prices?
EDIT: Some previous HN discussion "On choosing the Z80 over the 6502 (2014)" https://news.ycombinator.com/item?id=10763274
I tried getting it working a few years ago, but it wouldn't work with the TV. I wasn't really interested enough to get an old TV to use with it. Pretty amazing though, not many people are able to say they still have their first computer.
[1] https://play.google.com/store/apps/details?id=dk.rift.tzxdro...
I think my dad still have it in the basement, but i recall he never got much out of it.