Spaces:
Sleeping
Sleeping
Create src/registers.rs
Browse files- src/registers.rs +18 -0
src/registers.rs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#[derive(Debug, Clone)]
|
| 2 |
+
pub struct Registers {
|
| 3 |
+
pub r: [i64; 16],
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
impl Registers {
|
| 7 |
+
pub fn new() -> Self {
|
| 8 |
+
Self { r: [0; 16] }
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
pub fn get(&self, idx: usize) -> i64 {
|
| 12 |
+
self.r[idx]
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
pub fn set(&mut self, idx: usize, val: i64) {
|
| 16 |
+
self.r[idx] = val;
|
| 17 |
+
}
|
| 18 |
+
}
|