pub struct Mipsasm<'a> { /* private fields */ }Expand description
An instance of the assembler/disassembler
Implementations
sourceimpl<'a> Mipsasm<'a>
impl<'a> Mipsasm<'a>
sourcepub fn new() -> Mipsasm<'a>
pub fn new() -> Mipsasm<'a>
Create a new Mipsasm instance.
Sets the base address to 0 and the debug flag to false.
sourcepub fn base(&mut self, addr: u32) -> &mut Mipsasm<'a>
pub fn base(&mut self, addr: u32) -> &mut Mipsasm<'a>
Set the base address for the assembler.
Examples
use mipsasm::Mipsasm;
let mut mipsasm = Mipsasm::new();
mipsasm.base(0x8000_0000);sourcepub fn symbols(&mut self, syms: HashMap<&'a str, u32>) -> &mut Mipsasm<'a>
pub fn symbols(&mut self, syms: HashMap<&'a str, u32>) -> &mut Mipsasm<'a>
Provides the assembler with a set of symbols.
Examples
use mipsasm::Mipsasm;
use std::collections::HashMap;
let mut mipsasm = Mipsasm::new();
mipsasm.symbols(HashMap::from_iter(vec![("foo", 0x8000_0000)]));sourcepub fn debug(&mut self) -> &mut Mipsasm<'a>
pub fn debug(&mut self) -> &mut Mipsasm<'a>
Set the debug flag for the assembler.
When debug is set to true, the disassembler will print instructions with all extra whitespace stripped. This is used for testing and will most likely not be useful for other purposes.
Examples
use mipsasm::Mipsasm;
let mut mipsasm = Mipsasm::new();
mipsasm.debug();sourcepub fn assemble(&self, input: &str) -> Result<Vec<u32>, String>
pub fn assemble(&self, input: &str) -> Result<Vec<u32>, String>
Assembles a set of MIPS assembly instructions.
Examples
use mipsasm::Mipsasm;
let mut mipsasm = Mipsasm::new();
let instructions = mipsasm.assemble("
add $t0, $t1, $t2
addi $t0, $t1, 0x1234
");sourcepub fn disassemble(&self, input: &[u32]) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn disassemble(&self, input: &[u32]) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Disassembles a set of MIPS instructions.
Examples
use mipsasm::Mipsasm;
let mut mipsasm = Mipsasm::new();
let instructions = mipsasm.disassemble(&[0x00850018]);
assert_eq!(instructions, vec!["mult $a0, $a1"]);Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Mipsasm<'a>
impl<'a> Send for Mipsasm<'a>
impl<'a> Sync for Mipsasm<'a>
impl<'a> Unpin for Mipsasm<'a>
impl<'a> UnwindSafe for Mipsasm<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more