summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 20dde55..bb1d735 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,10 +5,12 @@ pub mod state;
use crate::core::*;
use crate::mem::Memory;
use crate::state::CpuState;
+use std::io::Write;
const MEMORY_SIZE: usize = 64 * 1024 * 1024;
const REGISTER_NAME_WIDTH: u32 = 0b11111;
const RO_TARGET: u32 = 0x80000000;
+const WDT_LOCATION: u32 = 0x90000000;
const UART_ADDR: u32 = 0x10000000;
fn main() {
@@ -23,9 +25,23 @@ fn main() {
.memory
.write_multiple_bytes(RO_TARGET as usize, f_dat.as_slice(), 99)
.unwrap();
+ state
+ .memory
+ .write_multiple_bytes(WDT_LOCATION as usize, &[
+ 65, 65, 103, 103, //0x67674141
+ 1, 0, 0, 0, // 1 (n_devices)
+ 0, 0, 0, 0, // 0 (device type, free RAM)
+ 0, 0, 0, 0, // 0 (free RAM, no driver)
+ 0, 0, 0, 16, // 0x10000000 (start addr)
+ 0, 0, 0, 3 // 48 MB (size)
+ ], 99)
+ .unwrap();
+
state.memory.write(UART_ADDR as usize, 99, 0).unwrap();
state.pc = RO_TARGET;
+ state.registers[10] = WDT_LOCATION;
+
loop {
{
handle_instruction(&mut state);
@@ -36,6 +52,9 @@ fn main() {
print!("{}", uart_byte as char);
}
state.memory.write(UART_ADDR as usize, 99, 0).unwrap();
+ std::io::stdout().flush().unwrap();
+
+ state.registers[0] = 0;
}
}
}
@@ -221,7 +240,6 @@ fn handle_instruction(state: &mut CpuState) {
_ => panic!("Illegal instruction: {:x}", word),
}
-
} // ecall (ebreak not implemented)
0b0101111 => {
let f5 = word >> 27;