From 5cbaf2dc66f6d2c48a6b319506e921d6aa6aef9d Mon Sep 17 00:00:00 2001 From: taitep Date: Mon, 22 Dec 2025 20:08:16 +0100 Subject: [PATCH] Implement BGEU --- src/instructions.rs | 1 + src/instructions/rvi.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/instructions.rs b/src/instructions.rs index c5519f8..271edd4 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -51,6 +51,7 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Option Some(rvi::beq(core, instr)), 0b001 => Some(rvi::bne(core, instr)), + 0b111 => Some(rvi::bgeu(core, instr)), _ => None, }, 0b01101 => Some(rvi::lui(core, instr)), diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index ea1c40d..6f7dfd2 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -122,3 +122,13 @@ pub fn bne(core: &mut Core, instr: Instruction) -> InstructionResult { 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 +}