Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub const CONST: u8 = 0x0;
- pub const LOAD_G: u8 = 0x1;
- pub const STORE_G: u8 = 0x2;
- pub const LOAD_L: u8 = 0x3;
- pub const STORE_L: u8 = 0x4;
- pub const LOAD_A: u8 = 0x5;
- pub const STORE_A: u8 = 0x6;
- pub const JMP: u8 = 0x7;
- pub const BRF: u8 = 0x8;
- pub const BRT: u8 = 0x9;
- pub const CALL: u8 = 0xA;
- pub const CALL_B: u8 = 0xB;
- pub const RET: u8 = 0xC;
- pub const LOAD_R: u8 = 0xD;
- pub const STORE_R: u8 = 0xE;
- pub const ASF: u8 = 0xF;
- pub const RSF: u8 = 0x10;
- pub const POP: u8 = 0x11;
- pub const ADD: u8 = 0x12;
- pub const SUB: u8 = 0x13;
- pub const MUL: u8 = 0x14;
- pub const DIV: u8 = 0x15;
- pub const MOD: u8 = 0x16;
- pub const EQ: u8 = 0x17;
- pub const NE: u8 = 0x18;
- pub const LT: u8 = 0x19;
- pub const LE: u8 = 0x1A;
- pub const GT: u8 = 0x1B;
- pub const GE: u8 = 0x1C;
- pub const NOT: u8 = 0x1D;
- pub const NEG: u8 = 0x1E;
- pub const HALT: u8 = 0x1F;
- pub const ARRAY: u8 = 0x20;
- pub fn opcode_to_string(opcode: u8) -> String {
- match opcode {
- CONST => "CONST".to_string(),
- LOAD_G => "LOAD_G".to_string(),
- STORE_G => "STORE_G".to_string(),
- LOAD_L => "LOAD_L".to_string(),
- STORE_L => "STORE_L".to_string(),
- LOAD_A => "LOAD_A".to_string(),
- STORE_A => "STORE_A".to_string(),
- JMP => "JMP".to_string(),
- BRF => "BRF".to_string(),
- BRT => "BRT".to_string(),
- CALL => "CALL".to_string(),
- CALL_B => "CALL_B".to_string(),
- RET => "RET".to_string(),
- LOAD_R => "LOAD_R".to_string(),
- STORE_R => "STORE_R".to_string(),
- ASF => "ASF".to_string(),
- RSF => "RSF".to_string(),
- POP => "POP".to_string(),
- ADD => "ADD".to_string(),
- SUB => "SUB".to_string(),
- MUL => "MUL".to_string(),
- DIV => "DIV".to_string(),
- MOD => "MOD".to_string(),
- EQ => "EQ".to_string(),
- NE => "NE".to_string(),
- LT => "LT".to_string(),
- LE => "LE".to_string(),
- GT => "GT".to_string(),
- GE => "GE".to_string(),
- NOT => "NOT".to_string(),
- NEG => "NEG".to_string(),
- HALT => "HALT".to_string(),
- ARRAY => "ARRAY".to_string(),
- _ => "UNKNOWN".to_string(),
- }
- }
Advertisement