386 Protected Mode Programmer's Reference Sheet - Compiled & Edited by Ed Pizzi All tables and most info From INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986 "!"=Not "|"=Or "X=!A/B"=Bit X Denotes A when set to 0 and B when set to 1 31 23 15 7 0 ÉData DescriptorÍÍØÍÑÍÑÍÑÍÑÍÍLimitÍÍØÍÑÍÍÍÍÍÑÍÑTypeÍÑÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º BASE 31..24 ³G³B³0³?³ 19...16 ³P³ DPL ³1³0³E³W³A³ BASE 23..16 º4 º SEGMENT BASE 15..0 ³ SEGMENT LIMIT 15..0 º0 ÌCode DescriptorÍÍØÍÑÍÑÍÑÍÑÍÍLimitÍÍØÍÑÍÍÍÍÍÑÍÑTypeÍÑÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ º BASE 31..24 ³G³D³0³?³ 19...16 ³P³ DPL ³1³1³C³R³A³ BASE 23..16 º4 ÌSystem DescriptorØÍØÍØÍØÍØÍÍLimitÍÍØÍØÍÍÍÍÍØÍÑTypeÍØÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ º BASE 31..24 ³G³X³0³?³ 19...16 ³P³ DPL ³0³?³?³?³?³ BASE 23..16 º4 ÌTSS SelectorÍÍÍÍÍØÍØÍØÍØÍØÍÍLimitÍÍØÍØÍÍÍÍÍØÍØTypeÍØÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ º BASE 31..24 ³G³0³0³?³ 19...16 ³P³ DPL ³0³1³0³B³1³ BASE 23..16 º 4 ÌTask GateÍÍÍÍÍÍÍÍØÍÏÍÏÍÏÍÏÍÍÍÍÍÍÍÍÍØÍØÍÍÍÍÍØÍØTypeÍØÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ º±±±±±±±±±±±±(NOT USED)±±±±±±±±±±±±±³P³ DPL ³0³0³1³0³1³±±±(NOT USED)±±±±º 4 º SELECTOR ³±±±±±±±±±±±±(NOT USED)±±±±±±±±±±±±±º 0 ÌCall GateÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÑÍÍÍÍÍÑÍÑTypeÍÑÍØÍÍÍÍÍÑÍÍDwordÍÍÍ͹ º OFFSET 31..16 ³P³ DPL ³0³1³1³0³0³0 0 0³ Count º 4 º SELECTOR ³ OFFSET 15..0 º 0 ÌInterrupt GateÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÑÍÍÍÑÍÑÍÑÍÑÍÑÍØÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍ͹ º OFFSET 31..16 ³ P ³DPL³0³1³1³1³0³0 0 0³(NOT USED) º4 ÌTrap GateÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍØÍÍÍØÍØÍØÍØÍØÍØÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍ͹ º OFFSET 31..16 ³ P ³DPL³0³1³1³1³1³0 0 0³(NOT USED) º4 ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÏÍÍÍÏÍÏÍÏÍÏÍÏÍØÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍͼ A - ACCESSED B - Task Busy on TSS E - EXPAND-DOWN (4 Stack Segs) ? - AVL (!Used & !Reserved) G - GRANULARITY (Limit * 4k) B - BIG (Only used w/ E. Upper lim -> 4G) P - SEGMENT PRESENT C - CONFORMING (Keep CPL/Change CPL->DPL) R - READABLE D - DEFAULT Operand Size (!USE16/USE32) W - WRITABLE DPL - DESCRIPTOR PRIVILEGE LEVEL S - Above Type Field 0=System Dword Count - # of Params to copy -> stack. For when CPL Changes. * When P=0, Only the P,DPL,S, and TYPE fields are used. All others available. TYPE - 1 Available 286 TSS 5 Task Gate B Busy 386 TSS 2 LDT 6 286 Interrupt Gate C 386 Call Gate 3 Busy 286 TSS 7 286 Trap Gate E 386 Interrupt Gate 4 Call Gate 9 Available 386 TSS F 386 Trap Gate 15 3 2 1 0 31 22 21 12 11 0 Segment ÉÍÍÍÍÍÍÍÍÍÍÑTÑÍÍÍ» Linear ÉÍÍÍÍÍËÍÍÍÍÍÍËÍÍÍÍÍÍÍÍ» Selector: º DT Index ³I³RPLº Address w/ º DIR º PAGE º OFFSET º ÈÍÍÍÍÍÍÍÍÍÍÏÍÏÍÍͼ Paging: ÈÍÍÍÍÍÊÍÍÍÍÍÍÊÍÍÍÍÍÍÍͼ TI - TABLE INDICATOR (!GDT/LDT) RPL - REQUESTOR'S PRIVILEGE LEVEL 31 Page Table Entry 12 11 0 ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÑÍÍÍÑÍÑÍÑÍÍÍÑUÑRÑÍ» º PAGE FRAME ADDRESS 31..12 ³ AVAIL ³0 0³D³A³0 0³S³W³Pº ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÏÍÍÍÏÍÏÍÏÍÍÍÏÍÏÍÏͼ R/W - Writable D - DIRTY Note: All Bits AVAIL if(!P) U/S - User/!Supervisor AVAIL - AVAILABLE FOR SYSTEMS PROGRAMMER USE TSS Format - (most word entries padded to 16 bits of 0) 00: Prev_TSS_Link dw ?,0 24: TASK_EFLAGS dd ? 48: TASK_ES dw ?,0 04: PL0_ESP dd ? 28: TASK_EAX dd ? 4C: TASK_CS dw ?,0 08: PL0_SS dw ?,0 2C: TASK_ECX dd ? 50: TASK_SS dw ?,0 0C: PL1_ESP dd ? 30: TASK_EDX dd ? 54: TASK_DS dw ?,0 10: PL1_SS dw ?,0 34: TASK_EBX dd ? 58: TASK_FS dw ?,0 14: PL2_ESP dd ? 38: TASK_ESP dd ? 5C: TASK_GS dw ?,0 18: PL2_SS dw ?,0 3C: TASK_EBP dd ? 60: TASK_LDT dw ?,0 1C: TASK_CR3 dd ? 40: TASK_ESI dd ? 64: TFLAG dw T & 01h 20: TASK_EIP dd ? 44: TASK_EDI dd ? 66: IO_MAP_PTR dw ? Prev_TSS_Link=If calls/ints go thru a Task Gate, new task stores old task TSS IO_MAP_PTR = 16-bit offset to IO Map in TSS seg. 8-bit Bitmap. 0=ok, 1=trap. TSS's shouldn't cross page boundaries if virtual memory is being used. Exceptions: 0 F Divide Err 6 F Invalid opcode 12 FE Stack exception 1 ?? Debug Exception 7 F No Coprocessor 13 FE General protection 2 NA NMI 8 AE Double fault 14 FE Page fault 3 T Breakpoint 9 A CP Seg Overrun(386) 15 (reserved) 4 T Overflow (INTO) 10 FE Invalid TSS 16 F Coprecessor error 5 F Bounds check 11 FE Seg not present 17-31 (reserved) F=Fault, T=Trap, A=Abort, NA=Not Applicable, ?=Depends E Appended to an Interrupt Type Letter Denotes Error Error Codes: Int 8, Double Fault - Error Code is Always Zero. Int 12, Stack Exception - Normally Zero, but can be of the standard type Int 14, Page Fault - 32-bits. 0=P, 1=R/W, 2=U/S 3=RSVD P - (!Non-Present Page Fault/Page-Level Protection Fault) R/W - Faulted on a (Read/!Write) U/S - Supervisor/!User Code caused fault RSVD - (!Caused by reserved bits set/Not caused by reserved bit violation.) Standard Error Code: Selector: Bits 15-3. TI: 2 IDT: 1 EXT: 0 IDT = If this is set, then the selector is an IDT vector #. Otherwise, the selector is a GDT/LDT selector, as indicated by TI (bit 2). EXT = If this is set, the error was not caused by the currently running program. (i.e. Interrupt handler) Eflags: 1 0 F E DC B A 9 8 7 6 5 4 3 2 1 0 Carry, Parity, Aux. Carry, Zero ³V³R³0³N³IO³O³D³I³T³S³Z³0³A³0³P³1³C³ Sign, Trap, Int Enable, Direction ³M³F³ ³T³PL³ IOPL, Nested Task, Resume, V86 CR0: 1F:Pg ... 4:Et 3:Ts 2:Em 1:Mp 0:Pe Protection Enabled, Monitor Coprocssr, Emulate FP Math, Task Switched, Extention Type (!287/387), Paging CR2: Page Fault Linear Address CR3: Bits 31 to 12=Page Directory Base Register Idtr: dw (Num_IDT_Entries * 8)-1 Gdtr: dw (Num_GDT_Entries * 8)-1 dd Linear_Address dd Linear_Address Note: Best viewed and printed from the MS-DOS command line editor.