Struct bad64::Instruction
source · pub struct Instruction { /* private fields */ }
Expand description
A decoded instruction
Implementations§
source§impl Instruction
impl Instruction
sourcepub fn address(&self) -> u64
pub fn address(&self) -> u64
Returns the instruction address
Example
use bad64::decode;
// nop - "\x1f\x20\x03\xd5"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.address(), 0x1000);
sourcepub fn opcode(&self) -> u32
pub fn opcode(&self) -> u32
Returns the instruction opcode
Example
use bad64::decode;
// nop - "\x1f\x20\x03\xd5"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.opcode(), 0xd503201f);
sourcepub fn op(&self) -> Op
pub fn op(&self) -> Op
Returns the instruction operation
Example
use bad64::{decode, Op};
// nop - "\x1f\x20\x03\xd5"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.op(), Op::NOP);
sourcepub fn operands(&self) -> &[Operand]
pub fn operands(&self) -> &[Operand]
Returns a slice of Operands
Example
use bad64::{decode, Operand, Reg};
// eor x0, x1, x2 - "\x20\x00\x02\xca"
let decoded = decode(0xca020020, 0x1000).unwrap();
let mut ops = decoded.operands();
assert_eq!(ops.len(), 3);
assert_eq!(ops[0], Operand::Reg { reg: Reg::X0, arrspec: None });
assert_eq!(ops[1], Operand::Reg { reg: Reg::X1, arrspec: None });
assert_eq!(ops[2], Operand::Reg { reg: Reg::X2, arrspec: None });
sourcepub fn flags_set(&self) -> Option<FlagEffect>
pub fn flags_set(&self) -> Option<FlagEffect>
Returns if the instruction updates the flags
Example
use bad64::{decode, FlagEffect};
// cmp x0, #0x41 - "\x1f\x04\x01\xf1"
let decoded = decode(0xf101041f, 0x1000).unwrap();
assert_eq!(decoded.flags_set(), Some(FlagEffect::Sets));
// nop - "\x1f\x20\x03\xd5"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.flags_set(), None);
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl Display for Instruction
impl Display for Instruction
source§impl Hash for Instruction
impl Hash for Instruction
source§impl PartialEq for Instruction
impl PartialEq for Instruction
impl Eq for Instruction
Auto Trait Implementations§
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more