ARM Instruction Reference

4.3.5CMP and CMN

Compare and Compare Negative.

Syntax

CMP{cond} Rn, Operand2 CMN{cond} Rn, Operand2 where:

cond

is an optional condition code (see Conditional execution on page 4-4).

Rn

is the ARM register holding the first operand.

Operand2

is a flexible second operand. See Flexible second operand on page 4-24

 

for details of the options.

Usage

These instructions compare the value in a register with Operand2. They update the condition flags on the result, but do not place the result in any register.

The CMP instruction subtracts the value of Operand2 from the value in Rn. This is the same as a SUBS instruction, except that the result is discarded.

The CMN instruction adds the value of Operand2 to the value in Rn. This is the same as an ADDS instruction, except that the result is discarded.

In certain circumstances, the assembler can substitute CMN for CMP, or CMP for CMN. Be aware of this when reading disassembly listings. See Instruction substitution on page 4-26 for details.

Condition flags

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

Use of r15

If you use r15 as Rn, the value used is the address of the instruction plus 8.

You cannot use r15 for any operand in any data processing instruction that has a register-controlled shift (see Flexible second operand on page 4-24).

4-34

Copyright © 2000, 2001 ARM Limited. All rights reserved.

ARM DUI 0068B

Page 144
Image 144
ARM VERSION 1.2 manual CMP and CMN, Compare and Compare Negative