2023-05-22 09:01:13 -05:00
|
|
|
use hbvm::{
|
2023-05-25 07:51:40 -05:00
|
|
|
bytecode::ops::{Operations::*, RWSubTypes::*},
|
2023-05-06 07:33:40 -05:00
|
|
|
engine::Engine,
|
2023-04-22 13:00:19 -05:00
|
|
|
RuntimeErrors,
|
|
|
|
};
|
2023-04-18 18:08:30 -05:00
|
|
|
|
|
|
|
fn main() -> Result<(), RuntimeErrors> {
|
2023-05-23 02:29:31 -05:00
|
|
|
// TODO: Grab program from cmdline
|
2023-04-22 17:17:49 -05:00
|
|
|
#[rustfmt::skip]
|
|
|
|
let prog: Vec<u8> = vec![
|
2023-05-25 07:51:40 -05:00
|
|
|
NOP as u8,
|
2023-05-23 02:29:31 -05:00
|
|
|
JUMP as u8, 0, 0, 0, 0, 0, 0, 0, 0,
|
2023-04-22 17:17:49 -05:00
|
|
|
];
|
2023-04-22 16:06:33 -05:00
|
|
|
|
2023-04-22 17:17:49 -05:00
|
|
|
let mut eng = Engine::new(prog);
|
|
|
|
// eng.set_timer_callback(time);
|
2023-05-22 22:47:29 -05:00
|
|
|
eng.enviroment_call_table[10] = Some(print_fn);
|
2023-05-06 07:33:40 -05:00
|
|
|
eng.run()?;
|
|
|
|
eng.dump();
|
2023-05-09 03:36:37 -05:00
|
|
|
println!("{:#?}", eng.registers);
|
2023-04-22 16:06:33 -05:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn time() -> u32 {
|
|
|
|
9
|
|
|
|
}
|
2023-05-06 07:33:40 -05:00
|
|
|
pub fn print_fn(engine: &mut Engine) -> Result<&mut Engine, u64> {
|
|
|
|
println!("hello");
|
|
|
|
Ok(engine)
|
2023-04-18 18:08:30 -05:00
|
|
|
}
|