Blog post
This commit is contained in:
parent
49bcb1af62
commit
69c6c074f9
4 changed files with 84 additions and 19 deletions
56
_posts/2016-04-30-the-intel-8080-cpu.md
Normal file
56
_posts/2016-04-30-the-intel-8080-cpu.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
layout: post
|
||||
title: The Intel 8080 CPU
|
||||
date: 2016-04-30 14:00:00
|
||||
permalink: /blog/2016/04/30/
|
||||
---
|
||||
|
||||
We'd like to introduce [PC8080](/modules/pc8080/), a new 8080-based machine emulator recently added to the
|
||||
PCjs Project.
|
||||
|
||||
Our first [8080 Test Machine](/devices/pc8080/machine/test/) loads a copy of the
|
||||
[8080 Exerciser](https://web.archive.org/web/20151006085348/http://www.idb.me.uk/sunhillow/8080.html)
|
||||
(specifically, [8080EX1](/devices/pc8080/rom/test/8080EX1.MAC)) 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", which most other 8080 emulations 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, while 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](http://www.righto.com/) has some fascinating blog posts on the 8085 that also
|
||||
provide clues as to how the 8080 likely operates:
|
||||
|
||||
* [Inside the ALU of the 8085 microprocessor (January 2013)](http://www.righto.com/2013/01/inside-alu-of-8085-microprocessor.html)
|
||||
* [Silicon reverse engineering: The 8085's undocumented flags (February 2013)](http://www.righto.com/2013/02/looking-at-silicon-to-understanding.html)
|
||||
* [The 8085's register file reverse engineered (March 2013)](http://www.righto.com/2013/03/register-file-8085.html)
|
||||
* [Reverse-engineering the 8085's ALU and its hidden registers (July 2013)](http://www.righto.com/2013/07/reverse-engineering-8085s-alu-and-its.html)
|
||||
* [Reverse-engineering the flag circuits in the 8085 processor (July 2013)](http://www.righto.com/2013/07/reverse-engineering-flag-circuits-in.html)
|
||||
* [Reverse-engineering the 8085's decimal adjust circuitry (August 2013)](http://www.righto.com/2013/08/reverse-engineering-8085s-decimal.html)
|
||||
|
||||
The idea is to make [PC8080](/modules/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](/devices/pc8080/machine/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](https://github.com/phooky) work
|
||||
[reverse-engineering the VT100](https://github.com/phooky/VT100-Hax).
|
||||
|
||||
*[@jeffpar](http://twitter.com/jeffpar)*
|
||||
*April 30, 2016*
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
layout: page
|
||||
title: Space Invaders (Under Construction)
|
||||
permalink: /devices/pc8080/machine/invaders/
|
||||
sitemap: false
|
||||
machines:
|
||||
- type: pc8080
|
||||
id: invaders
|
||||
|
|
@ -12,18 +11,11 @@ machines:
|
|||
Space Invaders (Under Construction)
|
||||
---
|
||||
|
||||
This is a test of [PC8080](/modules/pc8080/), a new 8080-based machine emulator being added to the
|
||||
This is a test of [PC8080](/modules/pc8080/), a new 8080-based machine emulator recently added to the
|
||||
PCjs Project. It's a work-in-progress, so there's not much to look at yet. And the goal is not to build
|
||||
yet-another Space Invaders/Arcade Machine emulator -- that's been done many times over -- but to start with
|
||||
a well-understood 8080-based machine architecture that doesn't need a lot of peripherals, and use it as the
|
||||
first test case for another CPU that we can add to the PCjs toolbox.
|
||||
|
||||
The idea is to make [PC8080](/modules/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 adaptation will be a DEC VT100 terminal emulator (itself
|
||||
an 8080-based machine) which can then be "wired up" to other PCjs machine simulations.
|
||||
a well-understood 8080-based machine architecture that doesn't need a lot of peripherals, and use it as an
|
||||
early test case for another classic CPU that we can add to the PCjs toolbox.
|
||||
|
||||
Assorted [Space Invaders Hardware Notes](#space-invaders-hardware-notes) are collected below.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,18 +14,35 @@ machines:
|
|||
This is a test of [PC8080](/modules/pc8080/), a new 8080-based machine emulator being added to the
|
||||
PCjs Project.
|
||||
|
||||
This test machine loads a copy of the
|
||||
The test machine below loads a copy of the
|
||||
[8080 Exerciser](https://web.archive.org/web/20151006085348/http://www.idb.me.uk/sunhillow/8080.html)
|
||||
(specifically, [8080EX1](/devices/pc8080/rom/test/8080EX1.MAC)) and intercepts *just* enough of the exerciser's
|
||||
CP/M calls to display its progress.
|
||||
(specifically, [8080EX1](/devices/pc8080/rom/test/8080EX1.MAC)) and intercepts the exerciser's CP/M console
|
||||
calls so that you can see its progress in the Control Panel window. This is a "headless" test machine
|
||||
(no keyboard or display), so that's all you get.
|
||||
|
||||
The good news: PC8080 passes all the 8080 Exerciser tests. At 2Mhz, the tests do take quite a while,
|
||||
but you can click the speed button while the machine is running to increase the simulated speed; it will
|
||||
wrap around to 2Mhz if you try to exceed the maximum speed that your system supports.
|
||||
The good news: PC8080 passes all the 8080 Exerciser tests. And it doesn't do it by using all sorts of weird
|
||||
"flags tables", which most other 8080 emulations 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 all 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).
|
||||
|
||||
At 2Mhz, the 8080 Exerciser tests take quite a while, but you can click the speed button while the machine is running
|
||||
to increase the simulated speed; it will revert to 2Mhz when you exceed the maximum speed that your system supports.
|
||||
|
||||
NOTE: The original [8080 Exerciser website](http://www.idb.me.uk/sunhillow/8080.html) is currently unavailable,
|
||||
so we refer you to the copy on
|
||||
[archive.org](https://web.archive.org/web/20151006085348/http://www.idb.me.uk/sunhillow/8080.html).
|
||||
The 8080 Exerciser has also been "forked" on [GitHub](https://github.com/begoon/8080ex1).
|
||||
The 8080 Exerciser source code has also been "forked" on [GitHub](https://github.com/begoon/8080ex1).
|
||||
|
||||
{% include machine.html id="test8080" %}
|
||||
|
||||
8080 Online Resources
|
||||
---
|
||||
|
||||
[8080 Opcode Map](http://pastraiser.com/cpu/i8080/i8080_opcodes.html)
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ CPUSim.prototype.subByte = function(src)
|
|||
*/
|
||||
CPUSim.prototype.subByteBorrow = function(src)
|
||||
{
|
||||
src ^= 0xff
|
||||
src ^= 0xff;
|
||||
this.resultAuxOverflow = this.regA ^ src;
|
||||
return this.resultParitySign = (this.resultZeroCarry = (this.regA + src + ((this.resultZeroCarry & 0x100)? 0 : 1)) ^ 0x100) & 0xff;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue