Altair BASIC via 8080 emulation Dec 2015
Some of this retrocomputing emulation goes quite far. Some emulators running code for these old machine can generate a video out signal - with an entire community around the computers people used to tinker & play with in their youth. See RetroPie, for example.
Let’s not go there for now, but we could try an emulation of a more general-purpose low end machine, from the 1970..1980’s era. Such as this clunky beast, called the Altair 8800:
Check out the hefty 8V @ 8A linear DC power supply in the rear of that cabinet.
There is a nice and clean emulation of the Intel 8080 microcomputer chip available - and as always it’s on GitHub. We can take this code and pair it with Altair BASIC. It’s famous because it was Microsoft’s first product (you may have heard of that company somewhere).
The particular version we’ll use is the smallest one, which fits in 4 KB, with the rest of the 16 KB emulated RAM available for user programs and data. All code on GitHub, as usual:
[emu8080] MEMORY SIZE? TERMINAL WIDTH? WANT SIN? Y 13015 BYTES FREE BASIC VERSION 3.2 [4K VERSION] OK PRINT 1+2, 1/3, SIN(3.14159/4) 3 .333333 .707106 OK
Sorry, no “PI” this time (this version only supports single-letter variable names). But still: an editor, a runtime, floating point, and some trigonometry and other routines. And it all fits in less than 4000 bytes of 8080 machine code.
There’s even a tiny BASIC variant, called MINOL (PDF), which fits in a diminutive 1.75 KB!
As with the 6502 emulator, speed is not stellar with this way of running BASIC code:
LIST 10 FOR I=1 TO 10000:NEXT I OK RUN OK
That second “OK” takes roughly 8 seconds to appear. But it works. In fact, this emulator is billed as one of the most accurate ones for 8080 chips - passing the CPUTEST.COM suite which tests every aspect of the CPU. It’s slightly too large to fit in our 16 KB of emulated RAM, though we could probably get it to work by running it out of flash memory.
Altair BASIC was the start of an entire industry, and machines like it were used to develop and run a minute “Disk Operating System” called CP/M for example. Which led to a whole slew of new designs, most notably MS-DOS. All you needed to run tons of exciting software (and games!) was an Altair with 1 or 2 floppy disk drives. It sure wasn’t cheap, but it came to a point where the more affluent hobbyists could afford it - just like 3D printing now:
(more info here - note the 60-day delivery times: this was not for the impatient!)
From the Wikipedia page on CP/M:
A minimal 8-bit CP/M system would contain the following components:
- A computer terminal using the ASCII character set
- An Intel 8080 (and later the 8085) or Zilog Z80 microprocessor
- At least 16 kilobytes of RAM (beginning at address 0)
- A means to bootstrap the first sector of the diskette
- At least one floppy disk drive
Compare that to a Hy-Tiny and you can see the astonishing drop in price, 40 years later…
The point of all this is not that you’d want to develop code in such a limited environment, let alone throw away performance by emulating an 8080 chip to run a BASIC interpreter, but that there are some deep lessons to be learned from software which gets so much done with so little code. Altair BASIC and its CP/M & floppy-based successors were able to offer a sufficiently rich environment for people to do fairly amazing and advanced things with it.
All in 16..64 kilobytes of RAM. But enough of that… let’s get back to the 21st century!