Question Bank from Unit-I and Unit-II
Microprocessor and Microcontroller
Flags
Q. 1 Draw the flag register format of 8086? What are the functions of status and control flags?
Structure of Flag -
D1 D1 D1 D12 D11 D10 D9 D8 D D6 D5 D4 D3 D2 D1 D0
5 4 3 7
× × × × OV D I T S Z × AC × P × CY
Status Flag: These flags of the microprocessor reflect the result after arithmetic or logical operation
performed by the microprocessor. There are six status flags in 8086 microprocessor.
(i) Carry Flag: It is set if there is a carry-out or a borrow-in for the most significant bit of the
result during the execution of an arithmetic instruction. Otherwise it is reset.
(ii) Parity Flag: It is set if result of a byte operation or lower byte of the word operation
contain an even number of ones, otherwise it is zero.
(iii) Auxiliary Carry Flag: It is set if there is a carry-out or a borrow-in for the lower nibble of
a 8 bit or a 16 bit number. This flag is used for BCD operations and it is not available for
the programmer.
(iv) Zero Flag: It is set if the result of an arithmetic or logic operation is zero, otherwise it is
reset.
(v) Sign Flag: After the execution of arithmetic or logical operation, if the MSB of the result
is 1, the sign flag is set. Sign flag 1 indicates the result is negative, otherwise it is
positive.
(vi) Overflow Flag: It is set if the signed result is out of range. During addition this flag is set
when there is a carry into the MSB and no carry out of the MSB or vice-versa. For
subtraction, it is set when the MSB needs a borrow and there is no borrow from the
MSB or vice-versa
EXAMPLE:
After adding two sixteen bit numbers 65D1H and 2359H the result is 892AH and the status of
various status flags are as follows:
Carry flag = 0, Parity flag = 0, Auxiliary Carry flag = 0
Sign flag = 0, Zero flag = 0, Overflow flag = 1
Control Flag: These flags control certain operations of the microprocessor. There are three status
flags in 8086 microprocessor.
(i) Direction Flag: This flag is used in string manipulation instructions.
If it is ‘0’, then the microprocessor works in auto increment mode i.e the string is processed from
the lowest address to the highest address.
If it is ‘1’, then the microprocessor works in auto decrement mode i.e the string is processed from
the highest address to lowest the address.
(ii) Interrupt Flag: This flag must be set to recognize maskable interrupt request at the INTR
©Prepared By: Dr. Yogesh Misra, Professor in ECE, GMRIT, Rajam
1
input of 8086. When this flag is reset, the requests at INTR are ignored.
(iii) Trap Flag: If this flag is set then microprocessor enters in the single step execution
mode. In other words, if this flag is set then trap interrupt is generated after the
execution of each instruction. This mode of operation is used for debugging of software.
©Prepared By: Dr. Yogesh Misra, Professor in ECE, GMRIT, Rajam
2