Unreal mode

From Wikipedia, the free encyclopedia

For efficiency reasons, the 80286 and later x86 processors use the base address stored in their internal "descriptor" cache whenever accessing memory, regardless if they are operating in real or protected mode. The "selector", i.e. the 16-bit "segment number" visible to the programmer is used once, while reloading a segment register, to update the various fields of the respective "descriptor", and then is simply disregarded.

Unlike real mode, protected mode and long mode, unreal mode is not a separate addressing mode the x86 processors or x86-64 processors can operate in. Rather, unreal mode (also big real mode, huge real mode, flat real mode) is a variant of real mode (PE=0), in which one or more data segment registers have been loaded with 32-bit addresses and limits.

To enable unreal mode, the program has to enter protected mode, locate a flat descriptor in the GDT or LDT or create such, load some of the segment registers with the respective protected mode "selector" , then cancel back protected mode. When jumping back to RM, the processor will continue using the cached descriptors as established in PM, at least until the segment registers are reloaded - thus allowing access to 4 GiB of "extended" memory from inside real mode.

The Intel 80386 Programmers Reference Manual [1] (section 14.5, page 210) from 1986 does not contain any information about what happens if the programmer does not follow the guidelines when returning to real mode. Thus unreal mode could be described as originally being a side-effect or a bug. However, code that makes use of unreal mode can run without changes on modern processors as well, provided that the the code is not executed in virtual 8086-mode.

Some DOS extenders use this feature to address the high memory. It was used by many computer games in the 1990 to 1995 time frame, since it allowed programmers to use more memory than in real mode, which is restricted to 1 MiB (640 KiB usable), but still access the DOS operating system, which doesn't work in protected mode. After the introduction of Windows 95 unreal mode quickly fell out of favour as programs using it cannot be run in the DOS prompt of Microsoft Windows; they require a "Restart in MS-DOS mode" in Windows 95 and 98, and cannot be run at all on Windows NT, 2000, Me, and XP systems. For those operating systems, an emulator such as DOSBox is the only way to run programs designed for unreal mode. Unreal mode is still extensively used by BIOS code.

[edit] See also

In other languages