Or rather, introducing PC8080, a new 8080-based machine emulator recently added to the PCjs Project.

Our first 8080 Test Machine loads a copy of the 8080 Exerciser (specifically, 8080EX1) and intercepts the exerciser’s CP/M console calls so that you can see its progress in the Control Panel window. It’s a “headless” test machine (no keyboard or display), so that’s all you get.

The good news: PC8080 passes all the 8080 Exerciser tests. And it doesn’t do it by using all sorts of weird “flags tables” that most other 8080 emulators seem to fall back on.

Like all the other CPU emulations in the PCjs Project, PC8080 never “calculates” the flags unless/until they are actually required, which considerably speeds up arithmetic operations.

Of particular note are the 8080’s subtract, compare, and decrement operations, which actually perform addition, not subtraction, by using two’s complement arithmetic in “stages”: the first stage (inverting the source operand) occurs before the addition, and the second stage (incrementing the inverted operand) occurs after the addition. And it appears to be the result of the first stage, not the second, that determines the state of the Auxiliary Carry flag (AF).

The behavior of the Auxiliary Carry flag (AF) and the associated DAA instruction are probably the most significant (and least understood) arithmetic differences between the 8080 and all later x86-based CPUs. Well, there’s also the fact that the 8080 doesn’t provide an Overflow flag (OF). Internally however, PC8080 retains the ability to calculate overflow (since PC8080 was a fork of PCjs), which should be useful when we add Z80 support to PC8080.

On a related note, Ken Shirriff has some fascinating blog posts on the 8085 that also provide clues as to how the 8080 likely operates:

The idea is to make PC8080 sufficiently configurable so that it will work with a variety of 8080-based systems, including those with memory-mapped video displays (like Space Invaders), as well as simpler terminal-based systems, like the CP/M-based systems of old.

In fact, as soon as Space Invaders is working, my next planned adaptation is a DEC VT100 terminal emulator (itself an 8080-based machine) which can then be “wired up” to other PCjs machine simulations. This will not be yet-another VT100-compatible emulation – which, like 8080 emulators, has been done to death – but rather a simulation of the original VT100 hardware, building on Adam Mayer’s work reverse-engineering the VT100.

April 30, 2016