ST Joseph'S College: " Microprocessor 8086
ST Joseph'S College: " Microprocessor 8086
ST Joseph'S College: " Microprocessor 8086
TERM PAPER ON
“ MICROPROCESSOR 8086”
As a partial requirement for the Degree of
BACHELOR OF SCIENCE
1
ST JOSEPH’S COLLEGE(AUTONOMOUS)
P.B.27094, 36, Lalbhagh Road, Banglore-560027
2
Acknowledgement
SYED SAIF
17MEC24019
3
ST JOSEPH’S COLLEGE(AUTONOMOUS)
P.B.27094, 36, Lalbhagh Road, Banglore-560027
CERTIFICATE
This is to certify that term paper entitled “A Compact Study
On Microprocessor(8086)” a bonafide work carried out by Syed
Saif student of Department of BSC, ST JOSEPH’S
COLLEGE(AUTONOMOUS) This term paper report is been
submitted during the year 2018-19 in partial fulfilment of the
requirement of the degree of Bachelor of Science 5th Semester.
Ms Regina Mathias
Term paper Guide
Date:…………
Place: Bangalore
4
Contents
Microprocessor
INTRODUCTION OF MICROPROCESSOR
GENERATION OF MICROPROCESSORS
MICROPROCESSOR 8086
COMPARITISON BETWEEN 8086 AND 8085
ARCHITECHTURE OF 8086
8086 INSTRUCTION SETS
8086 INTERRUPTS
80086 ADDRESSING MODES
5
Microprocessor
A microprocessor is a controlling unit of a micro-computer, fabricated on
a small chip capable of performing Arithemetic Logical Unit (ALU)
operations and communicating with the other devices connected to it.
Microprocessor over-view
Microprocessor is a controlling unit of a micro-computer, fabricated on a
small chip capable of performing ALU (Arithmetic Logical Unit) operations
and communicating with the other devices connected to it.
Microprocessor consists of an Arithmetic Logic Unit, register array, and a
control unit. ALU performs arithmetical and logical operations on the
data received from the memory or an input device. Register array
contains the registers identified by letters like B, C, D, E, H, L and
accumulator. The CU controls the flow of data and instructions within the
computer.
Introduction
History
Fair child semiconductors (founded in 1957) invented the first IC in 1959 that
marked the microprocessor history. In 1968, Gordan Moore, Robert Noyce and
Andrew Grove resigned from the Fair child semiconductors and started their own
company: Integrated Electronics (Intel). The first microprocessor Intel 4004 was
invented in 1971. A microprocessor is also known as a central processing unit in
which numbers of peripherals’ are fabricated on a single chip. It has ALU , a control
unit, registers, bus systems and a clock to perform computational tasks.
6
Generation of Microprocessor
1st Generation
This was the period during 1971 to 1973 of microprocessor’s history. In 1971 intel
created the 1st microprocessor “4004” that would run at a clock speed of (108
KHz).With only 4 bits as the word size, the 4004 could only represent signed
numbers in the range -8 to +7, which is indeed very small. So, it was not really of
practical use for arithmetic calculations. However, it found applications in controlling
devices.
2nd Generation
Intel 8008 was the next in the evolution, the first 8-bit microprocessor. This was in
the year 1972. This was soon followed by Intel 8080, also an 8-bit microprocessor.
Intel 8080 was the first commercially popular 8bit microprocessor. With 8 bits as the
word size, it could represent signed numbers in the range of −128 to +127. This is
also not a good enough range for performing arithmetic calculations. Thus, the 8080
also was used only for control applications.
Some other microprocessors like 6800 from Motorola, Z-80 from Zilog were also
Popular at this time.
They were costly as they were based on NMOS technology fabrication and also for
their superfast speed.
3rd Generation
Around 1978, Intel released 8086, the first 16-bit microprocessor. With 16-bit word
size, it was possible to represent signed numbers in the range of −32,768 to
+32,767, which is quite a decent range for performing arithmetic calculations. As
such, this processor became very popular for control applications and also for
number crunching operations. Speeds of those processors were 4 times better than
the 2nd generation processors. Not to be outdone, Motorola came out with 68000,
their 16-bit processor. Zilog released Z-8000, again a 16-bit processor. These are
the most popular 16-bit processors.
7
4th Generation
In the early 80s, Intel released the 32-bit processor, the Intel 80386, by using
HCMOS fabrication. With 32-bit word size, it was possible to represent signed
numbers in the range ±2×109, which is quite a large range for performing arithmetic
calculations. If floating point notation is used, it can represent much larger numbers.
As such, this processor became very popular as the Control Process Unit in
computers for number crunching operations. At this time, Motorola came out with
68020, their 32-bit processor. Intel released 80486, which was basically an 80386
processor and 80387 numeric co-processor on a single chip. Motorola released
68030. In the early 90s, Intel released 80586 by the name Pentium processor. It is
so fast in performing arithmetic operations and executing instructions. The Pentium
4 released in 2000 has 42 Million transistors worked with a clock frequency of (1.5
GHz) and is rated for 1500 MIPS (Million instructions per second).
5th Generation
From 1995 to until now so many processors pocessing high-performance and high-
speed processors that make use of 64-bit processors. The present-day computers
based on microprocessors are already faster than the mini computers and
sometimes the main frame computers of yesteryear, and they are available at a
small fraction of the cost of such main frame computers.
8
Fisrt the instructions are stored in the memory in a sequential order. The
microprocessor fetches those instructions from the memory, then
decodes it and executes those instructions till STOP instruction is
reached. it sends the result in binary to the output port later. Between
these processes, the register stores the temporarily data and ALU
performs the computing functions.
Features of a Microprocessor
List of some of the most prominent features of any microprocessor −
Cost-effective − The microprocessor chips are available at low
prices and results its low cost.
Size − The microprocessor is of small size chip, hence is portable.
Low Power Consumption − Microprocessors are manufactured by
using metaloxide semiconductor technology, which has low power
consumption.
Versatility − The microprocessors are versatile as we can use the
same chip in a number of applications by configuring the software
program.
Reliability − The failure rate of an IC in microprocessors is very
low, hence it is reliable.
Microprocessor classification
Microprocessor can be classified into three categories −
9
RISC Processor
RISC stands for Reduced Instruction Set Computer. It is designed to
reduce the execution time by simplify the instruction set of the
computer. Using RISC processors, each instruction requires only one
clock cycle to execute results in uniform execution time. This reduces the
efficiency as there are more lines of code, hence more RAM is needed to
store the instructions. The compiler also has to work more to convert
high-level language instructions into machine code.
Some of the RISC processors are −
Architecture of RISC
RISC microprocessor architecture uses highly-optimized set of
instructions. It is used in portable devices like Apple iPod due to its
power efficiency.
10
Characteristics of RISC
The major characteristics of a RISC processor are as follows −
It consists of simple instructions.
It supports various data-type formats.
It utilizes simple addressing modes and fixed length instructions for
pipelining.
It supports register to use in any context.
One cycle execution time.
“LOAD” and “STORE” instructions are used to access the memory
location.
It consists of larger number of registers.
It consists of less number of transistors.
CISC Processor
CISC stands for Complex Instruction Set Computer. It is designed to
minimize the number of instructions per program, ignoring the number
of cycles per instruction. The emphasis is on building complex
instructions directly into the hardware.
The compiler has to do very little work to translate a high-level language
into assembly level language/machine code because the length of the
code is relatively short, so very little RAM is required to store the
instructions.
Some of the CISC Processors are −
11
IBM 370/168
VAX 11/780
Intel 80486
Architecture of CISC
Its architecture is designed to decrease the memory cost because more
storage is needed in larger programs resulting in higher memory cost. To
resolve this, the number of instructions per program can be reduced by
embedding the number of operations in a single instruction.
Characteristics of CISC
12
Coprocessor
A coprocessor is a specially designed microprocessor, which can handle
its particular function many times faster than the ordinary
microprocessor.
For example − Math Coprocessor.
Some Intel math-coprocessors are −
14
Microprocessor 8086
8086 Microprocessor is an enhanced version of 8085Microprocessor that was
designed by Intel in 1976. It is a 16-bit Microprocessor having 20 address lines
and16 data lines that provides up to 1MB storage. It consists of powerful instruction
set, which provides operations like multiplication and division easily.
It supports two modes of operation, i.e. Maximum mode and Minimum mode.
Maximum mode is suitable for system having multiple processors and Minimum
mode is suitable for system having a single processor.
Intel 8086 was launched in 1978.
It was the first 16-bit microprocessor.
This microprocessor had major improvement over the execution
speed of 8085.
It is available as 40-pin Dual-Inline-Package(DIP).
It is available in three versions:
8086 (5 MHz)
8086-2 (8 MHz)
8086-1 (10 MHz)
It consists of 29000 transistors.
It has a 16 line data bus.
And 20 line address bus.
It could address up to 1MB of memory.
It has more than 20000 instructions.
It supports multiplication and division.
Features of 8086
The most prominent features of a 8086 microprocessor are as follows −
It has an instruction queue, which is capable of storing six
instruction bytes from the memory resulting in faster processing.
It was the first 16-bit processor having 16-bit ALU, 16-bit registers,
internal data bus, and 16-bit external data bus resulting in faster
processing.
It is available in 3 versions based on the frequency of operation −
o 8086 → 5MHz
o 8086-2 → 8MHz
o (c)8086-1 → 10 MHz
15
It uses two stages of pipelining, i.e. Fetch Stage and Execute Stage,
which improves performance.
Fetch stage can prefetch up to 6 bytes of instructions and stores
them in the queue.
Execute stage executes these instructions.
It has 256 vectored interrupts.
It consists of 29,000 transistors.
Comparison between 8085 & 8086 Microprocessor
Size − 8085 is 8-bit microprocessor, whereas 8086 is 16-bit
microprocessor.
Address Bus − 8085 has 16-bit address bus while 8086 has 20-bit
address bus.
Memory − 8085 can access up to 64Kb, whereas 8086 can access
up to 1 Mb of memory.
Instruction − 8085 doesn’t have an instruction queue, whereas
8086 has an instruction queue.
Pipelining − 8085 doesn’t support a pipelined architecture while
8086 supports a pipelined architecture.
I/O − 8085 can address 2^8 = 256 I/O's, whereas 8086 can
access 2^16 = 65,536 I/O's.
Cost − The cost of 8085 is low whereas that of 8086 is high.
16
o Architecture of 8086
The following diagram depicts the architecture of a 8086 Microprocessor −
EU (Execution Unit)
Execution unit gives instructions to BIU stating from where to fetch the data and
then decode and execute those instructions. Its function is to control operations on
data using the instruction decoder & ALU. EU has no direct connection with system
buses as shown in the above figure, it performs operations over data through BIU.
Let us now discuss the functional parts of 8086 microprocessors.
ALU
It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND,
NOT operations.
Flag Register
It is a 16-bit register that behaves like a flip-flop, i.e. it changes
its status according to the result stored in the accumulator. It has
9 flags and they are divided into 2 groups − Conditional Flags
and Control Flags.
17
Conditional Flags
It represents the result of the last arithmetic or logical instruction executed.
Following is the list of conditional flags −
Carry flag − This flag indicates an overflow condition for arithmetic
operations.
Auxiliary flag − When an operation is performed at ALU, it results
in a carry/barrow from lower nibble (i.e. D0 – D3) to upper nibble
(i.e. D4 – D7), then this flag is set, i.e. carry given by D3 bit to D4
is AF flag. The processor uses this flag to perform binary to BCD
conversion.
Parity flag − This flag is used to indicate the parity of the result,
i.e. when the lower order 8-bits of the result contains even number
of 1’s, then the Parity Flag is set. For odd number of 1’s, the Parity
Flag is reset.
Zero flag − This flag is set to 1 when the result of arithmetic or
logical operation is zero else it is set to 0.
Sign flag − This flag holds the sign of the result, i.e. when the
result of the operation is negative, then the sign flag is set to 1 else
set to 0.
Overflow flag − This flag represents the result when the system
capacity is exceeded.
Control Flags
Control flags controls the operations of the execution unit. Following is the list of control flags −
Trap flag − It is used for single step control and allows the user to execute
one instruction at a time for debugging. If it is set, then the program can be
run in a single step mode.
Interrupt flag − It is an interrupt enable/disable flag, i.e. used to allow/prohibit
the interruption of a program. It is set to 1 for interrupt enabled condition and
set to 0 for interrupt disabled condition.
Direction flag − It is used in string operation. As the name suggests when it
is set then string bytes are accessed from the higher memory address to the
lower memory address and vice-a-versa.
19
address or the content of other register that holds the offset
address.
o SS − It stands for Stack Segment. It handles memory to store
data and addresses during execution.
o ES − It stands for Extra Segment. ES is additional data
segment, which is used by the string to hold the extra
destination data.
Instruction pointer − It is a 16-bit register used to hold the
address of the next instruction to be executed.
8086 was the first 16-bit microprocessor available in 40-pin DIP
(Dual Inline Package) chip. Let us now discuss in detail the pin
configuration of a 8086 Microprocessor.
20
8086 Pin Diagram
Here is the pin diagram of 8086 microprocessor −
21
It is multiplexed with status pin S7.
RD (Read)
Pin 32(ouput)
22
INTR
It is available at pin 18. It is an interrupt request signal, which is
sampled during the last clock cycle of each instruction to determine
if the processor considered this as an interrupt or not.
NMI
It stands for non-maskable interrupt and is available at pin 17. It is
an edge triggered input, which causes an interrupt request to the
microprocessor.
$\overline{TEST}$
This signal is like wait state and is available at pin 23. When this
signal is high, then the processor has to wait for IDLE state, else the
execution continues.
MN/$\overline{MX}$
It stands for Minimum/Maximum and is available at pin 33. It
indicates what mode the processor is to operate in; when it is high,
it works in the minimum mode and vice-aversa.
INTA
It is an interrupt acknowledgement signal and id available at pin 24.
When the microprocessor receives this signal, it acknowledges the
interrupt.
ALE
It stands for address enable latch and is available at pin 25. A
positive pulse is generated each time the processor begins any
operation. This signal indicates the availability of a valid address on
the address/data lines.
DEN
It stands for Data Enable and is available at pin 26. It is used to
enable Transreceiver 8286. The transreceiver is a device used to
separate data from the address/data bus.
DT/R
It stands for Data Transmit/Receive signal and is available at pin
27. It decides the direction of data flow through the transreceiver.
When it is high, data is transmitted out and vice-a-versa.
M/IO
This signal is used to distinguish between memory and I/O
operations. When it is high, it indicates I/O operation and when it is
low indicates the memory operation. It is available at pin 28.
WR
It stands for write signal and is available at pin 29. It is used to
write the data into the memory or the output device depending on
the status of M/IO signal.
23
HLDA
It stands for Hold Acknowledgement signal and is available at pin
30. This signal acknowledges the HOLD signal.
HOLD
This signal indicates to the processor that external devices are
requesting to access the address/data buses. It is available at pin
31.
QS1 and QS0
These are queue status signals and are available at pin 24 and 25.
These signals provide the status of instruction queue. Their
conditions are shown in the following table −
0 0 No operation
S0, S1, S2
These are the status signals that provide the status of operation,
which is used by the Bus Controller 8288 to generate memory & I/O
control signals. These are available at pin 26, 27, and 28. Following
is the table showing their status −
S2 S1 S0 Status
0 0 0 Interrupt acknowledgement
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
24
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
LOCK
When this signal is active, it indicates to the other processors not to
ask the CPU to leave the system bus. It is activated using the LOCK
prefix on any instruction and is available at pin 29.
RQ/GT1 and RQ/GT0
These are the Request/Grant signals used by the other processors
requesting the CPU to release the system bus. When the signal is
received by CPU, then it sends acknowledgment. RQ/GT0 has a
higher priority than RQ/GT1.
26
NPG − Used to negate each bit of the provided byte/word and add 1/2’s
complement.
CMP − Used to compare 2 provided byte/word.
AAS − Used to adjust ASCII codes after subtraction.
DAS − Used to adjust decimal after subtraction.
Instruction to perform multiplication
MUL − Used to multiply unsigned byte by byte/word by word.
IMUL − Used to multiply signed byte by byte/word by word.
AAM − Used to adjust ASCII codes after multiplication.
Instructions to perform division
DIV − Used to divide the unsigned word by byte or unsigned double word by
word.
IDIV − Used to divide the signed word by byte or signed double word by word.
AAD − Used to adjust ASCII codes after division.
CBW − Used to fill the upper byte of the word with the copies of sign bit of the
lower byte.
CWD − Used to fill the upper word of the double word with the sign bit of the
lower word.
Bit Manipulation Instructions
These instructions are used to perform operations where data bits are involved, i.e.
operations like logical, shift, etc.
Following is the list of instructions under this group −
Instructions to perform logical operation
NOT − Used to invert each bit of a byte or word.
AND − Used for adding each bit in a byte/word with the corresponding bit in
another byte/word.
OR − Used to multiply each bit in a byte/word with the corresponding bit in
another byte/word.
XOR − Used to perform Exclusive-OR operation over each bit in a byte/word
with the corresponding bit in another byte/word.
TEST − Used to add operands to update flags, without affecting operands.
Instructions to perform shift operations
SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in
LSBs.
SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.
SAR − Used to shift bits of a byte/word towards the right and copy the old
MSB into the new MSB.
27
Instructions to perform rotate operations
ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and
to Carry Flag [CF].
ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and
to Carry Flag [CF].
RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and
CF to MSB.
RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and
CF to LSB.
String Instructions
String is a group of bytes/words and their memory is always allocated in a
sequential order.
Following is the list of instructions under this group −
REP − Used to repeat the given instruction till CX ≠ 0.
REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag
ZF = 1.
REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero
flag ZF = 1.
MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to
another.
COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the
provided memory location.
OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the
provided memory location to the I/O port.
SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a
byte in AL or string word with a word in AX.
LODS/LODSB/LODSW − Used to store the string byte into AL or string word
into AX.
Program Execution Transfer Instructions (Branch and Loop
Instructions)
These instructions are used to transfer/branch the instructions during an execution.
It includes the following instructions −
Instructions to transfer the instruction during an execution without any condition −
CALL − Used to call a procedure and save their return address to the stack.
RET − Used to return from the procedure to the main program.
JMP − Used to jump to the provided address to proceed to the next
instruction.
28
Instructions to transfer the instruction during an execution with some conditions −
JA/JNBE − Used to jump if above/not below/equal instruction satisfies.
JAE/JNB − Used to jump if above/not below instruction satisfies.
JBE/JNA − Used to jump if below/equal/ not above instruction satisfies.
JC − Used to jump if carry flag CF = 1
JE/JZ − Used to jump if equal/zero flag ZF = 1
JG/JNLE − Used to jump if greater/not less than/equal instruction satisfies.
JGE/JNL − Used to jump if greater than/equal/not less than instruction
satisfies.
JL/JNGE − Used to jump if less than/not greater than/equal instruction
satisfies.
JLE/JNG − Used to jump if less than/equal/if not greater than instruction
satisfies.
JNC − Used to jump if no carry flag (CF = 0)
JNE/JNZ − Used to jump if not equal/zero flag ZF = 0
JNO − Used to jump if no overflow flag OF = 0
JNP/JPO − Used to jump if not parity/parity odd PF = 0
JNS − Used to jump if not sign SF = 0
JO − Used to jump if overflow flag OF = 1
JP/JPE − Used to jump if parity/parity even PF = 1
JS − Used to jump if sign flag SF = 1
Processor Control Instructions
These instructions are used to control the processor action by setting/resetting the
flag values.
Following are the instructions under this group −
STC − Used to set carry flag CF to 1
CLC − Used to clear/reset carry flag CF to 0
CMC − Used to put complement at the state of carry flag CF.
STD − Used to set the direction flag DF to 1
CLD − Used to clear/reset the direction flag DF to 0
STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.
CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.
Iteration Control Instructions
These instructions are used to execute the given instructions for number of times.
Following is the list of instructions under this group −
LOOP − Used to loop a group of instructions until the condition satisfies, i.e.,
CX = 0
29
LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 &
CX = 0
LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0
& CX = 0
JCXZ − Used to jump to the provided address if CX = 0
Interrupt Instructions
These instructions are used to call the interrupt during program execution.
INT − Used to interrupt the program during execution and calling service
specified.
INTO − Used to interrupt the program during execution if OF = 1
IRET − Used to return from interrupt service to the main program
30
Microprocessor - 8086 Interrupts
Interrupt is the method of creating a temporary halt during program
execution and allows peripheral devices to access the microprocessor.
The microprocessor responds to that interrupt with an ISR (Interrupt
Service Routine), which is a short program to instruct the
microprocessor on how to handle the interrupt.
The following image shows the types of interrupts we have in a 8086
microprocessor −
Hardware Interrupts
Hardware interrupt is caused by any peripheral device by sending a
signal through a specified pin to the microprocessor.
The 8086 has two hardware interrupt pins, i.e. NMI and INTR. NMI is a
non-maskable interrupt and INTR is a maskable interrupt having lower
priority. One more interrupt pin associated is INTA called interrupt
acknowledge.
NMI
It is a single non-maskable interrupt pin (NMI) having higher priority
than the maskable interrupt request pin (INTR)and it is of type 2
interrupt.
When this interrupt is activated, these actions take place −
Completes the current instruction that is in progress.
Pushes the Flag register values on to the stack.
Pushes the CS (code segment) value and IP (instruction pointer)
value of the return address on to the stack.
31
IP is loaded from the contents of the word location 00008H.
CS is loaded from the contents of the next word location 0000AH.
Interrupt flag and trap flag are reset to 0.
INTR
The INTR is a maskable interrupt because the microprocessor will be
interrupted only if interrupts are enabled using set interrupt flag
instruction. It should not be enabled using clear interrupt Flag
instruction.
The INTR interrupt is activated by an I/O port. If the interrupt is enabled
and NMI is disabled, then the microprocessor first completes the current
execution and sends ‘0’ on INTA pin twice. The first ‘0’ means INTA
informs the external device to get ready and during the second ‘0’ the
microprocessor receives the 8 bit, say X, from the programmable
interrupt controller.
These actions are taken by the microprocessor −
First completes the current instruction.
Activates INTA output and receives the interrupt type, say X.
Flag register value, CS value of the return address and IP value of
the return address are pushed on to the stack.
IP value is loaded from the contents of word location X × 4
CS is loaded from the contents of the next word location.
Interrupt flag and trap flag is reset to 0
Software Interrupts
Some instructions are inserted at the desired position into the program
to create interrupts. These interrupt instructions can be used to test the
working of various interrupt handlers. It includes −
34
Microprocessor - 8086 Addressing Modes
The different ways in which a source operand is denoted in an instruction
is known as addressing modes. There are 8 different addressing
modes in 8086 programming −
36
Bibliography
Reference of books
1. Introduction to Microprocessors and Microcontrollers-By
John Crisp
2. Microprocessor interfacing and applications- By Rena
SINGH and B.P. SINGH
3. Advanced microprocessors and Peripherals- By AKRAY
and K.M. BHURCHANDI
4. Microprocessor and its applications-By
R.THEAGARAJAN and S.DHANAPAL and
S.DHANASEKARAN
5. Fundamentals of microprocessors and its Applications –
By ANOKH SINGH AND A.K.CHHABRA
37