blob: 1ef6f135bb1e21d4dab7bacf3bb57ae1a11ac32c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
extern crate yaxpeax_arch;
use yaxpeax_arch::{Arch, Decodable, LengthedInstruction};
#[derive(Debug)]
pub enum Opcode {
NOP
}
#[derive(Debug)]
pub struct Instruction {
pub opcode: Opcode
}
impl LengthedInstruction for Instruction {
type Unit = <PIC24 as Arch>::Address;
fn len(&self) -> Self::Unit {
3 // ish
}
}
impl Decodable for Instruction {
fn decode<'a, T: IntoIterator<Item=&'a u8>>(bytes: T) -> Option<Self> {
let mut blank = Instruction { opcode: Opcode::NOP };
match blank.decode_into(bytes) {
Some(_) => Some(blank),
None => None
}
}
fn decode_into<'a, T: IntoIterator<Item=&'a u8>>(&mut self, bytes: T) -> Option<()> {
match bytes.into_iter().next() {
Some(0x00) => {
self.opcode = Opcode::NOP;
Some(())
},
_ => None
}
}
}
pub struct PIC24;
impl Arch for PIC24 {
type Address = u32;
type Instruction = Instruction;
type Operand = ();
}
|