Implement JALR, fix JAL, change how some stuff in instructions.rs is expressed

This commit is contained in:
2025-12-21 19:36:25 +01:00
parent 944ed573c6
commit 6c39a5eef2
2 changed files with 13 additions and 10 deletions

View File

@@ -117,15 +117,21 @@ pub fn lui(core: &mut Core, instr: Instruction) -> InstructionResult {
InstructionResult::Normal
}
pub fn auipc(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), core.pc.wrapping_add(instr.imm_u()));
core.advance_pc();
InstructionResult::Normal
}
pub fn jal(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), core.pc);
core.reg_write(instr.rd(), core.pc.wrapping_add(4));
core.pc = core.pc.wrapping_add(instr.imm_j());
InstructionResult::Normal
}
pub fn auipc(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), core.pc.wrapping_add(instr.imm_u()));
core.advance_pc();
pub fn jalr(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), core.pc.wrapping_add(4));
core.pc = core.reg_read(instr.rs1()).wrapping_add(instr.imm_i());
InstructionResult::Normal
}