VOGONS


First post, by Zorbid

User metadata
Rank Member
Rank
Member

http://ioccc.org/2013/cable3/hint.html

The author hereby presents, for the delectation (?) of the judges, a portable PC emulator/VM written specifically for the IOCCC […]
Show full quote

The author hereby presents, for the delectation (?) of the judges, a portable PC emulator/VM written specifically for the IOCCC which runs DOS, Windows 3.0, Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 …

In just 4043 bytes of C source, you get a complete mid-late 1980s-era IBM-compatible PC, consisting of:

  • Intel 8086/186 CPU
  • 1MB RAM
  • 8072A 3.5" floppy disk controller (1.44MB/720KB)
  • Fixed disk controller (supports a single hard drive up to 528MB)
  • Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA 80x25 16-color text mode support
  • 8253 programmable interval timer (PIT)
  • 8259 programmable interrupt controller (PIC)
  • 8042 keyboard controller with 83-key XT-style keyboard
  • MC146818 real-time clock
  • PC speaker

The emulator uses the SDL graphics library for portability, and compiles for Windows, Mac OS X, Linux and probably most other 32-bit/64-bit systems too.

Apparently, they cheat a bit regarding code size. x86 machine language is translated to a simpler instruction set, and the lookup tables are stored in the 12k BIOS. Still, it's quite a feat!

.

Reply 3 of 4, by Zorbid

User metadata
Rank Member
Rank
Member

I forgot this priceless snippet:

If you like living on the edge you can try building the emulator on a big endian machine, and you will get an emulation of a big endian 8086, a rather bizarre and somewhat useless beast. For everyone else, please run the emulator on a little endian machine.