Interuptions

This commit is contained in:
Mwa
2026-03-15 23:32:13 +01:00
parent aead858727
commit c38bb22e88
6 changed files with 575 additions and 195 deletions

View File

@@ -126,6 +126,10 @@ enum Instruction {
Jump(Labeli32), //address / 4
Call(Labeli32), //address / 4
Ret(),
Reti(),
Swi(),
Dint(),
Eint(),
GetStack(Reg),
SetStack(Op2),
Data(Labeli32),
@@ -173,13 +177,9 @@ impl Instruction {
Labeli17::LabelLow(l) => {
encode_imm(1, 1, reg.into(), reg1.into(), (prgm[l] & 0xFFFF) as i32)
}
Labeli17::LabelHigh(l) => encode_imm(
1,
1,
reg.into(),
reg1.into(),
(prgm[l] as u32 >> 16) as i32,
),
Labeli17::LabelHigh(l) => {
encode_imm(1, 1, reg.into(), reg1.into(), (prgm[l] as u32 >> 16) as i32)
}
},
Instruction::Sub(reg, reg1, op2) => encode_op2(01, 2, reg.into(), reg1.into(), *op2),
Instruction::Or(reg, reg1, op2) => encode_op2(01, 3, reg.into(), reg1.into(), *op2),
@@ -233,6 +233,10 @@ impl Instruction {
(dest & 0x1FFF_FFFF) | (1 << 29)
}
Instruction::Ret() => encode_reg(2, 0b1000, 0, 0, 0),
Instruction::Reti() => encode_reg(2, 0b1000, 0, 0, 0) | 1 << 29,
Instruction::Swi() => encode_reg(2, 0b1001, 0, 0, 0),
Instruction::Dint() => encode_reg(2, 0b1011, 0, 0, 0),
Instruction::Eint() => encode_reg(2, 0b1100, 0, 0, 0),
Instruction::GetStack(reg) => encode_reg(2, 0b1101, reg.into(), 0, 0),
Instruction::SetStack(op2) => encode_op2(2, 0b1110, 0, 0, *op2),
Instruction::Data(labeli32) => match labeli32 {
@@ -361,6 +365,7 @@ struct RegexCollection {
}
fn process_line(prgm: &mut Program, (linenum, line): (usize, String), rgx: &RegexCollection) {
let linenum = linenum + 1;
let mut no_comment = line.split(';').next().unwrap_or("");
let binding = no_comment.to_ascii_lowercase();
no_comment = binding.as_str();
@@ -550,6 +555,18 @@ fn process_line(prgm: &mut Program, (linenum, line): (usize, String), rgx: &Rege
chk(0);
Instruction::Ret()
}
"reti" => {
chk(0);
Instruction::Reti()
}
"eint" => {
chk(0);
Instruction::Eint()
}
"dint" => {
chk(0);
Instruction::Dint()
}
"halt" => {
chk(0);
Instruction::Jump(Labeli32::Value(0))