| |||
| Home > ARM and Thumb Instructions > General data processing instructions > CMP and CMN | |||
Compare and Compare Negative.
CMP{cond}Rn,Operand2
CMN{cond}Rn,Operand2
where:
condis an optional condition code.
Rnis the ARM register holding the first operand.
Operand2is a flexible second operand.
These instructions compare the value in a register with .
They update the condition flags on the result, but do not place
the result in any register.Operand2
The CMP instruction subtracts the value of from
the value in Operand2.
This is the same as a RnSUBS instruction, except that
the result is discarded.
The CMN instruction adds the value of to
the value in Operand2.
This is the same as an RnADDS 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.
You cannot use PC for any operand in any data processing instruction that has a register-controlled shift.
You can use PC (R15) in these ARM instructions without
register controlled shift but this is deprecated in ARMv6T2 and
above.
If you use PC as in
ARM instructions, the value used is the address of the instruction
plus 8.Rn
You cannot use PC for any operand in these Thumb instructions.
You can use SP for in
ARM and Thumb instructions.Rn
You can use SP for in
ARM instructions but this is deprecated in ARMv6T2 and above.Rm
You can use SP for in
a 16-bit Thumb RmCMP instruction
but this is deprecated in ARMv6T2 and above. Other use of SP for Rn, Rm is
not permitted in Thumb.Rm
The following forms of these instructions are available in Thumb code, and are 16-bit instructions:
CMP Rn, RmLo register restriction does not apply.
CMN Rn, Rm and Rn must
both be Lo registers.Rm
CMP Rn,
#imm must
be a Lo register. Rn range
0-255.imm