UM012811-0904
Architectural
Overview
eZ8 CPU
User Manual
5
Figure 2. Flags Register
Interrupts, the Software Trap (TRAP) instruction, and Illegal Instruction Traps all write
the value of the Flags Register to the stack. Executing an Interrupt Return (IRET) instruc-
tion restores the value saved on the stack into the Flags Register.
Carry Flag
The Carry flag (C) is 1 when the result of an arithmetic operation generates a carry out of
or a borrow into the most significant bit (Bit 7) of the data. Otherwise, the Carry flag is 0.
Some bit rotate or shift instructions also affect the Carry flag. There are three instructions
available for directly changing the value of the Carry Flag:
•
Complement Carry Flag (CCF)
•
Reset Carry Flag (RCF)
•
Set Carry Flag (SCF)
Zero Flag
For arithmetic and logical operations, the Zero (Z) flag is 1 if the result is 0. Otherwise, the
Zero flag is 0. If the result of testing bits in a register is
00H
, the Zero flag is 1; otherwise,
the Zero flag is 0. Also, if the result of a rotate or shift operation is
00H
, the Zero flag is 1;
otherwise, the Zero flag is 0.
Sign Flag
The Sign (S) flag stores the value of the most-significant bit of a result following an arith-
metic, logical, rotate or shift operation. For signed numbers, the eZ8 CPU uses binary
two’s complement to represent the data and perform the arithmetic operations. A 0 in the
C Z
S V D H F2 F1
Flags Register
Bit
0
Bit
7
Half Carry Flag
Decimal Adjust Flag
Overflow Flag
Sign Flag
Zero Flag
Carry Flag
User Flags