Revisiting the DOS Memory Models
Segmented memory on early x86 and DOS systems forced programmers to juggle overlapping segments, 64 KB limits, and multiple memory models, leading to elaborate workarounds like EMS/XMS, overlays, and specialized compilers. Commenters weigh whether this was an ugly hack or a clever response to severe hardware and cost constraints, contrasting Intel’s design with contemporaries like the 68000 and exploring how similar ideas resurface today in 64‑bit pointer compression, x32, and WebAssembly. The thread also highlights lesser-known tools (QEMM, 386MAX, Zortech handle pointers) and reflects on how these historical choices still shape modern ABI, OS, and compiler design.
Modern compressed pointers and x32/x64 conventions
- Java’s pointer compression is discussed as analogous to old memory models: 32-bit references shifted to form 64-bit addresses.
- Commenters emphasize it’s not “wasted” alignment: object headers and atomicity already enforce alignment, and compressed oops are a major win up to ~32 GB heaps.
- x32 ABI (32-bit pointers on 64-bit kernels) is mentioned as an attempt at similar savings, but it saw little adoption and is now effectively deprecated.
- Some note you can still manually keep all code/data under 4 GB in 64‑bit mode and use 32‑bit pointers in non‑C environments.
8086 segmentation, address space, and elegance debates
- Several argue 8086’s overlapping segments and multiple pointer types are inelegant; others respond that it was a pragmatic tradeoff given cost, pin limits, and memory sizes of the era.
- Alternatives are proposed (non‑overlapping segments, combining two 16‑bit registers as a 32‑bit pointer, different selector layout on 286), but counterarguments focus on relocatability, wasted address space, and historical constraints.
- Comparisons are drawn with 68000 and PDP‑11; 8086 seen as cheaper and easier to reuse CP/M software.
- There’s discussion of RIP-relative addressing on x86‑64/RISC‑V and the need for indirection (GOT/PLT, large code models), with no fully “elegant” solution agreed upon.
DOS memory models, EMS/XMS, overlays, and tools
- Thread expands beyond the article to EMS/XMS, DPMI, unreal mode, DJGPP, and overlays; multiple people recall using different memory managers (QEMM, 386MAX, JEMM386, etc.).
- Overlays are highlighted as a key technique for large DOS apps, with examples from games and Turbo Pascal/Borland C support.
- Some note compact/large models were theoretically useful but often avoided in practice due to far‑pointer cost; many preferred small/medium plus manual
faruse.
Protected mode, segmentation today, and niche models
- On 32‑bit and 64‑bit Windows, segment registers mostly point to flat zero-based spaces, with FS/GS reserved for thread structures and TLS.
- Discussion of 286/386 selectors, descriptor tables, and a “missed opportunity” to lay out selector bits to yield a linear address space; reasons for Intel’s choice are debated and remain unclear.
- Zortech’s handle pointers and VCM are cited as compiler-level virtual memory schemes, compared to what could be done in WebAssembly with multi-memory and paging-like tricks.
Nostalgia and developer experience
- Many recall the complexity of CONFIG.SYS/AUTOEXEC.BAT juggling, TSRs, overlays, and tight memory budgets as both painful and fun.
- DJGPP and 32‑bit DOS extenders are remembered as a relief, simplifying pointers and enabling larger heaps and graphics buffers.