forked from Rativel/BurritOS
📝 Documentation updates
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
use crate::simulator::machine::{NUM_FP_REGS, NUM_INT_REGS};
|
||||
//! # Register
|
||||
//!
|
||||
//! This mod contains the definition of the Register structs
|
||||
//! for use within the Machine module.
|
||||
|
||||
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 {}
|
||||
@@ -16,7 +20,6 @@ pub struct Register<U: RegisterNum> {
|
||||
}
|
||||
|
||||
impl<U: RegisterNum> Register<U> {
|
||||
|
||||
/// Returns the current value held in register *position*
|
||||
pub fn get_reg(&self, position: u8) -> U {
|
||||
self.register[position as usize]
|
||||
@@ -29,28 +32,22 @@ impl<U: RegisterNum> Register<U> {
|
||||
pub fn set_reg(&mut self, position: u8, value: U) {
|
||||
if position != 0 { self.register[position as usize] = value; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
impl Register<i64> {
|
||||
|
||||
/// i64 register constructor
|
||||
pub fn init() -> Register<i64> {
|
||||
Register {
|
||||
register: [0i64; NUM_INT_REGS]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Register<f32> {
|
||||
|
||||
/// f32 register constructor
|
||||
pub fn init() -> Register<f32> {
|
||||
Register {
|
||||
register: [0f32; NUM_FP_REGS]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user