Implement SLLI and fix sign extension of immediates for I-type and S-type instructions

This commit is contained in:
2025-12-21 14:00:47 +01:00
parent 87e6d03dbd
commit d03863f5a2
3 changed files with 24 additions and 4 deletions

View File

@@ -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
}