16

TL;DR:

The Z80 was introduced not long after the 8080 and replaced it quickly and almost entirely for personal computing. Still, a large chunk of new software written stayed with 8080 code, making no or only very limited use of Z80 instructions.

Are there any reliable numbers of the amount of Z80-only software for OS that supported both CPUs? For the fine print see below.


Story Behind

While the 8080 started its CPU lineage in 1975, it was dethroned two years later by the less expensive and (hardware wise) more versatile Z80. Right in time for the home computer era starting ca. 1977. Except for some very early systems (Altair/SOL), late (DAI) or undead (Interact) designs and regional circumstances (COMECON countries *1) the Z80 ruled the market for 8080-compatible CPUs (*2).

Still, even throughout all of the 1980s many software packages did not use Z80 instructions - or in case of compilers, did not generate Z80 code (*3). There were programs explicitly Z80-based, like ZCPR replacing CP/M's shell CCP with a Z80 optimized version, but it felt like a minority (*4).

This is even more astonishing as not only new computers were designed around the Z80, but also a good part of all S100 systems were upgraded (*5) with the new, more powerful (and less power consuming) Z80. After all, early Z80 cards doubled the speed to 4 MHz (*5). Later cards not only cranked that up to 6 or 8 MHz but offered addressing past 64 KiB, interfaces and even full 64 KiB on board.

Fine Print

What I'm looking for is (somewhat) reliable numbers to get a picture how true my impression is - or isn't. Of course a relevant result can only be found for operating systems that supported 8080 as well - at least at some point. Main candidate might be CP/M and its derivatives. It does not make any sense to look at OS that were only used with/made for Z80-only-systems, like Tandy TRS-80, CPC or MSX (*7).

A good answer might include some quantification, like how much of a certain software archive is 8080 code vs. Z80 (or later) code. Might be interesting to see what metrics can be used.

Since more software was produced later (i.e. Software production increases a lot during the 1980s), a result might be biased toward Z80, but that's fine as it simply shows at the end of the Z80 era.


*1 - And even here the Z80 was a strong opponent, as Eastern Germany did, unlike most COMECON countries not clone the 8080, but went right away (and 4 years late) for the Z80

*2 - Intel's 8085 did find some usage in portable devices like the Kyotronic series due its low power CMOS version.

*3 - Including Turbo-Pascal. While it and its products needed a Z80 to run, the compiler itself produced clean 8080 code. Only its runtime/libraries contained Z80 code - most likely as they were written in Assembly.

*4 - IIRC, later ZCPR also came in a 8080 code only version. But my memory might be false.

*5 - All the Altairs and IMSAIs I have came with Z80 cards instead of the original 8080 board. Quite often the Godbout/CompuPro Z-CPU or the Ithaca Z-80.

*6 - Especially Godbout's Z-CPU was famous for being stable at 6 MHz and above.

*7 - Thinking of it, it might be even more interesting if similar patterns would show up at such systems, as they provide no incentive to avoid Z80 code. Lets make it an addition for bonus points :))

John Dallman
  • 13,177
  • 3
  • 46
  • 58
Raffzahn
  • 222,541
  • 22
  • 631
  • 918
  • “Backwards compatibility means not locking out cross-compatibility” is the notion I’ve had to this question since my KayPro days. – RonJohn Feb 20 '23 at 06:13
  • I think your assumption is primarily true: Once the Z80 had established its market, there wasn't any mainstream new machine that used Intel's CPU. CP/M simply had to have a Z80. I am, however, even today, somewhat baffled about the amount of appliances ("non--computers") an 8080 can be found in. – tofro Feb 20 '23 at 07:42
  • 5
    If you write an application for an operating system that supports both the Z80 and the 8080, you are pretty much forced to use 8080 compatible code. It's either that or shut out a segment of your potential market. – JeremyP Feb 20 '23 at 08:59
  • 1
    @tofro True, the 8080 was extreme successful in embedded applications. Much like all early ones. Otherwise we wouldn't have the 8086. – Raffzahn Feb 20 '23 at 10:25
  • 1
    @JeremyP Are you? Glad this didn't stop 286/386 software for the 8086 MS-DOS. Would have crippled much loved software. Likewise, as noted, Z80 software does existed for CP/M, thus the question is about 'how much', not 'did it exist or why not'. – Raffzahn Feb 20 '23 at 10:31
  • 2
    The earliest software for 286/386 based machines ran on MS-DOS/PC-DOS and was 8086 software. But that didn't last too long because the 286 protected mode allowed significant advantages once operating systems caught up. The Z80 extended instructions did not offer such an advantage and there was little incentive for most companies to offer Z80 only software. – jwh20 Feb 20 '23 at 23:18
  • @Raffzahn It's not the same scenario at all. The advantages of the 80286 and 386 over the 8086 were much larger than those of the Z80 over the 8080. But it did happen: people were restricting themselves to 16 bit code long after computers were being shipped with 386's. – JeremyP Feb 22 '23 at 08:50
  • @JeremyP You're kinda contradicting your own statement. Either there the advantage does matter, or it doesn't. Can't be both at once. Also, unlike with PCs, the amount of 8080 was, as mentioned, next to non existing by 1980. – Raffzahn Feb 22 '23 at 08:56
  • @Raffzahn Nope. The first part was explaining why your analogy fails. The second part was saying that, even ignoring that failure, there really was some inertia caused by the dominant platform being DOS (and then Win16). – JeremyP Feb 22 '23 at 10:21
  • @JeremyP You might want to rethink your logic. First you claim that Z80 users were forced to use 8080, despite Z80 being the majority, then state that the analogy (that 286 over 86 as a similar case with a different outcome) is wrong, just to claim that 286 had great advantage but not has been used - which clearly was the case, as there was a substantial amount of software requiring at least a 286/AT system. – Raffzahn Feb 22 '23 at 16:41
  • @Raffzahn I didn't say anybody was forced to do anything. It would have been a rational business decision when targeting something like CP/M to target the 8080. And it's never an absolute. The real world is mess: you can always find exceptions. – JeremyP Feb 23 '23 at 08:35
  • Hey, just to let you know I'm working on a corpus-based answer to this, and the results are surprising even me. There are a few well-known ZX Spectrum games that appear to be almost entirely 8080 code! Since CP/M-80 COM files have no code/data segment, I'm having to guess (uh, "develop an heuristic", I meant ☺) what's Z80 code or accidentally matching data. So far it's looking like anything greater than 35× valid Z80 2+ byte opcodes per 10,000 bytes binary is probably Z80 – scruss Feb 24 '23 at 01:30
  • @scruss interesnt - especially the Spectrum bits. would support my general assumption the Z80 code isn't of much advantage for tightly packed code - and I do for sure assume that Spectrum games are well wrung out. – Raffzahn Feb 24 '23 at 02:03
  • 3
    I know anecdotes are not data, but my personal experience was that I wrote for the 8080 despite always having a Z80. The differences didn't seem significant enough to spend the effort to optimize; the 8080 was already very capable. – Mark Ransom Feb 25 '23 at 04:53
  • @scruss would this have something to do with the compiler used, or were all these written in assembler? – Thorbjørn Ravn Andersen Feb 27 '23 at 15:23
  • Interesting, my edit has been rolled back, see https://retrocomputing.meta.stackexchange.com/a/766/576 what appears to be the community consensus of capitalization of question titles – Omar and Lorraine Jan 04 '24 at 11:40
  • @OmarandLorraine You might look closer as it has not been rolled back, but corrected where it tried to insert personal style. Next, the comment you're pointing does not talk about capitalization but title length. Also, the meta question is strictly about the title field, not titles within, which also got changed (inconsistent as it did only change 1 of 2 titles - not to mention that the rest is as well stylish changes most may not really improve anything.). Are you still on this crusade? – Raffzahn Jan 04 '24 at 12:47
  • @Raffzahn Alright then, I'll leave it. – Omar and Lorraine Jan 04 '24 at 12:50
  • @OmarandLorraine Don't get me wrong. I'm quite grateful about all the help brushing up my bad gramer. It's just that blurry line between basic correction and one sided adaption to a specific/local style that needs to be watched while focusing on content. – Raffzahn Jan 04 '24 at 13:14

2 Answers2

13

Summary:

Are there any reliable numbers of the amount of Z80-only software for OS that supported both CPUs?

No, not previously, and not from third parties. I've had to rely on my own research here. For the 3487 unique CP/M-80 COM files in the Oakland archive, 55% likely contain only 8080 code, while 45% would appear to include some Z80-only opcodes

Since more software was produced later (i.e. Software production increases a lot during the 1980s), a result might be biased toward Z80, …

From the software archives I've been able to look at (including the Oakland CPM Archive CD-ROM plus some archives of miscellaneous commercial CP/M-80 software), I don't get a clear picture of more people contributing code that would only run on Z80s as time went by. Here's a graph of the guessed 8080 vs Z80 code in the SIG/M library by slightly uneven time:

graph of guessed "z80ness" of contributions to the Sim/M library throughout the early 1980s. There is no clear pattern to the data. There is, however, a tiny Captain Zilog at the top right of the graph

The terminology used in the graph will be explained later.

Background

CP/M-80 COM files are simple containers of bytes with no headers and no segmentation into code and data. Thus it's hard to say what's actual code, and what might be data. To further confound the issue, the Z80 can run 8080 code perfectly.

One way to guess if a CP/M executable contains Z80 code is to count the number of two-byte sequences in the file that correspond to Z80-only opcodes. These opcodes (detailed here: Z80 Instruction Set) start with one of four byte values: 0xCB, 0xDD, 0xED or 0xFD. The second byte of the Z80-only instruction can take a variety of defined values: they are fairly easy to count.

It is assumed that code written for the Z80 will have more of these specific two byte sequences than code written for the 8080. The Z80 instructions are be completely valid data to an 8080, so they will still be seen occasionally in pure 8080 COM files.

From counting the number of Z80-only byte sequences in files (using is_z80.sh, a Linux tool I wrote), I came up with a heuristic: the Z80ness of a binary is the number of Z80-only byte sequences per 10,000 bytes. The odd scale is to ensure that the value is a useful integer range from 0–~900.

Reviewing known 8080 binaries (all of DR's system disks, for example) and comparing them against binaries for Z80 home computers, it became clear that 8080 code typically had fewer than 40× Z80 byte sequences per 10,000 bytes. Any “Z80ness” over about 40 appeared to be written specifically for the Z80 and wouldn't run on an 8080/8085 at all.

To track the change of code target with time, I looked at the SIG/M Amateur Computer Group of New Jersey disks. This group released over 300 volumes of “PD” software from 1981–1987. If the Z80 opcodes gained mindshare with time, surely this would have been reflected in a clear trend in the SIG/M disks? The graph shows otherwise: there's no real trend at all. People were programming Z80s as if they were 8080s, pretty much all the way through SIG/M's life span.

There are, of course, exceptions:

  1. WordStar, the classic word processor for CP/M, stayed solidly 8080 compatible throughout its life. But a v4.x release for the MicroBee computer appears to be almost pure Z80 code. John Dallman notes, however, that WordStar 4 was based on a clone, NewWord.

  2. Code written for the Apple II Z80 CP/M cards appears to be solidly 8080, unless it's a hardware specific driver, then it has Z80 opcodes.

  3. A few games for the Z80-based Sinclair ZX Spectrum use suspiciously few Z80 opcodes. One example appears to be Hudson Soft's Stop the Express, originally written as 暴走特急SOS, "Runaway Express SOS", for the Sharp X1.

scruss
  • 21,585
  • 1
  • 45
  • 113
  • 1
    As awesome as expected! Tiny question: what is each dot representing? One Program or One Disk or ? Also, you mention ZX games - do you have a sizeable archive to check against? might be interesting to see if the phenomena is there as well - without and need of restriction that is. – Raffzahn Feb 25 '23 at 14:23
  • One dot is, effectively, one disk volume. When I plotted it per COM file per volume, it was pure noise. I do (well, TOSEC has ...) giant archive of ZX Spectrum and other Z80 machine binaries. With graphics and game data, though, we risk false-positive identification of Z80 opcodes in program data, and this would mask any 8080 code – scruss Feb 25 '23 at 19:06
  • Really pure noise, or would it need maybe a different form of graph? The scatter plot against time makes a point about next to no change but doesn't really show about distribution. Since time seems of less of an influence, number of programs vs number of (assumed) Z80 might go more toward differentiation. Maybe a heat map or box-and-whisker plot might show distribution clearer? Regarding game data, I would not think that there is much masking. At least no systematic, so it may over emphase on Z80, but not make it impossible to see if pure 8080 is a noticeable amount or not. – Raffzahn Feb 25 '23 at 19:45
  • I think I'm hitting my interest/expertise ceiling on this one. Regarding systems, maybe something like ZX81 code might show 8080 influences more, since it's almost graphics-free? – scruss Feb 26 '23 at 01:45
  • 1
    If a CP/M program required a z80 it would be documented as such, right? So you could just search for text in the documentation stating that a Z80 was required? – Bruce Abbott Feb 26 '23 at 15:38
  • @BruceAbbott - good point, but documentation is not always there, or consistent. There would seem to be a general assumption that everyone was using Z80. For example, Simon Kelley's BCPL compiler package for CP/M is very heavy on the Z80 code, has pages of documentation, and not one mention of being incompatible with the 8080 – scruss Feb 26 '23 at 16:27
  • Would the real benefit of the Z80 opcodes be a smaller executable, and therefore only really interesting if the executable was large enough to have trouble fitting in memory? – Thorbjørn Ravn Andersen Feb 26 '23 at 22:32
  • @ThorbjørnRavnAndersen - slightly smaller, but the extra Z80 instructions are convenient for programmers, if often no faster than the equivalent 8080 routine – scruss Feb 27 '23 at 00:47
  • I see what you mean. I read some of the catalog files on the Oakland CD and a few did say Z80, then in one I found this :- "All of the programs (except one in Microsoft Basic) are written in Turbo Pascal Verson 2.0. The Turbo compiler produces Z-80 code." – Bruce Abbott Feb 27 '23 at 05:42
  • @scruss convenience things are always nice, so it would as I said primarily save space and not time? – Thorbjørn Ravn Andersen Feb 27 '23 at 15:29
  • @ThorbjørnRavnAndersen Maybe some space, but not a ton. I don't think many programs bumped up against the TPA limit often – scruss Feb 28 '23 at 00:57
  • 1
    @BruceAbbott - that's odd: Turbo Pascal only ran on Z80 systems but produced 8080 code. Also, there are thousands of packages. There is no earthly way I'm going through these manually to see if the docs (which often aren't there) say anything about Z80 – scruss Feb 28 '23 at 00:59
  • 1
    Yes, the docs are clearly not reliable. I think you have done enough. – Bruce Abbott Feb 28 '23 at 03:45
  • It will also be skewed because there are apps that are 8080 but test for Z80 to use a few things like LDIR. In fact some of the older CP/M 8080 emulators are basically 8080 + LDIR and friends to cover a lot more apps. The other reason for 8080 code was V20 compatibility. – Alan Cox Jun 22 '23 at 18:17
  • 1
    WordStar classic was versions 1.0 to 3.4. WordStar 4.0 was a new program. based on the clone NewWord, which MicroPro had bought while they still had money. – John Dallman Jan 04 '24 at 23:52
  • Prior to WordStar there was WordMaster and that would have also been 8080. – PDP11 Jan 17 '24 at 05:49
3

I think you can look at this in two ways:

  1. What amount of code was actually written in Z80 assembly using Z80 mnemonics, and what amount of code used 8080 mnemonics (otherwise, using the same 8080 opcodes). Without the source code, there is actually no way to find any data today on that. Choice of language was definitely one of taste - my personal choice has always been Zilog's way of writing - I simply found it easier to read and intuitively understand, but YMMV.

  2. Code actually using new Z80 instructions - This pretty much looks into "how useful were Z80 extensions over the 8080 instruction set to the average programmer". And here, it definitely depends on how far your code "owns the machine". The Z80/8080 lacks a really clear distinction between application and OS space - If your OS tends to use, for example, the Z80 alternate register set or the index registers, there's not much point in using it in application code, because saving your context might simply be too expensive. So, we need to look into specific machines to determine "what could be made usable".

    On the ZX Spectrum, for example, probably 90% of the more sophisticated games had to use IM2 (which would show up in code dumps only as one single Z80 one-byte opcode), because that was the only way to get to a reliable timing base other than pure cycle counting. For games using sophisticated graphics and interrupt-driven music, IM2 basically was a must, and I would guess IM2 was the most-used Z80-specific feature on the ZX Spectrum.

    I have no clear view on the alternate register set, there must have been a lot of games for the ZX Spectrum that used it, especially when you used stack access to the video memory where the number of usable registers is key for fast graphics. Other than "I need a bunch of scratch registers now", the usefulness of the alternate register set can be considered limited.

    Index registers (IX and IY) are sometimes very useful, but can be expensive from a code density and cycle count view - indexed access typically uses 1-2 bytes more code space and roughly more than twice the CPU cycles compared to access over an address register, so were sometimes considered a luxury feature.

    Loop instructions: Loop instructions (like LDIR, for example) are - after IM2 - probably the most commonly used extensions of the Z80 over the 8080. Especially for memcpy-like applications, they are both a lot faster and more dense than the same thing in "explicit 8080". But they are not the fastest method: If you do stack-based memcpy (because that's faster) you're using 8080 instructions yet again.

Looking away from specialised platforms like the Z80 that have a somewhat more "traditional" segregation between application and OS - like CP/M, you had yet another choice to make, which was your user base. CP/M is clean 8080 code, so you were free to use any extended Z80 feature without the OS interfering. How much customers do I lose when offering Z80-only applications? Notably the only really omnipresent piece of software (that comes to my mind) that took the Z80 decision was Turbo Pascal. (And I really don't think it hurt that product much).

I also have a feeling that software originating in Europe and Asia has a bit more of a tendency towards the Z80 (probably because these regions jumped on the CP/M wagon relatively late when the Z80 was already omnipresent) than US software.

tofro
  • 34,832
  • 4
  • 89
  • 170
  • The Digital Research MP/M and CP/M 1.4, 2.2 ASM assemblers were only for Intel 8080 codes. This assembler was available at zero cost and all installations. When writing code you are limited to the available tools. When I was writing new bits and pieces for the CP/M BIOS it was always 8080 code even for dedicated Z80 systems. – PDP11 Jan 17 '24 at 05:43