From 7177633477f1b9851a949c2c7b005185c3925b23 Mon Sep 17 00:00:00 2001 From: taitep Date: Mon, 22 Dec 2025 18:00:15 +0100 Subject: [PATCH] WHY WAS I USING S-TYPE IMMEDIATE IN LD (also add some more debugging info on an exception) --- src/core.rs | 1 + src/instructions/rvi.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.rs b/src/core.rs index ce704fb..08f029b 100644 --- a/src/core.rs +++ b/src/core.rs @@ -64,6 +64,7 @@ impl Core { InstructionResult::Normal => {} InstructionResult::Exception(_e) => { eprintln!("Exception from instruction"); + eprintln!("PC: {:016X}, instr: {:08X}", self.pc, instr.0); break; } InstructionResult::Pause => { diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index f182e88..0920e80 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -62,7 +62,7 @@ pub fn sd(core: &mut Core, instr: Instruction) -> InstructionResult { } pub fn ld(core: &mut Core, instr: Instruction) -> InstructionResult { - let addr = core.reg_read(instr.rs1()).wrapping_add(instr.imm_s()); + let addr = core.reg_read(instr.rs1()).wrapping_add(instr.imm_i()); if !addr.is_multiple_of(std::mem::size_of::() as Addr) { return InstructionResult::Exception(());