UNIT1_8086 microprocessor notes
UNIT1_8086 microprocessor notes
• No.
INPUT OUTPUT
MICROPROCESSOR
MEMORY
Input/Output
SYSTEM BUS
Control Unit
Memory
ROM RAM
Second Generation:
• After 1973, the second generation µPs such as Motorola 6800 and 6809, Intel
8085 and Zilog Z80 evolved.
• These µPs were fabricated using NMOS technology. The NMOS process offered
faster speed and higher density than PMOS.
Contd….
Third Generation:
• After 1978, the 3rd generation microprocessors were introduced.
• Typical µPs were Intel 8086/ 80186/ 80286 and Motorola 68000/ 68010. These
µPs were designed using HMOS technology. HMOS provides the following
advantage over NMOS. 1) Speed power produced (SSP) of HMOS is 4 times
better than that of NMOS.
• Later, Intel introduced a high speed version of the 8085A called 8085AH using
HMOS technology to fabricate the 8085A.
• One of the most popular 16-bit µP introduced by Intel was 8088.
Contd….
Fourth Generation:
• In 1980, the fourth generation µPs were evolved.
• Intel introduced the first commercial 32 bit microprocessor, Intel 432.
• Since 1985, more 32-bit µPs have been introduced. These include Intel
iAPX80386, Intel 80486, Motorola MC68020/68030/68040, National
semiconductor NS 32032.
• These processors were fabricated using the low power version of HMOS
technology called HCMOS, and they include an on-chip RAM called the cache
memory to speed up program execution.
Table 1.1: Evaluation of major microprocessor characteristics from Intel
Applications of Microprocessors
1. Analytical scientific instruments 2. Smart terminals
3. Stacker crane controls 4. Conveyor controls
5. Standalone electronics cash system 6. Electronic games
7. Vending and dispensing machines 7. Market scales
8. Traffic light controls 9.Home heating and lighting controls
10. Security & fire alarm system 11. Home appliances
12. Computer aided instruction 13. Desktop computers
14. Payroll system 14. Automobile diagnostics
15. Data communication processing
16. I/O terminal for computers.
Main Features of 8086
1. Enhanced version of 8085 microprocessor.
2. Designed by Intel in 1976.
3. It is a 16-bit processor.
4. It has a 16-bit data bus, 𝐷! − 𝐷"# .
5. 8086 has a 20-bit address bus, 𝐴! − 𝐴"$ , which means it can address up
to 2%! memory locations.
6. It can read/write data to a memory (or) port either 16-bit (or) 8-bit at a
time.
7. It uses a 40-pin dual in line package.
8. Frequency range of 8086 is 6-10 MHz
Main Features of 8086
9. It requires +5V power supply.
10. It has powerful instruction set that supports MUL and DIV
operations.
11. Designed to operates in two modes:
Minimum mode: system having single processor
Maximum mode: system having multiple processors
12. It consists of 29,000 transistors.
13. It has 256 vectored interrupts.
14. Supports two stage pipelining (Fetch and Execute stages)
Main Features of 8086
14. Address and data lines are multiplexed
𝐴𝐷! − 𝐴𝐷"#
𝐴"& − 𝐴"$
15. Instruction system byte queue
It can pre-fetch up to six instruction bytes from memory and queues them
in order to speed up instruction execution.
16. 8086 has two blocks – BIU and EU.
BIU – performs bus operations like instruction fetching, reading/writing
operands for memory and calculating addresses of memory operands,
prefetch up to 6 instruction bytes.
EU – executes instructions from the instruction system byte queue.
Memory Banking
8086 Memory
• 20-bit address bus 00000 8-bit data
• Memory space of 8086 = 2!" = 1 𝑀𝐵 =1024 KB
• Figure 1.4 shows memory space of the 8086
consisting of 1,048,576 bytes or 524,288 16-bit
words.
-------------------------
1 𝑀𝐵 Memory space
FFFFF
Chip 1 (Odd Chip 2 (Even
bank/Higher bank): Bank/Lower Bank) Fig. 1.3: Memory space of 8086
512 KB 512 KB
Fig. 1.4: Memory space of the 8086 consisting of 1,048,576 bytes or 524,288 16-bit words.
(𝑎) (𝑏)
Fig. 1.5: (a) By reading from an even-addressed bank and an odd-addressed bank the 8086 can read two bytes
from memory simultaneously. (b) If the 16-bit word begins at an odd address, the 8086 will require two
memory read or write cycles.
Odd Addressed Bank Even Addressed Bank
00001H 00000H
00003H 00002H
00005H 00004H
00007H 00006H
512 KB 512 KB
FFFFBH FFFFAH
FFFFDH FFFFCH
FFFFFH FFFFEH
1 0 So, A! bit will be
3
5
2
4
used to decide which
chip is to be selected.
---------------
---------------
𝐴"# −−− −𝐴$ 𝐴% 𝐴"
will be used for
address (19-bits)
Address = 20-bits
𝐴!" −−−−−−−−− − 𝐴# 𝐴$ 𝐴% 𝐴! 𝐴& Address
0 −−−−−−−−−−−− − 0 0 0 0 00000𝐻
0 −−−−−−−−−−−− − 0 0 0 1 00001𝐻
0 −−−−−−−−−−−− − 0 0 1 0 00002𝐻
0 −−−−−−−−−−−− − 0 0 1 1 00003𝐻
𝐴!"
512 𝐾𝐵 512 𝐾𝐵
(HB) (LB)
𝐴% 𝐶𝑆 𝐶𝑆
8086
𝐴!
𝐵𝐻𝐸
𝐴&
1 1 Idle
Fig. 1.6: Higher and lower memory banks of 8086
(𝑎) (𝑏)
Fig. 1.7: (a) Even address byte transfer by 8086 and (b) Odd address byte transfer by 8086.
Aligned Word
• Mis-aligned words
o Word operand does not start at even address.
o Need 2 read cycles to read/write the word (8086)
• Issues two addresses to access the two even-aligned words
containing the operand in order to access the operand.
• slower but transparent to programmer.
Pin Diagram of 8086
MIN MAX
MODE MODE
• During the first T state i.e. T1 state, address will be carried on the
multiplexed bus.
1 clock period = 1 - T state
• 8086 bus cycle takes four T states.
• In the first T state i.e. T1, AD"# − AD! used to carry address and act as
A"# − A!
• So, the first step in any of the microprocessor initiated operations (i.e. I/O
read, I/O write, Mem. Read and Mem. Write) is generating address.
• Remaining 4 address lines are multiplexed with status signals
A"$ /S& − A"&/S0 → Multiplexed Address/Status Bus → 𝑃𝑖𝑛𝑠 = 35 −
38.
Pin Diagram of 8086
• So, during T1 state, a total of 20 address lines are available.
• After the first step, control signals will be generated followed by sending
the data.
• So, in subsequent T states, AD"# − AD! will be used to carry data, i.e.
D"# − D! and A"$ /S& − A"&/S0 will be used to carry status signals.
16 A!" − A&
AD!% − AD& 8
𝐵𝐻𝐸 D Q
A!" /S# − A!# /S$
2
𝐵𝐻𝐸/ S'
4 8
8 2 > 𝑄%
𝐴𝐿𝐸 STB
0 8-bit
D = Q at negative edge triggered of clock
8 [3] So, this is latching of input data to the output.
6 Octal Latch
Pin Diagram of 8086
• To provide frequency to the Microprocessor (MP) – MP provided with
CLK pin → 𝑃𝑖𝑛 = 19
IC 8284 is connected externally to 8086 – clock generator
Crystal oscillator used – are more stable
The crystal oscillator of IC 8284 generates a frequency of 15 MHz and in
combination with DIV by 3 Counter generates a frequency of 5 MHz for
8086.
• DT/R : Data Transmit/Receive. This pin required in minimum systems, that want to use an 8286 or
8287 data bus transceiver. The direction of data flow is controlled through the transceiver.
• DEN : Data enable. This pin is provided as an output enable for the 8286/8287 in a minimum system
which uses transceiver. DEN is active low(0) during each memory and input-output access and for
INTA cycles
A!" − A &
𝐴𝐿𝐸 STB
AD!' − AD&
8 21 8282 Latch
A!" /S* − A!* /S$ 𝐵𝐻𝐸
0 8-bit [3]
8 𝐵𝐻𝐸/ S)
6 𝑂𝐸
S$ − S)
𝐷𝐸𝑁 DT/𝑅5
𝐺1𝐴 𝐺1𝐵
Control Signal Generation (Minimum Mode)
Three pins 𝑅𝐷, 𝑊𝑅 and M/𝐼𝑂 → 𝑃𝑖𝑛 = 32, 29 𝑎𝑛𝑑 28, respectively used
to generate four control signals.
M/𝐼𝑂 𝑅𝐷 𝑊𝑅 Operation
0 0 1 𝑌1 = 𝐼𝑂𝑅
0 1 0 𝑌2 = 𝐼𝑂𝑊
1 0 1 𝑌5 = 𝑀𝐸𝑀𝑅
1 1 0 𝑌6 = 𝑀𝐸𝑀𝑊
𝑀𝑁/𝑀𝑋 → 𝑃𝑖𝑛 = 33
• When 𝑀𝑁/𝑀𝑋= 1; Minimum Mode activated (No coprocessors connected).
𝑀𝑁/𝑀𝑋 connected to 𝑉$$
• When 𝑀𝑁/𝑀𝑋= 0 (connected to GND); Maximum Mode activated (8086
connected to coprocessors).
READY → 𝑃𝑖𝑛 = 22
• This pin is used to insert Wait state into the timing cycle of 8086.
• If READY = 1, no effect on operation. Data from peripheral devices is ready to be
read.
• If READY = 0, 8086 enters into Wait state like idle.
• It is used to synchronize slow peripheral devices.
𝑇𝐸𝑆𝑇 → 𝑃𝑖𝑛 = 23
WAIT instruction. MP will WAIT until 𝑇𝐸𝑆𝑇 = 0
RESET
• This causes processor to immediately terminate its present activity.
• The signal must be active HIGH for at least four clock cycles.
Maximum Mode Signals
• Here, either a numeric coprocessor of the type 8087 or another processor
(8089) is interfaced with 8086.
• The Memory, Address Bus, Data Buses are shared resources between the
two processors.
• The control signals for Maximum mode of operation are generated by the
Bus Controller chip 8288.
• The three status outputs 𝑆!, 𝑆=" and 𝑆% from the processor are input to 8288.
• The outputs of the bus controller are the Control Signals, namely DEN,
DT/R*, IORC*, IOWTC*, MWTC*, MRDC*, ALE etc.
𝑆! , 𝑆O" and 𝑆% → 𝑃𝑖𝑛 = 26, 27 𝑎𝑛𝑑 28, respectively.
𝑆! 𝑆3" 𝑆# Function
0 Interrupt acknowledgment
0 0
0 0 1 I/O read
0 1 0 I/O write
0 1 1 𝐻𝑎𝑙𝑡
1 0 0 Instruction fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 Not used
1
Queue Status signals QS" QS# Operation
QS" and QS! → Pin = 24 and 25, respectively 0 0 Read the first byte
(opcode fetch) from queue
QS = Queue status
0 1 Empty the queue
• As discussed, 8086 contains 6 byte Instruction
1 0 Not used
Queue. Read subsequent bytes
• So, by using this Instruction Queue, we can 1 1 from the queue
overlap Fetch and Execute stages and increase
the speed of the operation called Pipelining.
IORD
• The I/O read command output provides
I/O with its read control signal.
IOWR
• The I/O write command output provides I/O with its write control
signal.
AMWR
• Advanced memory write control pin provides memory with an
early/advanced write signal.
MWR
• The memory write control pin provides memory with its normal write
control signal.
MRD
• The memory read control pin provides memory with a read control
signal.
RQ/GT! and RQ/GT" → 𝑃𝑖𝑛 = 31 𝑎𝑛𝑑 30, respectively
(RQ: Request; GT: Grant)
• Maximum mode – is a multi processor configuration,
RQ/GT& ; RQ/GT!
8 Bus Master
0
8
6 After the data transfer is over, bus master sends active Low signal on RT/GT then 8086 regains control
of system bus.
𝑀N 𝑀O 𝑀. 𝑀+
-----------------------------------------------
Service
Interrupt -----------------------------------------------
Request
Bus
Request
Service
“Read” Cycle Timing Diagram for Minimum Mode
• By using three terminals [M/𝐼𝑂, 𝑅𝐷 𝑎𝑛𝑑 𝑊𝑅], we can execute four
Machine Cycles.
. Memory Read [M/𝐼𝑂 =1, 𝑅𝐷 = 0 𝑎𝑛𝑑 𝑊𝑅 = 1]
. Memory Write [M/𝐼𝑂 =1, 𝑅𝐷 = 1 𝑎𝑛𝑑 𝑊𝑅 = 0]
. I/O Read [M/𝐼𝑂 = 0, 𝑅𝐷 = 0 𝑎𝑛𝑑 𝑊𝑅 = 1]
. I/O Write [M/𝐼𝑂 = 0, 𝑅𝐷 = 1 𝑎𝑛𝑑 𝑊𝑅 = 0]
‘Read’ Cycle timing Diagram for Minimum Mode
DEN
MRDC
-----------------------
-----------------------
-----------------------
-----------------------
“Read” Cycle Timing Diagram for Maximum Mode
Memory Segmentation
• Memory segmentation is a solution to a problem.
• 8085 did not have a segmented memory. The problem started with large
memories. Hence, the need of Segmentation.
• 8086 can access a total of 1MB of memory. Memory accessed by 8086
• Used: storing programs and data. Code
• Programs are called Code and Data are called Data.
1MB
Stack
Data
How do you store them?
• Programs (code):
o Stored sequentially (not randomly).
o After every instruction, the address gets incremented.
o So, program (code) will go downwards.
• Data:
o Data can be stored anyhow
o Can be stored sequentially (or) randomly (unstructured data)
o Data can go anywhere in any direction.
• Stack:
o In memory, you also have Stack.
o Stack also stores data. This is in structured form.
o As we keep adding the data in Stack, address gets decremented. Stack
grows upwards.
• Code grows downwards.
• Stack grows upwards. Code
• Data can go anywhere.
• Eventually, they all are going to overwrite on each
other.
Stack
• But with 8086, as the memory increases, it becomes
c
c
difficult to manage.
Data
• In 8086, Memory is divided into 4 Memory accessed by 8086
sections/segments called as Code Segment, 00000H
Stack Segment, Data Segment and Extra Code Segment
Segment. Stack Segment
• Who creates these segments? The programmer.
• At the start of the program, programmer Data Segment
initializes the segments and later the Extra Segment
Microprocessor makes sure there is no FFFFFH
overwriting.
00000H
. Code
Stack
PA (20-bits) = 12345H
Data
Extra
FFFFFH
To understand Segmentation, let us consider an example.
• Consider the Code Segment. Look at one location in the Code Segment.
• How do you identify every memory location? Every Memory location
must have its own unique address.
• This unique address of each Memory location is called as Physical
Address/Actual address (PA).
• This Physical Address (PA) is of 20-bits.
Ex: PA = 12345H (20-bits)
(Adv. - this PA is unique for each memory location and Disadv – it is of 20-
bits - not computer compatible/byte compatible)
• 20 − 𝑏𝑖𝑡𝑠 are 2 "⁄% bytes – not byte compatible.
• So, we never use 20-bits PA.
• 8085 had 16-bit address bus and hence 16-bit address which was byte
compatible.
• Why we need 20-bit address bus? Since, we want to access large memory.
• 20-bit address bus (or) 16-bits address bus – 20-bit address bus – to
access larger memory.
• 20-bit address (or) 16-bit address – 16-bit address - since byte compatible.
• We have 20-bit address bus, so bound to have 20-bit address and this is
the physical address. But, no longer going to use.
• We are going to use 16-bit address called as Virtual Address.
• We are creating a Virtual Address.
• Going to abolish Physical Address.
Virtual Address (VA) = Segment Address (16-bit) and Offset Address
(16-bit)
Segment Address – starting address of each Segment.
Offset Address – Address of each location within a Segment.
Each of the Segment Address and Offset Address are stored in Segment
Registers and Offset Registers, respectively.
Offset Address: is the distance from the starting of the segment to the
required location.
• There are three addresses, Physical Address, Segment Address and Offset
Address.
• Which address you never give – Physical address.
• Which address you provide only once – Segment address, at the beginning
of the program, to identify the program.
• Which address you give every time in the program – Offset address – it is
provided always in the program.
• Code Segment – Starting Offset address is 0000H.
• If the programmer starts writing the instructions.
• Will the instructions be overwritten.
• No, as you will run out of Offset Addresses.
• Offset addresses are defined from 0000H – FFFFH.
• They are restricted. There is a limit in the Offset Address.
0000H
• Offset Address size = 16-bit = 26! = 2! x 267 = 64 𝐾𝐵
--------
Code
(maximum size) FFFFH
0000H
Stack
-------
FFFFH
Data
FFFFFH Extra
8086 𝜇𝑃
Segment Registers (16) Offset Registers (16)
1000H 2345H
Address Bus
cc
CS cc
IP
cc
cc
SS SP
cc BP
cc
DS SI
cc
ES DI
2. If, SS = 3000H
3000 𝑋 10 + 0000 = 30,000
If the offset at the beginning is 0000H
So, the Stack Segment actually begins at 30,000.
2. If, DS = 5237H
So, the Data Segment actually begin at 52370.
5234𝐹
𝑁𝑒𝑎𝑟𝑒𝑠𝑡 𝑙𝑜𝑐. 𝑡𝑜 𝑠𝑡𝑎𝑟𝑡
𝑎 𝑛𝑒𝑤 𝑠𝑒𝑔𝑚𝑒𝑛𝑡
52350
Stack Pointer (SP): ___
• Stack grows upwards.
----------------
TOS
• Top of stack (TOS) is pointed by SP.
• Push (or) Pop operation done from TOS.
• Address of TOS is given by SP. Stack grows upwards
• For Stack Segment, the register used to store the STACK
offset addresses is Stack Pointer (SP).
• After every Push operation, SP gets decremented.
-------------------------------------------------------------=----------------------------------=-----
BIU 6
!. 5
4 6-Byte
3 Pre-fetch
CS (16)
2 Queue
1
SS
------------------------------------------------------------------------------------------------------------------------------------------
------------------
DS
ES
IP
Control Section
---------------
AX - the Accumulator
BX - the Base Register
CX - the Count Register
DX - the Data Register
DX
– Data register
– Used in multiplication and division
– Also used in I/O operations
Pointer and Index Registers
• Before return from the Subroutine, POP instructions can be used to pop
values back from the stack into the corresponding registers.
Stack
To memory & I/O
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------=----------------------------------=-----
BIU 6
!. 5
4 6-Byte
3 Pre-fetch
CS (16)
2 Queue
1
SS
------------------------------------------------------------------------------------------------------------------------------------------
------------------
DS
ES
IP
Control Section
---------------
BL CL BL AH AL
DH DL
Working of ADD BL, CL:
1. Instruction stored in memory.
2. To fetch instruction from Memory, registers CS and IP come into picture.
CS gives segment address and IP gives offset address – using these two
address – MP calculates Physical address using ∑ 𝑈𝑛𝑖𝑡.
3. MP puts this PA on address bus to fetch instruction from memory - through
data bus instruction is stored in Queue.
4. Control section receives Opcode of ADD – decoded in Control section.
5. After decoding, Control Section generates control signals for different
entities.
Program to Add using one register:
04𝐻 + 05𝐻 = 09𝐻
BL BL
X X X X OF DF IF TF SF ZF X AC X PF X CF
Ex: 1 1 1 1 1 1 1 1
+0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
1 Carry out of MSB
If result of an operation is 0 0 0 0 0 0 1 1
Ex: 1 1 1 1 1 1 1 1
+0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
1 𝐶𝐹 = 1
Unsigned/Signed Numbers:
• An 8-bit number. Can be treated as unsigned (or) signed number.
• Unsigned numbers do not have sign. They are always assumed to be
positive (ex. Your roll number, score od a match).
• In such numbers, all the 8-bits give Magnitude.
• No bit is wasted in giving the Sign.
• Irrespective of whether MSB is 0 (or) 1, the number is positive.
• So, the concept which we saw just now, that MSB tells whether no. positive
(or) negative does not apply to unsigned numbers.
2G = 256 positive numbers
0 − 255 0 0 0 0 0 0 0 0 → smallest number
00𝐻 − 𝐹𝐹𝐻 1 1 1 1 1 1 1 1 → largest number
Signed Numbers:
𝑀𝑆𝐵 7-bits. 8-bit number → 2G = 256 – all not positive
Sign bit Magnitude nor negative
2H = 128 combinations with S = 1 → negative numbers
2H = 128 combinations with S = 0 → positive numbers
−128 … … … … − 1 0 … … … … … . . 127
−80 … … … … . −01 00 … … … … … 7𝐹𝐻
Range of negative numbers Range of positive numbers
3 7𝐻 0 0 1 1 0 1 1 1 𝑂𝐹 𝑆𝐹 𝑍𝐹 𝐴𝐶 𝑃𝐹 𝐶
+2 9𝐻 0 0 1 0 1 0 0 1 ↓ ↓ ↓ ↓ ↓ ↓
6 0𝐻 0 1 1 0 0 0 0 0 0 0 0 1 1 0
Ex: 3
4 2𝐻 0 1 0 0 0 0 1 0 𝑂𝐹 𝑆𝐹 𝑍𝐹 𝐴𝐶 𝑃𝐹 𝐶
+4 3𝐻 0 1 0 0 0 0 1 1 ↓ ↓ ↓ ↓ ↓ ↓
8 5𝐻 1 0 0 0 0 1 0 1 1 1 0 0 0 0
• Carry Flag, Overflow Flag, Parity Flag, Auxiliary Carry and Signed Flag
are the Status Flags – indicate the status of the current result.
• These are changed by the ALU after every arithmetic & logical operation.
• Rest three flags called as – Control Flags. These ae used by the
programmer – programmer control these 3 flags.