chore: add macros for ModRM GPR Instruction parsing

This commit is contained in:
2025-05-13 12:22:54 +09:00
parent c71ddb4419
commit 47a002cd79
2 changed files with 24 additions and 13 deletions

View File

@@ -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()))
}};
}