Many drawbacks of real mode, most notably the fact that real mode programs can only access 1 MB of the computer's physical memory, motivated
Intel to create a totally differant environment known as protected mode. Protected mode was introduced with the 80286
processor around 1990 (before the advent of the 80286 processor, computers ran exclusively in real mode). Although the protected mode
architecture underwent significant changes with the advent of the 80386 processor, it has changed very little since then. Even the computers of today
are essentially the same as the 386 computers of ten years ago except that today's computers are much faster and contain more memory.
Consequently, the basic protected mode environment is the same as it was on 386 computers.
Most of what we will cover in this chapter has, in fact, remained the same since the 286 computers. Consequently, the best place to look for
detailed documentation on the protected mode of today is to consult the documentation on the 80386 processor of a decade ago.
Intel's 80386 reference manual, which has been converted to HTML by a number of independent
people and organizations, describes protected mode in gross detail.
In protected mode, logical address are not converted to physical addresses by the shift-and-add method, as in real mode. Instead, segments are used as indecies into one of two special tables, called the Global Descriptor Table (GDT) and the Local Descriptor Table (LDT). The GDT and LDT are stored in memory with the following structure.
| Offset | Contents |
|---|---|
| 00-07 | NULL Descriptor (ignored) |
| 08-0F | First Descriptor |
| 10-17 | Second Descriptor |
| 18-1F | Third Descriptor |
| . . . | . . . |
Each table can contain any arbitrary number of entries and each entry, or Descriptor is eight bytes long. Each descriptor describes several attributes about a segment in memory, such as the segment base, access rights, etc. The physical address and the size of the GDT and LDT are stored in special registers called the GDTR and the LDTR. The GDTR and the LDTR can only be accessed by special instructions (standard instructions like "mov" cannot access them).
When the processor converts a logical address into a physical address, it uses a step-by-step process which is outlined as follows:
Suppose the GDT and the LDT contain the following data:
| GDT | LDT | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Here are the physical addresses that would result from some sample logical addresses.
| Logical Address | Physical Address |
|---|---|
| 0000:0000 | Undefined (NULL Selector is used) |
| 0008:0000 | 00000000h |
| 000c:0000 | 10000000h |
| 000c:000A | 1000000Ah |
| 0018:3000 | 00013000h |
| 0020:3000 | Undefined (exceeds the bounds of the GDT table) |
| 0024:3000 | Undefined (exceeds the bounds of the LDT table) |
There are many important points to make note of concerning the resolution of logical addresses under protected mode:
So far, we have only scratched the surface of protected mode, but we have covered enough to try some problems. It should be noted that although we have covered how protected mode works, we have not discussed how to actually switch to protected mode. For now, we will assume that all DOS programs will run in real mode and all windows program will run in protected mode (the Windows operating system switches the computer from real mode to protected mode when it loads).