📝 ♻️ Doc updates & Registers are now sized from consts
This commit is contained in:
parent
928628c305
commit
35fdb1e0b0
@ -1,3 +1,5 @@
|
||||
use crate::simulator::machine::{NUM_FP_REGS, NUM_INT_REGS};
|
||||
|
||||
use std::ops::{Add, Sub};
|
||||
|
||||
pub trait RegisterNum: Add<Output=Self> + Sub<Output=Self> + PartialEq + Copy {}
|
||||
@ -21,6 +23,9 @@ impl<U: RegisterNum> Register<U> {
|
||||
}
|
||||
|
||||
/// Set value of register *position* to *value*
|
||||
///
|
||||
/// Checking against trying to set a new value to the 0th register
|
||||
/// as its value is NOT supposed to change
|
||||
pub fn set_reg(&mut self, position: usize, value: U) {
|
||||
if position != 0 { self.register[position] = value; }
|
||||
}
|
||||
@ -33,7 +38,7 @@ impl Register<i64> {
|
||||
/// i64 register constructor
|
||||
pub fn init() -> Register<i64> {
|
||||
Register {
|
||||
register: [0i64; 32]
|
||||
register: [0i64; NUM_INT_REGS]
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +49,7 @@ impl Register<f32> {
|
||||
/// f32 register constructor
|
||||
pub fn init() -> Register<f32> {
|
||||
Register {
|
||||
register: [0f32; 32]
|
||||
register: [0f32; NUM_FP_REGS]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user