diff --git a/src/simulator/register.rs b/src/simulator/register.rs index 4cbe50d..2f78d30 100644 --- a/src/simulator/register.rs +++ b/src/simulator/register.rs @@ -1,3 +1,5 @@ +use crate::simulator::machine::{NUM_FP_REGS, NUM_INT_REGS}; + use std::ops::{Add, Sub}; pub trait RegisterNum: Add + Sub + PartialEq + Copy {} @@ -20,7 +22,10 @@ impl Register { self.register[position as usize] } - /// Set value of register *position* to *value* + /// 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 register constructor pub fn init() -> Register { Register { - register: [0i64; 32] + register: [0i64; NUM_INT_REGS] } } @@ -44,7 +49,7 @@ impl Register { /// f32 register constructor pub fn init() -> Register { Register { - register: [0f32; 32] + register: [0f32; NUM_FP_REGS] } }