Expand description
x86 and x86-64 instruction decoder.
The tables in generated/ are produced by cargo xtask codegen from Intel
XED’s datafiles (third_party/xed); the decoding logic around them is
written by hand. The crate is no_std; its only dependency is
binbun_isa, whose traits it implements (X86) and whose control-flow
vocabulary Instruction::flow returns.
Structs§
- Attributes
- A set of
Attributes. - Cpuid
Field - Bits
low..=highofregisterfrom CPUID leafleaf, subleafsubleaf, which must equalvalue. - Decoder
- Decodes the instructions of a buffer one after another (a linear sweep).
- Flag
Effect - One flag and what happens to it.
- FlagSet
- A set of flags, laid out as in
RFLAGS(the x87 condition codes in bits 28 to 31, whichRFLAGSdoes not use). - Flags
- An instruction’s effect on the flags.
- Instruction
- A decoded instruction.
- Intel
- An instruction in Intel syntax, at an address (for branch targets).
- Memory
- A memory operand (or an address computation,
LEA). - Operand
- An operand of a decoded instruction.
- Unknown
Name - Error of parsing a name that names nothing.
- X86
- The x86 instruction set (16, 32 and 64-bit), for analyses written
against
binbun_isa::Architecture.
Enums§
- Action
- How an instruction accesses an operand.
- Attribute
- A property of instructions (XED’s attributes).
- Category
- A broad kind of instruction (XED’s categories).
- Condition
- The condition an instruction tests.
- Cpuid
Register - A CPUID output register.
- Decode
Error - Why bytes do not decode to an instruction. The variants follow XED’s
xed_error_enum_t. - Element
Base - The kind of an operand’s elements.
- Element
Type - An operand’s element type (XED’s xtype).
- Encoding
- An instruction’s prefix family.
- Extension
- The ISA extension an instruction belongs to.
- Flag
- A flag of
RFLAGS, or an x87 condition code. - Flag
Action - What an instruction does to a flag.
- Form
- An instruction form: a mnemonic with one kind of operands, as XED
names it (its iform), e.g.
MOV_GPRv_MEMv. - IsaSet
- The CPUID-detectable feature set an instruction needs (XED’s ISA sets).
- Mnemonic
- An instruction’s operation, as XED classifies it (its iclass).
- Mode
- The processor mode instructions are decoded for.
- Operand
Name - An operand’s name: which decoder field holds its value (XED’s
xed_operand_enum_t). - Operand
Width - An operand width code (XED’s
xed_operand_width_enum_t): the operand’s size, often depending on the effective operand size. - Register
- A register, including XED’s pseudo registers (stack pointer updates, x87 status words, MSRs) that instructions use implicitly.
- Register
Class - The kind of a
Register. - Value
- The decoded value of an operand.
- Visibility
- Whether an operand appears in assembly.
Constants§
- MAX_
LENGTH - The longest x86 instruction.
- MAX_
OPERANDS - Most operands an instruction has: the longest
Instruction::operands.
Functions§
- decode
- Decodes the instruction at the start of
bytes. - decode_
flow - What control-flow recovery needs of the instruction at the start of
bytes, which is ataddress:FlowStep::ofthedecoded instruction, without decoding what flow does not depend on where the 64-bit fast path applies. - decode_
length - Decodes the length of the instruction at the start of
bytes. - relative_
target - The address
displacementfrom the end ofinstructionataddress, wrapped as the instruction pointer wraps (XED’sprint_rel_sym): to 16 bits with a 16-bit operand size (exceptXBEGIN), else to the mode’s width.