Descriptors

A selector specifies a descriptor, which describes a memory segment. The attributes described include the base or starting address of the memory segment, the size of the segment and what accesses are allowed.

Protected mode addressing in a 386 or later begins with Descriptor Tables which are described by hardware registers. There are three Descriptor Tables, each of which is discussed below after supplying the format of individual descriptors. The tables contain the descriptors and the descriptors are selected by an interrupt number or by the content of a selector register.

An application descriptor is required for all accesses to instructions and to data. For most segments, the limit is the largest valid offset. If the offset is larger than the limit, a general protection exception occurs. The exception to this rule occurs for data segments which are 'expand down'. In this case, the offset must be greater than the content of the limit field. The system stack ( ring 0 ) is an example of an Expand Down segment.

To find the linear address of the data element, the processor adds the offset ( obtained from the instruction ) to the base address of the segment. That's the end of the discussion for offsets!

There are three distinct kinds of data recognized by the processor:

The primary distinction between stack and data is that data segments begin at offset zero and expand upward ( to the limit ) while stack segments begin at the highest offset and expand downward ( to just greater than the limit ). Many language implementations use data segments for their stack, which is perfectly acceptable, but it makes it impossible to 'grow' the stack.

The descriptor for a memory reference is found by using the appropriate selector as the index to a table or, if you ignore the 3 lower bits, as an offset to the table, since descriptors are 8 bytes long.


[Back: Protected Mode]
[Next: Selector Format]