Implement JALR, fix JAL, change how some stuff in instructions.rs is expressed
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user