This is interesting, though it might be a bit of a cheat. He's put some data in the BIOS image to assist in decoding instructions (not to take away from how amazing this is!):<p>"CPU supports the full 8086/186 instruction set. Due to the complexities of the 8086’s arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversion, along with instruction lengths and how each instruction modifies the flags, is assisted by some lookup tables which form part of the BIOS binary."<p>With that in mind, the BIOS is _hand-written_ and about 12kB (gzips to <4kB), so that's also a fantastic achievement. All-in-all, this is a wonderful entry.
I went through and reformatted the code, after expanding all of the macros that contained unbalanced parens: <a href="http://eigenstate.org/cable3-formatted.c" rel="nofollow">http://eigenstate.org/cable3-formatted.c</a><p>I still haven't puzzled out exactly what all the variables are, but I think that this makes the structure much clearer.
The source itself: <a href="http://ioccc.org/2013/cable3/cable3.c" rel="nofollow">http://ioccc.org/2013/cable3/cable3.c</a><p>Or after running through preprocessing (not a huge help I found, sadly): <a href="https://gist.github.com/peterc/8259713" rel="nofollow">https://gist.github.com/peterc/8259713</a>
> Instruction codings are complex and irregular in size and structure, with multiple addressing modes and no consistent memory placement for operands, very often multiple possible encodings for the same instruction<p>It's only complex and irregular if you look at it wrong. ;)<p>The x86 (like the 808{5,6} and the Z80) instructions look organised in an octal format: ftp://mipt.cc/Opcode.txt<p>I haven't inspected the code in any detail to see if it takes advantage of this.
Here's a link to a fully functional Windows binary (built with Visual Studio 2013):<p><a href="http://sdrv.ms/1hodqjP" rel="nofollow">http://sdrv.ms/1hodqjP</a><p>Just add the bios and image files elsewhere.
/snip
This entry weighs in at a magical 4043 bytes (8086 nibbles, 28,301 bits). It manages to implement most of the hardware in a 1980’s era IBM-PC using a few hundred fewer bits than the total number of transistors used to implement the original 8086 CPU.
/snip<p>Just a small reminder how far we have come - and what Moore's law (RIP) has done for us. Yes the original PC had few enough transistors one could actually count them. NowadAys ...<p>An awesome piece of work
Neat, the linked hd.img file contains windows, Simcity, AutoCAD, etc. Has anyone compiled this for Windows? If so, would you kindly post the binary? It'd be fun to play with this old software again.
If you're on Linux and don't want to bother installing a VGA font, there's no need. Do Ctrl+Alt+F6 (or lower) to switch to a terminal and run it there, then do Ctrl+Alt+F7 to switch back later.<p>Also, if someone can tell me how to make Windows not make the emulator segfault on my machine, that'd be great.<p>EDIT: Oh, it works fine in a graphical terminal. I'm guessing SDL failing to init on a text terminal broke everything.<p>EDIT 2: ALL THIS, PLUS REVERSI! You can even play Reversi!