#[cfg(feature="use-serde")] #[macro_use] extern crate serde_derive; #[cfg(feature="use-serde")] extern crate serde; //#[cfg(feature="use-serde")] //use serde::{Serialize, Deserialize}; extern crate yaxpeax_arch; use yaxpeax_arch::{Arch, Decoder, LengthedInstruction}; #[derive(Debug)] pub enum Opcode { NOP } #[derive(Debug)] pub struct Instruction { pub opcode: Opcode } impl LengthedInstruction for Instruction { type Unit = ::Address; fn min_size() -> Self::Unit { 3 } fn len(&self) -> Self::Unit { 3 // ish } } #[derive(Default, Debug)] pub struct InstDecoder {} impl Decoder for InstDecoder { fn decode>(&self, bytes: T) -> Option { let mut blank = Instruction { opcode: Opcode::NOP }; match self.decode_into(&mut blank, bytes) { Some(_) => Some(blank), None => None } } fn decode_into>(&self, instr: &mut Instruction, bytes: T) -> Option<()> { match bytes.into_iter().next() { Some(0x00) => { instr.opcode = Opcode::NOP; Some(()) }, _ => None } } } #[cfg(feature="use-serde")] #[derive(Debug, Serialize, Deserialize)] pub struct PIC24; #[cfg(not(feature="use-serde"))] #[derive(Debug)] pub struct PIC24; impl Arch for PIC24 { type Address = u32; type Instruction = Instruction; type Decoder = InstDecoder; type Operand = (); }