Decimal Adjust Accumulator Flag; Parity/Overflow Flag - IXYS zilog Z80 User Manual

Table of Contents

Advertisement

Decimal Adjust Accumulator Flag

The Decimal Adjust Accumulator (DAA) instruction uses this flag to distinguish between
ADD and SUBTRACT instructions. For all ADD instructions, N sets to 0. For all SUB-
TRACT instructions, N sets to 1.

Parity/Overflow Flag

The Parity/Overflow (P/V) Flag is set to a specific state depending on the operation being
performed. For arithmetic operations, this flag indicates an overflow condition when the
result in the Accumulator is greater than the maximum possible number (+127) or is less
than the minimum possible number (–128). This overflow condition is determined by
examining the sign bits of the operands.
For addition, operands with different signs never cause overflow. When adding operands
with similar signs and the result contains a different sign, the Overflow Flag is set, as
shown in the following example.
+120
+105
+225
The two numbers added together result in a number that exceeds +127 and the two posi-
tive operands result in a negative number (–95), which is incorrect. The Overflow Flag is
therefore set.
For subtraction, overflow can occur for operands of unalike signs. Operands of alike signs
never cause overflow, as shown in the following example.
(–)
The minuend sign has changed from a positive to a negative, resulting in an incorrect dif-
ference; the Overflow Flag is set.
Another method for identifying an overflow is to observe the Carry to and out of the sign
bit. If there is a Carry in and no Carry out, or if there is no Carry in and a Carry out, then
an Overflow has occurred.
This flag is also used with logical operations and rotate instructions to indicate the result-
ing parity is even. The number of 1 bits in a byte are counted. If the total is Odd, ODD par-
ity is flagged (i.e., P = 0). If the total is even, even parity is flagged (i.e., P = 1).
UM008011-0816
=
0111
1000
=
0110
1001
=
1110
0001
+127
0111
1111
–64
1100
0000
+191
1011
1111
ADDEND
AUGEND
(–95)
SUM
MINUEND
SUBTRAHEND
DIFFERENCE
Decimal Adjust Accumulator Flag
Z80 CPU
User Manual
67

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the zilog Z80 and is the answer not in the manual?

Questions and answers

Table of Contents