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
SuffixFlagsMeaning
EQZ = 1Equal
NEZ = 0Not equal
CS or HSC = 1Higher or same, unsigned
CC or LOC = 0Lower, unsigned
MIN = 1Negative
PLN = 0Positive or zero
VSV = 1Overflow
VCV = 0No overflow
HIC = 1 and Z = 0Higher, unsigned
LSC = 0 or   Z = 1Lower or same, unsigned
GEN = VGreater than or equal, signed
LTN != VLess than, signed
GTZ = 0 and N = VGreater than, signed
LEZ = 1 and N != VLess than or equal, signed
ALCan have any valueAlways. 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