| |||
| Home > Vector Floating-point Programming > VFP and condition codes | |||
In ARM state, you can use a condition code to control the execution of any VFP instruction. The instruction is executed conditionally, according to the status flags in the CPSR, in exactly the same way as almost all other ARM instructions.
In Thumb® state
on a Thumb-2 processor, you can use an IT instruction
to set condition codes on up to four following VFP instructions.
None of the processors supported by this toolkit supports Thumb-2.
The only VFP instruction that can be used to update the status
flags is FCMP. It does not update the flags in the
CPSR directly, but updates a separate set of flags in the FPSCR (see FPSCR, the floating-point status and
control register).
To use these flags to control conditional instructions, including
conditional VFP instructions, you must first copy them into the
CPSR using an FMSTAT instruction (see FMRX, FMXR, and FMSTAT).
Following an FCMP instruction, the precise meanings
of the flags are different from their meanings following an ARM
data-processing instruction. This is because:
floating-point values are never unsigned, so the unsigned conditions are not needed
Not-a-Number (NaN) values have no ordering relationship with numbers or with each other, so additional conditions are required to account for unordered results.
The meanings of the condition code mnemonics are shown in Table 5.2.
Table 5.2. Condition codes
| Mnemonic | Meaning after ARM data processing instruction | Meaning after VFP FCMP instruction |
|---|---|---|
EQ | Equal | Equal |
NE | Not equal | Not equal, or unordered |
CS / HS | Carry set / Unsigned higher or same | Greater than or equal, or unordered |
CC / LO | Carry clear / Unsigned lower | Less than |
MI | Negative | Less than |
PL | Positive or zero | Greater than or equal, or unordered |
VS | Overflow | Unordered (at least one NaN operand) |
VC | No overflow | Not unordered |
HI | Unsigned higher | Greater than, or unordered |
LS | Unsigned lower or same | Less than or equal |
GE | Signed greater than or equal | Greater than or equal |
LT | Signed less than | Less than, or unordered |
GT | Signed greater than | Greater than |
LE | Signed less than or equal | Less than or equal, or unordered |
AL | Always (normally omitted) | Always (normally omitted) |
The type of the instruction that last updated the flags in the CPSR determines the meaning of condition codes.