minor bugfixes

This commit is contained in:
Mwa
2026-03-16 18:10:43 +01:00
parent 636ff0a430
commit cd2e5319bc
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);
Instruction::Xor(reg(0), reg(1), Op2::Direct(-1))
}
"swi" => {
chk(0);
Instruction::Swi()
}
"let" => {
chk(2);
let r = reg(0);

View File

@@ -281,7 +281,7 @@ impl Display for Cond {
#[cfg(feature = "debug")]
pub(crate) fn instr_to_text(i: u32, a: u32, book: &HashMap<u32, String>) -> 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 => {

View File

@@ -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::<u32>(next[1]) {
Ok(i) => {
let v = simulation.ram[i as usize/4];
let v = simulation.ram[i as usize / 4];
println!(
"0x{:8x} -- {}",
v,