
ST10R272L - CENTRAL PROCESSING UNIT
52/320
carry.
The C-flag is always cleared for logical, multiply and divide ALU operations because these
operations cannot cause a carry.
For shift and rotate operations, the C-flag represents the value of the bit shifted out last. If a
shift count of zero is specified, the C-flag will be cleared. The C-flag is also cleared for a
prioritize ALU operation, because a ’1’ is never shifted out of the MSB during the
normalization of an operand.
For Boolean bit operations with only one operand, the C-flag is always cleared. For Boolean
bit operations with two operands, the C-flag represents the logical ANDing of the two
specified bits.
V-Flag: For addition, subtraction and 2’s complement, the V-flag is always set to ’1’ if the
result overflows the maximum range of signed numbers (16 bits for word operations
('–8000h' to '+7FFFh'), or by 8 bits for byte operations ('–80h' to '+7Fh')), otherwise the V-flag
is cleared. Note that the result of an integer addition, integer subtraction, or 2's complement
is not valid, if the V-flag indicates an arithmetic overflow.
For multiplication and division, the V-flag is set to '1' if the result cannot be represented in a
word data-type, otherwise it is cleared. Note that a division by zero will always cause an
overflow. In contrast to the result of a division, the result of a multiplication is valid regardless
of whether the V-flag is set to '1' or not.
Since logical ALU operations cannot produce an invalid result, the V-flag is cleared by these
operations.
The V-flag is also used as 'Sticky Bit' for rotate-right and shift-right operations. Using the
C-flag only, gives a rounding error (caused by a shift right operation) of one half of the LSB
of the result. Using the V-flag, the C-flag together gives finer resolution on the rounding error
(see table below).
For Boolean bit operations with only one operand, the V-flag is always cleared. For Boolean
bit operations with two operands, the V-flag represents the logical ORing of the two specified
bits.
Z-Flag: The Z-flag is set to '1' if the result of an ALU operation equals zero, otherwise it is
cleared.
C-Flag
V-Flag
Rounding error quantity
0
0
-
No rounding error
0
1
0<
Rounding error
<
1
/
2
LSB
1
0
-
Rounding error
=
1
/
2
LSB
1
1
-
Rounding error
>
1
/
2
LSB
Table 7 Shift right rounding