Flag Registers of 8085 Microprocessor

In this tutorial, we will learn about the different types of flag registers in 8085 Microprocessor. By Akash Kumar Last updated : May 14, 2023

The Flag register is basically a special type of register or we can also say that they are Special Purpose Register. And based upon the value of result after any type of arithmetic and logical operation the value of flag bits become either set (1) or reset (0). In 8085 microprocessor, flag register basically consists of 8 bits and from these 8 bit, only 5 of them are useful.

Different Types of Flag Registers of 8085 Microprocessor

The following are the 5 types of flag registers in 8085 Microprocessor. They are:

1. Sign Flag

Represented by the symbol S. After any type of arithmetic operation or logical operation if the value of D7 becomes 1 it basically shows that the number is negative and the sign flag is now set, if the value of D7 becomes is 0, it basically shows that the number is positive and the sign flag is now reset.

Example:

MVI A 40 (load the value40H in register A)
MVI B 30 (load the value 30H in register B)
SUB B (A = A – B)

These set of instructions willbasically reset the sign flag to 0 as 40 – 30 is always apositive number.

2. Zero Flag (Z)

After any type of arithmetical or logical operation if the output becomes 0 (00)H, then zero flag is said to be set with value 1, if not it becomes reset with the value 0.

Example:

MVI A 40 (load the value of40H in register A)
SUB A 

These set of instructions will basically set the zero flag to the value 1 as 40H – 40H is always gives result as 00H.

3. Auxiliary Cary Flag (AC)

This type of flag is basically used in the BCD number system(0-9). If after any type of arithmetic or logical operation D3 generates any carry and passes on to D4 this flag becomes set with value 1, otherwise, it will become reset with value 0. This is the only flag register which is not used or accessed by the programmer.

Example:

MOV A 2C (load the value 2CH in register A)
MOV B 38 (load the value 38H in register B)
ADD B (A = A + B)

These set of instructions will set the auxiliary carry flag and set the value to 1, as on adding 2C and 38, addition of these lower order will generate a carry.

4. Parity Flag (P)

After any type of arithmetic or logical operation if the result is even parity, means it has even number of 1 bit, the parity register becomes set with value 1, otherwise, it becomes reset with value 0.

Example:

MVI A 06 (load 06H value in register A)

This instruction will set the value of parity flag to 1 as the BCD code of 06H is 00000110, which contains even number of ones here the no of 1s is 2.

5. Carry Flag (CY)

Carry is generated only when while performing n bit operations if it will lead to a result which has more than n bits, then this flag becomes set with value 1, otherwise it becomes reset with value 0.

Example:

MVI A 40 (load 40H value in register A)
MVI B 60 (load 60H value in register B)
SUB B (A = A – B)

These set of instructions will set the carry flag with value 1 as 40 – 60 generates answer with borrow.





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.