Register - Status Flag

Z80 Registers

About

The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the results of arithmetic instructions.

Status Flag Register

Usage

One instruction, multiple Data Type Result

The status flags allow a single arithmetic instructions to produce results for three different data types:

If the result of an arithmetic operation is treated as:

  • an unsigned integer, the CF flag indicates an out-of-range condition (carry or a borrow);
  • a signed integer (two’s complement number), the OF flag indicates a carry or borrow;
  • a BCD digit, the AF flag indicates a carry or borrow.

where:

Multiple-precision arithmetic on integers

When performing multiple-precision arithmetic on integers, the CF flag is used in conjunction with the add with carry (ADC) and subtract with borrow (SBB) instructions to propagate a carry or borrow from one computation to the next.

Conditional value

The condition instructions use one or more of the status flags as condition codes and test them for:

Management

List

The status flag functions are:

Code Bit Name Description
CF 0 Carry flag Set if an arithmetic operation generates:
* a carry
* or a borrow
out of the most significant bit of the result;
cleared otherwise.
This flag indicates an overflow condition for unsigned-integer arithmetic. It is also used in multiple-precision arithmetic.
PF 2 Parity flag Set if the least-significant byte of the result contains an even number of 1 bits; cleared otherwise
AF 4 Auxiliary Carry flag Set if an arithmetic operation generates:
* a carry
* or a borrow out of bit 3 of the result;
cleared otherwise.
This flag is used in binary-coded decimal (BCD) arithmetic.
ZF 6 Zero flag Set if the result is zero; cleared otherwise.
SF 7 Sign flag Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.)
OF 11 overflow flag Set if the integer result is:
* too large a positive number
* or too small a negative number (excluding the sign-bit)
to fit in the destination operand; cleared otherwise.
This flag indicates an overflow condition for signed-integer (two’s complement) arithmetic.

Modification

Documentation / Reference

  • 3.4.3.1 - Status Flags





Discover More
Card Puncher Data Processing
CPU - Condition Instruction

conditional statement in Instruction. Jcc (jump on condition code cc), SETcc (byte set on condition code cc), LOOPcc, CMOVcc (conditional move) The condition instructions use one or...
Eflags Registers
CPU Register - Eflag

The 32-bit EFLAGS register contains: a group of status flags, a control flag (DF), and a group of system flags. When suspending a task, the processor automatically saves the state of...
Card Puncher Data Processing
Instruction - Bit Instruction

bit instruction (BT, BTS, BTR, and BTC) The bit instructions copy a specified bit into the CF flag.
Card Puncher Data Processing
Instructions - Arithmetic Instructions

Arithmetic Instruction are the device implementation of the Arithmetic functions ADD, SUB, MUL, and DIV instructions. The status flags of the EFLAGS register indicate the results...
Card Puncher Data Processing
Overflow Exception

overflow is instruction exception that is triggered by the ALU via a status flag when the arithmetic operation does not have enough space to be performed. If a programmer incorrectly: declares...



Share this page:
Follow us:
Task Runner