From 8d479202b0c9dbe13bb95ad572a060b69642ec26 Mon Sep 17 00:00:00 2001 From: krolxon Date: Mon, 5 Jan 2026 12:12:57 +0530 Subject: add labels, improve documentation, add step debug --- src/instructions.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/instructions.rs') 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", + _ => "???", + } + } +} -- cgit v1.2.3