background image

Vol. 3A 3-11

PROTECTED-MODE MEMORY MANAGEMENT

S (descriptor type) flag

Specifies whether the segment descriptor is for a system segment (S flag is clear) or a code or data 
segment (S flag is set).

DPL (descriptor privilege level) field

Specifies the privilege level of the segment. The privilege level can range from 0 to 3, with 0 being 
the most privileged level. The DPL is used to control access to the segment. See Section 5.5, “Priv-
ilege Levels”, 
for a description of the relationship of the DPL to the CPL of the executing code 
segment and the RPL of a segment selector.

P (segment-present) flag

Indicates whether the segment is present in memory (set) or not present (clear). If this flag is clear, 
the processor generates a segment-not-present exception (#NP) when a segment selector that 
points to the segment descriptor is loaded into a segment register. Memory management software 
can use this flag to control which segments are actually loaded into physical memory at a given 
time. It offers a control in addition to paging for managing virtual memory.
Figure 3-9 shows the format of a segment descriptor when the segment-present flag is clear. When 
this flag is clear, the operating system or executive is free to use the locations marked “Available” to 
store its own data, such as information regarding the whereabouts of the missing segment.

D/B (default operation size/default stack pointer size and/or upper bound) flag

Performs different functions depending on whether the segment descriptor is an executable code 
segment, an expand-down data segment, or a stack segment. (This flag should always be set to 1 
for 32-bit code and data segments and to 0 for 16-bit code and data segments.)

Executable code segment. The flag is called the D flag and it indicates the default length for 
effective addresses and operands referenced by instructions in the segment. If the flag is set, 
32-bit addresses and 32-bit or 8-bit operands are assumed; if it is clear, 16-bit addresses and 
16-bit or 8-bit operands are assumed. 
The instruction prefix 66H can be used to select an operand size other than the default, and the 
prefix 67H can be used select an address size other than the default.

Stack segment (data segment pointed to by the SS register). The flag is called the B (big) 
flag and it specifies the size of the stack pointer used for implicit stack operations (such as 
pushes, pops, and calls). If the flag is set, a 32-bit stack pointer is used, which is stored in the 
32-bit ESP register; if the flag is clear, a 16-bit stack pointer is used, which is stored in the 16-
bit SP register. If the stack segment is set up to be an expand-down data segment (described in 
the next paragraph), the B flag also specifies the upper bound of the stack segment.

Expand-down data segment. The flag is called the B flag and it specifies the upper bound of 
the segment. If the flag is set, the upper bound is FFFFFFFFH (4 GBytes); if the flag is clear, the 
upper bound is FFFFH (64 KBytes).

G (granularity) flag

Determines the scaling of the segment limit field. When the granularity flag is clear, the segment 
limit is interpreted in byte units; when flag is set, the segment limit is interpreted in 4-KByte units. 
(This flag does not affect the granularity of the base address; it is always byte granular.) When the 
granularity flag is set, the twelve least significant bits of an offset are not tested when checking the 

Figure 3-9.  Segment Descriptor When Segment-Present Flag Is Clear

31

16 15

13

14

12 11

8 7

0

0

Available

D
P

L

Type

S

4

31

0

Available

0

Available