From d03863f5a211809db49da118f7e0d754abc65e51 Mon Sep 17 00:00:00 2001 From: taitep Date: Sun, 21 Dec 2025 14:00:47 +0100 Subject: Implement SLLI and fix sign extension of immediates for I-type and S-type instructions --- src/instructions/rvi.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/instructions') diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index 2d342df..2eb48f9 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -64,3 +64,18 @@ pub fn jal(core: &mut Core, instr: Instruction) -> InstructionResult { core.pc = core.pc.wrapping_add(instr.imm_j()); InstructionResult::Normal } + +pub fn slli(core: &mut Core, instr: Instruction) -> InstructionResult { + core.reg_write(instr.rd(), core.reg_read(instr.rs1()) << instr.imm_shamt()); + + eprintln!( + "slli x{}, x{}, {}", + instr.rd(), + instr.rs1(), + instr.imm_shamt() + ); + + core.pc = core.pc.wrapping_add(4); + + InstructionResult::Normal +} -- cgit v1.2.3