Professional Documents
Culture Documents
Microprocesso
r
Jibesh Kanti Saha
Fourth Generation
During 1980s
Low power version of HMOS technology (HCMOS)
32 bit processors
Third Generation Physical memory space 224 bytes = 16 Mb
During 1978 Virtual memory space 240 bytes = 1 Tb
HMOS technology Faster speed, Higher packing Floating point hardware
density Supports increased number of addressing modes
16 bit processors 40/ 48/ 64 pins
Easier to program Intel 80386
Dynamically relatable programs
Processor has multiply/ divide arithmetic hardware
More powerful interrupt handling capabilities
Flexible I/O port addressing
Second Generation
Intel 8086 (16 bit processor) During 1973
NMOS technology Faster speed, Higher density,
Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces and I/O ports
Between 1971 – 1973 Greater number of levels of subroutine nesting
PMOS technology, non compatible with TTL Better interrupt handling capabilities
4 bit processors 16 pins
8 and 16 bit processors 40 pins Intel 8085 (8 bit processor)
Due to limitations of pins, signals are multiplexed
Heart of a Microprocessor
• Heart of the microprocessor is
known as central processing
unit.
• It consists:
1. Registers.
2. Arithmetic Logic Unit (ALU)
3. Control Unit (CU)
• Processor also have memory
unit with bus interface units.
• Microprocessor as its own has
no meaning.
• It needs input devices and
output devices.
How does the processor connect to the external world
• Processor has 3 kinds of buses:
1. Address bus
2. Data bus
3. Control bus
• Bus = configuration that contains many
wires of similar kinds.
• These buses are connected to various
I/O devices, peripheral devices and
memory devices.
• Input devices gives data and output
device takes data.
• How does the processor know if the
device is input or output?
• Using address decoder: it takes address
lines from processor, decodes it and
triggers various devices we connect.
What does your processor understands?
Architecture of 8086
• How is a processor defined?
7
Architecture of 8086
• Divided into two parts:
1. Bus Interface Unit (BIU)
2. Execution Unit (EU)\
• Execution unit : Executes everything for
the processor. Consists :
1. ALU: Performs arithmetic and
logical operations required of any
program.
2. General purpose registers : these
register can be addressed as 8 bit
or 16 bit register.
• Bus interface unit: communication
purpose. Consists of:
1. Segment registers: used to address
memory space. (ROM/RAM).
2. Address compute Engine: Converts
the logical address that is held by
the segment register into a physical
address.
8
3. Instruction queue.
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Code Segment Register
Registers
16-bit
Architecture
Segment Data Segment Register
Registers
16-bit
10
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Stack Segment Register
Registers
16-bit
11
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment
Registers Extra Segment Register
16-bit
12
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Instruction Pointer
Registers
16-bit
A group of First-In-First-Out
(FIFO) in which up to 6 bytes
of instruction code are pre
fetched from the memory
ahead of time.
Architecture
EU Accumulator Register (AX)
Registers
AL in this case contains the low order byte of the word, and
AH contains the high-order byte.
15
8086 Microprocessor
Execution Unit (EU)
Architecture
EU
Registers Data Register (DX)
18
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Stack Pointer (SP) and Base Pointer (BP)
Registers
SP and BP are used to access data in the stack
segment.
20
8086 Microprocessor
Execution Unit (EU)
Architecture Auxiliary Carry Flag Carry Flag
Flag Register
This is set, if there is a carry from the lowest nibble, This flag is set, when there is a carry out
i.e, bit three during addition, or borrow for the of MSB in case of addition or a borrow in
lowest nibble, i.e, bit three, during subtraction. case of subtraction.
This flag is set, when the result of This flag is set, if the result of the This flag is set to 1, if the lower byte of the
any computation is negative computation or comparison performed by result contains even number of 1’s ; for odd
an instruction is zero number of 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Tarp Flag
Over flow Flag If this flag is set, the processor enters the
This flag is set, if an overflow occurs, i.e, if the result of a signed operation is large
single step execution mode by generating
enough to accommodate in a destination register. The result is of more than 7-bits in
size in case of 8-bit signed operation and more than 15-bits in size in case of 16-bit sign
internal interrupts after the execution of
operations, then the overflow will be set. each instruction
1. Register Addressing
Group I : Addressing modes for register and immediate data
2. Immediate Addressing
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for memory data
6. Indexed Addressing
8. String Addressing
1. Register Addressing The instruction will specify the name of the register which holds the
data to be operated by the instruction. Source operand, destination
2. Immediate Addressing operand or both contained in 8086 register
23
8086 Microprocessor
Addressing Modes Group I : Addressing modes for register and immediate data
1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit data is specified
2. Immediate Addressing as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is moved to DL
6. Indexed Addressing
(DL) 08H
7. Based Index Addressing
9. Direct I/O port Addressing The 16-bit data (0A9FH) given in the instruction is moved to AX
register
10. Indirect I/O port Addressing
12. Implied Addressing Source operand is in immediate mode and destination operand is in
register mode
24
86 Microprocessor
Addressing Modes : Memory Access
20 Address lines 8086 can address up to 220 = 1M bytes of memory
Physical Address will have to be calculated Physical Address : Actual address of a byte in
memory. i.e. the value which goes out onto the address bus.
Each time the processor wants to access memory, it takes the contents of a segment
register, shifts it one hexadecimal place to the left (same as multiplying by 1610), then add
the required offset to form the 20- bit address
1. Register Addressing
2. Immediate Addressing
Here, the effective address of the memory location at which the
3. Direct Addressing
data operand is stored is given in the instruction.
4. Register Indirect Addressing
The effective address is just a 16-bit number written directly in
5. Based Addressing the instruction.
11. Relative Addressing This addressing mode is called direct because the displacement of
the operand from the segment base is specified directly in the
12. Implied Addressing instruction.
26
Process
• IF EA= 0040 and DS=3050 then BIU generates 20 bit physical address
by adding 4 zeros to LSB of DS in binary and then add EA+DS=
0040+30500=30540
• BIU generates this address 30540 on the 8086 pins and then initiates
memory read cycle to read the 16 bit data starting from 30540
location.
• Memory logic places 16 bit contents of locations 30540 and 30541 on
data pins.
• BIU transfer this data to EU
• EU then moves the data to CX
27
8086 Microprocessor
Addressing Modes Group II : Addressing modes for memory data
1. Register Addressing In Register indirect addressing, name of the register which holds
the effective address (EA) will be specified in the instruction.
2. Immediate Addressing
Registers used to hold EA are any of the following registers:
3. Direct Addressing
BX, BP, DI and SI.
4. Register Indirect Addressing
Content of the DS register is used for base address calculation.
5. Based Addressing
Example:
6. Indexed Addressing
28
Process
• MOV [DI] BX : The offset value is stored in DI(0020) and this is added
with DS(5004). After adding this will give 20 bit address (50060).
• Then the contents of BL and BH are moved to memory location 50060
and 50061 respectively
29
8086 Microprocessor
Addressing Modes Group II : Addressing modes for memory data
1. Register Addressing In Based Addressing, BX or BP is used to hold the base value for
effective address and a signed 8-bit or unsigned 16-bit
2. Immediate Addressing displacement will be specified in the instruction.
(AL) (MA)
(AH) (MA + 1)
30
8086 Microprocessor
Addressing Modes Group II : Addressing modes for memory data
1. Register Addressing SI or DI register is used to hold an index value for memory data
and a signed 8-bit or unsigned 16-bit displacement will be specified
2. Immediate Addressing in the instruction.
(CL) (MA)
(CH) (MA + 1)
31
8086 Microprocessor
Addressing Modes Group II : Addressing modes for memory data
1. Register Addressing
In Based Index Addressing, the effective address is computed from
2. Immediate Addressing the sum of a base register (BX or BP), an index register (SI or DI)
and a displacement.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DX, [BX + SI + 0AH]
5. Based Addressing
Operations:
6. Indexed Addressing
000AH 0AH (Sign extended)
7. Based Index Addressing
32
8086 Microprocessor
Addressing Modes Group II : Addressing modes for memory data
33
8086 Microprocessor
Addressing Modes Group III : Addressing modes for I/O ports
1. Register Addressing These addressing modes are used to access data from standard I/O
mapped devices or ports.
2. Immediate Addressing
In direct port addressing mode, an 8-bit port address is directly
3. Direct Addressing specified in the instruction.
34
8086 Microprocessor
Addressing Modes Group IV : Relative Addressing mode
1. Register Addressing
2. Immediate Addressing
35
8086 Microprocessor Group IV : Implied Addressing mode
Addressing Modes
1. Register Addressing
2. Immediate Addressing
3. Direct Addressing
5. Based Addressing
6. Indexed Addressing
Instructions using this mode have no operands. The instruction
itself will specify the data to be operated by the instruction.
7. Based Index Addressing
9. Direct I/O port Addressing This clears the carry flag to zero.
36
8086 Microprocessor
Instruction Set
8086 supports 6 types of instructions.
2. Arithmetic Instructions
3. Logical Instructions
37
8086 Microprocessor
Instruction Set
1. Data Transfer Instructions
Instructions that are used to transfer data/ address in to registers, memory locations and I/O ports.
Generally involve two operands: Source operand and Destination operand of the same size.
A 8-bit data can only be moved to 8-bit register/ memory and a 16-bit data can be moved to 16-bit register/
memory.
38
8086 Microprocessor
Instruction Set
1. Data Transfer Instructions
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
39
8086 Microprocessor
Instruction Set
5. Processor Control Instructions
Mnemonics Explanation
STC Set CF 1
CLC Clear CF 0
NOP No operation
ESC opcode mem/ reg Used to pass instruction to a coprocessor which shares the address and data bus
with the 8086
Checks flags
41
8086 Microprocessor
Instruction Set
42
8086 Microprocessor
Instruction Set
Mnemonics Explanation
JC disp8 Jump if CF = 1
JP disp8 Jump if PF = 1
JO disp8 Jump if OF = 1
JS disp8 Jump if SF = 1
43
Interrupt of 8086
INT 21h, function 9 enables us the LEA (LOAD EFFECTIVE ADDRESS) instruction.
LEA DX, MSG ; providing msg is stored before
MOV AH,9;
INT 21h
Programmable Interrupt Controller
8259A
• It’s a specific peripheral device that
can be connected to 8086 to manage
complex interrupt Systems.
• 8086 only have two hardware
interrupts.
• So complex systems cant be utilized.
• So we use 8259A
• It supports 8 different hardware
interrupts at a time.
• IR0 – IR7
Programmable Interrupt Controller
8259A Block diagram
Programmable Interrupt Controller
8259A Block diagram
1. Simple I/O
I. Assume peripheral is always ready to send or receive data.
II. I/O read operation enables the input port and transfers status information to data bus.
III. Similarly, I/O write operation enables the output port and transfers the data byte to peripheral.
2. Strobe I/O
I. Used when peripheral devices are slow and not always ready.
II. Slow devices must generate a control signal called Strobe.
III. Data is sent with the strobe signal and strobe signal indicates that data is ready.
IV. Readiness of peripheral is checked by microprocessor by the method of polling and interrupt.
Detail mathivanan
I/O Communication
Parallel I/O methods
1. Handshake
I. Processor and peripheral exchange handshake signals to indicate readiness of peripherals
and to synchronize timing of data transfer.
II. Two types:
A. Single handshake: Only microprocessor checks for readiness
B. Double handshake: Both microprocessor and peripheral exchange signals.
2. DMA controlled I/O
I. Usually microprocessor controls the process of data transfer between processor and
peripherals.
II. But peripherals with high speed in this case takes over.
III. Capable of transferring at much higher rate than processor.
IV. DMA controlled is used to manage all transfers.
Detail mathivanan
Programmable Peripheral Interface
8255A
• 40 pin DIP chip that helps 8086 to manage I/O devices and data in different modes
• Has 24 input/output pins divided among 3 ports : port A, Port B and Port C.
• Port A and port B are two 8 bit parallel ports
• Port C can be one port or individual bits or two 4-bit port
Programmable Peripheral Interface
8255A
• Port A and port B are bidirectional I/O port.
• They are either latched output or buffered input.
• Port C is the control port.
• Port C can also assist I/O function of port A and B.
• 8255 has a control register and a byte written into it which controls
the i/o functions of the ports.
• The I/O ports of 8255 can be configured to operate in three
different mode:
1. Mode-0 : Simple I/O
2. Mode-1 : handshake I/O
3. Mode -2: bidirectional bus
• The other mode that 8255 offers is the BSR mode
1. Involves port C
2. Each of the port C can be individually set or reset
Programmable Peripheral Interface
8255A
• Mode 0: (simple I/O)
1. Port A and B are used as two simple 8 bit I/O port.
2. Port C is used as two 4 bit I/O port.
3. Each port is programmed to function as an input port or an output port.
• Mode 1: (single handshake I/O)
1. Port A and B function as 8 bit I/O port.
2. Ports A and B each use three lines from port C as control signal.
3. Remaining lines of port C are used as simple I/O function.
4. I/O data can be latched and interrupt logic is supported.
• Mode 2: (bidirectional handshake)
1. Only port A is configured for bidirectional handshake I/O operation.
2. It enables data bytes to be transmitted and received on the same 8 lines.
3. Used to transfer data bytes to and from another slave processor.
4. Port B is in mode 1 or mode 0.
5. PC3- PC7 of port C carry 5 handshake signals for bidirectional op.
6. PC0-PC2 used as general purpose I/O or handshake for port B.
Programmable Peripheral Interface
Programming of 8255A
• The ports are configured
to any mode by writing
control word into the
control register.
Programmable Peripheral Interface
Interfacing 8255A with 8086
Direct Memory Access
• Needs a DMA controller (8237)
• 8086 in min mode has HOLD input.
• Data from I/O to memory = DMA
write
• Data from memory to I/O = DMA read
• I/O sends DREQ to controller
requesting DMA read/write.
• Controller sends HRQ(hold request) to
HOLD of microprocessor.
• Processor samples HOLD in the
middle of every clock cycle.
• When HOLD is detected, it stops
executing, floats its buses and sends
out HLDA( hold acknowledge) to
controller.
• The DMA controller sends out a
control signal that disconnects all
buses from processor and connect
them to itself.
Direct Memory Access
• DMA controller gets control of the
buses and sends out the memory
address on the address bus where firs
byte of data from or to I/O device is
gonna be transferred.
• Finally, controller sends DACK (DMA
acknowledge) signal to I/O device.
• MEMR and IOW control signals DMA
read
• MEMW and IOR for DMA wirte on the
control bus.
• So, data transfer from or to I/O to
memory without passing through
microprocessor or DMA controller.
• Transfer complete? DMA controller
disables HOLD signal and releases
control of all buses.
• Processor regains control.
Programmable Interval Timer (8254)
• 8254 contains three 16 bit counters: counter-0, counter-1
and counter-2.
• A data bus buffer
• A read/write control logic and
• A control word register.
• Data bus 8254 is connected to the data bus of the system
through bidirectional data line D0-D7.
• Read/wrote control logic receives control signals from
processor.
• It enables appropriate counter register or control register
for the transfer of count or control word.
• Each counter is individually programmed to operate in
one of six mode by writing separate control word into the
control register.
• Clock frequency of up to 8MHz is applied to CLK input.
• GATE enables or disables the counting in some mode of
operation.
Programmable Interval Timer (8254)
• Clock frequency of up to 8MHz is applied to CLK input.
• GATE enables or disables the counting in some mode of operation.
• Counter generates output waveforms on the OUT line.
• 8255 has two address input pins A0 and A1, hence four internal addresses.
• The addresses are assigned to various counter and control registers:
CS RD WR A1 A0 Data bus operation
0 1 0 0 0 Write into counter-0
0 1 0 0 1 Write into counter-1
0 1 0 1 0 Write into counter-2
0 1 0 1 1 Write into control register
0 0 1 0 0 Read from counter-0
0 0 1 0 1 Read from counter-1
0 0 1 1 0 Read from counter-2
0 0 1 1 1 Tri-state
1 X X X X Tri-state
0 1 1 X X Tri-state
Programming the 8254
Programming the 8254
• Write control word into control register.
• Clock signal is applied to the CLK input
• Gate input held high.
• Count value is loaded into a counter register.
• Counter decrements the count for each CLK pulse and gives out a pulse at its OUT when
count reaches zero.
• The current count value = counter register.
• Using control word load 8254 with a count between 0001h and FFFFh for binary sequence or
00001d and 9999d for BCD sequence.
• Steps for initializing a counter:
1. Write control word into control register.
2. Write Low-order byte followed by high order byte into counter register.
8254 Modes of Operation
Six modes of operation:
1. Mode-0, Interrupt on terminal count
I. Gate controls Low and High on the OUT.
II. Can be used as interrupt signal.
2. Mode-1, Hardware-retriggerable one-shot
I. Gate triggers the counter and for the period of counting OUT=low.
II. Behaves like a retriggarable monostable mulitvibrator.
3. Mode-2, rate generator
I. Generates string of pulses.
II. Example: for count of 4, Out give pulse of 3 count (high), stops for 1 count (low)
4. Mode-3, square wave generator
I. Generates square wave
II. Same as mode-2, but OUT high for count/2 clock periods, low for the other half.
5. Mode-4, Software-triggered strobe
I. Produces a single pulse at its output.
6. Mode-5, Hardware-triggered strobe
I. Same as mode-4.
Detail Mathivanan
Interfacing 8254 with 8086