From 8ce7e3f8c6739b94d70a85cac85c257a47e80ce0 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Mon, 22 May 2023 22:52:17 +0100 Subject: [PATCH] fix jalr instruction to take arguments in the form of rd, rs, imm --- riscemu/instructions/RV32I.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/riscemu/instructions/RV32I.py b/riscemu/instructions/RV32I.py index a2cced2..1944279 100644 --- a/riscemu/instructions/RV32I.py +++ b/riscemu/instructions/RV32I.py @@ -269,9 +269,10 @@ class RV32I(InstructionSet): def instruction_jalr(self, ins: 'Instruction'): ASSERT_LEN(ins.args, 2) reg = ins.get_reg(0) - addr = ins.get_imm(1) + base = ins.get_reg(1) + addr = ins.get_imm(2) self.regs.set(reg, Int32(self.pc)) - self.pc = addr + self.pc = self.regs.get(base).unsigned_value + addr def instruction_ret(self, ins: 'Instruction'): ASSERT_LEN(ins.args, 0)