Implement BGEU

This commit is contained in:
2025-12-22 20:08:16 +01:00
parent ae57cdc691
commit 5cbaf2dc66
2 changed files with 11 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Option<Instr
// BRANCH // BRANCH
0b000 => Some(rvi::beq(core, instr)), 0b000 => Some(rvi::beq(core, instr)),
0b001 => Some(rvi::bne(core, instr)), 0b001 => Some(rvi::bne(core, instr)),
0b111 => Some(rvi::bgeu(core, instr)),
_ => None, _ => None,
}, },
0b01101 => Some(rvi::lui(core, instr)), 0b01101 => Some(rvi::lui(core, instr)),

View File

@@ -122,3 +122,13 @@ pub fn bne(core: &mut Core, instr: Instruction) -> InstructionResult {
InstructionResult::Normal InstructionResult::Normal
} }
pub fn bgeu(core: &mut Core, instr: Instruction) -> InstructionResult {
if core.reg_read(instr.rs1()) >= core.reg_read(instr.rs2()) {
core.pc = core.pc.wrapping_add(instr.imm_b());
} else {
core.advance_pc();
}
InstructionResult::Normal
}