5.3.3. CMP and CMN

Compare and Compare Negative.

Syntax

CMP Rn, #expr
CMP Rn, Rm
CMN Rn, Rm

where:

Rn

is the register containing the first operand.

expr

is an expression that evaluates (at assembly time)to an integer in the range 0-255.

Rm

is a register containing the second operand.

Usage

These instructions update the condition flags, but do not place a result in a register.

The CMP instruction subtracts the value of expr, or the value in Rm, from the value in Rn.

The CMN instruction adds the values in Rm and Rn.

Restrictions

In CMP Rn,#expr, and CMN instructions, Rn and Rm must be in the range r0 to r7.

In CMP Rn,Rm instructions, Rn and Rm can be any register r0 to r15.

Condition flags

These instructions update the N, Z, C, and V flags according to the result.

Architectures

These instructions are available in all T variants of the architecture.

Examples

    CMP r2,#255
    CMP r7,r12      ; high register IS allowed with CMP Rn,Rm
    CMN r1,r5

Incorrect examples

    CMP r2,#508     ; immediate value out of range
    CMP r9,#24      ; high register not allowed with #expr
    CMN r0,r10      ; high register not allowed with CMN
Copyright © 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B
Non-Confidential