chore: add macros for ModRM GPR Instruction parsing
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::{
|
||||
Args,
|
||||
instructions::{ImmediateByte, ImmediateWord, Instruction, Mnemonic, Register},
|
||||
};
|
||||
use crate::{modrmb, modrms, modrmv};
|
||||
use crate::{modrmb, modrmgprb, modrmgprv, modrms, modrmv};
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Generic errors, which are encountered during parsing.
|
||||
@@ -385,18 +385,9 @@ impl Disassembler {
|
||||
0x7E => Mnemonic::JLE(ImmediateByte(self.parse_byte())),
|
||||
0x7F => Mnemonic::JG(ImmediateByte(self.parse_byte())),
|
||||
|
||||
// 0x80..=0x83 => panic!("GRP1 not implemented"),
|
||||
0x80 => {
|
||||
let (target, reg) = self.parse_modrm_byte(OperandWidth::Byte(0));
|
||||
let imm = self.parse_byte();
|
||||
Self::modrm_reg_to_mnemonic(reg, target, OperandWidth::Byte(imm))
|
||||
}
|
||||
0x81 => {
|
||||
let (target, reg) = self.parse_modrm_byte(OperandWidth::Word(0));
|
||||
let imm = self.parse_word();
|
||||
Self::modrm_reg_to_mnemonic(reg, target, OperandWidth::Word(imm))
|
||||
}
|
||||
0x82 => panic!("Same as 0x80"),
|
||||
0x80 => modrmgprb!(self),
|
||||
0x81 => modrmgprv!(self),
|
||||
0x82 => modrmgprb!(self), // same as 0x80
|
||||
0x83 => panic!("Sign extented GPR1 not yet implemented"),
|
||||
|
||||
0x84 => modrmb!(self, TEST),
|
||||
|
||||
@@ -24,3 +24,23 @@ macro_rules! modrms {
|
||||
Mnemonic::$variant(target, SegmentRegister::by_id(reg))
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
/// Generate a GPR instruction from modrm byte for byte
|
||||
macro_rules! modrmgprb {
|
||||
($self:ident) => {{
|
||||
let (target, reg) = $self.parse_modrm_byte(OperandWidth::Byte(0));
|
||||
let imm = $self.parse_byte();
|
||||
Self::modrm_reg_to_mnemonic(reg, target, OperandWidth::Byte(imm))
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
/// Generate a GPR instruction from modrm byte for word
|
||||
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()))
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user