Write the function of segment register and flag register.


The function flag register: The Flag register is a Special Purpose Register Depending upon the value of result after any arithmetic and logical operation the flag bits become set (1) or reset (0).
There are total 9 flags in 8086 and the flag register is divided into two types:
Figure: 8086 flag register format



Status Flags: There are 6 flag registers in 8086 microprocessor which become set(1) or reset (0) depending upon condition after either 8-bit or 16-bit operation. These flags are conditional/status flags. 5 of these flags are same as in case of 8085 microprocessor and their working is also same as in 8085 microprocessor. The sixth one is the overflow flag.
(i) Zero Flag (Z): After any arithmetical or logical operation if the result is 0 (00) H, the zero flag becomes set i.e. 1, otherwise it becomes reset i.e. 0. 00 H zero flag is 1.
from 01 H to FFH zero flag is 0
1 - zero result
0 – non-zero result
(ii) Auxiliary Cary Flag (AC): This flag is used in BCD number system (0-9). If after any arithmetic or logical operation D (3) generates any carry and passes on to B (4) this flag becomes set i.e. 1, otherwise it becomes reset i.e. 0. This is the only flag register which is not accessible by the programmer 1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise
(iii) Parity Flag (P): If after any arithmetic or logical operation the result has even parity, an even number of 1 bits, the parity register becomes set i.e. 1, otherwise it becomes reset i.e. 0.1-accumulator has even number of 1 bits
0-accumulator has odd parity
(iv) Carry Flag (CY): Carry is generated when performing n bit operations and the result is more than n bits, then this flag becomes set i.e. l, otherwise it becomes reset i.e. 0.
During subtraction (AB), 1f A > B it becomes reset and if (A < B) it becomes set.
Carry flag is also called borrow flag 1-carry out from MSB bit on addition or borrow into MSB bit on subtraction
0-no carry out or borrow into MSB bit
(v) Overflow Flag (O): This flag will be set (1) if the result of a signed operation is too large to fit in the number of bits available to represent it otherwise reset (0). After any operation, if D [6] generates any carry and passes to D [7] OR if D [6] does not generates carry but D [7] generates, overflow flag becomes set, i.e., 1. If D [6] and D [7] both generate carry or both do not generate any carry, then overflow flag becomes reset, i.e., 0.
(vi) Control Flags: The control flags enable or disable certain operations of the microprocessor. There are 3 control flags in 8086 microprocessor and these are:
(vii) Directional Flag (D): This flag is specifically used in string instructions. If directional flag is set (1), then access the string data from higher memory location towards lower memory location: If directional flag is reset (0), then access the string data from lower memory location towards higher memory location.
(viii) Interrupt Flag (I): This flag is for interrupts. If interrupt flag is set (1), the microprocessor will recognize interrupt requests from the peripherals: If interrupt flag is reset (0), the microprocessor will not recognize and interrupt requests and will ignore them.
(ix) Trap Flag (T): This flag is used for on chip debugging setting trap flag puts the microprocessor into single step mode for debugging. In single stepping, the microprocessor executes a instruction and enters into single step ISR. If trap flag is set (1), the CPU automatically generates an internal interrupt after each instruction, allowing program to be inspected as it executes instruction by instruction.
If trap flag is reset (0), no function is performed.
The function Segmented register: Segments are specific areas defined in a program for containing data, code and stack. There are three main segments –
(i) Code Segment: It contains all the instructions to be executed. A 16-bit code Segment register or CS register stores the starting address of the code segment.
(ii) Data Segment: It contains data, constants and work areas. A 16-bit Data Segment register or DS register stores the starting address of the data Segment.

(iii) Stack Segment: It contains data and return addresses of procedures or subroutines. It is implemented as a 'stack' data structure. The Stack Segment register or SS register stores the starting address of the stack. Apart from the DS, CS and SS registers, there are other extra segment registers ES (extra segment), FS and GS, which provide additional segments for storing data. 

No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.