diff options
| author | taitep <taitep@taitep.se> | 2025-12-22 21:17:38 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2025-12-22 21:17:38 +0100 |
| commit | 2b5eb96187c8aa67b5d43abf1917e7158620f2f8 (patch) | |
| tree | 7eeb55b490da96d61759cfe4c266ba546843562d /src | |
| parent | be1b1b9fe6db7d72609596f220a287e5a944196b (diff) | |
Implement BLTU
Diffstat (limited to 'src')
| -rw-r--r-- | src/instructions.rs | 1 | ||||
| -rw-r--r-- | src/instructions/rvi.rs | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/instructions.rs b/src/instructions.rs index c184065..4a7a627 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -52,6 +52,7 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Option<Instr // BRANCH 0b000 => Some(rvi::beq(core, instr)), 0b001 => Some(rvi::bne(core, instr)), + 0b110 => Some(rvi::bltu(core, instr)), 0b111 => Some(rvi::bgeu(core, instr)), _ => None, }, diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index 6f7dfd2..7d57ce6 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -132,3 +132,13 @@ pub fn bgeu(core: &mut Core, instr: Instruction) -> InstructionResult { InstructionResult::Normal } + +pub fn bltu(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 +} |
