aboutsummaryrefslogtreecommitdiff
path: root/src/instructions.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2026-01-05 12:12:57 +0530
committerkrolxon <krolyxon@tutanota.com>2026-01-05 12:12:57 +0530
commit8d479202b0c9dbe13bb95ad572a060b69642ec26 (patch)
tree5a8f8c015c47bef497e4a54808da667db857fbfd /src/instructions.rs
parent2fb5bbaa8d97a390b3175026040709c762cb93ec (diff)
add labels, improve documentation, add step debug
Diffstat (limited to 'src/instructions.rs')
-rw-r--r--src/instructions.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/instructions.rs b/src/instructions.rs
index acfb8bd..ac88e94 100644
--- a/src/instructions.rs
+++ b/src/instructions.rs
@@ -8,3 +8,18 @@ pub enum Instruction {
JNZ = 0x06,
HLT = 0xFF,
}
+
+impl Instruction {
+ pub fn opcode_name(op: u8) -> &'static str{
+ match op {
+ 0x01 => "MOV",
+ 0x02 => "ADD",
+ 0x03 => "SUB",
+ 0x04 => "JMP",
+ 0x05 => "JZ",
+ 0x06 => "JNZ",
+ 0xFF => "HLT",
+ _ => "???",
+ }
+ }
+}