cmn.w

Compare Negative (Wide)

CMN.W <Rn>, <Operand2>

Thumb-2 32-bit Compare Negative (Add and update flags).

Details

Compare Negative (Add and update flags): computes Rn + Operand2, updating the N, Z, C, and V flags based on the result without writing to a destination register. This is a Thumb-2 (32-bit) instruction available in T32 execution state and is commonly used to compare a register against the negation of a value.

Pseudocode Operation

result ← Rn + Operand2
N ← result[31]
Z ← (result == 0)
C ← CarryOut(Rn + Operand2)
V ← OverflowFrom(Rn + Operand2)

Example

CMN.W r1, r2

Encoding

Binary Layout
1110101
1000
1
Rn
0
imm3
1111
imm2
stype
Rm
 
Format Thumb2 Data Proc
Opcode 0xEB100F00
Extension T32 (Thumb2)

Operands

  • Rn
    First source / base general-purpose register
  • Operand2
    Flexible second operand (register or shifted register)

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x03700000 CMN{<c>}{<q>} <Rn>, #<const> A32 cond | 00110 | 11 | 1 | Rn | 0 | 0 | 0 | 0 | imm12
0xF1100F00 CMN{<c>}{<q>} <Rn>, #<const> T32 11110 | i | 0 | 1000 | 1 | Rn | 0 | imm3 | 1111 | imm8
0x01700060 CMN{<c>}{<q>} <Rn>, <Rm>, RRX A32 cond | 00010 | 11 | 1 | Rn | 0 | 0 | 0 | 0 | 00000 | 11 | 0 | Rm
0x01700000 CMN{<c>}{<q>} <Rn>, <Rm> {, <shift> #<amount>} A32 cond | 00010 | 11 | 1 | Rn | 0 | 0 | 0 | 0 | imm5 | stype | 0 | Rm
0x42C0 CMN{<c>}{<q>} <Rn>, <Rm> T32 010000 | 1011 | Rm | Rn
0xEB100F30 CMN{<c>}{<q>} <Rn>, <Rm>, RRX T32 1110101 | 1000 | 1 | Rn | 0 | 000 | 1111 | 00 | 11 | Rm
0xEB100F00 CMN{<c>}.W <Rn>, <Rm> T32 1110101 | 1000 | 1 | Rn | 0 | imm3 | 1111 | imm2 | stype | Rm
0x01700010 CMN{<c>}{<q>} <Rn>, <Rm>, <type> <Rs> A32 cond | 00010 | 11 | 1 | Rn | 0 | 0 | 0 | 0 | Rs | 0 | stype | 1 | Rm

Description

Compare Negative (register) adds a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    shifted = Shift(R[m], shift_t, shift_n, PSTATE.C);
    (result, nzcv) = AddWithCarry(R[n], shifted, '0');
    PSTATE.<N,Z,C,V> = nzcv;