#![no_std] 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, // N; Do nothing ADD = 1, // RRR; #0 ← #1 + #2 SUB = 2, // RRR; #0 ← #1 - #2 MUL = 3, // RRR; #0 ← #1 × #2 DIV = 4, // RRR; #0 ← #1 ÷ #2 REM = 5, // RRR; #0 ← #1 % #2 AND = 6, // RRR; #0 ← #1 & #2 OR = 7, // RRR; #0 ← #1 | #2 XOR = 8, // RRR; #0 ← #1 ^ #2 NOT = 9, // RR; #0 ← !#1 // TODO: Add instruction for integer and float // reg ← reg + imm instructions ADDF = 10, // RRR; #0 ← #1 +. #2 SUBF = 11, // RRR; #0 ← #1 +. #2 MULF = 12, // RRR; #0 ← #1 +. #2 DIVF = 13, // RRR; #0 ← #1 +. #2 CP = 14, // RR; Copy #0 ← #1 LI = 15, // RI; Load immediate, #0 ← imm #1 LB = 16, // RRI; Load byte (8 bits), #0 ← [#1 + imm #2] LD = 17, // RRI; Load doublet (16 bits) LQ = 18, // RRI; Load quadlet (32 bits) LO = 19, // RRI; Load octlet (64 bits) SB = 20, // RRI; Store byte, [#1 + imm #2] ← #0 SD = 21, // RRI; Store doublet SQ = 22, // RRI; Store quadlet SO = 23, // RRI; Store octlet PAGEMAP = 24, // ?; Map a page PAGEUNMAP = 25, // ?; Unmap a page PAGEMP = 26, // ?; Page modify protection flags JMP = 27, // RI; Unconditional jump [#0 + imm #1] JMPCOND = 28, // ?; Conditional jump RET = 29, // N; Return ECALL = 30, // N; Issue system call }); #[repr(packed)] pub struct ParamRRR(pub u8, pub u8, pub u8); #[repr(packed)] pub struct ParamRRI(pub u8, pub u8, pub u64); #[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 ParamRRI {} unsafe impl OpParam for ParamRR {} unsafe impl OpParam for ParamRI {} unsafe impl OpParam for u64 {} unsafe impl OpParam for () {}