So there I was, very happy with my Apple ][plus. But then I saw someone on the internet post, and it seems that my Apple is an overpriced box with a toy microcontroller for a CPU, while real computers use an Intel 8080, 8085 or Zilog Z80 to run something called “CP/M”… but I’ve already spent so much money on the Apple, so can I turn it into a real computer?
Microcontroller says what?
First off, is the 6502 a microcontroller? Eh, not by modern standards, with no inbuilt ROM or RAM and no IO. But at the time of its release, MOS Technology definitely saw usecases we’d call “embedded” today as part of the processor’s mission. And if you buy a 65C02 today from the Western Design Center, you’re probably using it for that. Or for a hobby machine, I suppose.
But the same is also true of the Z80. And yeah, you can get those today straight from Zilog themselves. Good thing for TI; gotta keep that graphing calculator racket going. Insulting 8-bit processors by calling them microcontrollers, in this, the year 2020? That’s the only thing that keeps them going!
Back to the 1970s
But let’s take a look at the historical view to understand where my angry internet commenter friend might be coming from.
Today, many computer historians date the microcomputer era as starting in 1977 with the “Trinity” (a term which may not have been used at the time, but is definitely used now) of the Commodore PET, the Tandy/Radio Shack TRS-80 Model I, and the Apple ][. Two of these machines were 6502-based, and one was Z80-based. None of the three could run CP/M. (Some later TRS-80 computers could, but what Tandy did to the TRS-80 brand…)
But some might go back to 1974, with the Altair 8800. Nope, of course I don’t have one of those. In 1974 there were no Z80s or even 6502s; the Altair used the Intel 8080, an 8-bit design that was one of the first real heavily used microprocessors. It used a 100-pin bus that somehow managed to get in the hands of the military, ensuring support until the 1990s.
The Altair 8080 spawned a whole series of clones which used the same CPU (or the later Intel 8085 and Zilog Z80, which could run the same software, but required less support circuitry and added some features), but all these clones had slight differences; some would output through a teletype or serial terminal. Maybe others had a graphics display. Disk drives were still in the throes of shifting from 8” to the 5.25” disks we now call “big”, but they called “mini”.
And that was what CP/M was for: a Control Program and Monitor that could be ported to any of these machines, and paper over those differences for software. That’s still what operating systems do today. But the basic requirements were RAM in the right places (Tandy failed that one), and an Intel 8080-compatible CPU (Apple and Commodore whiffed that one).
So if you had been a microcomputer enthusiast or a business that was an early adopter in 1977, you might be a little miffed at the “Trinity”; sure, they were cheaper and more accessible than the expensive S-100 bus machines, and were a complete package, but they also ignored all the standards and were incompatible with all your software.
But this is a blog post about the Apple ][. An illustrious line of computers that would outlive its competition. And it did that through its expandability. Who needs S-100 when we have A-50?
That logo on the Z80 SoftCard might surprise you. How on earth did Microsoft have such an awesome logo in the 1970s, and why would they ever give it up? Also, why are they making Apple parts?
Well, Microsoft was the largest vendor of BASIC, a programming language that was available all over (my Apple ][plus has Microsoft BASIC in ROM), but had made its initial start on the Intel 8080 machines. So perhaps that’s why they decided to sell a card, to allow users access to the pre-existing ecosystem they had helped build. And it’s not even the only Microsoft card in my Apple!
The card was, according to Wikipedia, designed by Tim Paterson, who at the time worked for Seattle Computer Products, a hardware company that Microsoft often worked with in those days. He was also clearly a CP/M fan; when the official port to Intel’s new 8086 16-bit CPU was delayed, he wrote his own clone– a clone which became MS-DOS. So this card has quite a pedigree!
Install the card
So now we install the card. This is a pretty typical, if bare, setup, with a Microsoft RAM card in slot 0, and a 5.25” Disk Controller in slot 6. But the interesting thing is, this isn’t what Woz expected. Apple documentation of the time suggests that cards be added from left to right to allow the DMA priority lines (more on what that means later) to be continuous. Cards were supposed to be able to inhabit any slot; writing position-independent code is a bit hard on the 6502, but it’s not impossible.
Perhaps because of that difficulty, Microsoft decided to create a standard arrangement of cards. I’m not actually sure if this originated with Microsoft, but the SoftCard documentation is the earliest I can find it.
A memory expansion card in slot 0, a printer in slot 1, an IO device in slot 2, an 80 column card in slot 3, and disks in 5 and 6, with 7 being any type. That might seem familiar to a user of the Apple IIgs. (The Apple IIgs has a full contingent of slots, but maps its built-in hardware to the memory addresses of the original slots for backwards compatibility) Sure, they didn’t see the need for a mouse in 1980, but who did? (Xerox, yes) In any case, this card arrangement was pretty much standard among Apple users by the early-to-mid 1980s.
I want to run the CP/M card on my period-appropriate machine; not the IIgs, but the Apple II plus. Today, it’s hooked up to the Monitor ///; CP/M software doesn’t need color. In fact, this is a fairly period-accurate setup. While the Apple /// was not a huge success, its monitor seems to have been.
Turn it on!
The Apple ][plus, with the Z80 Softcard installed, still boots to its normal Autostart ROM, waiting for you to insert a disk. It’ll boot those disks like normal, and if you press reset, you can end up in Applesoft BASIC.
But of course, this is exactly how you’d want it. You wouldn’t want to suddenly lose all compatibility with 6502 software; in fact, the Z80 goes to great pains to keep compatibility, as we’ll see later. Things only change once you insert a CP/M boot disk.
Oops. Those slots are around 30 years old, some contact cleaner couldn’t hurt. And notice that it drops you in the ROM monitor (the “*” prompt) rather than BASIC. (Integer BASIC had a “>” prompt, and Applesoft a “]” prompt) In this case, it probably just did a
BRK opcode. You can get the same behavior in your own problems, which can be helpful in debugging.
Anyway, one deoxit later, and…
Enter Apple CP/M
And here we are! This is a “>” prompt, but it’s not Integer BASIC. You’ll find none of your familiar Apple DOS or ProDOS (which didn’t even exist yet) commands like
CATALOG will help you here.
The CP/M prompt is a lot like the DOS prompt. And that shouldn’t surprise you; after all, MS-DOS started out as a clone of CP/M. Familiar commands like
DIR to list a directory and
TYPE to print out a file exist here too. But it’s a very early ancestor; things like directories don’t exist just yet. The COM files are executables, just like in MS-DOS; EXE files aren’t a thing.
And you’ll see
GBASIC, a variant that supports Apple ][ high-resolution graphics) That’s right, this contains the Z80 version of Microsoft BASIC. And they even customized it for the Apple ][, which is pretty neat.
Notice that there are only 14195 bytes free in RAM. Unlike Applesoft, which resides in ROM, CP/M
MBASIC has to live in the free RAM, and CP/M’s OS facilities take up even more of that space. So this takes up a lot of space that could be used for your programs. But hey, the manual says it’s better.
By the way,
GBASIC, which does support high-resolution graphics, only gives you 5105 free bytes for your program. Hey, it still beats a stock VIC-20.
Let’s ‘benchmark’ this!
So, we have BASIC. This means that we can run our notoriously terrible benchmark, the Nicole Simulator! (For some history, this originated in my Tandy 1000HX blog post).
The Z80 in the Softcard is clocked at 2.041 MHz (it’s a little more complicated than that, as Apple ][ timing is a bit of a mess), which is similar to the clock speed the RAM runs at. That’s a bit slow for Z80, but remember that this test, a simple BASIC program, is primarily limited by the ability to put characters on screen. And the Apple ][ is very good at that.
Fun fact: I initially wrote that first line
FOR I=1TO10000, but something wanted the spaces. Not sure what; spaces are usually not required in BASIC, as you can see on the
20 PRINT"NYA" line.
In any case, here’s the result!
|Computer||CPU||Clock speed||Time to 10K nya (mm:ss)|
|Apple ][plus||MOS 6502||1 MHz||3:22|
|Tandy 1000 HX||Intel i8088||7.16 MHz||4:39|
|Tandy 1000 HX||NEC V20||7.16MHz||4:05|
|Sega SC-3000||Zilog Z80||4.00MHz||9:54|
|Tandy Color Computer 2||Motorola 6809A||895kHz||1:47|
|Nintendo Famicom||Ricoh 2A03||1.79MHz||8:20|
|RetroUSB AVS||Simulated 2A03||1.79MHz||8:30|
|Apple ][plus||Zilog Z80||2 MHz||4:19|
Very nice! The overhead of having to go through CP/M to write on screen doesn’t help compared to the stock bare-metal Applesoft routines, but this is still a great showing.
You might wonder why it does so much better than the Sega SC-3000. And honestly, I don’t know why the SC-3000 bombed that badly, but the fact that both it and the NES had comparable slow speeds makes me think that it has something to do with the fact that those systems can only access Video RAM during limited intervals, and don’t have direct access to it. (This is also how CGA works, but the beefier processors help there)
Still, this was way faster than I expected. Good on you, Z80.
More technical details
So, an interesting question you might have is how the Microsoft SoftCard manages to add a new CPU to a system through an expansion card. Especially one as different as the Z80 is from the 6502; they have no program compatibility, have different timing, and have different expected memory layouts. And the SoftCard contains no RAM! (Some later Z80 cards for the Apple ][ did include their own RAM, usually in order to run at faster speeds; I wonder how they’d do in the Nicole Simulator, though)
When Steve Wozniak designed the Apple ][, he figured that some cards in the future might want to be able to control the memory bus without the CPU getting in the way. This capability, called DMA (for “Direct Memory Access”), is very useful, as copying data from RAM can be much quicker without the CPU getting in the way and having to constantly pull instructions. The NES has a similar capability for copying data into sprite memory quickly.
So what the SoftCard does, essentially, is put the 6502 in DMA mode all the time. It needs to access the memory directly. It also has the capability to give control back to the 6502; this allows it to, to use an example right out of the manual, use the Apple ][’s ROM routines to read paddles. (That’s a highly timing-specific action, due to the lack of a real analog-to-digital converter)
But there’s a catch. Way up at the beginning of this blog post I linked to the WDC W65C02S, and it advertises one of its features as “Fully Static for Power and Radiation Management”. A static processor core is one that only needs power to maintain its internal state. You can make the clock speed of a W65C02S so low that you can control it with a button. A neat trick, and useful if you want to experiment with “bare-metal” computing.
But the NMOS 6502 (NMOS is just a form of semiconductor production) used in the Apple ][ isn’t static. If the clock is too slow, its internal registers will get corrupted, and it’ll lose its place in memory. This isn’t good for the Softcard; if it gives control back to the 6502, it could behave unpredictably.
An interesting thing about the Z80, though, is that it contains an extra REFRESH line that’s used to refresh dynamic memory. (Dynamic memory, like a dynamic CPU core, will lose its data if it’s not constantly refreshed) This was a major plus of the Z80 in its day; dynamic memory is much cheaper than static memory. The 6502 didn’t have it, and 6502 machines had to either implement it some other way (the Apple ][ uses its video circuit) or use expensive static RAM (and that’s why the VIC-20 has so little RAM).
Now, the Softcard doesn’t need to use that line to refresh RAM, because the Apple ][ video circuit can handle that. But it also doesn’t need to access the memory bus during a refresh cycle. (That’s the whole point of them, since you need access to the RAM to refresh it) Therefore, it uses the refresh line to determine blocks of time to let the 6502 run. This keeps it refreshed, just like dynamic RAM. A clever solution!
Running Z80 software
It doesn’t matter how clever your solutions are if you have no software to run with it. But that’s where we run into a snag. See, CP/M software, in theory, should run on any terminal. The basic functions provided in it for screen access were designed to be flexible, after all.
But when you load up a classic program like the wordprocessor WordStar (preferred by George R. R. Martin, though I hear he uses the 16-bit version these days), well, they just assumed you had 80 columns. That was how you’d print things out, after all.
I don’t have an 80-column card in my Apple ][ plus, so this obviously won’t work out too well for me. I found this to be a common issue with business software for CP/M, which was a bit frustrating.
A second issue I found was more easily surmountable. See, a lot of CP/M software you find online is distributed as raw executables. (Remember, floppy disks weren’t standardized in the 70’s) Using something like the Floppy Emu, though expects disk images. How do we get a disk image that’s formatted correctly? We use cpmtools. They’ve got it entirely covered, and I was able to run the one program that I know only needs a place to put sequential text:
Okay sure, you can run Zork natively on an Apple ][, and on everything else too. But hey, this is running natively too! There’s a real Z80 in there!
IIgs more like II… geewiz?
Okay, so I don’t have an 80-column card. But while writing this article, I realized: I have an Apple IIgs! It has all those cards built in! I even took a screenshot! Let’s take all those pointless modern cards out, and put in the real “heavy iron”. (All 80 column screenshots will be in original capture resolution, click to see the full size)
So it turns out you need to put the system into “Normal” mode (which runs it at 1 MHz) rather than the IIgs’s native “Fast” mode (2.8 MHz). This shouldn’t be surprising, with how closely tied the SoftCard is to the timing of the original Apple ][. But we have 80 columns! In fact, we boot right into it. And lowercase letters too… So we can run…
Well, there are more troubles. See, in CP/M, we need to hit “RESET” every time we change disks. Turns out that the IIgs doesn’t like that at all. So we’ll need to do a hard reboot every time we change disks, which is less than ideal. Thankfully, CP/M programs don’t have any trouble booting from the B: drive, so I can leave the boot disk in my real drive.
Okay, now we can run… business software!
Oh, and Zork too.
So that’s it!
That’s the Z80 Softcard. There were a few more cards of this sort, including faster Z80s, and other processors like the Motorola 6809 to run OS-9. In the end, I think the SoftCard is a good example of the sheer flexibility the Apple ][’s design allowed.
Now, when is Microsoft going to release a PCI Express card that lets me boot my x64 Windows PC into RISCOS running on ARM?