7 random discussion-provoking reasons why DOS/8086 emulation is slow and complex (from painful experience):
- Every memory reference needs to be converted to an absolute address from a segment and offset.
- Most instructions use a mod r/m byte containing register and memory information, which must be spilt into 3 individual components, each of which must be interpreted.
- Most instructions have different opcodes for 8bit and 16bit operations.
- Some opcodes refer to further groups of instructions. The instruction to be executed depends on a value taken from the above mod r/m byte.
- Instructions may contain a segment override, changing the segment to which the following instruction refers.
- Most instructions modify the auxiliary flag, which is a bitch to calculate manually (please correct me if I'm wrong).
- Because the OS has no control whatsoever over memory management (in real mode at least), there's no way of knowing what random memory addresses have been written to at any given moment. I wouldn't want to be the person assigned to write a dynarec for this thing.
Other Reasons why DOS games run slowly under a DOS emulator
I would imagine that most console emulators get their speed from emulating the graphics hardware at a high level. For example, the Mode7 graphics in the SNES would be emulated using native code for the host processor that replicated the effect of the Mode7 hardware.
There is no custom graphics hardware in the PC (at least in earlier models) - every pixel must be plotted individually by the emulation.
The EGA is capable of some primitive "graphics accceleration", but is also one of the most ridiculously over-complex graphics chipsets in existence. It is also organized in bitplanes.
I suppose the VGA also contains some graphics acceleration as shown by the numerous Amiga-style copper demos that appeared in the early 90's. My point is that the arcane nature of this hardware means that it hinders emulation rather than making it easier.
Most CGA modes and VGA mode 13h can thankfully, regardless of their internal organisation, be emulated quite nicely due to their linear organisation of pixels in memory.