13
(2) Condition Code Register (CCR): This 8-bit register contains internal CPU status
information, including the interrupt mask bit (I) and half-carry (H), negative (N), zero (Z),
overflow (V), and carry (C) flags.
Bit 7—Interrupt Mask Bit (I): Masks interrupts when set to 1. This bit is set to 1 at the
beginning of exception handling.
Bit 6—User Bit (U): Can be written and read by software for its own purposes (using the LDC,
STC, ANDC, ORC, and XORC instructions).
Bit 5—Half-Carry Flag (H): When the ADD.B, ADDX.B, SUB.B, SUBX.B, CMP.B, or NEG.B
instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and is cleared to 0
otherwise.
The H flag is used implicitly by the DAA and DAS instructions.
When the ADD.W, SUB.W, or CMP.W instruction is executed, the H flag is set to 1 if there is a
carry or borrow at bit 11, and is cleared to 0 otherwise.
Bit 4—User Bit (U): Can be written and read by software for its own purposes (using the LDC,
STC, ANDC, ORC, and XORC instructions).
Bit 3—Negative Flag (N): Indicates the most significant bit (sign bit) of data.
Bit 2—Zero Flag (Z): Set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data.
Bit 1—Overflow Flag (V): Set to 1 when an arithmetic overflow occurs, and cleared to 0 at other
times.
Bit 0—Carry Flag (C): Set to 1 when a carry occurs, and cleared to 0 otherwise. Used by:
•
Add instructions, to indicate a carry
•
Subtract instructions, to indicate a borrow
•
Shift and rotate instructions, to store the value shifted out of the end bit
The carry flag is also used as a bit accumulator by bit manipulation instructions.
Some instructions leave some or all of the flag bits unchanged. The LDC, STC, ANDC, ORC, and
XORC instructions enable the CPU to load and store CCR, and to set or clear selected bits by
logic operations. The N, Z, V, and C flags are used as branching conditions for conditional
branching (Bcc) instructions.
Refer to the H8/300 Series Programming Manual for the action of each instruction on the flag
bits.