Implement AUIPC
This commit is contained in:
@@ -48,6 +48,7 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Option<Instr
|
|||||||
},
|
},
|
||||||
0b01101 => Some(rvi::lui(core, instr)),
|
0b01101 => Some(rvi::lui(core, instr)),
|
||||||
0b11011 => Some(rvi::jal(core, instr)),
|
0b11011 => Some(rvi::jal(core, instr)),
|
||||||
|
0b00101 => Some(rvi::auipc(core, instr)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ pub fn jal(core: &mut Core, instr: Instruction) -> InstructionResult {
|
|||||||
InstructionResult::Normal
|
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 beq(core: &mut Core, instr: Instruction) -> InstructionResult {
|
pub fn beq(core: &mut Core, instr: Instruction) -> InstructionResult {
|
||||||
if core.reg_read(instr.rs1()) == core.reg_read(instr.rs2()) {
|
if core.reg_read(instr.rs1()) == core.reg_read(instr.rs2()) {
|
||||||
core.pc = core.pc.wrapping_add(instr.imm_b());
|
core.pc = core.pc.wrapping_add(instr.imm_b());
|
||||||
|
|||||||
Reference in New Issue
Block a user