Zero flag, Sign flag, Overflow flag – Zilog Z86193 User Manual
Page 152: Decimal adjust flag
Z8
®
CPU
User Manual
UM001604-0108
Instruction Set
145
Zero Flag
For arithmetic and logical operations, the Zero Flag (Z) is set to 1 if the result is zero. Oth-
erwise, the Zero Flag is cleared to 0.
If the result of testing bits in a register is
00h
, the Zero Flag is set to 1. Otherwise the Zero
Flag is cleared to 0.
If the result of a Rotate or Shift operation is
00h
, the Zero Flag is set to 1. Otherwise, the
Zero Flag is cleared to 0.
IRET changes the value of the Zero Flag when the Flag Register saved in the Stack is
restored. The WDT Instruction sets the Zero Flag to a 1.
Sign Flag
The Sign Flag (S) stores the value of the most significant bit of a result following an arith-
metic, logical, Rotate, or Shift operation.
When performing arithmetic operations on signed numbers, binary two’s-complement
notation is used to represent and process information. A positive number is identified by a
0 in the most significant bit position (bit 7); therefore, the Sign Flag is also 0.
A negative number is identified by a 1 in the most significant bit position (bit 7); therefore,
the Sign Flag is also 1.
IRET changes the value of the Sign Flag when the Flag Register saved in the Stack is
restored.
Overflow Flag
For signed arithmetic, Rotate, and Shift operations, the Overflow Flag (V) is set to 1 when
the result is greater than the maximum possible number (> 127) or less than the minimum
possible number (
<
–128) that can be represented in two’s-complement form. The Over-
flow Flag is set to 0 if no overflow occurs.
Following logical operations the Overflow Flag is set to 0.
IRET changes the value of the Overflow Flag when the Flag Register saved in the Stack is
restored.
Decimal Adjust Flag
The Decimal Adjust Flag (D) is used for BCD arithmetic. Because the algorithm for cor-
recting BCD operations is different for addition and subtraction, this flag specifies what
type of instruction was last executed so that the subsequent Decimal Adjust (DA) opera-
tion can function properly. Normally, the Decimal Adjust Flag cannot be used as a test
condition.
After a subtraction, the Decimal Adjust Flag is set to 1. Following an addition it is cleared
to 0.
- Z86233 Z86243 Z86733 Z86743 Z86C02 Z86C04 Z86C08 Z86C15 Z86C21 Z86C30 Z86C31 Z86C33 Z86C36 Z86C40 Z86C43 Z86C61 Z86C62 Z86C63 Z86C65 Z86C83 Z86C90 Z86C91 Z86C93 Z86C96 Z86E02 Z86E03 Z86E04 Z86E06 Z86E07 Z86E08 Z86E15 Z86E21 Z86E30 Z86E31 Z86E33 Z86E34 Z86E40 Z86E43 Z86E44 Z86E61 Z86E63 Z86E83 Z86K15 Z86L02 Z86L04 Z86L08 Z86L16 Z8E000 Z8E001 Z8PE003