mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-13 05:13:10 +00:00
Improved syscall handling.
This commit is contained in:
@@ -207,9 +207,8 @@ impl Executable for Inst {
|
||||
Inst::Mult (inst) => inst.exec(state),
|
||||
Inst::Shift(inst) => inst.exec(state),
|
||||
Inst::Store(inst) => inst.exec(state),
|
||||
//Inst::Sys (inst) => inst.exec(state),
|
||||
//Inst::Co (inst) => inst.exec(state),
|
||||
_ => todo!(),
|
||||
Inst::Sys (inst) => inst.exec(state),
|
||||
Inst::Co (_) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use super::ModifiesReg;
|
||||
use crate::inst::{
|
||||
basic::{Decode, TryEncode},
|
||||
exec::{ExecCtx, ExecError, Executable},
|
||||
parse::LineArg,
|
||||
DisplayCtx, InstDisplay, InstFmtArg, Parsable, ParseCtx, ParseError, Register,
|
||||
};
|
||||
@@ -121,3 +122,9 @@ impl ModifiesReg for Inst {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Executable for Inst {
|
||||
fn exec<Ctx: ExecCtx>(&self, state: &mut Ctx) -> Result<(), ExecError> {
|
||||
state.sys(*self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ pub mod error;
|
||||
pub use error::ExecError;
|
||||
|
||||
// Imports
|
||||
use super::basic;
|
||||
use crate::{
|
||||
inst::{basic::mult::MultReg, Register},
|
||||
Pos,
|
||||
@@ -40,6 +41,9 @@ pub trait ExecCtx:
|
||||
|
||||
/// Writes a byte
|
||||
fn write_byte(&mut self, pos: Pos, value: u8) -> Result<(), ExecError>;
|
||||
|
||||
/// Executes a syscall
|
||||
fn sys(&mut self, inst: basic::sys::Inst) -> Result<(), ExecError>;
|
||||
}
|
||||
|
||||
/// An executable instruction
|
||||
|
||||
@@ -33,6 +33,9 @@ pub enum ExecError {
|
||||
JumpWhileJumping,
|
||||
|
||||
/// Unknown syscall
|
||||
#[error("Unknown syscall")]
|
||||
UnknownSys,
|
||||
#[error("Unknown syscall {comment:#x}")]
|
||||
UnknownSys {
|
||||
/// Syscall comment
|
||||
comment: u32,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user