From ab5711a77e2a6872ca1392c1dbc2f545f7d3ab3b Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Mon, 27 Feb 2023 21:16:40 +0100 Subject: Add ADD, DEC, TEST, RET instructions --- src/insn/add.rs | 7 +++++++ src/insn/dec.rs | 7 +++++++ src/insn/ret.rs | 7 +++++++ src/insn/test.rs | 7 +++++++ 4 files changed, 28 insertions(+) create mode 100644 src/insn/add.rs create mode 100644 src/insn/dec.rs create mode 100644 src/insn/ret.rs create mode 100644 src/insn/test.rs (limited to 'src/insn') diff --git a/src/insn/add.rs b/src/insn/add.rs new file mode 100644 index 0000000..b8456c4 --- /dev/null +++ b/src/insn/add.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +impl Add for Asm { + fn add(&mut self, op1: Reg64, op2: Reg64) { + self.encode_rr(0x01, op1, op2); + } +} diff --git a/src/insn/dec.rs b/src/insn/dec.rs new file mode 100644 index 0000000..7de5a54 --- /dev/null +++ b/src/insn/dec.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +impl Dec for Asm { + fn dec(&mut self, op1: Reg64) { + self.encode_r(0xff, 1, op1); + } +} diff --git a/src/insn/ret.rs b/src/insn/ret.rs new file mode 100644 index 0000000..74086d8 --- /dev/null +++ b/src/insn/ret.rs @@ -0,0 +1,7 @@ +use crate::Asm; + +impl Asm { + pub fn ret(&mut self) { + self.emit(&[0xc3]); + } +} diff --git a/src/insn/test.rs b/src/insn/test.rs new file mode 100644 index 0000000..1319e3f --- /dev/null +++ b/src/insn/test.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +impl Test for Asm { + fn test(&mut self, op1: Reg64, op2: Reg64) { + self.encode_rr(0x85, op1, op2); + } +} -- cgit v1.2.3