Files
rasp/src/vm/reg.rs

106 lines
1.6 KiB
Rust
Raw Normal View History

macro_rules! registers {
{
$($variant:ident = $value:expr),* $(,)?
} => {
pub type Reg = u8;
$(
pub const $variant: Reg = $value;
)*
pub fn reg_name(reg: Reg) -> Option<&'static str> {
match reg {
$(
$value => Some(stringify!($variant)),
)*
_ => None,
}
}
};
}
registers! {
// https://crates.io/crates/packed_struct
// TODO : check this muffugin shit out!!
// Instruction pointer
IP = 0,
// Stack pointer
SP = 1,
// Frame pointer
FP = 2,
// Flags
FLAGS = 3,
// Zero
NULL = 4,
UNUSED01 = 5,
UNUSED02 = 6,
UNUSED03 = 7,
UNUSED04 = 8,
UNUSED05 = 9,
UNUSED06 = 10,
UNUSED07 = 11,
UNUSED08 = 12,
// General status code
STATUS = 13,
R00 = 14,
R01 = 15,
R02 = 16,
R03 = 17,
R04 = 18,
R05 = 19,
R06 = 20,
R07 = 21,
R08 = 22,
R09 = 23,
R10 = 24,
R11 = 25,
R12 = 26,
R13 = 27,
R14 = 28,
R15 = 29,
R16 = 30,
R17 = 31,
R18 = 32,
R19 = 33,
R20 = 34,
R21 = 35,
R22 = 36,
R23 = 37,
R24 = 38,
R25 = 39,
R26 = 40,
R27 = 41,
R28 = 42,
R29 = 43,
R30 = 44,
R31 = 45,
R32 = 46,
R33 = 47,
R34 = 48,
R35 = 49,
R36 = 50,
R37 = 51,
R38 = 52,
R39 = 53,
R40 = 54,
R41 = 55,
R42 = 56,
R43 = 57,
R44 = 58,
R45 = 59,
R46 = 60,
R47 = 61,
R48 = 62,
R49 = 63,
}
pub const LAST_REG: Reg = R49;