Compare commits

..

2 Commits

Author SHA1 Message Date
Mwa
4e23ac7bff Merge branch 'main' of ssh://gitea.jthillard.fr:222/mwa/bisare_sim_rs 2026-03-16 18:12:03 +01:00
Mwa
cd2e5319bc minor bugfixes 2026-03-16 18:10:43 +01:00
3 changed files with 12 additions and 3 deletions

View File

@@ -579,6 +579,10 @@ fn process_line(prgm: &mut Program, (linenum, line): (usize, String), rgx: &Rege
chk(2); chk(2);
Instruction::Xor(reg(0), reg(1), Op2::Direct(-1)) Instruction::Xor(reg(0), reg(1), Op2::Direct(-1))
} }
"swi" => {
chk(0);
Instruction::Swi()
}
"let" => { "let" => {
chk(2); chk(2);
let r = reg(0); let r = reg(0);

View File

@@ -281,7 +281,7 @@ impl Display for Cond {
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
pub(crate) fn instr_to_text(i: u32, a: u32, book: &HashMap<u32, String>) -> String { pub(crate) fn instr_to_text(i: u32, a: u32, book: &HashMap<u32, String>) -> String {
let addr = |addr: u32| { let addr = |addr: u32| {
let real = a.wrapping_add(addr * 4); let real = a.wrapping_add(addr * 4) % 0x8000_0000;
match book.get(&real) { match book.get(&real) {
Some(s) => s.clone(), Some(s) => s.clone(),
None => format!("{addr}"), None => format!("{addr}"),
@@ -722,6 +722,7 @@ impl Computer {
if N >= 16 { if N >= 16 {
panic!(); panic!();
} }
#[cfg(feature = "debug")]
println!("serving interupt {kind:?} {arg:?}"); println!("serving interupt {kind:?} {arg:?}");
match self.interupts { match self.interupts {
InteruptState::Disabled => { InteruptState::Disabled => {

View File

@@ -323,7 +323,11 @@ fn main() -> Result<(), Error> {
simulation.regs[i + 1] simulation.regs[i + 1]
); );
} }
println!("SP: {:08x} PC: {:08x}", simulation.sp, simulation.pc); println!(
"SP: {:08x} PC: {:08x}",
simulation.sp * 4,
simulation.pc * 4
);
println!("RAM near SP"); println!("RAM near SP");
let min_pc = (simulation.pc).min(0x0100_0000 / 4 - 8); let min_pc = (simulation.pc).min(0x0100_0000 / 4 - 8);
let min_sp = (simulation.sp).min(0x0100_0000 / 4 - 8); let min_sp = (simulation.sp).min(0x0100_0000 / 4 - 8);