Jan 032014

8080js is Yet Another 8080 Emulator. But why?

Chris Double’s js8080 emulator is pretty good if you want to play around. But it has a really big issues – some instructions simply don’t work, some instructions set the flags totally bad and DAA instruction is probably guessing rather than computing. Stephan Tramm did a pretty good work with his i8080 CP/M emulator. But it is still slightly differrent from original (“silicon”) CPU.

The biggest challenge were two testing software: so-called “Kelly Smith Test” and – the greatest one – 8080 Exerciser (a.k.a. Sunhillow). The first one does some basic tests, it checks known border states and simply says: OK, or Error at… The second one does a lot of combinations of data manipulating instructions, and the result is a set of CRC codes (one for each test case). They are compared with CRCs from real “silicon” CPUs. It checks all non-standard states very well and deeply.

My emulator passed Kelly Smith test a long time ago. But Exerciser was a really big issue. It takes a lot of changes and tests and fixes, but – it works!

So I keep my promise and release this JS emulator as open source library. Here it is: 8080js

PS: Big thanks to Roman Borik for his help.

  2 Responses to “Intel 8080 emulator in JavaScript”

  1. Martin,

    I too am using Chris Double’s js8080 in an emulator, specifically I started with Stephan Tramm’s version. I had to change some things to suit my purpose. When I looked at your code to see what you have changed, and thus what bugs you have found and fixed, I noticed something odd.

    The Intel 8080 programming guide says that conditional jumps (taken or not) are always 10 cycles, but your code makes it 15 cycles if taken, 10 cycles if not taken. Is that 8085 timing or something?

    Also, for conditional calls, you have made the taken calls consume 18 cycles, but the intel manual says it is 17 cycles. What is your source that indicates 18 is the right number?

    Your version of the code, like the original, doesn’t respect the HALT flag. I added a “this.halted” state member, setting it initially to false. If the HLT instruction (0x76) is reached, this.halted = true. Then in the instruction dispatch loop, if interrupts are enabled and an interrupt is pending, I set this.halted to false. Otherwise, if this.halted is true, it is treated like a NOP and the PC isn’t advanced. Otherwise, normal instruction dispatch occurs.

  2. Hi Jim, thanks for your report. I guess the Jcond timing is really my mistake. I’ll fix it as well as HLT.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">