// icodes pub struct Icode {} impl Icode { // Official names pub const BRK: u8 = 0x00u8; pub const LIT: u8 = 0x1 << 7; // AKA keep Yes really. Per spec; pub const INC: u8 = 0x01; pub const POP: u8 = 0x02; pub const NIP: u8 = 0x03; pub const SWP: u8 = 0x04; pub const ROT: u8 = 0x05; pub const DUP: u8 = 0x06; pub const OVR: u8 = 0x07; pub const EQL: u8 = 0x08; pub const NEQ: u8 = 0x09; pub const GTH: u8 = 0x0a; pub const LTH: u8 = 0x0b; pub const JMP: u8 = 0x0c; pub const JCN: u8 = 0x0d; pub const JSR: u8 = 0x0e; pub const STH: u8 = 0x0f; pub const LDZ: u8 = 0x10; pub const STZ: u8 = 0x11; pub const LDR: u8 = 0x12; pub const STR: u8 = 0x13; pub const LDA: u8 = 0x14; pub const STA: u8 = 0x15; pub const DEI: u8 = 0x16; pub const DEO: u8 = 0x17; pub const ADD: u8 = 0x18; pub const SUB: u8 = 0x19; pub const MUL: u8 = 0x1a; pub const DIV: u8 = 0x1b; pub const AND: u8 = 0x1c; pub const ORA: u8 = 0x1d; pub const EOR: u8 = 0x1e; pub const SFT: u8 = 0x1f; // Opcode flags pub const SHORT: u8 = 0x1 << 5; pub const RETURN: u8 = 0x1 << 6; pub const KEEP: u8 = 0x1 << 7; // Hacking around the official names for some things pub const XOR: u8 = Icode::EOR; pub const EQ: u8 = Icode::EQL; pub const NE: u8 = Icode::NEQ; pub const GT: u8 = Icode::GTH; pub const LT: u8 = Icode::LTH; pub const OR: u8 = Icode::ORA; pub const NOP: u8 = Icode::POP | Icode::KEEP; pub const fn parse(opcode: u8) -> (u8, u8, u8, u8) { let kflag: u8 = (opcode >> 7) & 0x1; let rflag: u8 = (opcode >> 6) & 0x1; let sflag: u8 = (opcode >> 5) & 0x1; let icode: u8 = opcode & 0x1F; (kflag, rflag, sflag, icode) } }