Struct VexInstruction
pub struct VexInstruction { /* private fields */ }
Expand description
Constructs a VEX-encoded instruction using a builder pattern. This approach makes it visually
easier to transform something the manual’s syntax, VEX.128.66.0F 73 /7 ib
to code:
VexInstruction::new().length(...).prefix(...).map(...).w(true).opcode(0x1F).reg(...).rm(...)
.
Implementations§
§impl VexInstruction
impl VexInstruction
pub fn new() -> VexInstruction
pub fn new() -> VexInstruction
Construct a default VEX instruction.
pub fn length(self, length: VexVectorLength) -> VexInstruction
pub fn length(self, length: VexVectorLength) -> VexInstruction
Set the length of the instruction.
pub fn prefix(self, prefix: LegacyPrefixes) -> VexInstruction
pub fn prefix(self, prefix: LegacyPrefixes) -> VexInstruction
Set the legacy prefix byte of the instruction: None | 66 | F2 | F3. VEX instructions pack these into the prefix, not as separate bytes.
pub fn map(self, map: OpcodeMap) -> VexInstruction
pub fn map(self, map: OpcodeMap) -> VexInstruction
Set the opcode map byte of the instruction: None | 0F | 0F38 | 0F3A. VEX instructions pack these into the prefix, not as separate bytes.
pub fn w(self, w: bool) -> VexInstruction
pub fn w(self, w: bool) -> VexInstruction
Set the W bit, denoted by .W1
or .W0
in the instruction string.
Typically used to indicate an instruction using 64 bits of an operand (e.g.
64 bit lanes). EVEX packs this bit in the EVEX prefix; previous encodings used the REX
prefix.
pub fn opcode(self, opcode: u8) -> VexInstruction
pub fn opcode(self, opcode: u8) -> VexInstruction
Set the instruction opcode byte.
pub fn reg(self, reg: impl Into<Register>) -> VexInstruction
pub fn reg(self, reg: impl Into<Register>) -> VexInstruction
Set the register to use for the reg
bits; many instructions use this as the write operand.
pub fn opcode_ext(self, n: u8) -> VexInstruction
pub fn opcode_ext(self, n: u8) -> VexInstruction
Some instructions use the ModRM.reg field as an opcode extension. This is usually denoted by
a /n
field in the manual.
pub fn rm(self, reg: impl Into<RegisterOrAmode>) -> VexInstruction
pub fn rm(self, reg: impl Into<RegisterOrAmode>) -> VexInstruction
Set the register to use for the rm
bits; many instructions use this
as the “read from register/memory” operand. Setting this affects both
the ModRM byte (rm
section) and the VEX prefix (the extension bits
for register encodings > 8).
pub fn vvvv(self, reg: impl Into<Register>) -> VexInstruction
pub fn vvvv(self, reg: impl Into<Register>) -> VexInstruction
Set the vvvv
register; some instructions allow using this as a second, non-destructive
source register in 3-operand instructions (e.g. 2 read, 1 write).
pub fn imm_reg(self, reg: impl Into<Register>) -> VexInstruction
pub fn imm_reg(self, reg: impl Into<Register>) -> VexInstruction
Set the imm byte when used for a register. The reg bits are stored in imm8[7:4]
with
the lower bits unused. Overrides a previously set Self::imm field.
pub fn imm(self, imm: u8) -> VexInstruction
pub fn imm(self, imm: u8) -> VexInstruction
Set the imm byte. Overrides a previously set Self::imm_reg field.