UM012811-0904
Architectural
Overview
eZ8 CPU
User Manual
6
most significant bit position (Bit 7) identifies a positive number; therefore, the Sign flag is
also 0. A 1 in the most significant position (Bit 7) identifies a negative number; therefore,
the Sign flag is also 1.
Overflow Flag
For signed arithmetic, rotate or shift operations, the Overflow (V) flag is 1 when the result
is greater than the maximum possible number (>127) or less than the minimum possible
number (<–128) that can be represented with 8-bits in two’s complement form. The Over-
flow flag is 0 if no overflow occurs. Following logical operations, the Overflow flag is 0.
Following addition operations, the Overflow flag is 1 when the operands have the same
sign, but the result has the opposite sign. Following subtraction operations, the Overflow
flag is 1 if the two operands are of opposite sign and the sign of the result is same as the
sign of the source. Following rotation operations, the Overflow flag is 1 if the sign bit of
the destination operand changed during rotation.
Decimal Adjust Flag
The Decimal Adjust (D) flag is used for Binary-Coded Decimal (BCD) arithmetic opera-
tions. Because the algorithm for correcting BCD operations is different for addition and
subtraction, this flag specifies the type of instruction that was last executed, enabling the
subsequent decimal adjust (DA) operation. Normally, the Decimal Adjust flag cannot be
used as a test condition. After a subtraction, the Decimal Adjust flag is 1. Following an
addition, it is 0.
Half Carry Flag
The Half Carry (H) flag is 1 when an addition generates a carry from Bit 3 or a subtraction
generates a borrow from Bit 4. The DA instruction converts the binary result of a previous
addition or subtraction into the correct BCD result using the Half Carry flag. As in the
case of the Decimal Adjust flag, the user does not normally access this flag directly.
Condition Codes
The C, Z, S and V flags control the operation of the conditional jump (JP cc and JR cc)
instructions. Sixteen frequently useful functions of the flag settings are encoded in a 4-bit
field called the condition code (cc), which forms Bits 7:4 of the first opcode of conditional
jump instructions. Table 2 summarizes the condition codes. Some binary condition codes
can be created using more than one assembly code mnemonic. The result of the flag test
operation determines if the conditional jump executes.