Webcentive RISC-V Reference

beq

Branch if equal

Extension
RV32I/RV64I base integer
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
beq xs1, xs2, imm
Length
32-bit

Encoding

31252420191514121176210
imm[12|10:5]rs2rs1000imm[4:1|11]1100011

Match 0x00000063, mask 0x0000707f. Source: beq bimm12hi rs1 rs2 bimm12lo 14..12=0 6..2=0x18 1..0=3 in riscv-opcodes/extensions/rv_i.

FieldBitsriscv-opcodes name
imm[12|10:5]31:25bimm12hi
rs224:20rs2
rs119:15rs1
imm[4:1|11]11:7bimm12lo

Description

Branch to PC + imm if the value in register xs1 is equal to the value in register xs2.

Raise a MisalignedAddress exception if PC + imm is misaligned.

Description from riscv-unified-db, reformatted.

Operation

XReg lhs = X[xs1];
XReg rhs = X[xs2];

if (lhs == rhs) {
  jump_halfword($pc + $signed(imm));
}

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages