← Home

CB<cc> (register)

Compare registers and branch

This instruction compares the values in two registers, and conditionally branches to a label at a PC-relative offset if the condition is true. This instruction provides a hint that this is not a subroutine call or return. This instruction does not affect the condition flags.

This instruction is used by the pseudo-instructions CBLE (register), CBLO (register), CBLS (register), and CBLT (register).

Branch class

(FEAT_CMPBR)

313029282726252423222120191817161514131211109876543210
sf1110100ccRm00imm9Rt

32-bit greater than encoding

(sf == 0 && cc == 000)

CBGT <Wt>, <Wm>, <label>

32-bit greater than or equal encoding

(sf == 0 && cc == 001)

CBGE <Wt>, <Wm>, <label>

32-bit higher encoding

(sf == 0 && cc == 010)

CBHI <Wt>, <Wm>, <label>

32-bit higher or same encoding

(sf == 0 && cc == 011)

CBHS <Wt>, <Wm>, <label>

32-bit equal encoding

(sf == 0 && cc == 110)

CBEQ <Wt>, <Wm>, <label>

32-bit not equal encoding

(sf == 0 && cc == 111)

CBNE <Wt>, <Wm>, <label>

64-bit greater than encoding

(sf == 1 && cc == 000)

CBGT <Xt>, <Xm>, <label>

64-bit greater than or equal encoding

(sf == 1 && cc == 001)

CBGE <Xt>, <Xm>, <label>

64-bit higher encoding

(sf == 1 && cc == 010)

CBHI <Xt>, <Xm>, <label>

64-bit higher or same encoding

(sf == 1 && cc == 011)

CBHS <Xt>, <Xm>, <label>

64-bit equal encoding

(sf == 1 && cc == 110)

CBEQ <Xt>, <Xm>, <label>

64-bit not equal encoding

(sf == 1 && cc == 111)

CBNE <Xt>, <Xm>, <label>

Decode (all encodings)

if !IsFeatureImplemented(FEAT_CMPBR) then EndOfDecode(Decode_UNDEF); end; let datasize : integer{} = 32 << UInt(sf); let t : integer = UInt(Rt); let m : integer = UInt(Rm); let offset : bits(64) = SignExtend{}(imm9::'00'); var op : CmpOp; var unsigned : boolean; case cc of when '000' => op = Cmp_GT; unsigned = FALSE; when '001' => op = Cmp_GE; unsigned = FALSE; when '010' => op = Cmp_GT; unsigned = TRUE; when '011' => op = Cmp_GE; unsigned = TRUE; when '110' => op = Cmp_EQ; unsigned = TRUE; when '111' => op = Cmp_NE; unsigned = TRUE; otherwise => EndOfDecode(Decode_UNDEF); end;

Assembler Symbols

<Wt>

Is the 32-bit name of the general-purpose register to be tested, encoded in the "Rt" field.

<Wm>

Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field.

<label>

Is the program label to be conditionally branched to. Its offset from the address of this instruction, in the range -1024 to 1020, is encoded as "imm9" times 4.

<Xt>

Is the 64-bit name of the general-purpose register to be tested, encoded in the "Rt" field.

<Xm>

Is the 64-bit name of the second general-purpose source register, encoded in the "Rm" field.

Operation

let operand1 : bits(datasize) = X{}(t); let operand2 : bits(datasize) = X{}(m); let branch_conditional : boolean = TRUE; let value1 : integer = if unsigned then UInt(operand1) else SInt(operand1); let value2 : integer = if unsigned then UInt(operand2) else SInt(operand2); var cond : boolean; case op of when Cmp_EQ => cond = value1 == value2; when Cmp_NE => cond = value1 != value2; when Cmp_GE => cond = value1 >= value2; when Cmp_GT => cond = value1 > value2; end; if cond then BranchTo{64}(PC64() + offset, BranchType_DIR, branch_conditional); else BranchNotTaken(BranchType_DIR, branch_conditional); end;


Version 2026.06 — Copyright © 2010-2026 Arm Limited or its affiliates.

This site is provided as a community resource and is NOT affiliated with nor endorsed by Arm Limited.