Change run to not disassemble instruction when cpu is stopped and show stopped status

This commit is contained in:
pjht 2023-03-23 10:34:01 -05:00
parent 9cdbe2e071
commit cdb0f1d8d7
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -88,7 +88,6 @@ fn main() -> Result<(), anyhow::Error> {
last_peek_format: (peek::Format::Hex, peek::Size::Byte),
};
if args.run {
let mut out = String::new();
while !state.cpu.stopped {
match state.cpu.step() {
Ok(()) => (),
@ -98,11 +97,7 @@ fn main() -> Result<(), anyhow::Error> {
}
}
}
out += &format!("{}\n", state.cpu);
let pc = state.cpu.pc();
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
out.pop(); // Remove trailing newline
println!("{out}");
println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu);
return Ok(());
}
Repl::<_, anyhow::Error>::new(state)
@ -239,9 +234,14 @@ fn main() -> Result<(), anyhow::Error> {
}
}
}
if state.cpu.stopped {
out += &format!("CPU stopped at PC {:#x}\n", state.cpu.pc());
}
out += &format!("{}\n", state.cpu);
if !state.cpu.stopped {
let pc = state.cpu.pc();
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
}
out.pop(); // Remove trailing newline
Ok(Some(out))
},