forked from AbleOS/holey-bytes
VM exceptions
This commit is contained in:
parent
859e14daa6
commit
fce7a96e50
|
@ -36,7 +36,7 @@ macro_rules! load {
|
||||||
*$self.reg_mut(tg) = $self
|
*$self.reg_mut(tg) = $self
|
||||||
.memory
|
.memory
|
||||||
.load::<$size>($self.reg(a0).int() + offset)
|
.load::<$size>($self.reg(a0).int() + offset)
|
||||||
.unwrap();
|
.ok_or(Exception::LoadAccess)?;
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ macro_rules! store {
|
||||||
$self
|
$self
|
||||||
.memory
|
.memory
|
||||||
.store::<$size>($self.reg(a0).int() + offset, *$self.reg(src))
|
.store::<$size>($self.reg(a0).int() + offset, *$self.reg(src))
|
||||||
.unwrap();
|
.map_err(|_| Exception::StoreAccess)?;
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ impl<'a> Vm<'a> {
|
||||||
Ok(unsafe { Self::new_unchecked(program) })
|
Ok(unsafe { Self::new_unchecked(program) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) -> Result<(), Exception> {
|
||||||
use hbbytecode::opcode::*;
|
use hbbytecode::opcode::*;
|
||||||
loop {
|
loop {
|
||||||
let Some(&opcode) = self.program.get(self.pc)
|
let Some(&opcode) = self.program.get(self.pc)
|
||||||
else { return };
|
else { return Ok(()) };
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
match opcode {
|
match opcode {
|
||||||
|
|
Loading…
Reference in a new issue