Internal Architecture and Features of the 8086 Microprocessor

8086 microprocessor

The 8086 microprocessor uses CISC architecture, meaning it supports many complex instructions. It has a 20-bit address bus that can access up to 1 MB of memory and a 16-bit data bus for transferring data.

Bus Interface Unit (BIU)

The BIU (Bus Interface Unit) handles all data and address transfers for the EU (Execution Unit). It sends out addresses, fetches instructions, reads data from memory or ports, and writes data to memory or ports. It mainly consists of two parts: the instruction queue and the segment registers.

The BIU can store up to 6 bytes of instructions in a queue using the FIFO (First In, First Out) method. When the EU is ready for the next instruction, it reads it directly from this queue. This helps speed up program execution by allowing instruction fetching and execution to happen at the same time. This process is called pipelining.

The BIU has a special unit to generate a 20-bit address. It uses four segment registers to hold the upper 16 bits of the starting addresses of four memory segments: code, data, stack, and extra. The 8086 divides its 1 MB memory into segments, each up to 64KB in size.

Code segment register and instruction pointer (IP):

The CS (Code Segment) register holds the starting address of the current code segment. The IP (Instruction Pointer) holds the offset or distance to the next instruction. By adding the CS address and the IP offset, the 8086 gets the exact address of the instruction to be fetched for execution.

Data Segment: The data segment contains the starting address of a program’s data segment. Instructions: Use this address to locate data. This address, plus an offset value in an instruction, causes a reference to a specific byte location in the data segment.

Stack Segment: The Stack Segment (SS) holds the starting address of the stack. The Stack Pointer (SP) gives the offset within this segment. Together, SS and SP point to the current location in the stack being accessed.

Extra Segment: The Extra Segment (ES) is used for handling memory addresses during string operations. String instructions use the ES register along with the Destination Index (DI) to calculate the 20-bit physical address.

Execution Unit (EU): The EU decodes and executes the instructions. The EU contains an arithmetic and logic unit (ALU), a control unit, and a number of registers. These features provide for the execution of instructions and arithmetic and logical operations. It has nine 16-bit registers which are AX, BX, CX, DX, SP, BP, SI, DI, and the flag. The first four can be used as 8 8-bit registers (AH, Al, BH, BL, CH, DH, DL).

AX register: The AX register is a 16-bit accumulator, and AL is its lower 8-bit part. Input/output (IN or OUT) instructions use AX for 16-bit data and AL for 8-bit data when transferring data to or from an I/O port.

BX register: The BX register is called the base register because it can be used to help calculate memory addresses. It is similar to the H and L registers in the 8085. BX can also work with DI or SI for special addressing methods.
 

2. Arithmetic Instructions: Arithmetic Instructions are used to perform basic mathematical operations such as addition, subtraction, multiplication, and division. In the 8086 microprocessor, examples include ADD, SUB, MUL, and DIV.

Examples:

  • ADD: Addition
  • SUB: Subtraction
  • MUL: Unsigned multiplication
  • IMUL: Signed multiplication
  • DIV: Unsigned division
  • IDIV: Signed division
  • INC: Increment
  • DEC: Decrement
     
ADD AX, BX ; AX = AX + BX
SUB CX, 1 ; CX = CX - 1
MUL BX ; AX = AX * BX

3. Logical Instructions: Logic Instructions are used to perform bitwise logical operations on data, such as AND, OR, XOR, and NOT. In the 8086 microprocessor, common logic instructions include AND, OR, XOR, and NOT.

Examples:

  • AND: Logical AND
  • OR: Logical OR
  • XOR: Logical XOR
  • NOT: Bitwise NOT
  • TEST: AND (affects flags only)
     
AND AL, 0F0H ; Clear lower 4 bits
OR AL, BL ; Set bits from BL

4. Control Transfer Instructions: Control Transfer Instructions are used to change the flow of execution in a program. In the 8086 microprocessor, these include jumps (JMP), calls (CALL), returns (RET), and conditional branches (like JE, JNE, JC). They are mainly divided into two types:

  1. Unconditional Transfer Instructions

  • These instructions always change the program flow.
  • Examples:
  • JMP – Unconditional jump to a specified location.
  • CALL – Calls a subroutine and saves the return address on the stack.
  • RET – Returns from a subroutine to the saved address.
  • INT – Calls an interrupt service routine.
  • 2 . Conditional Transfer Instructions
  • These instructions change the flow only if a specific condition is met, usually based on the status of flags (e.g., Zero Flag, Carry Flag).
  • Examples:
  • JE / JZ – Jump if equal / zero
  • JNE / JNZ – Jump if not equal / not zero
  • JC – Jump if carry
  • JNC – Jump if no carry
  • JG, JL, JGE, JLE – Jump based on greater/lesser comparisons
5. Loop Instructions: Loop Instructions in the 8086 microprocessor are used to repeat a block of code a specific number of times. They automatically update the CX register, which acts as a counter.
Example:
LOOP: loop until complete
LOOPE: Loop while equal
LOOPZ: loop while zero
LOOPNE: loop while not equal
LOOPNZ: loop while not zero

String Instructions in the 8086 microprocessor are used to perform operations on strings of data stored in memory. They work with the SI (Source Index), DI (Destination Index), and CX (Counter) registers, often in combination with the REP prefix for repeated execution.

Common String Instructions:

  1. MOVSB / MOVSW – Move byte/word from source to destination.
  2. LODSB / LODSW – Load byte/word from source into the accumulator (AL/AX).
  3. STOSB / STOSW – Store byte/word from the accumulator into a destination.
  4. SCASB / SCASW – Compare the accumulator with a byte/word in memory.
  5. CMPSB / CMPSW – Compare bytes/words from source and destination strings.
  6. REP – Repeat the following string instruction while CX ≠ 0.

Coding in Assembly language:
Assembly language programming language has taken its place in between the machine
language (low level) and the high-level language.

  •  A high-level language’s one statement may generate many machine instructions.
  • Low-level language consists of either binary or hexadecimal operations. One symbolic
    statement generates one machine-level instruction.

Advantage of ALP

  • They generate small and compact execution module.
  • They have more control over hardware.
  • They generate an executable module and run faster.

Disadvantages of ALP:

  • Machine dependent.
  •  Lengthy code
  • Error-prone (likely to generate errors).

Assembly language features:
The main features of ALP are program comments, reserved words, identifiers, statements, and directives that provide the basic rules and framework for the language.

Program comments:

  • The use of comments throughout a program can improve its clarity.
  •  It starts with a semicolon (;) and terminates with a new line.  E.g. 

ADD AX, BX                        ; Adds AX & BX

Identifiers:

  • An identifier (or symbol) is a name that applies to an item in the program that is expected to be referenced.
  •  Two types of identifiers are Name and Label.
  • Name refers to the address of a data item, such as NUM1 DB 5, COUNT DB 0
  • Label refers to the address of an instruction.
  •  E.g.: MAIN PROC FAR
  • L1: ADD BL, 73

Reserved words:

  • Certain names in assembly language are reserved for their own purpose to be used only under special conditions and include.
  •  Instructions : Such as MOV and ADD (operations to execute)
  •  Directives: Such as END, SEGMENT (information to assembler)
  • Operators: Such as FAR, SIZE
  •  Predefined symbols: such as @DATA, @ MODEL

Statements:

  • ALP consists of a set of statements with two types
  • Instructions, e. g. MOV, ADD.
  • Directives, e. g. define a data item.

Statents

Directives:

The directives are the number of statements that enable us to control the way in which the source program is assembled and lists. These statements, called directives, act only during the assembly of a program and generate no machine-executable code. The different types of directives are:

 1) The page and title listing directives: The page and title directives help to control the format of a listing of an assembled program. This is their only purpose, and they have no effect on the subsequent execution of the program.The page directive defines the maximum number of lines to list as a page, and the
maximum number of characters per line.

PAGE [Length] [Width]
Default: Page [50][80]

TITLE gives the title and places the title on the second line of each page of the program. TITLE text [comment].

2) SEGMENT directive

It gives the start of a segment for stack, data, and code.

  • Seg-name               Segment [align][combine][‘class’][Seg-name ENDS]
  • Seg-name ENDS
  • Segment name must be present, must be unique, and must follow assembly language naming conventions.
  • An ENDS statement indicates the end of the segment.
  • Align option indicates the boundary on which the segment is to begin; PARA is used to align the segment on a paragraph boundary.
  • The combine option indicates whether to combine the segment with other segments when they are linked after assembly. STACK, COMMON, PUBLIC, etc are combined types.
  • Class option is used to group related segments when linking. The class code for the code segment, the stack for the stack segment, and the data for the data segment.

3) PROC Directives

The code segment contains the executable code for a program, which consists of one or
more procedures, defined initially with the PROC directives and ended with the ENDP
directive.
PROC – name              PROC [FAR/NEAR]

…………….
…………….
…………….
PROC – name         ENDP

  •  FAR is used for the first executing procedure, and the rest of the procedures call will be NEAR.
  •  The procedure should be within the segment.

4) END Directive

  •  An END directive ends the entire program and appears as the last statement.
  •  ENDS directive ends a segment and ENDP directive ends a procedure. END PROC-Name

5) ASSUME Directive

  • An .EXE program uses the SS register to address the stack, DS to address the data
    segment and CS to address the code segment.
  •  Used in conventional full segment directives only.
  • The assume directive is used to tell the assembler the purpose of each segment in the
    program.
  •  Assume SS: Stack name, DS: Data Segname CS: codesegname

6) Processor directive

  •  Most assemblers assume that the source program is to run on a basic 8086 level computer.
  •  Processor directive is used to notify the assembler that the instructions or features introduced by the other processors are used in the program. E.g. .386 – program for 386 protected mode.

7) Dn Directive (Defining data types)

Assembly language has directives to define data syntax [name] Dn expression The Dn directive can be any one of the following:
DB             Define byte                     1 byte
DW            Define word                    2 bytes
DD            Define double                 4 bytes
DF            defined farword              6 bytes
DQ           Define quadword            8 bytes
DT           Define 10 bytes                10 bytes

Assembling, Linking and Executing

1.Assembling

  • Assembling is the process of changing a source program into an object program, but only if there are no syntax errors. It creates a temporary file called a .obj file or module.
  • It also calculates the memory address (offset) for each piece of data in the data section and for each instruction in the code section.
  • A header is added to the .obj file, which contains some incomplete addresses needed later.
  • If there is a syntax error, the assembler will show an error and will not create the object file.
  • The assembler usually creates three files: .obj, .lst, and .crf. The last two are optional and may be created during the process.
  • For small programs, a programmer can assemble the code manually by converting each instruction (mnemonic) into machine code using a lookup table.
  • The assembler reads each instruction as text (ASCII characters) and translates it into the correct machine code.

Assembler Types: There are two types of assemblers:

a) One-pass assembler:

  • This type of assembler reads the assembly language program only once and directly converts it into object code at the same time.
  • This assembler has the program of defining forward references only.
  • The jump instruction uses an address that appears later in the program during scan; in that case, the programmer defines such addresses after the program is assembled.

b) Two pass assembeler:

A two-pass assembler reads the assembly language program two times (in two passes) to convert it into object code.

  • First Pass: It reads the entire program to identify all labels and calculate their addresses. It stores this information in a symbol table but does not generate machine code yet.
  • Second Pass: It reads the program again and converts each instruction into machine code using the symbol table created in the first pass.

2. Linking:

Linking is the process of combining one or more object files to create a single executable file. Here’s what happens during linking:

  • It connects different parts of the program that were written separately or in different files.
  • It resolves external references, like functions or variables used in one file but defined in another.
  • It uses information from the object files (.obj) and library files to join everything together correctly.
  • The result of linking is usually an executable file (.exe) that can be run by the computer.

Address Mode of 8086

Addressing modes describe types of operands and the way in which they are accessed for executing an instruction. An operand address provides source of data for an instruction to process an instruction to process. An instruction may have from zero to two operands. For two operands first is the destination and the second is the source operand. The basic modes of addressing are register, immediate, and memory, which are described below.

1. Register Addressing:

Register Addressing is an addressing mode where the data (operand) is kept inside a register.In this mode, the instruction uses the register name directly to get or store the data.It is very fast because the processor can access data from registers quickly.In this mode, both the source and destination of the data can be registers.e.g.

                                        MOV AX, BX

2. Immediate Addressing 

In this addressing mode, the immediate data is included directly as part of the instruction itself. It appears as one or more bytes right after the instruction. This mode uses a constant value or an expression.

   Example:

             MOV AH, 35H
             MOV BX, 7A25H

3) Direct memory addressing:
In this type of addressing mode, a 16-bit memory address (offset) is directly specified in the instruction as a part of it. One of the operands is the direct memory and the other operand is the register.

                                  E.g. ADD AX, [5000H]

 

 

error: Content is protected !!
Scroll to Top