implement error type and new ideas
This commit is contained in:
@@ -5,7 +5,10 @@ use crate::{
|
||||
mem::Memory,
|
||||
registers::Registers,
|
||||
},
|
||||
utils::access::is_address_error,
|
||||
utils::{
|
||||
access::is_address_error,
|
||||
error::{Error, Severity, Type::UnhandledInstruction},
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Interpreter {
|
||||
@@ -59,16 +62,21 @@ impl Cpu for Interpreter {
|
||||
Some(instr)
|
||||
}
|
||||
|
||||
fn execute(&mut self, mem: &Memory) -> Result<u32, String> {
|
||||
fn step(&mut self, mem: &Memory) -> Result<u32, Error> {
|
||||
if let Some(instr) = self.fetch_then_advance(mem) {
|
||||
self.decode(instr)?;
|
||||
self.decode_execute(instr)?;
|
||||
}
|
||||
|
||||
Ok(1)
|
||||
}
|
||||
|
||||
fn decode(&mut self, instr: Instruction) -> Result<(), String> {
|
||||
todo!("decode")
|
||||
fn decode_execute(&mut self, instr: Instruction) -> Result<(), Error> {
|
||||
match instr.opcode() {
|
||||
_ => Err(Error {
|
||||
severity: Severity::Error,
|
||||
err_type: UnhandledInstruction(instr),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user