Struct bad64::Instruction[][src]

pub struct Instruction { /* fields omitted */ }

A decoded instruction

Implementations

impl Instruction[src]

pub fn mnem(&self) -> &'static str[src]

Returns the instruction mnemonic

Example

use bad64::decode;
// nop - "\x1f\x20\x03\xd4"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.mnem(), "nop");

pub fn address(&self) -> u64[src]

Returns the instruction address

Example

use bad64::decode;
// nop - "\x1f\x20\x03\xd4"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.address(), 0x1000);

pub fn operation(&self) -> Operation[src]

Returns the instruction operation

Example

use bad64::{decode, Operation};
// nop - "\x1f\x20\x03\xd4"
let decoded = decode(0xd503201f, 0x1000).unwrap();
assert_eq!(decoded.operation(), Operation::NOP);

pub fn operand(&self, n: usize) -> Option<Operand>[src]

Returns an instruction operand

Arguments

  • n - returns the nth operand

Example

use bad64::{decode, Imm, Operation, Operand, Reg};
// add x0, x1, #0x41  - "\x20\x04\x01\x91"
let decoded = decode(0x91010420, 0x1000).unwrap();

assert_eq!(decoded.operation(), Operation::ADD);
assert_eq!(decoded.num_operands(), 3);
assert_eq!(decoded.operand(0), Some(Operand::Reg { reg: Reg::X0, shift: None }));
assert_eq!(decoded.operand(1), Some(Operand::Reg { reg: Reg::X1, shift: None }));
assert_eq!(decoded.operand(2), Some(Operand::Imm64 { imm: Imm { neg: false, val: 0x41 }, shift: None }));
assert_eq!(decoded.operand(3), None);

pub fn num_operands(&self) -> usize[src]

Returns the operand count

Example

use bad64::{decode, Operation};
// eor x0, x1, x2  - "\x20\x00\x02\xca"
let decoded = decode(0xca020020, 0x1000).unwrap();

assert_eq!(decoded.num_operands(), 3);

pub fn operands(&self) -> &[Operand][src]

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(), decoded.num_operands());
assert_eq!(ops[0], Operand::Reg { reg: Reg::X0, shift: None });
assert_eq!(ops[1], Operand::Reg { reg: Reg::X1, shift: None });
assert_eq!(ops[2], Operand::Reg { reg: Reg::X2, shift: None });

Trait Implementations

impl Clone for Instruction[src]

impl Debug for Instruction[src]

impl Eq for Instruction[src]

impl Hash for Instruction[src]

impl PartialEq<Instruction> for Instruction[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.