From 05b4ccbbc19f98a97e23e5acd3252ac0a48afc48 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 28 Nov 2019 02:22:47 -0800 Subject: update pic24 to revised decoder trait --- src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 20786d9..7dc4872 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ extern crate serde; extern crate yaxpeax_arch; -use yaxpeax_arch::{Arch, Decodable, LengthedInstruction}; +use yaxpeax_arch::{Arch, Decoder, LengthedInstruction}; #[derive(Debug)] pub enum Opcode { @@ -29,18 +29,21 @@ impl LengthedInstruction for Instruction { } } -impl Decodable for Instruction { - fn decode>(bytes: T) -> Option { +#[derive(Default, Debug)] +pub struct InstDecoder {} + +impl Decoder for InstDecoder { + fn decode>(&self, bytes: T) -> Option { let mut blank = Instruction { opcode: Opcode::NOP }; - match blank.decode_into(bytes) { + match self.decode_into(&mut blank, bytes) { Some(_) => Some(blank), None => None } } - fn decode_into>(&mut self, bytes: T) -> Option<()> { + fn decode_into>(&self, instr: &mut Instruction, bytes: T) -> Option<()> { match bytes.into_iter().next() { Some(0x00) => { - self.opcode = Opcode::NOP; + instr.opcode = Opcode::NOP; Some(()) }, _ => None @@ -59,5 +62,6 @@ pub struct PIC24; impl Arch for PIC24 { type Address = u32; type Instruction = Instruction; + type Decoder = InstDecoder; type Operand = (); } -- cgit v1.1