If you haven't seen JSNES or
do. The most interesting thing about these emulators, though is the
source. JSNES is on GitHub so you can
casually browse files like
cpu.js to see how the emulator works.
In fact, if you've never written an emulator but wondered how they work,
JSNES is worth checking out. Emulators aren't really as scary as they
sound: they're essentially decoders that can understand code for
particular hardware and run it in a different environment. They're giant
case statements and simple algorithms.
In JSNES, you can see how the CPU registers and interrupts are handled.
Since the original hardware has been reverse engineered there's nothing
fundamentally complicated or difficult to understand, there's just a
sizable amount of code.
Now all we need to do is find the source for an x86 emulator to create a