Licchavi Lyceum

ll

Licchavi Lyceum

Status Flags of 8085 Microprocessor

The 8085 Microprocessor contains a special register called the Flag Register that indicates the status of the arithmetic and logical operations performed by the Arithmetic Logic Unit (ALU). These flags provide information about the result of an operation and are therefore called Status Flags.

In the 8085 microprocessor, the flag register is an 8-bit register in which five bits are used as flags. These flags are automatically set or reset depending on the result produced by arithmetic or logical instructions. The remaining three bits are unused.

Flag Register Format

The structure of the flag register in the 8085 microprocessor is shown below:

D7   D6   D5   D4   D3   D2   D1   D0

S   Z   X   AC   X   P   X   CY

  • S – Sign Flag
  • Z – Zero Flag
  • AC – Auxiliary Carry Flag
  • P – Parity Flag
  • CY – Carry Flag
  • X – Unused bits

1. Sign Flag (S)

The Sign Flag indicates whether the result of an operation is positive or negative. It reflects the value of the most significant bit (MSB) of the result.

  • If MSB = 1, the sign flag is set (S = 1), indicating a negative result.
  • If MSB = 0, the sign flag is reset (S = 0), indicating a positive result.

In the 8085 microprocessor, numbers are represented in two’s complement form, therefore the MSB determines the sign of the result.

2. Zero Flag (Z)

The Zero Flag indicates whether the result of an arithmetic or logical operation is zero.

  • If the result is zero, the zero flag is set (Z = 1).
  • If the result is not zero, the zero flag is reset (Z = 0).

Example: If the instruction produces a result equal to 00H, the zero flag becomes set.

3. Auxiliary Carry Flag (AC)

The Auxiliary Carry Flag is used in Binary Coded Decimal (BCD) arithmetic operations. It indicates a carry generated from the lower nibble (bit D3) to the higher nibble (bit D4).

  • If a carry occurs from bit D3 to bit D4, AC is set.
  • Otherwise, AC is reset.

This flag is mainly used by the DAA (Decimal Adjust Accumulator) instruction to perform correct BCD arithmetic.

4. Parity Flag (P)

The Parity Flag indicates whether the number of 1s in the result is even or odd.

  • If the number of 1s in the result is even, the parity flag is set (P = 1).
  • If the number of 1s is odd, the parity flag is reset (P = 0).

Example:

  • Result = 10101010 → Four 1s → Even parity → P = 1
  • Result = 10101000 → Three 1s → Odd parity → P = 0

5. Carry Flag (CY)

The Carry Flag indicates whether a carry or borrow is generated during arithmetic operations.

  • If a carry is generated from the most significant bit (MSB), the carry flag is set (CY = 1).
  • If no carry occurs, the carry flag is reset (CY = 0).

The carry flag is also affected by rotation and comparison instructions.

Summary of Status Flags

Flag Name Function
S Sign Flag Indicates whether the result is positive or negative.
Z Zero Flag Indicates whether the result is zero.
AC Auxiliary Carry Indicates carry from bit D3 to D4 (used in BCD arithmetic).
P Parity Flag Indicates whether the result has even or odd parity.
CY Carry Flag Indicates carry or borrow generated during arithmetic operations.

Conclusion

Status flags play an important role in the operation of the 8085 microprocessor. They provide information about the outcome of arithmetic and logical instructions performed by the ALU. These flags are also used for conditional branching instructions such as JZ, JC, JP, and JM. Understanding the function of each flag is essential for programming and analyzing microprocessor-based systems.