From 3c9597a105670c91a6c11493204a4828ed54d235 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 19 Oct 2019 22:51:44 -0700 Subject: add more regspec helpers, some allcaps to lowercase --- src/lib.rs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c2cd016..7dcd0a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,7 @@ impl RegSpec { } #[inline] - pub fn RIP() -> RegSpec { + pub fn rip() -> RegSpec { RegSpec { num: 0, bank: RegisterBank::RIP @@ -63,7 +63,7 @@ impl RegSpec { } #[inline] - pub fn EIP() -> RegSpec { + pub fn eip() -> RegSpec { RegSpec { num: 0, bank: RegisterBank::EIP @@ -128,6 +128,26 @@ impl RegSpec { } #[inline] + pub fn rsi() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 6 } + } + + #[inline] + pub fn rdi() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 7 } + } + + #[inline] + pub fn r8() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 8 } + } + + #[inline] + pub fn r9() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 9 } + } + + #[inline] pub fn eax() -> RegSpec { RegSpec { bank: RegisterBank::D, num: 0 } } @@ -141,6 +161,11 @@ impl RegSpec { pub fn al() -> RegSpec { RegSpec { bank: RegisterBank::B, num: 0 } } + + #[inline] + pub fn cl() -> RegSpec { + RegSpec { bank: RegisterBank::B, num: 1 } + } } #[allow(non_camel_case_types)] @@ -217,6 +242,7 @@ impl Operand { } } +#[allow(non_camel_case_types)] #[cfg(feature="use-serde")] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] pub enum RegisterBank { @@ -2070,7 +2096,7 @@ fn read_E_anybank>(bytes_iter: &mut T, instr: &mut Instruct } else if (modrm & 7) == 5 && modbits == 0b00 { let disp = read_num(bytes_iter, 4, &mut instr.length); instr.operands[result] = Operand::RegDisp( - if addr_width == 8 { RegSpec::RIP() } else { RegSpec::EIP() }, + if addr_width == 8 { RegSpec::rip() } else { RegSpec::eip() }, disp as i32 ); } else if (modrm & 7) == 4 { -- cgit v1.1