mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-06-03 01:50:18 +00:00
Added better error-reporting to the emulator.
This commit is contained in:
parent
ed7ca9a227
commit
890c2b7b79
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1813,7 +1813,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "svc16"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "svc16"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
edition = "2021"
|
||||
authors = ["Jan Neuendorf"]
|
||||
description = "An emulator for a simple virtual computer"
|
||||
|
@ -36,8 +36,8 @@ pub enum EngineError {
|
||||
#[error("Division by zero")]
|
||||
ZeroDivision,
|
||||
|
||||
#[error("Invalid instruction")]
|
||||
InvalidInstruction,
|
||||
#[error("Invalid instruction {0}")]
|
||||
InvalidInstruction(u16),
|
||||
}
|
||||
|
||||
impl Engine {
|
||||
@ -216,7 +216,7 @@ impl Engine {
|
||||
}
|
||||
self.advance_inst_ptr();
|
||||
}
|
||||
_ => return Err(EngineError::InvalidInstruction),
|
||||
_ => return Err(EngineError::InvalidInstruction(opcode)),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -87,8 +87,11 @@ fn main() -> Result<()> {
|
||||
let engine_start = Instant::now();
|
||||
while !engine.wants_to_sync() && ipf <= cli.max_ipf && !paused {
|
||||
match engine.step() {
|
||||
Err(_) => {
|
||||
handle_event_loop_error(&elwt, "Invalid operation");
|
||||
Err(e) => {
|
||||
handle_event_loop_error(
|
||||
&elwt,
|
||||
format!("{} (after {} instructions)", e, ipf),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user