← Home

CBH<cc>

Compare halfwords and branch

This instruction compares the halfword 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 CBHLE, CBHLO, CBHLS, and CBHLT.

Branch class

(FEAT_CMPBR)

313029282726252423222120191817161514131211109876543210
01110100ccRm11imm9Rt
H

Greater than encoding

(cc == 000)

CBHGT <Wt>, <Wm>, <label>

Greater than or equal encoding

(cc == 001)

CBHGE <Wt>, <Wm>, <label>

Higher encoding

(cc == 010)

CBHHI <Wt>, <Wm>, <label>

Higher or same encoding

(cc == 011)

CBHHS <Wt>, <Wm>, <label>

Equal encoding

(cc == 110)

CBHEQ <Wt>, <Wm>, <label>

Not equal encoding

(cc == 111)

CBHNE <Wt>, <Wm>, <label>

Decode (all encodings)

if !IsFeatureImplemented(FEAT_CMPBR) then EndOfDecode(Decode_UNDEF); constant integer datasize = 8 << UInt(H); constant integer t = UInt(Rt); constant integer m = UInt(Rm); constant bits(64) offset = SignExtend(imm9:'00', 64); CmpOp op; boolean unsigned; 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);

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.

Operation

constant bits(datasize) operand1 = X[t, datasize]; constant bits(datasize) operand2 = X[m, datasize]; constant boolean branch_conditional = TRUE; constant integer value1 = if unsigned then UInt(operand1) else SInt(operand1); constant integer value2 = if unsigned then UInt(operand2) else SInt(operand2); boolean cond; 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; if cond then BranchTo(PC64 + offset, BranchType_DIR, branch_conditional); else BranchNotTaken(BranchType_DIR, branch_conditional);


Version 2025.09 — Copyright © 2010-2025 Arm Limited or its affiliates.

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