diff options
| author | taitep <taitep@taitep.se> | 2025-12-21 14:00:47 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2025-12-21 14:00:47 +0100 |
| commit | d03863f5a211809db49da118f7e0d754abc65e51 (patch) | |
| tree | cd453f114fbc7e9292c7253981b1b1a7679cad3e /src/instructions | |
| parent | 87e6d03dbd6498b06c9d4ec477d3be37b2b99686 (diff) | |
Implement SLLI and fix sign extension of immediates for I-type and S-type instructions
Diffstat (limited to 'src/instructions')
| -rw-r--r-- | src/instructions/rvi.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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 +} |
