CB<cc> (immediate)

Compare register with immediate and branch

This instruction compares the value in a register with an immediate, and conditionally branches to a label at a PC-relative offset if the comparison 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 CBGE (immediate), CBHS (immediate), CBLE (immediate), and CBLS (immediate).

Branch
(FEAT_CMPBR)

313029282726252423222120191817161514131211109876543210
sf1110101ccimm60imm9Rt

Encoding for the 32-bit greater than variant

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

CBGT <Wt>, #<imm>, <label>

Encoding for the 32-bit less than variant

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

CBLT <Wt>, #<imm>, <label>

Encoding for the 32-bit higher variant

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

CBHI <Wt>, #<imm>, <label>

Encoding for the 32-bit lower variant

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

CBLO <Wt>, #<imm>, <label>

Encoding for the 32-bit equal variant

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

CBEQ <Wt>, #<imm>, <label>

Encoding for the 32-bit not equal variant

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

CBNE <Wt>, #<imm>, <label>

Encoding for the 64-bit greater than variant

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

CBGT <Xt>, #<imm>, <label>

Encoding for the 64-bit less than variant

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

CBLT <Xt>, #<imm>, <label>

Encoding for the 64-bit higher variant

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

CBHI <Xt>, #<imm>, <label>

Encoding for the 64-bit lower variant

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

CBLO <Xt>, #<imm>, <label>

Encoding for the 64-bit equal variant

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

CBEQ <Xt>, #<imm>, <label>

Encoding for the 64-bit not equal variant

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

CBNE <Xt>, #<imm>, <label>

Decode for all variants of this encoding

if !IsFeatureImplemented(FEAT_CMPBR) then EndOfDecode(Decode_UNDEF); end; let datasize : integer{} = 32 << UInt(sf); let t : integer = UInt(Rt); 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_LT; unsigned = FALSE; when '010' => op = Cmp_GT; unsigned = TRUE; when '011' => op = Cmp_LT; unsigned = TRUE; when '110' => op = Cmp_EQ; unsigned = TRUE; when '111' => op = Cmp_NE; unsigned = TRUE; otherwise => EndOfDecode(Decode_UNDEF); end; let value2 : integer = UInt(imm6);

Assembler Symbols

<Wt>

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

<imm>

Is an unsigned immediate, in the range 0 to 63, encoded in the "imm6" 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.

Operation

let operand1 : bits(datasize) = X{}(t); let branch_conditional : boolean = TRUE; let value1 : integer = if unsigned then UInt(operand1) else SInt(operand1); var cond : boolean; case op of when Cmp_EQ => cond = value1 == value2; when Cmp_NE => cond = value1 != value2; when Cmp_LT => 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;


2026-03_rel 2026-03-26 20:48:11

Copyright © 2010-2026 Arm Limited or its affiliates. All rights reserved. This document is Non-Confidential.