Website Summary Files Commits Branches @commit @diff @stats
path: root / vm / src / main.rs
blob: bfd35ec24d3a4e87ae6038a6c604e80ee6fd42c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mod vm;
mod vmm;

use clap::Parser;

use vm::{ VirtualMachine, VirtualMachineInterface };
use vmm::VirtualMachineMonitor;

#[derive(Parser, Debug)]
#[command(about, long_about = None)]
struct Args {
    /// Path to assembled binary
    binary_path: Option<String>,

    /// Time between each instruction execution
    #[arg(short, long, default_value_t = 2)]
    tick_gap: u64,

    /// How often the command-line updates
    #[arg(short, long, default_value_t = 200)]
    refresh: u64,
}

fn main() {
    let args = Args::parse();

    let vm = if let Some(path) = &args.binary_path {
            VirtualMachine::create_from_file(args.tick_gap, path)
        } else {
            VirtualMachine::create(args.tick_gap)
        };
    vm.spawn();

    let mut monitor = VirtualMachineMonitor::new(args.refresh);
    monitor.start(vm);
}