summary refs log tree commit diff
path: root/src/opcodes.rs
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-12-07 13:29:46 -0700
committerAshelyn Rose <git@ashen.earth>2024-12-07 13:29:46 -0700
commitfbbeed8c10dc9c9bdb34f946d5b844b537ebad7a (patch)
tree096b6387ed9a72c93cafb3e8052be51c78c52b11 /src/opcodes.rs
parent3e51fca06d097698add372c1052751b3b6313be3 (diff)
Proof of concept for macro opcode defs
Diffstat (limited to 'src/opcodes.rs')
-rw-r--r--src/opcodes.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/opcodes.rs b/src/opcodes.rs
new file mode 100644
index 0000000..e8ef7fe
--- /dev/null
+++ b/src/opcodes.rs
@@ -0,0 +1,28 @@
+use opcode_proc::generate_opcodes;
+
+generate_opcodes!(
+    pub enum OpCodes {
+        #[code(0x00)]
+        fn Nop() {
+            
+        },
+
+        #[code(0x10)]
+        fn Add(a: u32, b: u32) -> u32 {
+            a + b
+        },
+
+        #[code(0x11)]
+        fn Sub(a: u32, b: u32) -> u32 {
+            a - b
+        },
+
+        #[code(0x23)]
+        fn Jnz(&mut interpreter, comparison: u32, offset: u32) {
+            if comparison != 0 {
+                interpreter.reg_program += offset;
+            }
+        }
+    }
+);
+