I’m working on a RISC-V CPU emulator and have all instructions implemented. The thing is that I’m not sure if the jumps are failing. This is the current implementation I have for BGEU to make an example:
void CPU::BGEU() {
uint8_t rs1 = instDecoded.registers[0];
uint8_t rs2 = instDecoded.registers[1];
uint32_t inmediate = instDecoded.inmediate;
if (static_cast<uint32_t>(registers[rs1]) >= static_cast<uint32_t>(registers[rs2]))
pc += inmediate;
}
I have another method called “clock” which executes the instruction and then add 4 to PC, but I don’t know if after a jump I should add 4.
1