aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/insn
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-02-27 21:16:40 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-02-27 21:16:40 +0100
commitab5711a77e2a6872ca1392c1dbc2f545f7d3ab3b (patch)
tree0ecab4660bbbf0faeb5199bbc80ee53243d641ee /src/insn
parent957663f5d483b1abaa3f5af25e32c274218319d5 (diff)
downloadjuicebox-asm-ab5711a77e2a6872ca1392c1dbc2f545f7d3ab3b.tar.gz
juicebox-asm-ab5711a77e2a6872ca1392c1dbc2f545f7d3ab3b.zip
Add ADD, DEC, TEST, RET instructions
Diffstat (limited to 'src/insn')
-rw-r--r--src/insn/add.rs7
-rw-r--r--src/insn/dec.rs7
-rw-r--r--src/insn/ret.rs7
-rw-r--r--src/insn/test.rs7
4 files changed, 28 insertions, 0 deletions
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<Reg64, Reg64> 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<Reg64> 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<Reg64, Reg64> for Asm {
+ fn test(&mut self, op1: Reg64, op2: Reg64) {
+ self.encode_rr(0x85, op1, op2);
+ }
+}