Writing ARM and Thumb Assembly Language
2-20
Copyright © 2000, 2001 ARM Limited. All rights reserved.
ARM DUI 0068B
2.5
Conditional execution
In ARM state, each data processing instruction has an option to update ALU status flags
in the
Current Program Status Register
(CPSR) according to the result of the operation.
Add an
S
suffix to an ARM data processing instruction to make it update the ALU status
flags in the CPSR.
Do not use the
S
suffix with
CMP
,
CMN
,
TST
, or
TEQ
. These comparison instructions always
update the flags. This is their only effect.
In Thumb state, there is no option. All data processing instructions update the ALU
status flags in the CPSR, except when one or more high registers are used in
MOV
and
ADD
instructions.
MOV
and
ADD
cannot update the status flags in these cases.
Almost every ARM instruction can be executed conditionally on the state of the ALU
status flags in the CPSR. Refer to Table 2-1 on page 2-21 for a list of the suffixes to add
to instructions to make them conditional.
In ARM state, you can:
•
update the ALU status flags in the CPSR on the result of a data operation
•
execute several other data operations without updating the flags
•
execute following instructions or not, according to the state of the flags updated
in the first operation.
In Thumb state, most data operations always update the flags, and conditional execution
can only be achieved using the conditional branch instruction (
B
). The suffixes for this
instruction are the same as in ARM state. No other instruction can be conditional.
2.5.1
The ALU status flags
The CPSR contains the following ALU status flags:
N
Set when the result of the operation was Negative.
Z
Set when the result of the operation was Zero.
C
Set when the operation resulted in a Carry.
V
Set when the operation caused oVerflow.
Q
ARM architecture v5E only. Sticky flag (see
The Q flag
on page 4-5).
A carry occurs if the result of an addition is greater than or equal to 2
32
, if the result of
a subtraction is positive, or as the result of an inline barrel shifter operation in a move
or logical instruction.
Overflow occurs if the result of an add, subtract, or compare is greater than or equal to
2
31
, or less than –2
31
.
Содержание Developer Suite
Страница 10: ...Preface x Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 110: ...Assembler Reference 3 32 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 185: ...ARM Instruction Reference ARM DUI 0068B Copyright 2000 2001 ARM Limited All rights reserved 4 75 Example MSR CPSR_f r5 ...
Страница 238: ...Thumb Instruction Reference 5 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 282: ...Vector Floating point Programming 6 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 360: ...Index Index 6 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...