pub fn linear_sweep(data: &impl AsRef<[u16]>) -> LinearSweep<'_>
Notable traits for LinearSweep<'_>
impl Iterator for LinearSweep<'_> type Item = Result<Instruction, MOSISError>;
Expand description

Iterates over a slice of bytes, performing a linear sweep disassembly to MOSIS Instructions.

Iterate over a byte slice, disassembling as big endian u16s, yielding Instructions or MOSISErrors when disassembly fails.

Examples

use mosis::{linear_sweep, Instruction::*, Register::*};

let bytes = [0x2312, 0x2a34, 0x3a98, 0x3fed];
let mut x = linear_sweep(&bytes);

assert_eq!(x.next(), Some(Ok(Add { dst: R3, x: R1, y: R2 })));
assert_eq!(x.next(), Some(Ok(Add { dst: Ra, x: R3, y: R4 })));
assert_eq!(x.next(), Some(Ok(Sub { dst: Ra, x: R9, y: R8 })));
assert_eq!(x.next(), Some(Ok(Sub { dst: Rf, x: Re, y: Rd })));
assert_eq!(x.next(), None);
use mosis::linear_sweep;

for instruction in linear_sweep(bytes) {
    println!("{}", instruction.unwrap());
}