Compare Instructions Flashcards
< operation >
CMP – compare
Flags set to result of (Rn − Operand2).
< operation >
CMN – compare negative
Flags set to result of (Rn + Operand2).
< operation >
TST – bitwise test
Flags set to result of (Rn AND Operand2).
< operation >
TEQ – test equivalence
Flags set to result of (Rn EOR Operand2).
Comparisons produce no results –
- they just set condition codes. Ordinary instructions will also set condition codes if the “S” bit is set. The “S” bit is implied for comparison instructions.
CMP r0, #42
Compare R0 to 42.
CMN r2, #42
Compare R2 to -42.
TST r11, #1
Test bit zero.
TEQ r8, r9
Test R8 equals R9.
SUBS r1, r0, #42
Compare R0 to 42, with result
CMP is like
CMP is like SUB.
CMN is like
ADD – subtract of a negative number is the same as add.
TST is like
TST is like AND.
TEQ is like
TEQ is like EOR – exclusive or of identical numbers gives result of zero.