fix: correctly parse word instead of byte for GPR
This commit is contained in:
@@ -204,6 +204,8 @@ impl Disassembler {
|
||||
}
|
||||
|
||||
/// Match the modrm reg bits to the GPR1 mnemonics.
|
||||
/// GPR always has an imm value as second operand, but is available in both
|
||||
/// Byte and Word length.
|
||||
pub fn modrm_reg_to_mnemonic(reg: u8, target: ModRmTarget, imm: OperandWidth) -> Mnemonic {
|
||||
match imm {
|
||||
OperandWidth::Byte(b) => match reg {
|
||||
|
||||
@@ -26,7 +26,8 @@ macro_rules! modrms {
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
/// Generate a GPR instruction from modrm byte for byte
|
||||
/// Generate a GPR instruction from modrm byte for byte.
|
||||
/// GPR always has an imm value as second operand.
|
||||
macro_rules! modrmgprb {
|
||||
($self:ident) => {{
|
||||
let (target, reg) = $self.parse_modrm_byte(OperandWidth::Byte(0));
|
||||
@@ -37,10 +38,11 @@ macro_rules! modrmgprb {
|
||||
|
||||
#[macro_export]
|
||||
/// Generate a GPR instruction from modrm byte for word
|
||||
/// GPR always has an imm value as second operand.
|
||||
macro_rules! modrmgprv {
|
||||
($self:ident) => {{
|
||||
let (target, reg) = $self.parse_modrm_byte(OperandWidth::Word(0));
|
||||
let imm = $self.parse_byte();
|
||||
Self::modrm_reg_to_mnemonic(reg, target, OperandWidth::Word(imm.into()))
|
||||
let imm = $self.parse_word();
|
||||
Self::modrm_reg_to_mnemonic(reg, target, OperandWidth::Word(imm))
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user