13.07.2015 Views

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AMD64 Technology 24594 Rev. 3.10 February 2005temp_offset = selector AND 0xfff8 // upper 13 bits give an offset// in the descriptor tableIF (selector.TI = 0)// read 8 bytes from the gdt, split it into// (base,limit,attr) if the type bitstemp_desc = READ_MEM.q [gdt:temp_offset]// indicate a block of memory, or split// it into (segment,offset,attr)// if the type bits indicate// a gate, <strong>and</strong> save the result in temp_descELSEtemp_desc = READ_MEM.q [ldt:temp_offset]// read 8 bytes from the ldt, split it into// (base,limit,attr) if the type bits// indicate a block of memory, or split// it into (segment,offset,attr) if the type// bits indicate a gate, <strong>and</strong> save the result// in temp_descIF (selector.rpl or temp_desc.attr.dpl is illegal for the current mode/cpl)EXCEPTION [#GP(selector)]IF (temp_desc.attr.type is illegal for the current mode/chktype)EXCEPTION [#GP(selector)]IF (temp_desc.attr.p=0)EXCEPTION [#NP(selector)]RETURN (temp_desc)/////////////////////////////////////////////////////////////////////////////////// READ_IDT // Read an 8-byte descriptor from the IDT, return the descriptor/////////////////////////////////////////////////////////////////////////////////usage:temp_idt_desc = READ_IDT (vector)// "vector" is the interrupt vector numberdefinition:IF (LONG_MODE) // long-mode idt descriptors are 16 bytes longtemp_offset = vector*16ELSE // (LEGACY_MODE) legacy-protected-mode idt descriptors are 8 bytes longtemp_offset = vector*8temp_desc = READ_MEM.q [idt:temp_offset]// read 8 bytes from the idt, split it into// (segment,offset,attr), <strong>and</strong> save it in temp_descIF (temp_desc.attr.dpl is illegal for the current mode/cpl)56 Chapter 2: Instruction Overview

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!