diff options
author | iximeow <me@iximeow.net> | 2019-03-28 02:39:25 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2020-01-12 16:10:13 -0800 |
commit | 89838362bc43352c1cc2b5e6bc970aa0137cbc3b (patch) | |
tree | 778f15fcaf0d2ba2fe0cb01d5e9e765c9c6c3d5f /src | |
parent | 2ae7a2ef1bfae5b76937e4ba79c0c5703c589bcc (diff) |
support eflags, helpers to get RegSpec for *ax and rdx as well as {r,e}flags
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 67 |
1 files changed, 62 insertions, 5 deletions
@@ -11,7 +11,7 @@ use std::hint::unreachable_unchecked; use yaxpeax_arch::{Arch, ColorSettings, Decodable, LengthedInstruction}; -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub struct RegSpec { pub num: u8, pub bank: RegisterBank @@ -37,7 +37,7 @@ impl RegSpec { } #[inline] - fn RIP() -> RegSpec { + pub fn RIP() -> RegSpec { RegSpec { num: 0, bank: RegisterBank::RIP @@ -45,12 +45,69 @@ impl RegSpec { } #[inline] - fn EIP() -> RegSpec { + pub fn EIP() -> RegSpec { RegSpec { num: 0, bank: RegisterBank::EIP } } + + #[inline] + pub fn eflags() -> RegSpec { + RegSpec { + num: 0, + bank: RegisterBank::EFlags + } + } + + #[inline] + pub fn rflags() -> RegSpec { + RegSpec { + num: 0, + bank: RegisterBank::RFlags + } + } + + #[inline] + pub fn rbp() -> RegSpec { + RegSpec { + num: 5, + bank: RegisterBank::RFlags + } + } + + #[inline] + pub fn rsp() -> RegSpec { + RegSpec { + num: 4, + bank: RegisterBank::RFlags + } + } + + #[inline] + pub fn rax() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 0 } + } + + #[inline] + pub fn rdx() -> RegSpec { + RegSpec { bank: RegisterBank::Q, num: 2 } + } + + #[inline] + pub fn eax() -> RegSpec { + RegSpec { bank: RegisterBank::D, num: 0 } + } + + #[inline] + pub fn ax() -> RegSpec { + RegSpec { bank: RegisterBank::W, num: 0 } + } + + #[inline] + pub fn al() -> RegSpec { + RegSpec { bank: RegisterBank::B, num: 0 } + } } #[allow(non_camel_case_types)] @@ -86,10 +143,10 @@ pub enum Operand { Nothing } -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub enum RegisterBank { Q, D, W, B, rB, // Quadword, Dword, Word, Byte - CR, DR, S, EIP, RIP, // Control reg, Debug reg, Selector, ... + CR, DR, S, EIP, RIP, EFlags, RFlags, // Control reg, Debug reg, Selector, ... X, Y, Z, // XMM, YMM, ZMM ST, MM, // ST, MM regs (x87, mmx) } |