THE NULL DESCRIPTOR


The first entry in the Global Descriptor Table (GDT) is called the null descriptor. The NULL descriptor is unique to the GDT, as it has a TI=0, and INDEX=0. Most printed documentation states that this descriptor table entry must be 0. Even Intel is somewhat ambiguous on this subject, never saying what it CAN'T be used for. Intel does state that the 0'th descriptor table entry is never referenced by the processor.

Since the processor never references the NULL descriptor, then this implies that the data stored in its place can be used for any purpose. My favorite use for the NULL descriptor is to use it as a pointer to the GDT itself! The NULL descriptor is ideally suited for this purpose. The LGDT instruction needs a six-byte pointer to the GDT, and the NULL descriptor has 8 bytes that aren't accessed by the CPU -- making it an ideal candidate for this purpose. (For you sceptics, I've been doing this for about 10 years.)

The normal protocol used in addressing the GDT is as follows:

     GDT_PTR   DW   GDT_LENGTH-1
               DD   PHYSICAL_GDT_ADDRESS

Then in the code segment:

     LGDT      GDT_PTR

Using the NULL descriptor as a pointer to the GDT, simplifies the data segment, and conceptualization of the GDT as follows:

                  +-----------------+
                  |                 |
                  V                 |  Offset
     +------------------------+     |
GDT  |   Pointer to the GDT   |  ---+  00h
     +------------------------+
     |                        |        08h
     +------------------------+
     |    ...  ...  ...  ...  |

Then in the code segment:

     LGDT      GDT

The GDT_PTR variable is no longer needed, as the NULL descriptor is used in its place. Using the NULL descriptor in this manner offers a 'cleaner' approach to addressing the GDT.This technique can be viewed in any of my assembler source code files that use protected mode -- INT09.ASM for example.

View source code:
ftp://ftp.x86.org/pub/x86/source/int09/int09.asm
ftp://ftp.x86.org/pub/x86/source/386load/macros.386

Download entire source code archive:
ftp://ftp.x86.org/pub/x86/dloads/INT09.ZIP


Back to Productivity Enhancements

Return to theIntel
Secrets home page



© 1991-1999 Intel Secrets Web Site and Robert Collins. PGP key available.

Make no mistake!
This web site is proud to provide superior information and service without any affiliation to Intel Corporation.

"Intel Secrets", "What Intel doesn't want you to know" and anything with a dropped e in it, are phrases that infuriate Intel Corporation.

Pentium, Intel, and the letter "I" are registered trademarks of Intel Corporation. 386, 486, 586, P6, all other letters, and all other numbers are not!
All other trademarks are those of their respective companies. See Trademarks and Disclaimers for more info.

Robert Collins works somewhere in the United States of America. Robert may be reached via email or telephone.