Programming Model 8086

Programming Model of 8086:

As a programmer of the 8086 we must be familiar with the various registers in the execution unit (EU) and Bus Interface Unit (BIU).

Figure-1: Figure: Programming Model of 8086

Registers of 8086

  • Data Group of Registers:

    These registers are also called the general purpose registers and are used to store both the operands and the result. These are all 16 bit registers and each of these registers can be used as a whole 16 bit register or as part (8 bit) register.
    The register AX is used as accumulator and the register BX, CX and DX in addition to being general purpose registers can also be used for special purpose roles as given below:

AX Accumulator
BX base register
CX  Counter
DX to hold i/o address during certain i/o operations.
  • Pointer and Index Registers:

    These registers includes :

    • Pointer Registers : BP, IP and SP
    • Index Registers : SI, DI

 These registers are used in forming the effective address of an instruction. To provide flexible base and index addressing, a data address may be formed by adding together the combination of BX or BP register contents, index (SI or DI) register content and the displacement. The resulting address is called effective address (EA).i.e. EA=base Register Contents+ Index register Contenets + 8/16 bit displacement.

  • Segment Registers: The 8086 memory is divided into four overlapping segments. The starting address of each segment is stored in the corresponding segment registers. These are:

    Register Full Name
    CS Code Segment Register
    DS Data Segment Register
    SS Stack Segment Register
    ES Extra Segment Register

    The physical address of a data or an instruction is formed by adding the content of the segment register and the effective address formed by adding base, index and the displacement. PHY ADD = EA + Beginning of Segment Address.

  • FLAG (STATUS) REGISTER or Program Status Word (PSW):

    The 8086 has a 16 bit flag register of which only 9 bits are used as flags and the rest 7 bits are not used. These flags are set or reset after the operation in an ALU. Six of the flags are status indicators, reflecting properties of the result of the last arithmetic or logical instructions. These are CF, AF, PF, ZF, SF and OF. The 8086/88 has several instructions that can be used to transfer program control to a new memory location based on the state of the flags. Three of the flags can be set or reset directly by the programmer and are used to control the operation of the processor. These are TF, IF, and DF. All the flags are discussed in the following paragraph

Flags of 8086 Microprocessor
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF

Pupose of the individual Flags:

Sr. No. Name of Flag Purpose
1 Carry flag (CF): Carry flag (CF) 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 instruction. Otherwise, CF is reset.
2 Parity flag (PF): PF is set if the result produced by the instruction has even parity-that is, if it contains an even number of bits at the 1 logic level. If parity is odd, PF is reset.
3 Auxiliary carry flag (AF): Auxiliary Carry (AP) is set if there is a carry-out from the low nibble into the high nibble or a borrow-in from the high nibble into the low nibble of the lower byte in a l6-bit word. Otherwise, AF is reset.
4 Zero flag (ZF): Zero Flag (ZF) is set if the result produced by an instruction is zero. Otherwise, ZF is reset.
5 Sign flag (SF): The MSB of the result is copied into SF. Thus, SF is set if the result is a negative number or reset if it is positive.
6 Overflow flag (OF): When OF is set, it indicates that the signed result is out of range. If the result is not out of range, OF remains reset.
The other three flags are control flags. These three flags provide control functions of the 8086 as follows:
1 Trap flag (TF): If TF is set, the 8086 goes into the single-step mode of operation.
2 Interrupt flag (IF): The IF controls the operation of the INTR (interrupt request) input pin If IF=1, the INTR pin is enabled; If IF=0, the INTR pin is disabled. The state of IF bit is controlled by the STI (set IF) and CLI (clear IF) instructions.
3 Direction flag (DF): The direction flag select either the increment or decrement mode for the DI and/or SI registers during string instructions. If D=1, the registers are automatically decremented; if D=0, these registers are automatically incremented. The DF is set with STD (set direction)) and cleared with CLD (clear direction) instructions. The direction can be set for the string operations.

Questions based on registers of 8086 microprocessor

  1. Describe the programming model of the 8086 microprocessor
  2. What are the general purpose registers in 8086 microprocessor
  3. Why are the segment registers required in 8086 microprocessor
  4. Name the different segment registers of 8086 microprocessor, also write the purpose of each.
  5. Name and explain the different control flags in 8086 Microprocessor
  6. Name and explain the status flags of the 8086 microprocessor
Updated: September 16, 2020 — 10:19 am

Leave a Reply

Your email address will not be published. Required fields are marked *

care4you © 2020 Connect On Facebook DMCA.com Protection Status