Features

  1. Size: it is a 16 bit microprocessor.
  2. Address bus🚍: 20 bit address bus.
  3. Instruction Queue?📜: Yes, it has a instruction queue which can store upto 6 bytes.
  4. Pipelining support?: yes
  5. Data lines: it has 16 data lines.
  6. Memoryđź’ľ: Access upto 1 Mb of memory.
  7. Flag register sizeđźš©: 16 bits but only 9 bits are used.

“flag register”

General purpose registers

The general purpose registers are either used for holding data temporarily. They can also be used as a counters or used for storing offset address for some particular addressing modes.

There are 8 general purpose registers, i.e. AH, AL, BH, BL, CH, CL, DH, and DL. These registers can be used individually to store 8-bit data and can be used in pairs to store 16bit data. The H and L suffix on the 8 bit registers stand for high byte and low byte. These H and L makes a pair(AX, BX, CX, DX) of 16 bits. The letter X is used to specify the complete 16-bit register.

  • AX: The register AX is used as 16-bit accumulator whereas register AL (lower byte of AX) is used as 8-bit accumulator.

  • BX: It is used as a base register. It is used to store the starting base address of the memory area within the data segment.

  • CX: It is referred to as counter. It is used in loop instruction to store the loop counter.

  • DX: This register is used to hold I/O port address for I/O instruction.

Pointer registers

  • IP (Instruction Pointer): It is a 16-bit register used to hold the address of the next instruction to be executed. It is also known as PC(program counter).
  • BP (Base Pointer): Holds the base address of the stack.
  • SP (stack Pointer): Holds the top address of the stack.
esp registerebp register

Index registers

An index register is used for pointing to operand addresses during the run of a program. It is useful for stepping through strings and arrays. It can also be used for holding loop iterations and counters as well as for offset address.

  • SI (Source Index): used for string and memory array copying.
  • DI (Destination Index): DI is the Destination Index register performs the same function as SI.There is a class of Instructions called String Operations,that use DI to access the memory locations addressed by ES.

An example Program which copies a null-terminated string from the source_string to the destination_string using SI and DI registers.

section .data
    source_string db "Hello, World!", 0   ; Null-terminated source string
    destination_string db 20 dup(0)       ; Destination string with space for copying

section .text
    global _start

_start:
    mov esi, source_string   ; Load the address of the source string into SI
    mov edi, destination_string ; Load the address of the destination string into DI

copy_loop:
    mov al, [esi]           ; Load a byte from the source string into AL
    mov [edi], al           ; Store the byte from AL into the destination string
    inc esi                 ; Move SI to the next byte in the source string
    inc edi                 ; Move DI to the next byte in the destination string
    cmp al, 0               ; Compare the byte with null terminator
    je copy_done            ; If null terminator reached, exit the loop
    jmp copy_loop           ; Jump back to copy_loop to continue copying

copy_done:
    ; Add termination for the destination string
    mov byte [edi], 0

    ; Exit the program
    mov eax, 1              ; syscall number for exit
    xor ebx, ebx            ; exit status 0
    int 0x80                ; Call the kernel

section .bss
    ; Define uninitialized space for variables if needed

Memory segmentation

The physical address of the 8086 is 20-bits wide to access 1 M byte memory locations. However, its registers and memory locations which contain logical addresses are just 16-bits wide. Hence 8086 uses memory segmentation. It treats the 1 M byte of memory as divided into segments, with a maximum size of a segment as 64 Kbytes. Thus any location within the segment can be accessed using 16 bits. The 8086 allows only four active segments at a time.


What is a physical address? A physical address refers to the actual location of data or instructions in the physical memory (RAM) hardware. The physical memory is the actual hardware that stores the program’s data and code. The physical address is accessed through the corresponding logical address because a user cannot directly access the physical address.
What is a logical address? The logical address is a virtual address created by the CPU of the computer system. The logical address of a program is generated when the program is running. A group of several logical address is referred to a logical address space. Logical address of the program is visible to the users.
Logical address is also known as? Virtual Address.
What does MMU(Memory management unit) do?

logical address -> physical address


Segment registers

  • CS (Code Segment): Points to the segment containing the program’s executable code. The combination of CS and the Instruction Pointer (IP) is used to fetch instructions for execution.

  • DS (Data Segment): Points to the segment holding the program’s data. It’s used when the program wants to read or write data.

  • ES (Extra Segment): ES is additional data segment, which is used by the string to hold the extra destination data.

  • SS (Stack Segment): It handles memory to store data and addresses during execution. It works in conjunction with the Stack Pointer (SP) to manage the stack for function calls and local variables.

segment registers

Generation of 20 bit address

  • We konw registers are of 16 bits but address line is 20 bits, so the BIU always inserts zeros for the lower 4 bits (nibble) in the contents of segment register to generate 20-bit base address.

For example, if the code segment register contains 348A H, then code segment will start at address 348A0 H (segment address).

  • Then 16 bit offset address is added to the segment address. The offset is specified using a general-purpose register (like BX, SI, or DI), and the segment register is used to calculate the effective memory address.

Accessing memory: (segment_base « 4) + offset

eg: (CS « 4) + IP

physical address generation

Each segment requires particular segment register and offset register to generate 20-bit physical address as shown in table below:

Segment RegisterOffset RegisterSpecial Purpose
CSIPInstruction address
SSSP or BPStack address
DSBX, DI, SI, 8-bit or 16-bit numberData address
ESDI for string instructionString destination address

Address calculation of stack segment with the help of SP

stack segment

Logical Address in 8086 consists of a segment value and an offset address. Logical address is specified as segment: offset.

If logical address is A4FB:4872, then calculate the physical address

A4FB0 + 4872 = A9822