
DR
AFT
DR
AFT
DRAFT
DR
D
RAFT
DRAFT
DRA
FT DRAF
D
RAFT DRAFT DRAFT DRAFT DRAFT D
DRAFT
D
RAFT DRA
FT DRAFT DRAFT DRAFT DRA
UM10360_0
© NXP B.V. 2009. All rights reserved.
User manual
Rev. 00.06 — 5 June 2009
626 of 808
NXP Semiconductors
UM10360
Chapter 34: Appendix: Cortex-M3 User Guide
Use the
CBZ
and
CBNZ
instructions to compare the value of a register against zero and
branch on the result.
This section describes:
•
Section 34–2.3.7.1 “The condition flags”
•
Section 34–2.3.7.2 “Condition code suffixes”
2.3.7.1
The condition flags
The APSR contains the following condition flags:
N —
Set to 1 when the result of the operation was negative, cleared to 0 otherwise.
Z —
Set to 1 when the result of the operation was zero, cleared to 0 otherwise.
C —
Set to 1 when the operation resulted in a carry, cleared to 0 otherwise.
V —
Set to 1 when the operation caused overflow, cleared to 0 otherwise.
For more information about the APSR see
Section 35–1.1.3.5 “Program Status Register”
.
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 zero
•
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
.
Remark:
Most instructions update the status flags only if the S suffix is specified. See the
instruction descriptions for more information.
2.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.
shows the condition codes to use.
You can use conditional execution with the
IT
instruction to reduce the number of branch
instructions in code.
also shows the relationship between condition code suffixes and the N, Z,
C, and V flags.
Table 587. Condition code suffixes
Suffix
Flags
Meaning
EQ
Z = 1
Equal
NE
Z = 0
Not equal
CS or HS
C = 1
Higher or same, unsigned
≥
CC or LO
C = 0
Lower, unsigned <
MI
N = 1
Negative