Krolyxon
Commit 57bbca6

Branches

Tags

Refs →

bench51srcinstructions.rs

25 lines · 466 B · Rust

1#[repr(u8)]
2pub enum Instruction {
3 MOV = 0x01,
4 ADD = 0x02,
5 SUB = 0x03,
6 JMP = 0x04,
7 JZ = 0x05,
8 JNZ = 0x06,
9 HLT = 0xFF,
10}
11
12impl Instruction {
13 pub fn opcode_name(op: u8) -> &'static str{
14 match op {
15 0x01 => "MOV",
16 0x02 => "ADD",
17 0x03 => "SUB",
18 0x04 => "JMP",
19 0x05 => "JZ",
20 0x06 => "JNZ",
21 0xFF => "HLT",
22 _ => "???",
23 }
24 }
25}