From e65775774ad23c9aee5b62be26b8016ca8bd2e91 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sun, 5 Dec 2021 16:45:06 +0100 Subject: [PATCH] extended userspace RV32I with li, la and mv instruction --- riscemu/instructions/RV32I.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/riscemu/instructions/RV32I.py b/riscemu/instructions/RV32I.py index d8681d0..dcefb07 100644 --- a/riscemu/instructions/RV32I.py +++ b/riscemu/instructions/RV32I.py @@ -310,3 +310,22 @@ class RV32I(InstructionSet): def instruction_nop(self, ins: 'LoadedInstruction'): ASSERT_LEN(ins.args, 0) pass + + def instruction_li(self, ins: 'LoadedInstruction'): + ASSERT_LEN(ins.args, 2) + reg = ins.get_reg(0) + immediate = ins.get_imm(1) + self.regs.set(reg, immediate) + + def instruction_la(self, ins: 'LoadedInstruction'): + ASSERT_LEN(ins.args, 2) + reg = ins.get_reg(0) + immediate = ins.get_imm(1) + self.regs.set(reg, immediate) + + def instruction_mv(self, ins: 'LoadedInstruction'): + ASSERT_LEN(ins.args, 2) + rd, rs = ins.get_reg(0), ins.get_reg(1) + self.regs.set(rd, self.regs.get(rs)) + +