ccmp

Conditional Compare (Register)

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

Compares two registers if condition is true.

Pseudocode Operation

if ConditionHolds(cond) then temp ← Wn - Wm; N ← temp[31]; Z ← (temp == 0); C ← NOT(BorrowFrom(Wn, Wm)); V ← SignedOverflow(Wn, -Wm) else N ← nzcv[3]; Z ← nzcv[2]; C ← nzcv[1]; V ← nzcv[0]

Example

CCMP w1, w2, #nzcv, cond

Encoding

Binary Layout
0
31
1
30
1
29
11010010
28:21
Rm
20:16
cond
15:12
0
11
0
10
Rn
9:5
0
4
nzcv
3:0
 
Format Cond Comp
Opcode 0x7A400000
Extension Base

Operands

  • Wn
    Reg 1
  • Wm
    Reg 2
  • nzcv
    Flags
  • cond
    Condition

Related

Other forms of ccmp

  • ccmp Conditional Compare (Immediate)

More in Base

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0x7A400800 CCMP <Wn>, #<imm>, #<nzcv>, <cond> A64 0 | 1 | 1 | 11010010 | imm5 | cond | 1 | 0 | Rn | 0 | nzcv
0xFA400800 CCMP <Xn>, #<imm>, #<nzcv>, <cond> A64 1 | 1 | 1 | 11010010 | imm5 | cond | 1 | 0 | Rn | 0 | nzcv
0x7A400000 CCMP <Wn>, <Wm>, #<nzcv>, <cond> A64 0 | 1 | 1 | 11010010 | Rm | cond | 0 | 0 | Rn | 0 | nzcv
0xFA400000 CCMP <Xn>, <Xm>, #<nzcv>, <cond> A64 1 | 1 | 1 | 11010010 | Rm | cond | 0 | 0 | Rn | 0 | nzcv

Description

Conditional Compare (register) sets the value of the condition flags to the result of the comparison of two registers if the condition is TRUE, and an immediate value otherwise.

Operation

if ConditionHolds(cond) then
    bits(datasize) operand1 = X[n, datasize];
    bits(datasize) operand2 = X[m, datasize];
    operand2 = NOT(operand2);
    (-, flags) = AddWithCarry(operand1, operand2, '1');
PSTATE.<N,Z,C,V> = flags;