CCMP (immediate)

Conditional compare (immediate)

This instruction sets the value of the condition flags to the result of the comparison of a register value and an immediate value if the condition is TRUE, and an immediate value otherwise.

Encoding: 5-bit unsigned immediate

313029282726252423222120191817161514131211109876543210
1111010010100
sfopSimm5condo2Rno3nzcv

32-bit (sf == 0)

CCMP <Wn>, #<imm>, #<nzcv>, <cond>

64-bit (sf == 1)

CCMP <Xn>, #<imm>, #<nzcv>, <cond>

Decoding algorithm

constant integer n = UInt(Rn);
constant integer datasize = 32 << UInt(sf);
constant bits(4) condition = cond;
bits(4) flags = nzcv;
constant bits(datasize) imm = ZeroExtend(imm5, datasize);

Operation

if ConditionHolds(condition) then
    constant bits(datasize) operand1 = X[n, datasize];
    constant bits(datasize) operand2 = imm;
    (-, flags) = AddWithCarry(operand1, NOT(operand2), '1');
PSTATE. = flags;

Explanations

<Wn>: Is the 32-bit name of the general-purpose source register, encoded in the "Rn" field.
<imm>: Is a five bit unsigned (positive) immediate encoded in the "imm5" field.
<nzcv>: Is the flag bit specifier, an immediate in the range 0 to 15, giving the alternative state for the 4-bit NZCV condition flags, encoded in the "nzcv" field.
<cond>: <Xn>: Is the 64-bit name of the general-purpose source register, encoded in the "Rn" field.

Operational Notes

If PSTATE.DIT is 1: