From cd2e5319bc503dd24c83b1a081ee1377685b3b28 Mon Sep 17 00:00:00 2001 From: Mwa Date: Mon, 16 Mar 2026 18:10:43 +0100 Subject: [PATCH] minor bugfixes --- asm/src/main.rs | 4 ++++ simu/src/cpu.rs | 3 ++- simu/src/main.rs | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/asm/src/main.rs b/asm/src/main.rs index 3b74036..ae05df7 100644 --- a/asm/src/main.rs +++ b/asm/src/main.rs @@ -579,6 +579,10 @@ fn process_line(prgm: &mut Program, (linenum, line): (usize, String), rgx: &Rege chk(2); Instruction::Xor(reg(0), reg(1), Op2::Direct(-1)) } + "swi" => { + chk(0); + Instruction::Swi() + } "let" => { chk(2); let r = reg(0); diff --git a/simu/src/cpu.rs b/simu/src/cpu.rs index ea7ce2f..4371d27 100644 --- a/simu/src/cpu.rs +++ b/simu/src/cpu.rs @@ -281,7 +281,7 @@ impl Display for Cond { #[cfg(feature = "debug")] pub(crate) fn instr_to_text(i: u32, a: u32, book: &HashMap) -> String { let addr = |addr: u32| { - let real = a.wrapping_add(addr * 4); + let real = a.wrapping_add(addr * 4) % 0x8000_0000; match book.get(&real) { Some(s) => s.clone(), None => format!("{addr}"), @@ -722,6 +722,7 @@ impl Computer { if N >= 16 { panic!(); } + #[cfg(feature = "debug")] println!("serving interupt {kind:?} {arg:?}"); match self.interupts { InteruptState::Disabled => { diff --git a/simu/src/main.rs b/simu/src/main.rs index e711ed7..ba40140 100644 --- a/simu/src/main.rs +++ b/simu/src/main.rs @@ -323,7 +323,11 @@ fn main() -> Result<(), Error> { 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"); let min_pc = (simulation.pc).min(0x0100_0000 / 4 - 8); let min_sp = (simulation.sp).min(0x0100_0000 / 4 - 8); @@ -381,7 +385,7 @@ fn main() -> Result<(), Error> { if next.len() >= 2 { match parse_int::parse::(next[1]) { Ok(i) => { - let v = simulation.ram[i as usize/4]; + let v = simulation.ram[i as usize / 4]; println!( "0x{:8x} -- {}", v,