From dd47bf7bdff7c436876cca6d19b55d7c02c3f320 Mon Sep 17 00:00:00 2001 From: Jacob Urbanczyk Date: Sun, 31 Mar 2024 17:19:32 +0200 Subject: [PATCH] fix --- test/test_core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 3014bda44..7f98639c7 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -74,6 +74,10 @@ def push_instr(self, opcode): def push_register_load_imm(self, reg_id, val): addi_imm = signed_to_int(val & 0xFFF, 12) + lui_imm = (val & 0xFFFFF000) >> 12 + # handle addi sign extension, see: https://stackoverflow.com/a/59546567 + if val & 0x800: + lui_imm = (lui_imm + 1) & (0xFFFFF) yield from self.push_instr(UTypeInstr(opcode=Opcode.LUI, rd=reg_id, imm=lui_imm << 12).encode()) yield from self.push_instr(