2.6.3.7.2 Condition Code Suffixes

The instructions that can be conditional have an optional condition code, shown in syntax descriptions as {cond}. Conditional execution requires a preceding IT instruction. An instruction with a condition code is only executed if the condition code flags in the APSR meet the specified condition. The following table shows the condition codes to use. You can use conditional execution with the IT instruction to reduce the number of branch instructions in code. The table also shows the relationship between condition code suffixes and the N, Z, C, and V flags.

Table 2-23. Condition Code Suffixes
Suffix Flags Meaning
EQ Z = 1 Equal
NE Z = 0 Not equal
CS or HS C = 1 Higher or same, unsigned
CC or LO C = 0 Lower, unsigned
MI N = 1 Negative
PL N = 0 Positive or zero
VS V = 1 Overflow
VC V = 0 No overflow
HI C = 1 and Z = 0 Higher, unsigned
LS C = 0 or   Z = 1 Lower or same, unsigned
GE N = V Greater than or equal, signed
LT N != V Less than, signed
GT Z = 0 and N = V Greater than, signed
LE Z = 1 and N != V Less than or equal, signed
AL Can have any value Always. This is the default when no suffix is specified.

The following example shows the use of a conditional instruction to find the absolute value of a number. R0 = abs(R1).

Example 1

Absolute value

MOVS R0, R1 ; R0 = R1, setting flags

IT MI ; skipping next instruction if value 0 or positive

RSBMI R0, R0, #0 ; If negative, R0 = -R0

The following example shows the use of conditional instructions to update the value of R4 if the signed values R0 is greater than R1 and R2 is greater than R3.

Example 2

Compare and update value

CMP R0, R1 ; Compare R0 and R1, setting flags

ITT GT ; Skip next two instructions unless GT condition holds

CMPGT R2, R3 ; If 'greater than', compare R2 and R3, setting flags

MOVGT R4, R5 ; If still 'greater than', do R4 = R5