Update registers to be constants, add instructions to parser

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-01-27 18:41:33 -05:00
parent abf32665e2
commit b16974c7c4
4 changed files with 149 additions and 159 deletions

View File

@@ -1,83 +1,94 @@
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)]
pub enum Reg {
macro_rules! registers {
{
$($variant:ident = $value:expr),* $(,)?
} => {
pub type Reg = u8;
$(
#[allow(dead_code)]
pub const $variant: Reg = $value;
)*
};
}
registers! {
// https://crates.io/crates/packed_struct
// TODO : check this muffugin shit out!!
/// Instruction pointer
Ip = 0,
// Instruction pointer
IP = 0,
/// Stack pointer
Sp,
// Stack pointer
SP = 1,
/// Frame pointer
Fp,
// Frame pointer
FP = 2,
/// Flags
Flags,
// Flags
FLAGS = 3,
Unused00,
Unused01,
Unused02,
Unused03,
Unused04,
Unused05,
Unused06,
Unused07,
Unused08,
UNUSED00 = 4,
UNUSED01 = 5,
UNUSED02 = 6,
UNUSED03 = 7,
UNUSED04 = 8,
UNUSED05 = 9,
UNUSED06 = 10,
UNUSED07 = 11,
UNUSED08 = 12,
/// General status code
Status,
// General status code
STATUS = 13,
R00,
R01,
R02,
R03,
R04,
R05,
R06,
R07,
R08,
R09,
R10,
R11,
R12,
R13,
R14,
R15,
R16,
R17,
R18,
R19,
R20,
R21,
R22,
R23,
R24,
R25,
R26,
R27,
R28,
R29,
R30,
R31,
R32,
R33,
R34,
R35,
R36,
R37,
R38,
R39,
R40,
R41,
R42,
R43,
R44,
R45,
R46,
R47,
R48,
R49,
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,
LAST_REG = R49,
}