Breaking Through The 1 MB Barrier In DOS With Unreal Mode And More [Hackaday]

View Article on Hackaday

The memory map of the original 8086 computer with its base and extended memory made the original PC rather straightforward, but also posed countless issues for DOS-based applications as they tried to make use of memory beyond the legacy 1 MB address space. The initial ways to deal with this like EMS, XMS and UMB were rather cumbersome and often impractical, but with the arrival of the 80286 and 80386 processors more options opened up, including protected mode. More interestingly, this led to unreal mode, DOS extenders and the somewhat more obscure LOADALL instruction, as covered by [Julio Merino] in a new article.

This article builds on the first one which covered the older methods and covered the basics of protected mode. Where protected mode is convenient compared to real mode is that with the former the memory accesses go via the MMU and thus allows for access to 16 MB on the 80286 and 4 GB on the 80386. The segment descriptors and resolving of these that make this possible can be (ab)used on the 80286 and up by realizing that these segment descriptors are also used in real mode. Unreal mode is thus about switching to protected mode, loading arbitrary segment descriptors and switching back to real mode. As this is outside the original processor spec, it is commonly called ‘unreal mode’.

Representation of the structure of a DOS-extended application and how it relates to a DOS extender, DOS drivers, and raw hardware access. (Credit: Julio Merino)
Representation of the structure of a DOS-extended application and how it relates to a DOS extender, DOS drivers, and raw hardware access. (Credit: Julio Merino)

In the article [Julio] goes into a lot of detail on this, as well as an assembly implementation of unreal mode, before diving into the fascinating topic of DOS extenders. These are basically the reason why gaming under DOS on the level of Doom and Duke Nukem 3D was a thing at all, with the DOS/4G 32-bit DOS extender (in the form of the Watcom C-compiler DOS/4GW version mostly) forming the backbone. By switching between real and protected mode, applications got the best of both worlds.

The way that this integrated in Windows also gets its own summary, in the form of the DOS Protected Mode Interface (DPMI), which gets around issues with nesting protected modes (until virtualization). Despite the improvements over EMS, XMS and kin, this era of DOS applications came with enough pitfalls (and workarounds) of its own.