holey-bytes/hbvm/src/main.rs

27 lines
577 B
Rust
Raw Normal View History

2023-06-08 16:23:23 -05:00
use {
hbvm::{validate::validate, vm::Vm, RuntimeErrors},
std::io::{stdin, Read},
};
2023-04-18 18:08:30 -05:00
2023-06-07 17:52:24 -05:00
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut prog = vec![];
stdin().read_to_end(&mut prog)?;
2023-04-22 16:06:33 -05:00
2023-06-07 17:52:24 -05:00
if let Err(e) = validate(&prog) {
2023-06-06 15:56:28 -05:00
eprintln!("Program validation error: {e:?}");
return Ok(());
} else {
unsafe {
2023-06-07 17:52:24 -05:00
let mut vm = Vm::new_unchecked(&prog);
2023-06-07 17:25:38 -05:00
vm.memory.insert_test_page();
2023-06-06 15:56:28 -05:00
vm.run();
2023-06-07 17:52:24 -05:00
println!("{:?}", vm.registers);
2023-06-06 15:56:28 -05:00
}
}
2023-04-22 16:06:33 -05:00
Ok(())
}
pub fn time() -> u32 {
9
}