Microprocessor
Microprocessor
UNIT-I: THE 8086 MICROPROCESSOR, covering all listed topics in paragraph format:
1. Introduction to 8086
The Intel 8086 is a 16-bit microprocessor introduced by Intel in 1978. It marked the beginning of
the x86 architecture, which later became the foundation of most modern PCs. The 8086 has a
20-bit address bus, which allows it to access 1 MB of memory (2²⁰ bytes). It operates at a clock
speed between 5 MHz to 10 MHz and has a 16-bit data bus, which means it can process 16 bits
of data simultaneously. The 8086 supports pipelining using a 6-byte instruction queue, which
increases execution speed. It uses segmented memory to separate code, data, and stack
areas, making memory management flexible and efficient.
2. Microprocessor Architecture
The architecture of the 8086 microprocessor is split into two main units:
● Bus Interface Unit (BIU): This unit is responsible for fetching instructions from memory,
reading/writing data, and calculating the physical address. It includes the instruction
queue (6 bytes), segment registers (CS, DS, SS, ES), and the instruction pointer (IP).
● Execution Unit (EU): This unit decodes and executes instructions fetched by the BIU. It
contains the Arithmetic and Logic Unit (ALU), general-purpose registers (AX, BX, CX,
DX), pointer registers (SP, BP), index registers (SI, DI), flag register, and control logic.
The EU cannot directly access memory; it must request the BIU.
3. Addressing Modes
Addressing modes define how operands are accessed in memory or registers. The 8086
supports several addressing modes:
1. Immediate Addressing: Operand is specified in the instruction (e.g., MOV AX, 05H).
2. Register Addressing: Operand is a register (e.g., MOV AX, BX).
3. Direct Addressing: Memory address is directly specified (e.g., MOV AX, [1234H]).
4. Register Indirect Addressing: Memory address is held in a register (e.g., MOV AX,
[BX]).
5. Based Addressing: Uses base register (BX or BP) plus a displacement.
6. Indexed Addressing: Uses index register (SI or DI) plus a displacement.
7. Based-Indexed Addressing: Combines base and index registers (e.g., MOV AX,
[BX+SI]).
8. Relative Addressing: Used in control transfer instructions like JMP, with the offset
relative to current IP.
2
Assembler Directives are not executable but tell the assembler how to process the code.
Examples include:
6. Modular Programming
Modular programming involves dividing a large program into small, manageable modules or
procedures. Each module performs a specific task and can be compiled separately. In 8086,
procedures are used to achieve modularity. These are defined using PROC and ENDP directives.
Modular programming improves program organization, debugging, testing, and reusability of
code.
Linking combines multiple object files into one executable. It resolves references between
separately compiled modules. Relocation allows a program to be loaded into any memory
location by adjusting address references. The 8086 supports relocation through its segmented
memory system, where logical addresses are converted to physical addresses using
segment:offset combination (e.g., physical address = segment × 16 + offset).
3
8. Stacks
The stack is a portion of memory used for temporary storage. It operates in a Last-In-First-Out
(LIFO) manner. The stack is accessed using the SP (Stack Pointer) and SS (Stack Segment)
registers. Instructions like PUSH, POP, CALL, and RET use the stack. For example, when a
subroutine is called, the return address is pushed to the stack, and retrieved during return.
9. Procedures
asm
CopyEdit
MYPROC PROC
; procedure code
RET
MYPROC ENDP
10. Macros
Macros are reusable code snippets defined using the MACRO directive and substituted inline
during assembly. Unlike procedures, macros do not use CALL and RET, thus avoiding overhead.
However, they increase code size. Example:
asm
CopyEdit
PRINT_MSG MACRO
MOV AH, 09H
INT 21H
ENDM
Interrupts are events that cause the microprocessor to pause its current task and execute a
predefined subroutine (ISR). The 8086 supports 256 interrupt types, each associated with a
4-byte entry in the Interrupt Vector Table (IVT). Interrupts are of two types:
4
The 8086 offers specialized instructions for string operations, which work with the SI, DI, and
CX registers:
1. 8086 Signals
The Intel 8086 microprocessor uses a variety of signals to communicate with memory, I/O
devices, and other components. These signals are categorized as:
2. Basic Configurations
● Minimum Mode: Used for single-processor systems. The processor generates all
necessary control signals internally. Ideal for simple designs.
● Maximum Mode: Designed for multiprocessor environments. The 8086 relies on an
external bus controller (Intel 8288) to generate control signals. This mode supports
co-processors and other CPUs, enabling multitasking or distributed processing.
System bus timing defines how data and instructions move across the buses during read/write
cycles. Each bus cycle consists of at least four clock periods:
● T1: The processor places the address on the bus and asserts ALE.
● T2: The control signal (RD or WR) is activated.
● T3: Data is transferred (read or write) from memory or I/O device.
● T4: The bus is idle or prepared for the next operation.
Wait states (Tw) may be added between T3 and T4 if a slow device is involved.
Designing a microprocessor system involves connecting the 8086 to memory and I/O devices
through buses and control logic. Key components include:
● Latch (e.g., 74LS373): Used to separate address from the multiplexed AD0–AD15 lines.
● Transceiver (e.g., 74LS245): Allows bidirectional data flow between CPU and
memory/I/O.
● Decoder (e.g., 74LS138): Selects memory or I/O devices based on address.
● Clock generator (8284): Provides synchronized clock pulses.
Designers must ensure proper address decoding, control signal timing, and data
routing.
6
5. I/O Programming
Input/output programming involves interacting with external devices using software. The 8086
supports:
● Isolated I/O: Uses IN and OUT instructions with a separate 64K I/O address space.
● Memory-mapped I/O: Uses regular memory instructions to access I/O devices. Devices
are assigned memory addresses.
I/O programming involves polling (checking device status in a loop) or interrupts (device
signals processor when ready), depending on application requirements.
6. Introduction to Multiprogramming
Multiprogramming is a technique where multiple programs share CPU time and memory.
Although the 8086 doesn’t support true multitasking, it can implement multiprogramming using
software techniques. By storing the state of one program (register values, stack) and switching
to another, the CPU can give the illusion of concurrent execution. It improves CPU utilization
and response time in systems with frequent I/O operations.
The system bus is a group of wires that carry data, addresses, and control signals between the
processor, memory, and I/O devices. It has three main parts:
● Address Bus: Carries the address of the memory or I/O device (8086 has 20-bit
address bus, so it can access 1MB memory).
● Data Bus: Transfers actual data (16-bit in 8086).
● Control Bus: Carries control signals like read/write, interrupt requests, and clock pulses.
This shared bus structure ensures coordinated communication in a
microprocessor-based system.
8. Multiprocessor Configurations
Multiprocessor systems use multiple processors to perform tasks in parallel, improving speed
and reliability. In 8086 maximum mode:
● One 8086 can act as the master, while others are slaves.
● Communication occurs over the system bus.
● Control signals and arbitration logic determine which processor accesses memory or I/O
at a given time.
Shared memory or message-passing techniques manage inter-processor
communication and resource allocation.
7
9. Coprocessor
A coprocessor is an additional processor that works alongside the main CPU to handle
specialized tasks. The Intel 8087 is the coprocessor for the 8086 and performs complex
arithmetic operations, especially floating-point calculations. The 8086 identifies coprocessor
instructions through a special escape opcode (ESC), and the 8087 executes them concurrently.
This parallelism enhances computational efficiency, particularly in scientific and engineering
applications.
● Closely Coupled Systems: Multiple processors share the same memory and are tightly
integrated with a common clock and bus. Communication is fast and synchronization is
easier, but complexity and cost increase.
● Loosely Coupled Systems: Each processor has its own memory and communicates
via messages over a bus or network. These systems are more flexible and fault-tolerant,
commonly used in distributed computing environments.
After the 8086, Intel introduced more advanced processors with enhanced capabilities:
H
8
Memory interfacing refers to connecting RAM or ROM to the 8086 microprocessor so it can read
from or write to memory locations. This requires address decoding to ensure that specific
address ranges access particular memory chips. Control signals like RD and WR are used to
manage data transfer. I/O interfacing allows the microprocessor to interact with peripheral
devices such as switches, LEDs, displays, or sensors. The 8086 supports two types of I/O
interfacing: Isolated I/O, where separate instructions (IN and OUT) are used to access I/O ports
with a separate address space; and Memory-Mapped I/O, where I/O devices are treated as
memory locations, allowing regular memory instructions to be used.
Parallel communication transfers multiple bits of data simultaneously across multiple data lines.
The Intel 8255 Programmable Peripheral Interface (PPI) is widely used for parallel data
communication with 8086. It has three 8-bit ports (Port A, Port B, and Port C) that can be
configured for input or output in different modes. It is particularly useful for applications that
require fast data transfer, such as controlling displays, motors, or sensors. Mode 0 is basic I/O,
Mode 1 provides handshaking, and Mode 2 allows bidirectional data transfer. Proper
programming of the control word register allows flexible I/O control.
In serial communication, data is sent one bit at a time through a single data line. The Intel 8251
USART (Universal Synchronous/Asynchronous Receiver Transmitter) is used to manage
serial communication with the 8086. It supports both synchronous (with a clock) and
asynchronous (without clock) modes. Serial communication is slower than parallel but suitable
for long-distance and low-pin applications like modem interfaces, RS232 connections, and
inter-computer communication. Data framing, baud rate control, and status checking are
handled by the 8251 chip.
The 8086 microprocessor can only process digital data. To interface with the analog world,
Digital-to-Analog Converters (DACs) and Analog-to-Digital Converters (ADCs) are used.
DACs (like DAC0808) convert digital data from the microprocessor into corresponding analog
voltage or current. ADCs (like ADC0804 or ADC0809) take analog input (like from a temperature
sensor) and convert it into digital format for processing by the microprocessor. Control signals
like Start Conversion (SC), End of Conversion (EOC), and Output Enable (OE) are used during
the A/D conversion process.
9
5. Timer
Timers are essential for tasks that require accurate time delays or counting events. The Intel
8253/8254 Programmable Interval Timer has three independent 16-bit counters and can be
used in applications like generating time delays, producing waveforms, or counting pulses. Each
counter can operate in six different modes, such as interrupt on terminal count, hardware
retriggerable one-shot, or square wave generator. It is clocked by an external clock signal and
controlled using control words programmed by the CPU.
6. Keyboard/Display Controller
The Intel 8279 is a special-purpose chip designed to handle keyboard and display interfacing. It
relieves the CPU from the tasks of scanning and refreshing. The chip can scan up to 64-key
keyboards and control up to 16-digit 7-segment LED displays. It handles key debouncing, key
code generation, and provides FIFO buffers for storing keystrokes. For display, it continuously
refreshes the display using time-multiplexing without CPU intervention, making it efficient for
digital clocks, calculators, and embedded displays.
7. Interrupt Controller
Interrupts allow devices to get the processor’s attention asynchronously. The Intel 8259
Programmable Interrupt Controller (PIC) manages multiple interrupt sources and prioritizes
them. It supports eight interrupt inputs and can be cascaded to handle up to 64 interrupts. It
sends an interrupt request (INTR) to the CPU and receives an interrupt acknowledge (INTA)
in response. It supports programmable priority levels, masking of interrupts, and vectoring
(providing the address of the interrupt service routine). It is essential for responsive systems
handling multiple I/O devices.
8. DMA Controller
The Direct Memory Access (DMA) technique allows peripherals to directly read/write memory
without CPU involvement, increasing data transfer efficiency. The Intel 8237 DMA Controller is
commonly used with the 8086 for this purpose. It allows block data transfer between I/O and
memory. The controller takes over the system buses during transfer and signals the CPU via
HOLD and HLDA pins. Modes include block, demand, and single transfer, which are useful for
high-speed devices like hard drives and sound cards.
Programming for I/O interfacing includes writing assembly routines to configure and control
interface devices like the 8255, 8279, or 8253. Programs involve setting control words,
reading/writing ports, and managing handshaking. Applications may include automation,
measurement systems, and communication devices. The programs typically involve initializing
devices, polling or using interrupts to handle data, and storing or displaying results. Efficient I/O
10
● Traffic Light Control: A common application where the 8086, in conjunction with 8255
and timers, controls Red, Yellow, and Green LEDs in a sequence with time delays. This
simulates a real traffic light system.
● LED Display Interface: Uses 8255 to control LED matrices or 7-segment displays by
sending appropriate patterns to illuminate segments or pixels.
● LCD Display Interface: LCDs require control signals (RS, RW, EN) and data input. The
microprocessor sends commands (like clear, display on) and characters to display. LCDs
can show alphanumeric messages and are widely used in embedded systems.
● Keyboard Display Interface: Using 8279, a keyboard is scanned and inputs are stored
in FIFO. The same chip controls display output, allowing the creation of interactive
embedded systems.
● Alarm Controller: Interfaces sensors with the microprocessor to detect faults or
abnormal conditions (like smoke or heat). When triggered, it can activate an alarm using
a relay, buzzer, or siren. Interrupts can be used to signal the CPU immediately when
danger is detected.
SFRs are registers used to control internal operations of the 8051. These include:
The 8051 has 4 I/O ports (P0 to P3), each 8-bit wide. These ports can be programmed as input
or output:
4. Instruction Set
5. Addressing Modes
The 8051 has two timers: Timer 0 and Timer 1, each of 16 bits. They can work in different
modes (Mode 0, 1, 2, 3):
Serial communication is handled using SCON and SBUF registers. 8051 supports full-duplex
communication using UART. Mode 1 (8-bit UART) is the most common. The baud rate is set
using Timer 1 in auto-reload mode. For example, to transmit "A", we write to SBUF and wait for
the TI (Transmit Interrupt) flag.
9. Interrupts Programming
8051 has five interrupt sources: two external (INT0, INT1), two timers (T0, T1), and one
serial. The IE (Interrupt Enable) and IP (Interrupt Priority) registers are used to configure
them. Interrupts can be used to execute a routine when an event occurs, such as keypress,
timer overflow, or incoming data, improving program efficiency.
LCDs (e.g., 16x2) are interfaced using data lines (D0-D7) and control lines (RS, RW, EN).
Commands (clear, shift, cursor) and data (characters) are sent through ports. Keyboards
(typically 4x4 matrix) are scanned by sending rows low and reading columns. Debouncing and
13
ADC interfacing allows analog signals (from sensors) to be converted to digital values readable
by the 8051. ADC0804 is a commonly used chip, interfaced via 8255 or ports. DACs convert
digital values from 8051 to analog output, useful for generating audio signals or voltage levels.
Sensors like temperature, light, or motion sensors are used with ADCs to provide input to the
microcontroller system.
The 8051 can be connected to external program or data memory when internal memory is
insufficient. Port 0 and Port 2 are used for address/data multiplexing. The ALE signal is used to
latch the lower address byte. External RAM or ROM chips like 6264 (RAM) or 2764 (EPROM)
are commonly used.
Stepper motors are used in precise motion control applications. The 8051 can control a
stepper motor by sending a sequence of pulses to the driver circuit (ULN2003 or L293D).
Proper timing and direction control are handled in code. For waveform generation, timers and
DACs are used to produce square, triangular, or sine waves. This is useful in signal generation
or testing applications.