Real mode is always segmented, and everything (CPU, operating system, programs, even peripherals on the CPU bus) has access to all the system’s address space up to just over 1 MiB (1 MiB strictly before the 286). You can write programs without paying attention to segments, and you’ll be limited to 64 KiB per segment register, but nothing enforces that; this is the memory model used by default for COM programs under DOS (with the additional constraint that all segment registers point to the same segment). There’s no practical distinction between “real mode flat model” and “real mode segmented model”.
In “real mode flat model” as described in the document you’re referring to, all the above remains true: there is no limitation imposed by the architecture. Programs are written voluntarily without ever touching the segment registers, which means that they only have direct access to 64 KiB per segment register; as mentioned above, this is the model used by default in COM programs under DOS, and facilitates porting programs from 8-bit platforms. Programs always end up accessing other segments, indirectly, through operating system or BIOS services; for example when reading or writing files, or reading from the keyboard buffer, or writing to the screen. And nothing prevents programs from changing their segment registers and accessing other segments directly. When the operating system (DOS) starts a program, it gives it its own segments, separate from the operating system’s memory areas (and in systems with small amounts of memory, the program might not really have access to the full 64 KiB).
Basically, the architecture doesn’t impose any limitations on the use of segments (that’s why protected mode was added, later).
The 8086, 8088,/8088 and 80186/80188 CPUs only run in real, segmented mode. (Even if your program ignores segments, the CPU doesn’t.)
The 80286 introduced 16-bit protected mode with a 24-bit address space. This protected mode is segmented; segment registers now point to segment descriptions, which specify the location of each segment in memory, and their length, access permissions etc. Segments are necessary to take advantage of the protection provided by protected mode.
The 80386 introduced 32-bit protected mode, which stillalso relies on segments (butsegments; however the availability of 32-bit addresses means that segments can provide directbe configured to give access to all 4 GiB GiB of address space, so programs can again be written without taking much account of segments (and this is what most people refer to as “flat mode”). The 386 also introduced paging, which allows memory protection to be implemented without relying on segments (once the segments are configured appropriately).
Newer CPUs support all the modes available in older CPUs.
Up to Windows 3.0 included, Windows could run in real mode, using segments. Windows/386, Windows 3.0 and later could also run in protected mode, on 286s (Windows 3.0) and 386s. Windows NT, Windows 95 and all subsequent versions of Windows run in 32-bit protected mode. MS-DOS always ran in real mode; there were several DOS extenders which allowed programs to run in protected mode on top of DOS, such as DOS/4GW.
16- and 32-bit x86 protected mode still relies heavily on segments; like real mode, protected mode is always segmented. It’s possible to give the appearance of a flat mode in 32-bit protected mode, with segments set to cover all the address space, and that’s how most 32-bit operating systems work; instead of using segments to separate programs from each other, they rely on paging.
Mod Moved Comments To Chat
Stephen Kitt
- 131k
- 19
- 543
- 502
Update based on the latest comments with the sources for the notion of real mode flat model.
Stephen Kitt
- 131k
- 19
- 543
- 502