Infineon Technologies C166S V2 User Manual page 76

16-bit microcontroller
Table of Contents

Advertisement

• C-Flag: After an addition, the C-flag indicates that a "Carry" from the most significant
bit of the specified word or byte data type has been generated. After a subtraction or
a comparison, the C-flag indicates a "Borrow" which represents the logical negation of
a "Carry" for the addition.
This means that the C-flag is set to 1, if no carry from the most significant bit of the
specified word or byte data type has been generated during a subtraction. Subtraction
is performed by the ALU as a 2s complement addition. The C-flag is cleared when this
complement addition causes a "Carry".
The C-flag is always cleared for logical, multiply and divide ALU operations, because
these operations cannot cause a "Carry" flag to be set.
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 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: The addition, subtraction and 2's complement operations set the V-flag to '1'
if the result exceeds the range of 16 bit signed numbers for word operations ('–8000
to '+7FFF
'), or 8 bit signed numbers for byte operations ('–80
H
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 can not be represented
in a word data type, otherwise it is cleared. Note that a division by zero will always
cause an overflow. Unlike the division result, the result of multiplication is valid
regardless of V-flag value.
Since the 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
only the C-flag, a rounding error caused by a shift right operation can be estimated as
up to one half of the LSB of the result. In conjunction with the V-flag, the C-flag allows
evaluation of the rounding error with a finer resolution (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.
Shift Right Rounding Error Evaluation
• Z-Flag: The Z-flag is normally set to 1 if the result of an ALU operation equals zero;
otherwise, it is cleared.
User Manual
2-76
User Manual
C166S V2
Central Processing Unit
' to '+7F
'). Otherwise,
H
H
V 1.7, 2001-01
'
H

Advertisement

Table of Contents
loading

Table of Contents