Intel Manual Vol 3A, Section 3.4.2 wrote:
Index(Bits 3 through 15) — Selects one of 8192 descriptors in the GDT or LDT. The processor multiplies the index value by 8 (the number of bytes in a segment descriptor) and adds the result to the base address of the GDT or LDT (from the GDTR or LDTR register, respectively).
Looking at the selector number 0x8, we must remember that this value will be placed in the format of a segment selector of the format:
Code: Select all
Bits 0..1: Requested Privilege Level (RPL)
Bit 2: Descriptor table type
Bits 3...15: Index number into table
In our
jmp 0x8:codesel instruction, we are going to store 0x8 in the above format like this..
Code: Select all
1000 =
00000000000001 0 00
-- Index -- -- descriptor table type and rpl--
Remember the cpu multiplies the index by 8. This is because the lower 3 bits are for processor use.
So, lets do that...
Code: Select all
00000000000001b * 8 decimal = 8, or 1000 binary.
...So, now we have this in our selector:
Code: Select all
00000000001000 0 00
-- Index -- -- descriptor table type and rpl--
Notice the index is still 8? It uses this index value to offset into the descriptor specified by the table type (Which depends on the current state of the cpu)
You will find the above true for any selector from 0 through 8192, as 8192 is max allows selectors in a table.
I hope this answers your question.