Hardware Reference
In-Depth Information
Step 3
Go to step 2 if the logical expression C evaluates to true. Otherwise, exit.
To implement one of the looping constructs, we need to use the unconditional branch or one
of the conditional instructions. When executing conditional branch instructions, the HCS12
checks the condition fl ags in the CCR register.
2.6.1 Condition Code Register
The contents of the condition code register are shown in Figure 2.8. The shaded characters
are condition flags that reflect the status of an operation. The meanings of these condition flags
are as follows:
7
6
5
4
3
2
1
0
H
N
Z
V
C
S
X
I
Figure 2.8 Condition code register
C: the carry flag. Whenever a carry is generated as the result of an operation, this
flag will be set to 1. Otherwise, it will be cleared to 0.
V: the overflow flag. Whenever the result of a two's complement arithmetic
operation is out of range, this flag will be set to 1. Otherwise, it will be set to 0.
The V flag is set to 1 when the carry from the most significant bit and the second
most significant bit differ as the result of an arithmetic operation.
Z: the zero flag. Whenever the result of an operation is zero, this flag will be set to
1. Otherwise, it will be set to 0.
N: the negative flag. Whenever the most significant bit of the result of an operation
is 1, this flag will be set to 1. Otherwise, it will be set to 0. This flag indicates that
the result of an operation is negative.
H: the half-carry flag. Whenever there is a carry from the lower four bits to the
upper four bits as the result of an operation, this flag will be set to 1. Otherwise, it
will be set to 0.
2.6.2 Branch Instructions
Branch instructions cause program flow to change when specific conditions exist.
The HCS12 has three kinds of branch instructions, short branches , long branches , and bit-
conditional branches .
Branch instructions can also be classified by the type of condition that must be satisfied in
order for a branch to be taken. Some instructions belong to more than one category.
Unary (unconditional) branch instructions always execute.
Simple branches are taken when a specific bit in the CCR register is in a specific
state as a result of a previous operation.
Unsigned branches are taken when a comparison or a test of unsigned quantities
results in a specific combination of condition code register bits.
Signed branches are taken when a comparison or a test of signed quantities results
in a specific combination of condition code register bits.
 
Search WWH ::




Custom Search