Back to table of
contents
 Chapter 1Chapter 2 Chapter 3 On to
chapter 2 problems

Chapter 2 - Basic Protected Mode

Why use protected mode?

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.

Address mapping in Protected Mode

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.

OffsetContents
00-07NULL Descriptor (ignored)
08-0FFirst Descriptor
10-17Second Descriptor
18-1FThird 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:

Examples

Suppose the GDT and the LDT contain the following data:

GDTLDT
OffsetContents
00-07NULL Descriptor (ignored)
08-0Findex=1, base=00000000h
10-17index=2, base=00001000h
18-1Findex=3, base=00010000h
OffsetContents
00-07NULL Descriptor (ignored)
08-0Findex=1, base=10000000h
10-17index=2, base=01001000h
18-1Findex=3, base=00800000h

Here are the physical addresses that would result from some sample logical addresses.

Logical AddressPhysical Address
0000:0000Undefined (NULL Selector is used)
0008:000000000000h
000c:000010000000h
000c:000A1000000Ah
0018:300000013000h
0020:3000Undefined (exceeds the bounds of the GDT table)
0024:3000Undefined (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).

Back to Top


Back to table of
contents
 Chapter 1Chapter 2 Chapter 3 On to
chapter 2 problems
Hosted by www.Geocities.ws

1