2080 6

CSC167 ยท 2080 ยท 5 marks

What is flag? Explain all the flags present in 8085 microprocessor.

What is flag? Explain all the flags present in 8085 microprocessor. [5]

MicroprocessorChapter 4: Assembly Language ProgrammingFlags

Quick answer

A flag is a single-bit flip-flop (1-bit register) that indicates the status of the accumulator or other registers after the completion of an arithmetic or logical operation. These flip-flops are set (1) or reset (0) according to the data condition of the result stored in the accumulator.

Flags in 8085 Microprocessor

What is a Flag?

The flag register (also called the status register or F register) is an 8-bit register, but only 5 bits are used as flags in the 8085 microprocessor.


The 5 Flags of 8085 Microprocessor

The flag register layout is as follows:

Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
SZ--AC--P--CY

1. Sign Flag (S) -- Bit 7

  • Set to 1 if the MSB (bit 7) of the result is 1, indicating the result is negative.
  • Reset to 0 if the result is positive (MSB = 0).
  • Used in signed number arithmetic.

Example: If result = 10000001 (negative in 2's complement), S = 1.


2. Zero Flag (Z) -- Bit 6

  • Set to 1 if the result of the operation is zero.
  • Reset to 0 if the result is non-zero.

Example: If 05H - 05H = 00H, then Z = 1.


3. Auxiliary Carry Flag (AC) -- Bit 4

  • Set to 1 if there is a carry out from bit 3 to bit 4 (i.e., carry from the lower nibble to the upper nibble).
  • Primarily used in BCD (Binary Coded Decimal) arithmetic operations.

Example: If lower nibble addition produces a carry to bit 4, AC = 1.


4. Parity Flag (P) -- Bit 2

  • Set to 1 if the result contains an even number of 1s (even parity).
  • Reset to 0 if the result contains an odd number of 1s (odd parity).

Example: If result = 00000011 (two 1s -- even), then P = 1.


5. Carry Flag (CY) -- Bit 0

  • Set to 1 if there is a carry out from the MSB (bit 7) during addition, or a borrow during subtraction.
  • Reset to 0 if there is no carry or borrow.

Example: If FFH + 01H = 100H (carry out), then CY = 1.


Summary Table

FlagSymbolBit PositionSet When
SignS7Result is negative (MSB = 1)
ZeroZ6Result is zero
Auxiliary CarryAC4Carry from bit 3 to bit 4
ParityP2Result has even number of 1s
CarryCY0Carry out from MSB

These five flags together help the programmer make conditional decisions (using conditional jump instructions) based on the outcome of arithmetic and logical operations.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.