PC-relative Branch Range
Conditional branches use the B-type immediate, a signed PC-relative offset in 2-byte units, giving an approximate reach of +/-4 KiB from the current PC.
RISC-V Unprivileged ISA, RV32I control transfer instructionsBranch if rs1 is greater than or equal to rs2 (unsigned comparison)
BGEU uses opcode 1100011 (0x63), funct3 111. The rs1 and rs2 fields hold the comparison operands, and the 13-bit immediate encodes the branch offset (±4 KiB).
BGEU compares rs1 and rs2 as unsigned integers and branches if rs1 >= rs2 (range ±4 KiB). BLEU can be synthesized by swapping BGEU operands. BLTU is the logical inverse. Commonly used for address comparison and memory range checking.
BGEU is a conditional branch: when rs1 and rs2 satisfy the unsigned greater than or equal condition, the PC branches to the current PC plus the B-type offset; otherwise execution falls through.
These notes are checked against the RISC-V Unprivileged ISA manual and summarize operation semantics, immediate ranges, and edge behavior.
Conditional branches use the B-type immediate, a signed PC-relative offset in 2-byte units, giving an approximate reach of +/-4 KiB from the current PC.
RISC-V Unprivileged ISA, RV32I control transfer instructionsConditional branches only update the PC based on the comparison result. They do not write rd or save a return address; use JAL/JALR forms for calls and returns.
RISC-V Unprivileged ISA, RV32I control transfer instructionsUnderstand this scenario with real code like «bgeu x11, x12, valid # if x11 >= x12 (unsigned), go to valid».
Understand this scenario with real code like «bgeu x11, x12, valid # if x11 >= x12 (unsigned), go to valid».
Conditional branches use a B-type immediate, giving an approximate reach of +/-4 KiB from the current PC.
BLT/BGE compare as signed integers; BLTU/BGEU compare as unsigned integers. BEQ/BNE only test equality of the bit patterns.