BIT151 ยท 0 ยท 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]
Quick answer
A flag is a single-bit flip-flop (register) that reflects the status or condition of the result after an arithmetic or logical operation performed by the ALU (Arithmetic and Logic Unit). Flags are stored in a special 8-bit register called the Flag Register (also called the Status Register or Condition Code Register).
Flags in 8085 Microprocessor
What is a Flag?
The flag register works together with the Accumulator, and together they form a 16-bit Program Status Word (PSW).
Flag Register Structure in 8085
The 8085 has 5 flags (only 5 of the 8 bits are used):
Bit: D7 D6 D5 D4 D3 D2 D1 D0
S Z -- AC -- P -- CY
The 5 Flags of 8085
1. Sign Flag (S) - Bit D7
- Set to 1 if the result of an operation is negative (i.e., the MSB/D7 of the result is 1).
- Reset to 0 if the result is positive (MSB = 0).
- Used in signed number arithmetic.
2. Zero Flag (Z) - Bit D6
- Set to 1 if the result of an operation is zero.
- Reset to 0 if the result is non-zero.
- Commonly used in loop control and comparison operations.
3. Auxiliary Carry Flag (AC) - Bit D4
- Set to 1 if there is a carry out from bit D3 to bit D4 (i.e., carry from the lower nibble to the upper nibble).
- Used in BCD (Binary Coded Decimal) arithmetic operations.
- Also called the Half Carry Flag.
4. Parity Flag (P) - Bit D2
- 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).
- Used in error detection in data communication.
5. Carry Flag (CY) - Bit D0
- Set to 1 if there is a carry out from the MSB (bit D7) after an addition, or a borrow after a subtraction.
- Reset to 0 if there is no carry/borrow.
- Also used in rotate and shift operations.
Summary Table
| Flag | Bit Position | Set to 1 When |
|---|---|---|
| Sign (S) | D7 | Result is negative (MSB = 1) |
| Zero (Z) | D6 | Result is zero |
| Auxiliary Carry (AC) | D4 | Carry from D3 to D4 |
| Parity (P) | D2 | Result has even number of 1s |
| Carry (CY) | D0 | Carry out from MSB |
Note: Bits D5, D3, and D1 of the flag register are not used in the 8085 microprocessor.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.