finished initial interrupts implementation

This commit is contained in:
2025-06-25 00:13:55 +01:00
parent 92c4660a4d
commit 82b99c127c
5 changed files with 54 additions and 18 deletions
+3 -1
View File
@@ -10,7 +10,9 @@ pub enum Interrupt {
pub type Address = u32;
impl Interrupt {
const fn as_u8(self) -> u8 {
// someone tell clippy to stfu.
#[allow(clippy::must_use_candidate)]
pub const fn as_u8(self) -> u8 {
match self {
Self::Breakpoint => 0,
Self::HardFault => 1,
+5 -3
View File
@@ -54,12 +54,14 @@ impl Encode for Instruction {
],
no_args: [Nop, IntReturn, Halt],
special: [
Self::Interrupt(_) => todo!(),
Self::Data(data) => data,
Self::Interrupt(interrupt) => {
let opcode = u32::from(self.opcode());
(opcode << 26) | u32::from(interrupt.as_u8())
},
Self::Segment(segment) => {
let opcode = u32::from(self.opcode());
let segment = segment as u8;
(opcode << 26) | u32::from(segment)
(opcode << 26) | u32::from(segment as u8)
}
]
)