Updates to the ALU status flags

In ARM state, and in Thumb state on ARMv6T2 or later processors, most data processing instructions have an option to update ALU status flags in the Application Program Status Register (APSR) according to the result of the operation. Instructions with the optional S suffix update the condition flags. Conditional instructions that are not executed have no effect on the flags.

In Thumb state on processors before ARMv6T2, most data processing instructions update the ALU status flags automatically according to the result of the operation. There is no option to leave the flags unchanged and not update them. Other instructions cannot update the flags.

The APSR contains the following ALU status flags:

N

Set to 1 when the result of the operation is negative, cleared to 0 otherwise.

Z

Set to 1 when the result of the operation is zero, cleared to 0 otherwise.

C

Set to 1 when the operation results in a carry, cleared to 0 otherwise.

V

Set to 1 when the operation causes overflow, cleared to 0 otherwise.

A carry occurs:

Overflow occurs if the result of an add, subtract, or compare is greater than or equal to 231, or less than -231.

The instruction also determines the flags that get updated. Some instructions update all flags, and some instructions only update a subset of the flags. If a flag is not updated, the original value is preserved. In the Assembler Reference, the description of each instruction details the effect it has on the flags.

Note

Most instructions update the status flags only if the S suffix is specified. The instructions CMP. CMN, TEQ, and TST always update the condition code flags.

Show/hideSee also

Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0473C
Non-ConfidentialID080411