Flags are flip-flops that store bit 0 or 1 based on the arithmetic or logical operation performed by an arithmetic and logical unit (ALU). In most of the operations, the result is stored in the accumulator.
There are five flags present in 8085 microprocessor. All the flags are present in an 8-bit register called as status register or flags register. The flags generally reflect the status of arithmetic or logical operations. In 8085, 5 flags are definite at the definite bit of flag register. Figure 1 shows the bit positions reserved for these flags in the flag register.
Note: The status of flag effect according to the condition generated in arithmetic and logic operation.
The description and conditions of flags are as follows:
1. Sign Flag (S)
After the execution of an arithmetic or logic operation, if bit D7 of the result (usually in the accumulator) is 1, the sign flag is set. This flag is used with signed numbers. In a given byte, if D7 is 1, the number will be viewed as a negative number; if it is 0, the number will be considered positive. In arithmetic operations with signed numbers, bit D7 is reserved for indicating the sign, and the remaining seven bits are used to represent the magnitude of a number. However, the flag is irrelevant for the operations of unsigned numbers. So, this flag is used for operation on signed numbers.
2. Zero Flag (Z)
The zero flag is set (i.e. becomes 1) when the ALU operation results in 0, and the flag is reset (i.e. becomes 0) if the result is nonzero. This flag is affected by the results in the accumulator as well as in the other registers.
3. Parity Flag (P)
After the ALU operation, if the result contains even number of ones (even parity) the parity flag is set (i.e. becomes 1) and if the result has the odd number of one (odd parity) the parity flag resets (i.e. becomes 0).
4. Carry Flag (CY)
If an arithmetic operation results in a carry, the carry flag is set (i.e. becomes 1), otherwise, it is reset (i.e. becomes 0). It works as a borrow flag during subtraction.
5. Auxiliary Carry Flag (AC)
In an arithmetic operation, when a carry is generated by digit D3 and passed on to digit D4, the AC flag is set. Among the five flags, AC flag is used internally for BCD arithmetic operations and is not available for the programmer to change the sequence of the program with a jump instruction.
1. Status of a flag that effects according to the final result of arithmetic and logic operation ——– Sign and Parity flag
2. Status of a flag that effects according to the condition generated during the operation ——- Carry and Auxiliary carry flag
3. Out of five flags, the status of 4 flags can be used by a programmer during the programming —- Sign, Zero, Parity and Carry flags
4. Status of Auxiliary carry flag is not available for programmers.
5. Status of Auxiliary carry flag used internally for the BCD (Binary coded decimal) adjustment of the content of accumulator at the time of execution of DAA instruction.
DAA —– Decimal adjustment of the content of the accumulator