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. It provides a hint that this is not a subroutine call or return. This instruction does not affect the condition flags.
Variants: FEAT_CMPBR (ARMv9.6)
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | ||||||||||||||||||||||
cc | Rm | H | imm9 | Rt |
---|
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);
constant bits(datasize) operand1 = X[t, datasize]; constant bits(datasize) operand2 = X[m, datasize]; constant boolean branch_conditional = TRUE; boolean cond; constant integer value1 = Int(operand1, unsigned); constant integer value2 = Int(operand2, unsigned); case op of when Cmp_EQ cond = value1 == value2; when Cmp_NE cond = value1 != value2; when Cmp_GE cond = value1 >= value2; when Cmp_LT cond = value1 < value2; when Cmp_GT cond = value1 > value2; when Cmp_LE cond = value1 <= value2; if cond then BranchTo(PC64 + offset, BranchType_DIR, branch_conditional); else BranchNotTaken(BranchType_DIR, branch_conditional);