Flags registers in 8085

In 8085 microprocessor, the flags registers in 8085 can have a total of eight flags. Thus a flag can be represented by 1 bit of information. But only five flags are implemented in 8085. And they are:

  • Carry flag (Cy),
  • Auxiliary carry flag (AC),
  • Sign flag (S),
  • Parity flag (P), and
  • Zero flag (Z).

Carry flag (Cy): after performing the addition of any two 8-bit numbers, the carry generated can be either 0 or 1. That is only 1-bit. Thus to store the carry information 1-bit storage is enough. The Cy flag is stored in the LS bit position in the flags register. Instructions that use the Cy flag are widely used in the user programs.

Example 1: In the addition of 45H and F3H, the result thus produced will be 38H and with Cy flag = 1, as shown below.

Example 2: In the addition of 85H and 1EH, the result thus produced will be A3H with Cy = 0, as shown below.

Auxiliary carry flag (Ac): Now let us consider the addition of any two 8-bit (2-hex digit) numbers, a carry may be generated when we add the LS hex digits of the two numbers. Such a carry is called intermediate carry also known as half carry, or auxiliary carry (AC). Intel prefers to call it AC. In the above Example 1, AC was not generated but in Example 2, AC is generated.

Sign flag (S): The S flag is set to 1, when the result thus produced against any logical or arithmetic operations is negative, indicated by MS bit of 8-bit result being 1. It is reset to 0 otherwise if the result is positive, indicated by MS bit of 8-bit result being 0.

Parity flag (P): The P flag is set to 1, if the 8-bit result thus produced against any logical and arithmetic operation has an even number of 1’s in it. If there are odd number of 1’s in the 8-bit result, the P flag is reset to 0.

Zero flag (Z): The Z flag is set to 1, if after arithmetic and logical operations, the 8-bit result thus produced, is 00H. If the 8-bit result is not equal to 00H, the Z flag is reset to 0. Thus the Z flag is hoisted to indicate that the result is 0.

These individual flags are either set to 1, or reset to 0 depending on the result of execution of the last executed arithmetic or logical instruction. But in a few arithmetic and logical instructions, some or none of these flags are affected. Also there are some arithmetic and logical instructions, flag bits in the flag register will not get affected as well. As example in the execution of DCX and INX instructions, flag bit in flag register will not get affected at all.

Leave a Comment

Scroll to Top