ARM Instruction Reference

Some instructions update a subset of the flags. The other flags are unchanged by these instructions. Details are specified in the descriptions of the instructions.

You can execute an instruction conditionally, based upon the flags set in another instruction, either:

immediately after the instruction which updated the flags

after any number of intervening instructions that have not updated the flags.

For further information, see Conditional execution on page 2-20.

4.1.1The Q flag

The Q flag only exists in E variants of ARM architecture v5 and above. It is used to detect saturation in special saturating arithmetic instructions (see QADD, QSUB, QDADD, and QDSUB on page 4-55), or overflow in certain multiply instructions (see SMLAxy on page 4-46 and SMLAWy on page 4-49).

The Q flag is a sticky flag. Although these instructions can set the flag, they cannot clear it. You can execute a series of such instructions, and then test the flag to find out whether saturation or overflow occurred at any point in the series, without needing to check the flag after each instruction.

To clear the Q flag, use an MSR instruction (see MSR on page 4-74).

The state of the Q flag cannot be tested directly by the condition codes. To read the state of the Q flag, use an MRS instruction (see MRS on page 4-73).

ARM DUI 0068B

Copyright © 2000, 2001 ARM Limited. All rights reserved.

4-5

Page 115
Image 115
ARM VERSION 1.2 manual Q flag