#[derive(Debug, Default, Clone, Copy)]
#[allow(non_snake_case)]
pub struct Registers {
pub t0: u64,
pub t1: u64,
pub t2: u64,
pub t3: u64,
pub t4: u64,
pub t5: u64,
pub t6: u64,
pub t7: u64,
pub pc: u64,
pub t9: u64,
pub t8: u64,
pub t10: u64,
pub t11: u64,
pub cfr: u64,
pub lr: u64,
pub sp: u64,
pub d0: u64,
pub d1: u64,
pub d2: u64,
pub d3: u64,
pub d4: u64,
pub d5: u64,
pub d6: u64,
}
impl Registers {
pub const fn new() -> Self {
Self {
t0: 0,
t1: 0,
t2: 0,
t3: 0,
t4: 0,
t5: 0,
t6: 0,
t7: 0,
pc: 0,
t8: 0,
t9: 0,
t10: 0,
t11: 0,
cfr: 0,
lr: 0,
sp: 0,
d0: 0,
d1: 0,
d2: 0,
d3: 0,
d4: 0,
d5: 0,
d6: 0,
}
}
}
#[derive(Debug, Default)]
pub struct Machine {
pub regs: Registers,
}
impl Machine {
pub const fn new() -> Self {
Self {
regs: Registers::new(),
}
}
pub fn reset(&mut self) {
*self = Self::new();
}
pub fn lr_as_u64(&self) -> u64 {
self.regs.lr
}
}