diff --git a/src/main.rs b/src/main.rs index b6e4188..4960222 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,9 @@ struct Args { /// Just run the CPU instad of starting a REPL #[clap(short, long)] run: bool, + /// If not using a REPL, print the state of the CPU on halt + #[clap(short, long, requires("run"))] + print_state: bool, } fn main() -> Result<(), anyhow::Error> { @@ -91,7 +94,9 @@ fn main() -> Result<(), anyhow::Error> { while !state.cpu.stopped { state.cpu.step(); } - println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu); + if args.print_state { + println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu); + } return Ok(()); } Repl::<_, anyhow::Error>::new(state)