Real mode
This article needs additional citations for verification. (November 2012) |
Part of a series on |
Microprocessor modes for the x86 architecture |
---|
|
First supported platform shown in parentheses |
Real mode, also called real address mode, is an operating mode of all x86-compatible CPUs. The mode gets its name from the fact that addresses in real mode always correspond to real locations in memory. Real mode is characterized by a 20-bit segmented memory address space (giving 1 MB of addressable memory) and unlimited direct software access to all addressable memory, I/O addresses and peripheral hardware. Real mode provides no support for memory protection, multitasking, or code privilege levels.
Before the introduction of protected mode with the release of the 80286, real mode was the only available mode for x86 CPUs;[1] and for backward compatibility, all x86 CPUs start in real mode when reset, though it is possible to emulate real mode on other systems when starting in other modes.
History
The 80286 architecture introduced protected mode, allowing for (among other things) hardware-level memory protection. Using these new features, however, required a new operating system that was specifically designed for protected mode. Since a primary design specification of x86 microprocessors is that they are fully backward compatible with software written for all x86 chips before them, the 286 chip was made to start in 'real mode' – that is, in a mode which turned off the new memory protection features, so that it could run operating systems written for the 8086 and the 8088. As of 2018, current x86 CPUs (including x86-64 CPUs) are able to boot real mode operating systems and can run software written for almost any previous x86 chip without emulation or virtualization.
The PC
Addressing capacity
The 8086, 8088, and 80186 have a 20-bit address bus, but the unusual segmented addressing scheme Intel chose for these processors actually produces effective addresses which can have 21 significant bits. This scheme shifts a 16-bit segment number left four bits (making a 20-bit number with four least-significant zeros) before adding to it a 16-bit address offset; the maximum sum occurs when both the segment and offset are 0xFFFF, yielding 0xFFFF0 + 0xFFFF = 0x10FFEF. On the 8086, 8088, and 80186, the result of an effective address that overflows 20 bits is that the address "wraps around" to the zero end of the address range, i.e. it is taken modulo 2^20 (2^20 = 1048576 = 0x100000). However, the 80286 has 24 address bits and computes effective addresses to 24 bits even in real mode. Therefore, for the segment 0xFFFF and offset greater than 0x000F, the 80286 would actually make an access into the beginning of the second megabyte of memory, whereas the 80186 and earlier would access an address equal to [offset]-0x10, which is at the beginning of the first megabyte. (Note that on the 80186 and earlier, the first kilobyte of the address space, starting at address 0, is the permanent, immovable location of the interrupt vector table.) So, the actual amount of memory addressable by the 80286 and later x86 CPUs in real mode is 1 MB + 64 KB – 16 B = 1,114,096 B.
A20 line
Some programs predating the 80286 were designed to take advantage of the wrap-around (modulo) memory addressing behavior, so the 80286 presented a problem for backward compatibility. Forcing the 21st address line (the actual logic signal wire coming out of the chip) to a logic low, representing a zero, results in a modulo-2^20 effect to match the earlier processors' address arithmetic, but the 80286 has no internal capability to perform this function. When IBM used the 80286 in their
Switching to real mode
Intel introduced protected mode into the x86 family with the intention that operating systems which used it would run entirely in the new mode and that all programs running under a protected mode operating system would run in protected mode as well. Because of the substantial differences between real mode and even the rather limited 286 protected mode, programs written for real mode cannot run in protected mode without being rewritten. Therefore, with a wide base of existing real mode applications which users depended on, abandoning real mode posed problems for the industry, and programmers sought a way to switch between the modes at will. However, Intel, consistent with their intentions for the processor's usage, provided an easy way to switch into protected mode on the 80286 but no easy way to switch back to real mode. Before the 386 the only way to switch from protected mode back to real mode was to reset the processor; after a reset it always starts up in real mode to be compatible with earlier x86 CPUs back to the 8086. Resetting the processor does not clear the system's RAM, so this, while awkward and inefficient, is actually feasible. From protected mode, the processor's state is saved in memory, then the processor is reset, restarts in real mode, and executes some real mode code to restore the saved state from memory. It can then run other real mode code until the program is ready to switch back to protected mode. The switch to real mode is costly in terms of time, but this technique allows protected mode programs to use services such as BIOS, which runs entirely in real mode (having been designed originally for the
Decline
The changing towards the NT kernel resulted in the operating system not needing DOS to boot the computer as well as being unable to use it. The need to restart the computer in real mode MS-DOS declined after
See also
- Unreal mode
- Protected Mode
- Boot loader
- 80386
- IA-32
- x86 assembly language
- Conventional memory
References
- ^ "x86 CPU Reference (Archived at 8 September 2018 - Instead of 'A Brief x86 History' : alasir.com/x86ref : 403 Forbidden on 24 March 2023)". Archived from the original on September 8, 2018. Retrieved March 24, 2023.
{{cite web}}
: CS1 maint: bot: original URL status unknown (link) - ^ "Booting · Linux Inside". 0xax.gitbooks.io. Retrieved November 10, 2020.
- ^ "A20 Line - OSDev Wiki". wiki.osdev.org. Retrieved September 10, 2020.
External links
- Chourdakis, Michael (May 21, 2015). "The Real, Protected, Long mode assembly tutorial for PCs". Code Project.