Skip to content
Hirochika Asai edited this page May 8, 2015 · 4 revisions

x86 instructions

mov

GDT

31                                                             0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Base address  |G|D|X|A| Limit |P|DPL|S| Type  | Base address  | +8
| 24:31         | |B| | | 16:19 | |   | |       | 16:23         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Base address                  | Segment limit                 | +0
| 0:15                          | 0:15                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63                                                            32

G: Granularity bit. If 0 the limit is in 1 B blocks (byte granularity),
   if 1 the limit is in 4 KiB blocks (page granularity).
DB: Size bit. If 0 the selector defines 16 bit protected mode. If 1 it
    defines 32 bit protected mode. You can have both 16 bit and 32 bit
    selectors at once.
X: L bit in x86-64

P: Present bit. This must be 1 for all valid selectors.
DPL: Privilege, 2 bits. Contains the ring level, 0 = highest (kernel),
     3 = lowest (user applications).
A: 0
S: 1

Type: Ex DC RW Ac
Ex: Executable bit. If 1 code in this segment can be executed, ie. a
    code selector. If 0 it is a data selector.
DC: Direction bit/Conforming bit.
RW: Readable bit/Writable bit.
Ac: Accessed bit. Just set to 0. The CPU sets this to 1 when the segment
    is accessed.

"In IA-32e mode, bit 21 of the second doubleword of the segment descriptor indicates whether a code segment contains native 64-bit code. A value of 1 indicates instructions in this code segment are executed in 64-bit mode. A value of 0 indicates the instructions in this code segment are executed in compatibility mode."P. 3-12 Vol. 3A http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf

PAE: Vol. 3A 2-17

64bit IDT

System-Segment Descriptor

31                                                              0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved, IGN                       |0|0|0|0|0| Reserved, IGN | +12
|                                     | | | | | |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Base address                                                  |  +8
| 63:32                                                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Base address  |G|   |A| Limit |P|DPL|0| Type  | Base address  |  +4
| 31:24         | |   |V| 19:16 | |   | |       | 23:16         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Base address                  | Segment limit                 |  +0
| 15:0                          | 15:0                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Call-Gate Descriptor

31                                                              0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved, IGN                       |0|0|0|0|0| Reserved, IGN | +12
|                                     | | | | | |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target offset                                                 |  +8
| 63:32                                                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target offset                 |P|DPL|0| Type  | Reserved      |  +4
| 31:16                         | |   | |       |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target selector               | Target offset                 |  +0
|                               | 15:0                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Flags

31                                                             0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   |I|V|V|A|V|R|0|N|IOP|O|D|I|T|S|Z|0|A|0|P|1|C|
|                   |D|I|I|C|M|F| |T|L  |F|F|F|F|F|F| |F| |F| |F|
|                   | |P|F| | | | | |   | | | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Clone this wiki locally