2078 9

BIT151 ยท 2078 ยท 5 marks

What is flag? What are different flags available in 8085 microprocessor?

What is flag? What are different flags available in 8085 microprocessor? [5]

Microprocessor and Computer ArchitectureChapter 10: Computer Architecture Paradigms and 8085 FeaturesFlags in 8085 microprocessor

Quick answer

A flag is a single-bit flip-flop (register) that reflects the status (condition) of the result after the execution of an arithmetic or logical operation. Flags are part of the Program Status Word (PSW) or Flag Register in the 8085 microprocessor.

Flags in 8085 Microprocessor

What is a Flag?

The 8085 has an 8-bit flag register, but only 5 bits are used as flags.


The 5 Flags of 8085 Microprocessor

1. Sign Flag (S) -- Bit 7

  • Set to 1 if the result of an operation is negative (i.e., the Most Significant Bit of the result is 1).
  • Set to 0 if the result is positive.
  • Example: If result = 10000001 (negative in 2's complement), S = 1.

2. Zero Flag (Z) -- Bit 6

  • Set to 1 if the result of an operation is zero.
  • Set to 0 if the result is non-zero.
  • Example: If A = 05H and we subtract 05H, result = 00H, so Z = 1.

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

  • Set to 1 if there is a carry out from bit 3 to bit 4 (carry from lower nibble to upper nibble) during an arithmetic operation.
  • Primarily used for BCD (Binary Coded Decimal) arithmetic operations.
  • Example: 0FH + 01H = 10H, carry from bit 3 to bit 4, so AC = 1.

4. Parity Flag (P) -- Bit 2

  • Set to 1 if the result contains an even number of 1s (even parity).
  • Set to 0 if the result contains an odd number of 1s (odd parity).
  • Example: Result = 00000011 (two 1s, even), so 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.
  • Set to 0 if there is no carry/borrow.
  • Example: FFH + 01H = 100H, carry generated, so CY = 1.

Flag Register Layout (8-bit)

Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
SZXACXPXCY

X = Not used (undefined bits)


Summary Table

FlagSymbolSet to 1 When
SignSResult is negative (MSB = 1)
ZeroZResult is zero
Auxiliary CarryACCarry from bit 3 to bit 4
ParityPResult has even number of 1s
CarryCYCarry out from MSB or borrow

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