Protected Mode

When running on a 286 or 386 processor with at least 1 MB of memory, Windows runs in 286-compatible protected mode. In this mode, Windows can use the 640 KB of conventional memory and memory allocated from extended memory using the XMS (Extended Memory) driver included in the retail release of Windows 3.

In this mode, segment addresses do not correspond to physical memory. Instead, the segment addresses are called ”selectors,“ which reference physical memory through a descriptor table. Protected mode is called ”protected“ because the hardware of the 286 and 386 microprocessors ensures that programs do not load invalid segment addresses or attempt to access a segment beyond the segment's size. The processor generates a protection exception that the operating system (or in this case, Windows) traps. Windows responds by terminating the offending application.

For this reason, several rules are associated with protected mode:

Do not perform segment arithmetic.

Do not load far pointers with invalid addresses.

Do not attempt to address a segment beyond its allocated length.

Do not store data in code segments.

If you follow the memory allocation guidelines I discuss below, you should have no problem running your program in protected mode. You should do your development work in protected mode to more easily catch bugs; if you can't, you should definitely test your code in protected mode, because it can reveal bugs in your code that are not so evident when running in real mode.