Zero flag, Sign flag, Overflow flag – Zilog Z86193 User Manual

Page 152: Decimal adjust flag

Advertising
background image

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.

Advertising