# Flag registers of 8085 Microprocessor

Here, we are going learn about the **different types of flag registers of 8085 Microprocessor**.

Submitted by Akash Kumar, on November 08, 2018

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.

These 5 flags 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.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.