From fbbeed8c10dc9c9bdb34f946d5b844b537ebad7a Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Sat, 7 Dec 2024 13:29:46 -0700 Subject: Proof of concept for macro opcode defs --- src/opcodes.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/opcodes.rs (limited to 'src/opcodes.rs') 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; + } + } + } +); + -- cgit 1.4.1