From 98f2b5e554a249826e7eda6529066145d05d14d8 Mon Sep 17 00:00:00 2001 From: Michael <20937441+KMikeeU@users.noreply.github.com> Date: Wed, 13 May 2026 16:46:25 +0200 Subject: [PATCH] feat: add custom b-type instruction (jump) --- src/tinyriscv.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tinyriscv.h b/src/tinyriscv.h index b25ed85..0bd5767 100644 --- a/src/tinyriscv.h +++ b/src/tinyriscv.h @@ -98,6 +98,18 @@ inline void tinyriscv_custom_I_type(const u8 funct3, const u8 funct7, u32* x, } } + +//////////////////////////////////////////////////////////////////////////////// + +__attribute__((always_inline)) +inline void tinyriscv_custom_B_type(const u8 funct3, const u32* x, u32* pc, + const u8 rs1, const u8 rs2, const i16 imm){ + + switch(funct3){ + case /*CUSTOM bitcomp*/ 0: if((x[rs1] ^ 0x7C) != x[rs2]) *pc += (i32)imm - 4; break; + } +} + //////////////////////////////////////////////////////////////////////////////// __attribute__((always_inline)) @@ -213,6 +225,9 @@ void tinyriscv_step(tinyriscv_core* core){ case /*Custom-I-type*/ 0x0B: tinyriscv_custom_I_type(funct3, funct7, core->x, rd, rs1, imm_i, rs2); break; + case /*Custom-I-type*/ 0x2B: + tinyriscv_custom_B_type(funct3, core->x, &core->pc, rs1, rs2, imm_b); + break; case /*R-type*/ 0x33: tinyriscv_R_type(funct3, funct7, core->x, rd, rs1, rs2); break;