summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-01-16 03:49:00 -0800
committeriximeow <me@iximeow.net>2020-01-12 17:23:00 -0800
commite90196a82884abcbd950f17a457e0109fa1ca1b5 (patch)
treef717072a53c74d7459c9cd75471e2b92bd01aae6 /src
initial commit
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..1ef6f13
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,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 = ();
+}