MP
UNIT 2
1. 8086 Architecture
                       Caption
Overview:
    • 16-bit microprocessor by Intel.
     • Address Bus: 20-bit → Can address up
   to 1MB of memory.
     • Data Bus: 16-bit.
     • Follows CISC architecture.
     • Works in Minimum and Maximum
   mode.
Main Blocks:
A. Bus Interface Unit (BIU):
    • Fetches instructions from memory.
    • Calculates memory addresses.
    • Contains:
          • Instruction Queue (6 bytes)
          • Segment Registers (CS, DS, SS,
         ES)
          • Instruction Pointer (IP)
B. Execution Unit (EU):
     • Decodes and executes instructions.
     • Contains:
           • ALU
           • General-purpose registers (AX,
          BX, CX, DX)
           • Flags
           • Control unit
Segment Registers:
    • CS: Code Segment
    • DS: Data Segment
    • SS: Stack Segment
    • ES: Extra Segment
⸻
2. Pin Diagrams (40-pin DIP)
               Caption
8086 operates in two modes:
     • Minimum Mode: Single processor
     • Maximum Mode: Multiprocessor
Important Pins:
Pin Description
AD0–AD15 Address/Data lines (multiplexed)
A16–A19/S3–S6 Address/Status lines
RD Read signal
WR Write signal
ALE Address Latch Enable
INTR Interrupt Request
NMI Non-maskable Interrupt
CLK Clock input
RESET Resets the processor
3. Timing Diagram
Types:
        1. Read Cycle Timing:
            • Shows how 8086 reads data from
           memory.
            • Uses ALE, RD, and address/data
           lines.
        2. Write Cycle Timing:
            • Shows how 8086 writes data to
           memory or I/O.
            • Uses ALE, WR, and data lines.
T-States:
     • T1: Address is placed on the bus.
     • T2–T4: Data transfer occurs.
                     Caption
      • Wait States (Tw): Introduced if device
   is slow.
⸻
4. Addressing Modes
Types:
          1. Immediate: Operand is a constant.
             • MOV AX, 1234H
          2. Register: Operand is in register.
             • MOV AX, BX
          3. Direct: Memory address is given
         directly.
             • MOV AX, [1234H]
          4. Register Indirect: Address in
         register.
             • MOV AX, [BX]
          5. Indexed: Offset in index register.
             • MOV AX, [SI]
          6. Base + Index: MOV AX, [BX+SI]
          7. Relative: Used in branching
         instructions.
⸻
5. Instruction Set
Groups:
    • Data Transfer: MOV, PUSH, POP,
   XCHG, IN, OUT
    • Arithmetic: ADD, SUB, INC, DEC,
   MUL, DIV, NEG
    • Logical: AND, OR, XOR, NOT, TEST
    • Control Transfer: JMP, CALL, RET,
   LOOP, JZ, JNZ
    • String Instructions: MOVSB,
   MOVSW, LODSB, STOSB
    • Flag Control: STC, CLC, CLI, STI
    • Shift/Rotate: SHL, SHR, ROL, ROR
⸻
6. Instruction Templates
Instruction Description Example
MOV dest, src Copy src to dest MOV AX,
BX
ADD dest, src dest = dest + src ADD AX,
0100H
JMP label Jump to label JMP START
PUSH src Push on stack PUSH AX
POP dest Pop from stack POP AX
7. Assembly Language
Programming
A. Procedure
     • A block of code that performs a
   specific task.
PROC_NAME PROC
 ; Code
 RET
PROC_NAME ENDP
B. Macros
     • Named block of instructions; expanded
   inline at compile time.
MYMACRO MACRO
 MOV AX, BX
 ADD AX, 1
ENDM
MYMACRO ; Invokes macro
C. Number Conversion Example
      1. Decimal to Binary:
MOV AX, DECIMAL
MOV CX, 0AH ; divide by 10
DIV CX
        2. Binary to BCD:
    • Use DAA instruction after ADD for
   BCD correction.
D. String Operations
8086 has dedicated string instructions:
Instruction Description
MOVSB Move byte from DS:SI to ES:DI
LODSB Load byte from DS:SI into AL
STOSB Store AL into ES:DI
SCASB Compare AL with byte at ES:DI
CMPSBCompare byte at DS:SI with ES:DI
Example: Copy a string
CLD       ; Clear direction flag
MOV CX, LENGTH ; String length
MOV SI, OFFSET SRC
MOV DI, OFFSET DEST
REP MOVSB      ; Repeat move string byte