#[repr(C)]pub struct X86Operand {
pub operand: OperandType,
pub components: [OperandType; 2],
pub scale: u8,
pub size: u16,
pub immediate: isize,
pub segment: SegmentRegister,
}Expand description
An operand for an Instruction.
The type of operand is given by the operand member. If the type is
OperandType::NONE, none of the other members are defined.
If the operand type is not OperandType::NONE, then the size field
is valid.
If the type is OperandType::IMM, then the operand is a constant
integer contained in the immediate member.
If the type is OperandType::MEM, then the operand is a memory reference
and the other members are used as defined.
The address of a memory reference is effectively the following formula,
where references to the component array should look up the current value
should look up the current value of the register or substitute zero if
the value is OperandType::NONE:
address = components[0] + components[1] * scale + immediateTODO: Perhaps this should be an enumeration with separate values for invalid, immediate value, a memory reference or a register.
Fields§
§operand: OperandTypeThe type of the operand, a register or one of a set of special values.
components: [OperandType; 2]The address components of a memory operand.
scale: u8If this is a memory operand, then this value is used to scale the second component.
size: u16The size of the operand in bytes. For register operands, this is the size of the register. For memory operands, this is the size of the memory access.
immediate: isizeThe value of a constant integer when the operand is the IMM
type. When the operand is a memory reference, this contains
a constant offset for the memory reference.
segment: SegmentRegisterThe segment register that will be used for a memory access. This
will always contain a segment register, as SegmentRegister::DEFAULT
is resolved to the default register.