pub const REG_COUNT: usize = 60; macro_rules! constmod { ($vis:vis $mname:ident($repr:ty) { $($cname:ident = $val:expr),* $(,)? }) => { $vis mod $mname { $(pub const $cname: $repr = $val;)* } }; } constmod!(pub opcode(u8) { NOP = 0, // _ ADD = 1, // RRR SUB = 2, // RRR MUL = 3, // RRR DIV = 4, // RRR REM = 5, // RRR AND = 6, // RRR OR = 7, // RRR XOR = 8, // RRR NOT = 9, // RR // TODO: Add instruction for integer and float // reg ← reg + imm instructions ADDF = 10, // RRR SUBF = 11, // RRR MULF = 12, // RRR DIVF = 13, // RRR LI = 14, // RI LD = 15, // RI ST = 16, // RI MAPPAGE = 17, // ? UNMAPPAGE = 18, // ? JMP = 100, // I JMPCOND = 101, // I RET = 103, // _ ECALL = 255, // _ }); #[repr(packed)] pub struct ParamRRR(pub u8, pub u8, pub u8); #[repr(packed)] pub struct ParamRR(pub u8, pub u8); #[repr(packed)] pub struct ParamRI(pub u8, pub u64); /// # Safety /// TODO. pub unsafe trait OpParam {} unsafe impl OpParam for ParamRRR {} unsafe impl OpParam for ParamRR {} unsafe impl OpParam for ParamRI {} unsafe impl OpParam for u64 {} unsafe impl OpParam for () {}