Comprehensive Study Notes on 8086 Microprocessor Architecture, Programming, Interrupts, and Serial Communication
Microprocessor Fundamentals: Comparison Between 8085 and 8086
Intel introduced the 8086 microprocessor in 1976 as an advanced, 16-bit enhancement of the earlier 8-bit 8085 microprocessor.
The 8086 is fabricated using N-channel, High-speed Metal Oxide Semiconductor (HMOS) technology and housed in a 40-pin Dual Inline Package (DIP).
Structural and operational distinctions between the 8085 and 8086 processors:
Data Bus Width: The 8085 has an 8-bit data bus; the 8086 features a 16-bit data bus, allowing it to read or write 16 bits (one word) in a single bus cycle.
Address Bus Width and Memory Capacity: The 8085 provides a 16-bit address line addressing up to of memory. The 8086 provides a 20-bit address line addressing up to () of physical memory space.
Clock Frequencies: The 8085 typically operates at a clock speed of . The 8086 offers versions operating at clock frequencies of (standard 8086), (8086-2), and (8086-1).
Flag Register: The 8085 contains 5 active flags. The 8086 features 9 active flags (6 conditional/status flags and 3 control flags) embedded in a 16-bit flag register.
Memory Segmentation: The 8085 has a single flat memory space without hardware segmentation. The 8086 implements memory segmentation, dividing physical memory into logical segments of up to each.
Pipelining and Instruction Queue: The 8085 lacks instruction prefetching and pipelining (fetch and execute phases are strictly sequential). The 8086 incorporates a 6-byte instruction pre-fetch queue that allows overlapping instruction fetching with execution.
Processor Architecture Model: The 8085 is an accumulator-based microprocessor (the accumulator register is heavily tied to ALU operations). The 8086 is a general-purpose register-based processor.
Operating Modes: The 8085 operates in a single configuration mode. The 8086 operates in two distinct hardware modes: Minimum Mode (single-processor systems) and Maximum Mode (multiprocessor or coprocessor configurations).
Multiprocessing Support: In 8085 systems, only a single processor is used. In 8086 systems, multiple processors or external numeric data coprocessors (such as the 8087) can be employed.
Integration Density: The 8085 contains approximately transistors. The 8086 integrates approximately transistors.
System Cost: The 8085 involves lower implementation and chip costs, whereas the 8086 has a higher system design and component cost.
Intel 8086 Architecture and Register Organization

The internal architecture of the 8086 is partitioned into two independent processing units working concurrently to implement pipelining: the Bus Interface Unit (BIU) and the Execution Unit (EU).
Bus Interface Unit (BIU):
Interfaces directly with the system buses to execute all memory read/write cycles, instruction fetching, and I/O port read/write operations.
Contains the dedicated 20-bit address calculation adder circuit, calculating physical memory addresses using the relation:
Holds the 6-Byte Instruction Pre-fetch Queue, constructed using First-In, First-Out (FIFO) registers. While the Execution Unit executes an instruction, the BIU continuously prefetches up to 6 bytes of upcoming instruction code from memory, eliminating fetch-cycle latency.
Houses the four 16-bit Segment Registers:
Code Segment (CS): Points to the base of the code segment containing executable instructions.
Data Segment (DS): Points to the base of the data segment holding program variables and operands.
Stack Segment (SS): Points to the base of the stack segment dedicated to stack data and return addresses.
Extra Segment (ES): Serves as an additional data segment, commonly used for destination data in string operations.
Holds the 16-bit Instruction Pointer (IP) register, which holds the 16-bit offset address of the next sequential byte to be fetched from the Code Segment (). The IP is not directly accessible or alterable by programmer instructions; it updates automatically or via control transfer instructions.
Execution Unit (EU):
Responsible for decoding instructions, fetching operands from general-purpose registers or the BIU internal data bus, executing arithmetic and logic operations, and updating condition flags.
Contains the Arithmetic Logic Unit (ALU), which handles 8-bit and 16-bit arithmetic (addition, subtraction, multiplication, division) and logical operations.
Houses the Control Unit, which generates internal timing and control signals based on decoded opcodes.
Contains four 16-bit General Purpose Registers, which can also be addressed as eight individual 8-bit registers (High and Low bytes):
AX (Accumulator Register): Divided into and . Preferred register for arithmetic, logical, and data transfer operations as it yields the most compact machine code; mandatory for hardware multiplication, division, and direct I/O port instructions.
BX (Base Register): Divided into and . Commonly used for base addressing and can store memory offset addresses.
CX (Count Register): Divided into and . Serves as an automatic loop counter in loop instructions (
LOOP,JCXZ) and as a shift/rotate bit-counter via .DX (Data Register): Divided into and . Holds high-order bits during 32-bit multiplication/division results and acts as an indirect I/O port address pointer (
[DX]).Houses four 16-bit Pointer and Index Registers (accessible only as full 16-bit words, not split into high/low bytes):
Stack Pointer (SP): Holds the offset address to the current top of the stack within the Stack Segment ().
Base Pointer (BP): Primarily used to access parameters and local variables on the stack frame; defaults to the Stack Segment ().
Source Index (SI): Holds offset addresses when accessing data in the Data Segment; serves as the source offset in string operations ().
Destination Index (DI): Holds memory offset addresses; acts as the destination string offset in string operations ().
Flag Register (Status and Control Flags):

Consists of a 16-bit register where 9 bits function as active status or control indicators, while the remaining 7 bits are undefined/reserved (marked as ):
High Byte ():
X,X,X,X,OF,DF,IF,TFLow Byte ():
SF,ZF,X,AF,X,PF,X,CF
Six Conditional / Status Flags: Set () or cleared () automatically based on the result of an arithmetic or logical operation:
Carry Flag (CF, bit 0): Sets to if an arithmetic operation generates a carry out of the most significant bit (for addition) or a borrow (for subtraction); otherwise cleared to .
Parity Flag (PF, bit 2): Sets to if the low-order 8 bits of the result contain an even number of s (even parity); clears to if odd parity.
Auxiliary Carry Flag (AF / AC, bit 4): Sets to if a carry or borrow occurs from bit to bit (between the low and high nibbles) during binary-coded decimal (BCD) arithmetic. This is the only flag register bit that cannot be directly tested by branch instructions.
Zero Flag (ZF, bit 6): Sets to if the mathematical or logical result of an operation is exactly zero ( or ); cleared to if non-zero.
Sign Flag (SF, bit 7): Copies the most significant bit (MSB) of the result ( for 8-bit, for 16-bit). indicates a negative result, and indicates a positive result.
Overflow Flag (OF, bit 11): Sets to when the signed arithmetic result is too large (positive or negative) to fit in the destination register; signals an arithmetic overflow in two's complement operations.
Three Control Flags: Enable or disable specific processor operations:
Trap Flag (TF, bit 8): When set to , puts the processor into single-step execution mode for on-chip debugging. The CPU generates an internal Type 1 interrupt after executing each individual instruction.
Interrupt Enable Flag (IF, bit 9): When set to , the microprocessor recognizes external maskable hardware interrupt requests arriving on the pin. When cleared to , maskable interrupts are ignored.
Direction Flag (DF, bit 10): Used exclusively by string instructions. If (cleared via
CLD), auto-indexing increments and (string processing moves from low memory to high memory). If (set viaSTD), auto-indexing decrements and (string processing moves from high memory to low memory).
Pin Configuration and Signals of the 8086 Microprocessor

The 8086 is a 40-pin Dual Inline Package integrated circuit powered by a single supply connected to (pin 40), with reference ground connections on pins 1 () and 20 ().
Pin functions are divided into common signals, Minimum Mode signals, and Maximum Mode signals (determined by pin 33, ).
Common Signals (Pins 1–23 and 32–40):
(Pins 16–9, 8–2, 39): Bidirectional, time-multiplexed Address/Data bus. During bus state , they carry low-order memory addresses () or I/O addresses. During states and , they carry 16-bit data ().
(Pins 38–35): Time-multiplexed high-order address lines and bus status lines. Address bits are output during . During and , they output status bits :
Bits encode the segment register used for the current bus cycle (, , , ).
Bit indicates the state of the Interrupt Enable Flag (IF).
Bit is always held at logic .
(Pin 34): Bus High Enable / Status line. Asserted active low during to enable data onto the most significant half of the data bus (). Used when transferring a byte to/from an odd memory address or a full 16-bit word. Multiplexed with status signal during later clock states.
(Pin 32): Read strobe, active low output. Indicates the processor is reading memory or I/O data.
(Pin 22): Active high input signal from addressed memory or I/O devices indicating data transfer readiness; if low, the processor inserts wait states ().
(Pin 21): System reset, active high input. Must remain high for at least 4 clock cycles to clear internal registers, setting and .
(Pin 19): Clock input providing internal timing, operating at , , or .
(Pin 18): Interrupt Request, level-triggered active high input sampled during the final clock state of each instruction.
(Pin 17): Non-Maskable Interrupt, positive edge-triggered input (). Must remain high until recognized, and must be held at logic for at least 2 clock cycles before the transition.
(Pin 23): Active low input evaluated by the
WAITinstruction. If low, execution proceeds; if high, the CPU idles.(Pin 33): Mode selection pin. Connected to for Minimum Mode; tied to Ground for Maximum Mode.
Minimum Mode Signals (, Pins 24–31):
(Pin 31): Bus request input from DMA controllers.
(Pin 30): Hold Acknowledge output signaling the CPU has placed the buses into high-impedance state.
(Pin 29): Write strobe, active low output.
(Pin 28): Output distinguishing memory access (high) from I/O port access (low).
(Pin 27): Data Transmit/Receive output controlling the direction of bidirectional bus transceivers (, ).
(Pin 26): Data Enable, active low output enabling external data bus transceivers.
(Pin 25): Address Latch Enable, active high pulse used to latch the address from multiplexed lines into external latches (e.g., 8282/74LS373) during .
(Pin 24): Interrupt Acknowledge, active low output pulse generated in response to an input.
Maximum Mode Signals (, Pins 24–31):
and (Pins 31, 30): Bidirectional lines used by other bus masters to request and obtain bus control.
(Pin 29): Output asserting that other system bus masters cannot seize bus ownership during the locked instruction.
(Pins 28, 27, 26): Status outputs decoded by the external 8288 Bus Controller to generate system read/write bus commands.
(Pins 25, 24): Queue Status outputs reflecting internal instruction queue operations (, , , ).
Memory Segmentation, Stack Organization, and Physical Address Calculation
Memory Segmentation Principles:
The physical address space ( to ) is organized into logical segments of up to ().
Segment base addresses always begin on 16-byte boundaries (known as paragraph boundaries, where the lowest hexadecimal digit is ).
Standard segment register pairing with offset registers:
Code Segment (): paired with Instruction Pointer () to fetch instruction opcodes.
Data Segment (): paired with , , or for regular data operands.
Stack Segment (): paired with Stack Pointer () or Base Pointer () for stack operations.
Extra Segment (): paired with (and or ) for string destinations and general data.
Step-by-Step Physical Address Calculation Algorithm:
Step 1 (Compute Effective Address): Calculate the effective offset address () using the specified registers and displacements:
Step 2 (Identify Default Segment): Apply default hardware rules:
If the base/offset expression contains , the default segment is the Stack Segment (SS).
If the expression uses , , or (without ), the default segment is the Data Segment (DS).
Step 3 (Calculate Segment Base): Shift the 16-bit segment register left by 4 bits (multiply by or ):
Step 4 (Sum Base and Offset): Add the Effective Address to the Segment Base to yield the 20-bit Physical Address ():
Worked Numerical Address Calculation Examples:
Direct Addressing: Given , Instruction
MOV AX, [2500H].Based Addressing: Given , Instruction
MOV AX, [BP].Based-Indexed Addressing: Given , Instruction
MOV AX, [BX + SI].Based-Indexed with Displacement: Given , Instruction
MOV AX, [BX + SI + 20H].BP with Index and Displacement: Given , Instruction
MOV AX, [BP + DI + 50H].
Stack Memory Mechanics:

The stack is a LIFO (Last-In, First-Out) memory structure growing downward from high memory toward low memory addresses.
The bottom of the stack resides at offset
FFFEh, and the upper limit (end of stack) is at0000h.Current stack operations are referenced by the physical pointer .
PUSHOperation (16-bit word):The stack pointer decrements by 2:
Memory address calculated:
Higher byte stored at and lower byte at
POPOperation (16-bit word):Data retrieved from memory:
The stack pointer increments by 2:
Instruction Format, Instruction Cycle, and Machine Architectures
Instruction Cycle State Model:

The execution cycle of a microprocessor progresses through well-defined operational states:
Instruction Address Calculation: Determines the next memory location ().
Instruction Fetch: Transfers the opcode from memory into the instruction queue/register.
Instruction Operation Decoding: Decodes the bit patterns to configure internal paths.
Operand Address Calculation: Resolves effective addresses for source operands involving registers or memory.
Operand Fetch: Retrieves operands from registers or system memory; repeats for multiple operands.
Data Operation: The ALU executes the requested binary arithmetic or logic operation.
Operand Store Address Calculation: Determines the target destination location.
Operand Store: Writes the result back to registers or memory; handles multiple results if generated.
Cycle Completion: Loops back to calculate the next instruction address, or returns for vector/string data.
Instruction Representation and Encoding:
A simple instruction format consists of 16 bits: 4 bits allocated for the Opcode, 6 bits for the first Operand Reference, and 6 bits for the second Operand Reference.
Operands can fall into categories: Addresses, Numbers, Characters, or Logical Data.
Number of Address Fields and Program Comparative Analysis:
Evaluation of the mathematical expression:
3-Address Instructions: Retains source operands while writing directly to destination; requires long words:
SUB Y, A, B(computes )MPY T, D, E(computes )ADD T, T, C(computes )DIV Y, Y, T(computes )
2-Address Instructions: One operand field doubles as both source and destination (); requires temporary registers:
MOVE Y, A(sets )SUB Y, B(sets )MOVE T, D(sets )MPY T, E(sets )ADD T, C(sets )DIV Y, T(sets )
1-Address Instructions: Utilizes an implicit accumulator () for all operations:
LOAD D()MPY E()ADD C()STOR Y()LOAD A()SUB B()DIV Y()STOR Y()
0-Address (Stack-based) Instructions: All addresses are implicit; operates on operands pushed onto the top of the stack (
PUSH,POP,ADD).
Comprehensive 8086 Addressing Modes
An addressing mode defines how the processor locates operands. 8086 instructions fall into Sequential Control Flow Modes and Control Transfer Modes.
Sequential Control Flow Addressing Modes:
Register Addressing Mode: Operands reside exclusively within registers. Both registers must match in bit width (8-bit to 8-bit, or 16-bit to 16-bit). Segment-to-segment register movement is invalid.
Examples:
MOV AX, BX,MOV CX, AX,ADD BX, AXImmediate Addressing Mode: The source operand is constant data embedded directly in the instruction.
Examples:
MOV AL, 22H,MOV BX, 3456H,MOV CX, 4929H,ADD AX, 2387HDirect Addressing Mode: The instruction contains the 16-bit effective offset address inside brackets, defaulting to .
Examples:
MOV AL, [1234H],MOV BX, [5000H],MOV AX, [1592H]Register Indirect Addressing Mode: The offset address is stored in a pointer or index register (). Default segment is for , and for .
Examples:
MOV AX, [BX],ADD CX, [BX]Based Addressing Mode: The operand's offset is formed by adding an 8-bit or 16-bit displacement to a base register ( or ).
Examples:
MOV DX, [BX+04],ADD CL, [BX+08],MOV AX, [BP]Indexed Addressing Mode: The offset is the sum of an index register ( or ) and an 8-bit or 16-bit displacement.
Examples:
MOV BX, [SI+16],ADD AL, [DI+16]Based-Indexed Addressing Mode: Combines one base register ( or ) and one index register ( or ) to form the effective address.
Examples:
ADD CX, [BX+SI],MOV AX, [BP+DI]Based-Indexed with Displacement Mode: Combines a base register, an index register, and an immediate 8-bit or 16-bit displacement.
Examples:
MOV AX, [BX+DI+08],ADD CX, [BX+SI+16],MOV AX, [BP+DI+50H]Implied Addressing Mode: Operands are implicit to the opcode itself.
Examples:
CLC(clears carry flag),MUL BLRelative Addressing Mode: The target address is specified relative to the instruction pointer.
Example:
JMP 200H
Control Transfer Addressing Modes:
Intrasegment Direct Addressing: The branch target lies within the current code segment ( unchanged). The jump offset is specified as an immediate 8-bit or 16-bit displacement added to .
Example:
JMP [02]()Intrasegment Indirect Addressing: The branch target address within the current code segment is fetched from a 16-bit register or memory location.
Example:
JMP BX(the contents of register overwrite ; remains identical)Intersegment Direct Addressing: Branches from the current segment to a distinct segment. The instruction explicitly supplies both new 16-bit and values.
Example:
JMP 2000H:3000H(, )Intersegment Indirect Addressing: Replaces and with four consecutive bytes stored in memory.
Example:
JMP [5000H](loads low word from addresses5000Hand5001Hinto , and high word from5002Hand5003Hinto )
8086 Instruction Set Architecture (ISA)
1. Data Transfer Instructions:
MOV dest, src: Moves bytes or words between registers, memory, and immediate data. Cannot move memory-to-memory directly or segment-to-segment.XCHG dest, src: Swaps contents between two registers, or a register and memory (reg2reg1,memreg1).PUSH src/POP dest: Decrements by 2 and pushes 16-bit data; pops data and increments by 2.IN acc, port: Reads a byte/word into / from an 8-bit port address (IN AL, addr8) or indirect 16-bit port in (IN AX, [DX]).OUT port, acc: Writes a byte/word from / to an 8-bit port or indirect port specified in .
2. Arithmetic Instructions:
ADD dest, src: Computes . Sets all condition flags.ADC dest, src: Computes .SUB dest, src: Computes .SBB dest, src: Subtraction with borrow: .INC dest/DEC dest: Adds or subtracts 1 from register or memory. Updates , but does not affect the Carry Flag (CF).MUL src(Unsigned): For an 8-bit operand, computes . For a 16-bit operand, computes .IMUL src: Signed multiplication with identical register configurations.DIV src(Unsigned): Division of 16-bit dividend in by 8-bit divisor yields quotient in and remainder in . Division of 32-bit dividend in by 16-bit divisor yields quotient in and remainder in .IDIV src: Signed division following the same register allocation.CMP dest, src: Performs internal subtraction () and sets flags without modifying destination or source registers:If :
If :
If :
3. Logical Instructions:
AND dest, src: Bitwise logical AND; clears and to 0.OR dest, src: Bitwise logical OR; clears and to 0.XOR dest, src: Bitwise logical XOR; clears and to 0. Frequently used to clear registers (XOR AX, AX).TEST dest, src: Performs bitwise AND without modifying destination; updates flags to test specific bit fields.SHR dest, count: Logical shift right; bits shift right, MSB fills with , and the bit shifted out enters .SHL / SAL dest, count: Logical/Arithmetic shift left; bits shift left, LSB fills with , and the bit shifted out enters .RCR dest, count: Rotate right through Carry Flag; bits rotate right with acting as the 9th (or 17th) bit.ROL dest, count: Rotate left; bits rotate left, and the MSB bit copies simultaneously into the LSB position and .Shift/rotate count is either immediate , or held in register if greater than 1.
4. String Manipulation Instructions:
Strings are sequential blocks of bytes or words. Source is indexed by , and destination is indexed by .
Registers and are automatically incremented by 1 (byte) or 2 (word) if (
CLD), or decremented by 1 or 2 if (STD).MOVSB/MOVSW: Move string byte or word from to .CMPSB/CMPSW: Compares byte or word strings by performing internal subtraction and updating condition flags.LODSB/LODSW: Loads string byte from into (or word into ); auto-updates .STOSB/STOSW: Stores string byte from (or word from ) into memory location ; auto-updates .Repeat Prefixes:
REP(repeats string instruction while , decrementing each cycle);REPZ/REPE(repeats while and );REPNZ/REPNE(repeats while and ).
5. Processor Control Instructions:
STC: Set Carry Flag ().CLC: Clear Carry Flag ().CMC: Complement Carry Flag ().STD: Set Direction Flag ().CLD: Clear Direction Flag ().STI: Set Interrupt Flag (; enables maskable interrupts).CLI: Clear Interrupt Flag (; disables maskable interrupts).NOP: No operation (consumes clock cycles without affecting state).HLT: Halts instruction execution until an external hardware interrupt occurs.
6. Control Transfer Instructions:
Unconditional transfer:
CALL,RET,JMP.Relative conditional jumps (affecting flags and checking conditions within an 8-bit signed range to bytes,
disp8):Jump if Zero/Equal:
JZ/JE(Jump if Not Zero/Not Equal:
JNZ/JNE(Jump if Carry:
JC(Jump if No Carry:
JNC(Jump if Parity Even:
JP/JPE(Jump if Parity Odd:
JNP/JPO(Jump if Overflow:
JO(Jump if No Overflow:
JNO(Jump if Sign (Negative):
JS(Jump if Not Sign (Positive):
JNS(Unsigned comparisons:
JA/JNBE(Above),JAE/JNB(Above or Equal),JB/JNAE(Below),JBE/JNA(Below or Equal).Signed comparisons:
JG/JNLE(Greater),JGE/JNL(Greater or Equal),JL/JNGE(Less),JLE/JNG(Less or Equal).
Procedure Call and Return Mechanics:

Execution of
CALL Proc1pushes return address () onto the stack.Inside
Proc1, callingProc2at4600Hpushes next return address ().RETURNinstruction pops the top return address () into , returning toProc1.Subsequent calls and returns track execution dynamically using the stack frame.
Assembly Language Programming (ALP) Algorithms and Implementations
Searching for Data in an Array:
Searches an array beginning at offset
1200Hfor target valueAB96H. If found, writes its offset address to1400H; if not found, stores0000H.
MOV SI, 1200H ; Initialize SI to start of array
MOV AX, [SI] ; Load target value into AX
MOV CX, 05H ; Set loop counter for 5 comparisons
GG12:
INC SI ; Advance SI by 2 bytes (word size)
INC SI
CMP AX, [SI] ; Compare target with current element
JE SS ; If match found, branch to SS
DEC CX ; Decrement count
JNZ GG12 ; Continue loop if CX != 0
MOV SI, 0000H ; Value not found, assign 0000H to SI
SS:
MOV [1400H], SI ; Store matching location or 0000H at 1400H
HLT ; Halt
Separating Odd and Even Numbers:
Scans an array of 6 numbers at
1600Hto1605H, filtering odd values into destination memory starting at1500H.
MOV CL, 06H ; Counter = 6 elements
MOV SI, 1600H ; Source index points to array
MOV DI, 1500H ; Destination index points to output table
Loop1:
LODSB ; Load byte from [DS:SI] into AL, auto-increment SI
DEC CL ; Decrement loop count
ROR AL, 01H ; Rotate right by 1 bit into Carry Flag
JNB Skip ; If CF = 0, number is even; jump past store
ROL AL, 01H ; Restore original odd value
MOV [DI], AL ; Save odd number to [ES:DI]
INC DI ; Increment destination pointer
Skip:
CMP CL, 00H ; Check if all elements evaluated
JNE Loop1 ; Repeat if count > 0
HLT ; Terminate execution
BCD to Hexadecimal Conversion:
Converts an 8-bit packed BCD value at memory
1600H(e.g.,56BCD) to Hexadecimal (38Hor ) and stores it at1500H.
MOV SI, 1600H ; Source index = 1600H
MOV DI, 1500H ; Destination index = 1500H
MOV AL, [SI] ; Load packed BCD value
MOV AH, AL ; Copy BCD byte to AH
AND AH, 0FH ; Mask high nibble: AH contains LSD
MOV BL, AH ; Save LSD in BL register
AND AL, 0F0H ; Mask low nibble: AL contains MSD
MOV CL, 04H ; Set count to 4 bits
ROR AL, CL ; Shift MSD into lower 4 bits
MOV BH, 0AH ; Multiplier = 10 (decimal)
MUL BH ; Multiply MSD by 10 (Result in AX)
ADD AL, BL ; Add LSD to produce Hex equivalent
MOV [DI], AL ; Store hex byte at 1500H
HLT ; Stop
Bubble Sort in Ascending Order:
Sorts five 8-bit numbers located from
3000H:4000Hin ascending order.
MOV AX, 3000H
MOV DS, AX ; Set Data Segment
MOV CH, 04H ; Outer loop counter = n - 1 = 4
L3:
MOV CL, 04H ; Inner loop counter = 4
MOV SI, 4000H ; Reset pointer to start of array
L2:
MOV AL, [SI] ; Read element
MOV AH, [SI+01H] ; Read next adjacent element
CMP AL, AH ; Compare adjacent elements
JC L1 ; If AL < AH, already in order
JZ L1 ; If equal, do not swap
MOV [SI+01H], AL ; Swap elements
MOV [SI], AH
L1:
INC SI ; Move to next element
DEC CL
JNZ L2 ; Inner loop completion
DEC CH
JNZ L3 ; Outer loop completion
HLT
Bitwise Palindrome Checker:
Checks whether a 16-bit word at
2300His symmetrical bitwise. If palindrome, writesFFHto2500H; otherwise writes00H.
MOV AX, [2300H] ; Read 16-bit word
MOV CL, 10H ; 16-bit counter (16 decimal)
UP:
ROR AX, 1 ; Rotate AX right into Carry
RCL DX, 1 ; Rotate DX left pulling Carry
DEC CL
JNZ UP ; Repeat 16 times to completely reverse bits
CMP AX, DX ; Compare reversed word with original
JNZ DOWN ; If mismatch, branch to DOWN
MOV [2500H], 0FFH ; Is palindrome: store FFH
JMP EXIT
DOWN:
MOV [2500H], 00H ; Not palindrome: store 00H
EXIT:
HLT
String Reversal and Palindrome Verification via Stack:
Reverses a 100-byte () string at
2300Hinto2500Husing stack operations, verifies palindrome status, and outputsFFH(palindrome) or00H(non-palindrome) to display port64H.
MOV SI, 2300H ; Source pointer
MOV DI, 2500H ; Destination pointer
MOV CL, 64H ; 100 bytes
L1:
MOV AL, [SI]
PUSH AX ; Push each character onto stack
INC SI
DEC CL
JNZ L1
MOV CL, 64H
L2:
POP AX ; Pop characters in reversed sequence
MOV [DI], AL ; Save to destination array
INC DI
DEC CL
JNZ L2
MOV SI, 2300H ; Reset pointers to compare arrays
MOV DI, 2500H
MOV CL, 64H
CLD ; Forward direction
REPZ CMPSB ; Compare strings byte by byte
JNZ L3 ; If mismatch, jump to L3
MOV AL, 0FFH ; Palindrome confirmed
OUT 64H, AL ; Output to port 64H
JMP Exit
L3:
MOV AL, 00H ; Not a palindrome
OUT 64H, AL
Exit:
HLT
Binary to Gray Code Conversion:
Applies the rule: .
MOV SI, 1200H ; Input location
MOV AX, [SI] ; Read binary word
MOV BX, [SI]
SHR BX, 01H ; Shift right by 1 bit
XOR AX, BX ; AX = AX XOR (AX >> 1)
MOV [1400H], AX ; Store Gray code at 1400H
HLT
Greatest Common Divisor (GCD) Implementation:
Computes GCD of two numbers at
2300Hand2302Husing the Euclidean division algorithm.
MOV SI, 2300H
MOV DI, 2400H
MOV AX, [SI] ; First number
MOV BX, [SI+2] ; Second number
UP:
CMP AX, BX
JE EXIT ; If equal, GCD is found
JB EXCG ; If AX < BX, exchange them
UP1:
MOV DX, 0000H ; Clear DX for division
DIV BX ; Divide AX by BX (remainder in DX)
CMP DX, 0000H ; Check remainder
JE EXIT ; If remainder == 0, BX is GCD
MOV AX, DX ; Remainder becomes new dividend
JMP UP
EXCG:
XCHG AX, BX ; Ensure AX > BX
JMP UP1
EXIT:
MOV [DI], BX ; Store GCD at 2400H
HLT
Interrupt Architecture, IVT, and Exception Handling
An interrupt is an event that temporarily suspends the current program sequence to execute an Interrupt Service Routine (ISR), returning upon completion via the
IRETinstruction.Interrupt Processing Sequence:

1. The processor completes execution of the current instruction.
2. The interrupt signal is sampled on or triggered internally.
3. For maskable interrupts, if , the request is ignored; if , the CPU issues two active-low pulses on .
4. The interrupting peripheral supplies an 8-bit interrupt type number () on data lines during the second cycle.
5. The processor pushes the 16-bit Flag Register onto the stack.
6. Both and are cleared to , disabling further maskable interrupts and turning off single-stepping.
7. The current Code Segment register () is pushed onto the stack.
8. The current Instruction Pointer () is pushed onto the stack.
9. The address of the ISR is obtained from the Interrupt Vector Table:
Low word from memory address is loaded into .
High word from memory address is loaded into .
The ISR executes until reaching the
IRETinstruction, which pops , , and the original Flag Register from the stack, restoring pre-interrupt state.
Interrupt Vector Table (IVT):

Occupies the lowest of system memory ( to , exactly 1024 bytes).
Supports 256 vector entries (numbered 0 to 255). Each vector requires 4 contiguous bytes: the lower 2 bytes specify the ISR offset (), and the upper 2 bytes specify the segment ().
Allocation Breakdown:
Vectors 0 to 4 (Dedicated Processor Interrupts):
Type 0 (Divide Error): Triggered automatically if a
DIVorIDIVquotient exceeds destination register capacity or division by zero is attempted.Type 1 (Single Step): Generated after every instruction execution when the Trap Flag () is set to .
Type 2 (NMI Pin): Invoked by a positive-edge transition on the external pin, reserved for critical faults such as impending power failure.
Type 3 (Breakpoint): Invoked by the 1-byte opcode
INT 3(CCH); utilized by software debuggers to set execution breakpoints.Type 4 (Overflow): Invoked by the
INTOinstruction if the Overflow Flag () is set.
Vectors 5 to 31 (Reserved for System Use):
Vectors : Interfaced with the 8259A Interrupt Controller.
Vectors : Assigned to standard PC BIOS service routines.
Vectors 32 to 255 (Available for Users):
Vectors : Utilized by DOS operations.
Vectors : Open for user hardware and software applications.
Interfacing an Interrupt Vector via 74LS244:

When an external peripheral requires service, it asserts the pin high.
The CPU responds with active-low pulses. An active-low NAND logic gate decodes the condition to drive enable pins and of a 74LS244 octal buffer.
The inputs of the 74LS244 are hardwired to logic levels representing vector ():
Bits connected to (logic 1).
Bits connected to ground (logic 0).
The buffer drives onto data lines , which the processor reads to index the IVT.
Vector Table Lookup and Initialization:
Vector Calculation for Type :
Looking up table contents:
Byte at (Offset Low)
Byte at (Offset High)
Byte at (Segment Low)
Byte at (Segment High)
Resulting physical address:
Initializing Vector in Assembly:
PUSH AX ; Save modified registers
PUSH DS
MOV AX, 0000H ; Set DS to segment 0000H (IVT base)
MOV DS, AX
MOV AX, OFFSET isr40
MOV [0100H], AX ; Store offset of ISR at address 100H-101H
MOV AX, SEGMENT isr40
MOV [0102H], AX ; Store segment of ISR at address 102H-103H
POP DS ; Restore registers
POP AX
Bus Arbitration, I/O Interfacing, and the 82C59A Priority Controller
I/O Transfer Techniques:
Programmed I/O: The processor continuously executes instructions to poll peripheral status; simple to design, but wastes processor execution bandwidth.
Interrupt-Driven I/O: Peripherals signal readiness via interrupt lines, freeing the CPU to execute background tasks until service is required.
Direct Memory Access (DMA): An external DMA controller transfers data directly between high-speed memory and peripherals without routing bytes through the CPU.
Bus Arbitration Methods for I/O Modules:
Daisy Chaining:
Steps: If bus is not busy, a device asserts the shared Bus Request line. The Master activates the Bus Grant line, which serially propagates through device , then , then . The first requesting device intercepts the grant and asserts the shared Bus Busy line.
Advantages: Simple hardware layout; requires only three control lines regardless of device count.
Disadvantages: Priority is hardwired based on physical chain placement; poor fault tolerance (a failure in an upstream device breaks the arbitration chain for all downstream devices).
Polling Arbitration:
Steps: Requesting devices assert the shared Bus Request line. The master polls devices by placing unique device address IDs across dedicated polling lines. The identified requesting device responds by seizing the bus and asserting Bus Busy.
Advantages: Avoids the serial vulnerability of daisy chains; supports dynamic priority reassignment in software.
Disadvantages: Requires additional poll lines; introduces polling delays proportional to the number of attached devices.
Independent Request Arbitration:
Steps: Each device () has an independent Bus Request line () and Bus Grant line (). The master evaluates requests using internal priority logic and asserts the grant line for the chosen device. The selected device asserts Bus Busy.
Advantages: Extremely fast arbitration; full dynamic priority programming.
Disadvantages: High hardware overhead; requires dedicated control lines for devices.
Intel 82C59A Programmable Interrupt Controller (PIC):

Acts as an external arbiter managing up to 8 vectored priority interrupts per chip via input pins .
Cascading Configuration: Multiple 82C59A chips can be arranged in a master/slave hierarchy. A single Master PIC can connect up to 8 Slave PICs via its lines, expanding system capacity to service up to peripheral devices connected to a single processor pin.
Programmable Priority Modes:
Fully Nested Mode: Default configuration. Interrupt requests are ordered linearly from highest priority at down to lowest at .
Rotating Mode: Used when peripherals have equal priority. Once a device at a given line is serviced, it rotates to become the lowest priority in the group.
Special Mask Mode: Allows software to selectively inhibit interrupts from specific devices while permitting interrupts from other channels.
Serial Communication Principles and the RS-232 Protocol Standard
Serial vs. Parallel Data Transmission:
Parallel Transmission: Transmits a whole byte (8 bits) or word simultaneously across multiple parallel data lines during a single clock pulse. Yields high data rates across short distances, but suffers from wire costs, bulkiness, and inter-line capacitive crosstalk over longer runs.
Serial Transmission: Transmits data sequentially, bit by bit, over a single conductor or pair. Highly cost-effective and reliable over long distances.
Computer Interfacing Ports Overview:
Computer rear I/O panels host diverse interfaces: PS/2 ports for keyboard (purple) and mouse (green); RJ-45 Ethernet port; USB ports (Type-A, Type-B, Type-C, Mini, Micro); 15-pin 3-row high-density blue VGA port for monitors; 25-pin female DB-25 LPT1 parallel port for printers; 9-pin male DB-9 serial COM port; 15-pin 2-row yellow Game port for joysticks; and 3.5mm analog audio jacks (Line-In, Microphone, Speakers).
RS-232 Protocol Overview:
Standard protocol established for asynchronous serial data exchange between Data Terminal Equipment (DTE, such as computers or transmitters) and Data Communication Equipment (DCE, such as modems or receivers).
Standard operating limits: operational over cable distances up to at data rates up to (and higher over shorter distances).
Requires a common signal ground between DTE and DCE. Highly sensitive to induced line noise and crosstalk at higher baud rates.
Voltage levels ( to for logic 0/space; to for logic 1/mark) are fundamentally incompatible with standard TTL/CMOS logic, requiring hardware level converters (e.g., MAX232).
Flow Control and Handshaking Mechanisms:
No Handshaking: The receiver must read each incoming bit or character from its 1-bit or 1-byte receiver buffer before the transmitter delivers the next unit. If the receiver CPU is delayed, the unread buffer contents are overwritten, resulting in buffer overrun and data loss.
Hardware Handshaking (RTS/CTS & DTR/DSR):
Transmit flow is regulated by physical control lines:
RTS (Ready to Send): Driven high by DTE to indicate it wishes to transmit.
CTS (Clear to Send): Driven high by DCE to signal its buffer is empty and ready to accept data.
DTR (Data Terminal Ready): Driven by DTE to show it is powered on and operational.
DSR (Data Set Ready): Driven by DCE to confirm the modem/peripheral is ready.
DCD (Data Carrier Detect): Asserted by DCE upon detecting a valid carrier signal.
RI (Ring Indicator): Asserted by DCE upon sensing a telephone ringing signal.
RTS/CTS Cycle: When DTE has data, it pulls RTS high and waits. When DCE is ready, it pulls CTS high. The transmitter sends data; if the receiver buffer fills, CTS is pulled low, halting transmission until the buffer is cleared.
Software Handshaking (X-ON / X-OFF):
Avoids dedicated handshaking wires by embedding special control bytes directly in the data path.
When the receiver buffer approaches capacity, it transmits an
X-OFF(Transmitter Off) control byte. The transmitter suspends transmission until it receives anX-ON(Transmitter On) control byte.
Connector Pin Configurations (DB-9 and DB-25):

DB-9 Connector Pinout:
Pin 1: Carrier Detect (CD / DCD)
Pin 2: Receive Data (RxD)
Pin 3: Transmit Data (TxD)
Pin 4: Data Terminal Ready (DTR)
Pin 5: Signal Ground (GND)
Pin 6: Data Set Ready (DSR)
Pin 7: Request to Send (RTS)
Pin 8: Clear to Send (CTS)
Pin 9: Ring Indicator (RI)
DB-25 Connector Pinout:
Pin 1: Protective Ground
Pin 2: Transmitted Data (TxD / TD)
Pin 3: Received Data (RxD / RD)
Pin 4: Request to Send (RTS)
Pin 5: Clear to Send (CTS)
Pin 6: Data Set Ready (DSR)
Pin 7: Signal Ground / Common Return (GND)
Pin 8: Received Line Signal Detector (DCD)
Pin 9:
Pin 10:
Pin 11: Unassigned
Pin 12: Secondary DCD
Pin 13: Secondary CTS
Pin 14: Secondary Transmitted Data
Pin 15: DCE Transmitter Clock (Tx-CLK)
Pin 16: Secondary Received Data
Pin 17: Receiver Clock (Rx-CLK)
Pin 18: Local Loopback
Pin 19: Secondary RTS
Pin 20: Data Terminal Ready (DTR)
Pin 21: Signal Quality Detector / Remote Loopback
Pin 22: Ring Indicator (RI)
Pin 23: Data Signal Rate Selector
Pin 24: DTE Transmitter Clock (Tx-CLK)
Pin 25: Test Mode
Asynchronous Framing and Bit-Level Character Transmission:

In asynchronous transmission, the serial line idles in the marking state (logic 1).
Frame Structure:
Start Bit: A single transition to logic 0 (space) signaling the receiver to synchronize its clock.
Data Bits: 5 to 8 bits transmitted LSB first ( through or ).
Parity Bit: Optional bit appended for error detection, set to ensure an even or odd count of logic 1s.
Stop Bits: 1, 1.5, or 2 bits at logic 1 (mark) defining the end of the frame.
Framing Error: If the receiver detects a logic 0 when a stop bit (logic 1) is expected, a framing error is flagged, indicating clock desynchronization.
Worked Decoding Example for the Character Stream 'AppLe':
Configuration: ASCII encoding, even parity, 2 stop bits.
Serial Bitstream:
11111010000010110000011111111111111000001111111100011001111010100110111111111Character 1 ('A'):
Inactive line:
11111Start bit:
0Data bits (LSB first):
1000001(binary , which represents ASCII'A')Parity bit:
0(total 1s in data is 2; parity bit 0 maintains even parity)Stop bits:
11Character 2 ('p'):
Start bit:
0Data bits (LSB first):
0000111(binary , which represents ASCII'p')Parity bit:
1(data contains three 1s; parity bit 1 maintains even parity)Stop bits:
11Character 3 ('p'):
Inactive line:
11111111Start bit:
0Data bits:
0000111(ASCII'p')Parity bit:
1Stop bits:
11Character 4 ('L'):
Inactive line:
11Start bit:
0Data bits (LSB first):
0011001(binary , which represents ASCII'L')Parity bit:
1(data contains three 1s; parity bit 1 maintains even parity)Stop bits:
11Complete reconstructed ASCII message:
AppLe
Theory Exam Question & Answer
Question: Draw and explain the internal architecture of the Intel 8086 microprocessor. Describe the functions of the Bus Interface Unit (BIU) and Execution Unit (EU).
1. Introduction
The Intel 8086 is a microprocessor packaged in a 40-pin Dual Inline Package (DIP) with a address bus ( addressable memory) and a data bus.
Internally, the architecture is partitioned into two independent, concurrently functioning functional blocks:
Bus Interface Unit (BIU)
Execution Unit (EU)
This separation allows the 8086 to implement hardware pipelining, where instruction fetching overlaps with instruction decoding and execution.
2. Architectural Block Diagram

(In an examination, sketch the two major blocks side-by-side: the BIU on top/left with the 4 segment registers, IP, 20-bit adder, and 6-byte queue; and the EU on bottom/right with the general-purpose registers, pointer/index registers, ALU, control unit, and flag register).
3. Bus Interface Unit (BIU)
The BIU handles all data and address transfers across the external system buses for memory and I/O devices.
Key Functions:
Generates the physical memory address.
Fetches instruction opcodes from system memory.
Reads and writes operands from/to memory and I/O ports.
Buffers instructions in an internal pre-fetch queue.
Functional Components of BIU:
Instruction Pre-fetch Queue ( FIFO):
Implemented as a First-In, First-Out register array.
While the EU is decoding or executing an instruction, the BIU utilizes idle bus cycles to prefetch up to of instruction code sequentially from memory.
Eliminates instruction fetch latency, keeping the EU continuously supplied.
Segment Registers ( each):
Code Segment (): Holds the base address of the current code segment where program instructions reside.
Data Segment (): Points to the base of the data segment holding program variables and constants.
Stack Segment (): Points to the memory segment allocated for stack operations and return addresses.
Extra Segment (): Provides an additional data segment, notably used for destination strings in string instructions.
Instruction Pointer (, ):
Contains the offset address of the next sequential instruction byte to be fetched from the Code Segment ().
Automatically incremented by the BIU after every fetch and modified during branch, call, and jump instructions.
Dedicated Address Adder:
Calculates the physical address () from a segment base and a offset using:
Bus Control Logic:
Drives bus control signals (such as , , , and ) to coordinate bus transactions.
4. Execution Unit (EU)
The EU is completely isolated from the system buses and is responsible for decoding and executing instructions supplied by the BIU queue.
Key Functions:
Receives opcodes from the BIU FIFO queue.
Decodes instructions using the internal control unit.
Coordinates operand retrieval from general registers.
Performs arithmetic and logic operations via the ALU.
Updates status and control flags based on operation results.
Functional Components of EU:
Control Unit & Instruction Decoder:
Fetches opcodes from the queue, decodes them, and generates internal control signals to route data through the ALU and registers.
Arithmetic Logic Unit (ALU, ):
Capable of performing and arithmetic (, , , ) and logical (, , , shift, rotate) operations.
General-Purpose Registers ( each):
Can be used as full registers or addressed as pairs of registers (High and Low):
(, ) - Accumulator: Preferred for arithmetic/logical instructions; produces the most compact machine code; mandatory for hardware multiplication, division, and direct I/O.
(, ) - Base Register: Commonly used to store base offset memory pointers.
(, ) - Count Register: Used as an automatic loop counter (
LOOP) and shift/rotate bit counter ().(, ) - Data Register: Holds high-order bits during multiplication/division and holds port addresses in indirect I/O instructions.
Pointer and Index Registers ( each, accessible only as full words):
Stack Pointer (): Stores the offset address of the current top of the stack ().
Base Pointer (): Accesses data and parameters located within the stack frame ().
Source Index (): Serves as an offset pointer in data segment accesses and acts as the source string offset ().
Destination Index (): Serves as an offset pointer and destination string offset ().
Flag Register ():
Contains active flags:
6 Status/Conditional Flags: Carry Flag (), Parity Flag (), Auxiliary Carry Flag (), Zero Flag (), Sign Flag (), and Overflow Flag ().
3 Control Flags: Trap Flag ( for single-stepping), Interrupt Enable Flag (), and Direction Flag ( for string auto-indexing).
5. Pipelining in the 8086
In earlier processors like the 8085, the fetch, decode, and execute stages occurred strictly in serial sequence.
In the 8086, the BIU and EU operate in parallel. While the EU is executing an instruction, the BIU uses idle bus cycles to prefetch upcoming instructions into the 6-byte FIFO queue.
Consequently, the fetch cycle is overlapped with the execution cycle, minimizing instruction execution latency.