Possible Duplicate:
Emulate an Intel 8086 CPU

I know that there already is a code golf for this, but that one didn't require much. This one, however, is for masochists only! >:) OK, you need to emulate an entire 8086, every single opcode. Not every flag needs to be computed, but every single documented opcode needs to be implemented.

However, that's just the beginning. I STRONGLY encourage you to support more than just this. NEC V20? Why not? Soviet clones? Don't mind if I do.

For some help, opcodes 0x60 - 0x6F are just aliases for opcodes 0x70 - 0x7F on the 8086 and 8088 ONLY. If you ask the guy who runs reenigne.org, he'll say the same thing, simply because it's been proven by hardware tests, on an IBM XT.

Anyways, for bonus points, emulate an entire V20, 286, or 386, no facets left unemulated.

  • 3
    \$\begingroup\$ What is the metric here? \$\endgroup\$ Commented Jan 21, 2013 at 22:10
  • 1
    \$\begingroup\$ added the code-challenge tag. every puzzle needs a 'type'. \$\endgroup\$ Commented Jan 22, 2013 at 5:06
  • 2
    \$\begingroup\$ The other thread you mention is Emulate an Intel 8086 CPU, and I'm voting to close as a duplicate of that on the basis that any solution to this challenge is also a solution to that challenge. If you want solutions to the extended challenge to get double points, I think a better approach is to find someone willing to sponsor bounties. \$\endgroup\$ Commented Jan 22, 2013 at 9:46
  • 1
    \$\begingroup\$ Minority Opinion: I don't consider it a problem to have an expanded version of the same challenge. Something you can graduate towards by first solving the smaller one. But I cast the final close vote as "Not a real question" for the reason cited by dmckee. The beauty of the original question was the well-chosen subset and the well-written test program which exercised the desired subset. Where does this one end? Pentium? MMX? The fun was in the 0-60 part. That said, if this were edited to provide nicer constraints, perhaps a single output device, and a testing program, that'd be different.hth \$\endgroup\$ Commented Jan 24, 2013 at 7:09
  • 1
    \$\begingroup\$ ... and most vitally winning criteria. \$\endgroup\$ Commented Jan 24, 2013 at 7:12

1 Answer 1


C++ - 5084 lines


This emulates the entire 8086, the 80186 instruction set, and part of the NEC V20. This took me over 3 weeks.


Not the answer you're looking for? Browse other questions tagged or ask your own question.