0
6.5kviews
Explain flag register of 8086 and explain use of general purposed register.

Subject: MICROPROCESSOR & PERIPHERALS INTERFACING

Topic: Architecture of 8086 Microprocessor

Difficulty:Medium

1 Answer
0
90views

Flag Register

  1. Flag register is a part of EU (Execution Unit). It is a 16 bit register with each bit corresponding to a flip-flop.

  2. A flag is a flip-flop. It indicates some condition produced by the execution of an instruction. For example the zero flag (ZF) will set if the result of execution of an instruction is zero.

  3. Figure below shows the details of the 16 bit flag register of 8086 CPU.

enter image description here

  • It consists of 9 active flags out of 16. The remaining 7 flags marked ‘U’ are undefined flags.

  • These 9 flags are of two types:

  • 6 Status flags

  • 3 Control flags

Status Flag

  • Carry flag (CY)

    It is set whenever there is a carry or borrow out of the MSB (most significant bit) of a result.

    D7 bit for an 8 bit operation and D15 bit for a 16 bit operation.

  • Parity flag (PF)

    It is set if the result has even parity.

    If parity is odd, PF is reset.

    This flag is normally used for data transmission errors.

  • Auxiliary carry flag (AC)

    It is set if a carry is generated out of the lower nibble.

    It is used only in 8 bit operations like DAA and DAS.

  • Zero flag (ZF)

    It is set if the result is zero.

  • Sign flag (SF)

    It is set if the MSB of the result is 1. For signed operations such a number is treated as negative.

  • Overflow flag (OF)

    It will be set if the result of a signed operation is too large to fit in the number of bits available to represent it.

    It can be checked using the instruction INTO (Interrupt on Overflow).

Control flags:

  • Trap flag (TF)-

    It is used to set the trace mode i.e. start single stepping mode.

    Here the microprocessor is interrupted after every instruction so that the program can be debugged.

  • Interrupt enable flag (IF)-

    It is used to mask (disable) or unmask (enable) the INTR interrupt. If user sets IF flag, the CPU will recognize external interrupt requests. Clearing IF disables these interrupts.

  • Direction flag (DF)-

    If this flag is set, SI and DI are in the auto-decrementing mode in string operations.

General Purpose Register

General purpose registers are used to store temporary data within the microprocessor. There are 8 general purpose registers in 8086 microprocessor.

Figure – General purpose registers

1) AX – This is the accumulator. It is of 16 bits and is divided into two 8-bit registers AH and AL to also perform 8-bit instructions.

It is generally used for arithmetical and logical instructions but in 8086 microprocessor it is not mandatory to have accumulator as the destination operand.

Example:

ADD AX, AX (AX = AX + AX)

2) BX – This is the base register. It is of 16 bits and is divided into two 8-bit registers BH and BL to also perform 8-bit instructions. It is used to store the value of the offset.

Example:

MOV BL, [500] (BL = 500H)

3) CX – This is the counter register. It is of 16 bits and is divided into two 8-bit registers CH and CL to also perform 8-bit instructions. It is used in looping and rotation. Example:

MOV CX, 0005 LOOP

4) DX – This is the data register. It is of 16 bits and is divided into two 8-bit registers DH and DL to also perform 8-bit instructions. It is used in multiplication an input/output port address.

Example:

MUL BX (DX, AX = AX * BX)

5) SP – This is the stack pointer. It is of 16 bits. It points to the topmost item of the stack. If the stack is empty the stack pointer will be (FFFE)H. It’s offset address relative to stack segment.

6) BP – This is the base pointer. It is of 16 bits. It is primary used in accessing parameters passed by the stack. It’s offset address relative to stack segment.

7) SI – This is the source index register. It is of 16 bits. It is used in the pointer addressing of data and as a source in some string related operations. It’s offset is relative to data segment.

8) DI – This is the destination index register. It is of 16 bits. It is used in the pointer addressing of data and as a destination in some string related operations.It’s offset is relative to extra segment.

  • The above registers can also be temporary storage of data just as other general puropose register.
Please log in to add an answer.