Microprocessor U 3 Combined Notes
Microprocessor U 3 Combined Notes
Today’s Target
✓ Main features of 8086 microprocessor.
✓ Internal architecture: Bus Interface Unit, Execution unit, Memory
addressing, Memory Segmentation, Pipelining
✓ AKTU PYQs
MICROPROCESSOR AND MICROCONTROLLER (BEE-602)
The Execution Unit (EU): The execution unit of the 8086 tells the BIU where to fetch
instructions or data from, decodes instructions, and executes instructions. The EU contains
control circuitry, which directs internal operations. A decoder in the EU translates instructions
fetched from memory into a series of actions, which the EU carries out. The EU has a 16-bit
arithmetic logic unit (ALU) which can add, subtract, AND, OR, XOR, increment, decrement,
complement or shift binary numbers.
The main functions of EU are:
Decoding of Instructions
Execution of instructions
PIPELINING:
The process of fetching the next instruction when the present instruction is being executed is
called as pipelining
MEMORY SEGMENTATION
Segmentation is the process in which the main memory of the computer is logically
divided into different segments and each segment has its own base address. It is basically
used to enhance the speed of execution of the computer system, so that the processor is
able to fetch and execute the data from the memory easily and fast.
The Bus Interface Unit (BIU) contains four 16 bit special purpose registers (mentioned
below) called as Segment Registers.
Code segment register (CS): is used for addressing memory location in the code segment
of the memory, where the executable program is stored.
Data segment register (DS): points to the data segment of the memory where the data is
stored.
Extra Segment Register (ES): also refers to a segment in the memory which is another
data segment in the memory.
Stack Segment Register (SS): is used for addressing stack segment of the memory. The
stack segment is that segment of memory which is used to store stack data.
Need for Segmentation
The number of address lines in 8086 is 20, 8086 BIU will send 20bit address, so as to
access one of the 1MB memory locations. The four segment registers actually contain the
upper 16 bits of the starting addresses of the four memory segments of 64 KB each with
which the 8086 is working at that instant of time. A segment is a logical unit of memory
that may be up to 64 kilobytes long. Each segment is made up of contiguous memory
locations. It is an independent, separately addressable unit. Starting address will always
be changing. It will not be fixed.
Note that the 8086 does not work the whole 1MB memory at any given time. However, it
works only with four 64KB segments within the whole 1MB memory.
Types Of Segmentation
Today’s Target
✓ Internal architecture: 8086 Microprocessor Register organization.
✓ AKTU PYQs
REGISTER ORGANIZATION
GENERAL PURPOSE REGISTERS
There are 4 general purpose registers in 8086 microprocessor.
AX – This is the accumulator. It is of 16 bits and is divided into two 8-bit registers AH
and AL to also perform 8-bit instructions.
It is generally used for arithmetical and logical instructions but in 8086 microprocessor
it is not mandatory to have accumulator as the destination operand.
Example: ADD AX, AX (AX = AX + AX)
BX – This is the base register. It is of 16 bits and is divided into two 8-bit registers BH
and BL to also perform 8-bit instructions.
It is used to store the value of the offset.
Example: MOV BL, [500] (BL = 500H)
CX – This is the counter register. It is of 16 bits and is divided into two 8-bit registers CH
and CL to also perform 8-bit instructions.
It is used in looping and rotation.
Example: MOV CX, 0005 LOOP
DX – This is the data register. It is of 16 bits and is divided into two 8-bit registers DH
and DL to also perform 8-bit instructions.
It is used in multiplication an input/output port addressing.
Example: MUL BX (DX, AX = AX * BX)
SPECIAL PURPOSE REGISTERS
Pointer & Index Registers
SP – This is the stack pointer. It is of 16 bits.
It points to the topmost item of the stack. If the stack is empty the stack pointer will
be (FFFE)H. It’s offset address relative to stack segment.
BP – This is the base pointer. It is of 16 bits.
It is primary used in accessing parameters passed by the stack. It’s offset address
relative to stack segment.
SI – This is the source index register. It is of 16 bits.
It is used in the pointer addressing of data and as a source in some string related
operations. It’s offset is relative to data segment.
DI – This is the destination index register. It is of 16 bits.
It is used in the pointer addressing of data and as a destination in some string
related operations. It’s offset is relative to extra segment.
Instruction Pointer (IP) holds the offset address of the next instruction to be
executed within the code segment. It, along with the Code Segment (CS) register,
determines the complete address of the next instruction to be fetched.
Segment Registers
There are 4 segment registers in 8086 Microprocessor and each of them is of 16 bit.
The code and instructions are stored inside these different segments.
Code Segment (CS) Register:
The user cannot modify the content of these registers. Only the microprocessor's
compiler can do this.
Data Segment (DS) Register:
The user can modify the content of the data segment.
Stack Segment (SS) Registers:
The SS is used to store the information about the memory segment. The operations
of the SS are mainly Push and Pop.
Extra Segment (ES) Register:
By default, the control of the compiler remains in the DS where the user can add and
modify the instructions. If there is less space in that segment, then ES is used. ES is
also used for copying purpose.
FLAG REGISTER
The Flag register is a 16-bit register which contains 9 flags, and the remaining 7 bits
are idle in this register. It is of 2 types
1. Status Flags - In 8086 there are 6 different flags which are set or reset after 8-bit
or 16-bit operations
2. Control Flags - In 8086 there are 3 different flags which are used to enable or
disable some basic operations of the microprocessor
1. STATUS FLAGS
AC When some arithmetic operations generates carry after the lower half and sends it to
upper half, the AC will be 1
P This is even parity flag. When result has even number of 1, it will be set to 1,
otherwise 0 for odd number of 1s
CY This is carry bit. If some operations are generating carry after the operation this flag
is set to 1
O The overflow flag is set to 1 when the result of a signed operation is too large to fit.
2. Control Flags
I This is interrupt flag. If I = 1, then MPU will recognize the interrupts from
peripherals. For I = 0, the interrupts will be ignored
T This trap flag is used for on-chip debugging. When T = 1, it will work in a
single step mode. After each instruction, one internal interrupt is
generated. It helps to execute some program instruction by instruction.
ARCHITECTURE OF 8086 MICROPROCESSOR
University Questions
Today’s Target
✓ Pin Diagram of the 8086 Microprocessor
✓ Min & Max operating Modes 8086
✓ AKTU PYQs
PIN DIAGRAM OF 8086 MICROPROCESSOR
1. Power supply and frequency signals
It uses 5V DC supply at VCC pin 40, and uses
ground at VSS pin 1 and 20 for its operation.
2. Clock signal
Clock signal is provided through Pin-19. It
provides timing to the processor for operations. Its
frequency is different for different versions, i.e. 5MHz,
8MHz and 10MHz.
3. Address/data bus
AD0-AD15. These are 16 address/data bus.
AD0-AD7 carries low order byte data and AD8-AD15
carries higher order byte data. During the first clock
cycle, it carries 16-bit address and after that it carries
16-bit data.
4. Address/status bus
A16-A19/S3-S6. These are the 4 address/status
buses. During the first clock cycle, it carries 4-bit
address and later it carries status signals.
4. Address/status bus
A17/S4 A16/S3 Function
S5 and S6 provide information about the processor's state, with S6 always being a logic 0
and S5 indicating the status of the Interrupt Enable Flag (IF).
5. 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.
6. 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.
7. INTA
It is an interrupt acknowledgement signal
and id available at pin 24. When the microprocessor
receives this signal, it acknowledges the interrupt.
8. S7/BHE
BHE stands for Bus High Enable. It is available at pin 34 and used
to indicate the transfer of data using data bus D8-D15. This signal is low
during the first clock cycle, thereafter it is active.
9. MN/MX’
This pin signal indicates what mode the processor will operate in
Minimum/Maximum mode.
10. TEST’
This examined by a ‘WAIT’ instruction. If the TEST pin goes low(0),
execution will continue, else the processor remains in an idle state. The
input is internally synchronized during each of the clock cycle on leading
edge of the clock.
11. Ready
It is available at pin 22. It is an acknowledgement signal from I/O
devices that data is transferred. It is an active high signal. When it is high, it
indicates that the device is ready to transfer data. When it is low, it indicates
wait state.
12. RESET
It is available at pin 21 and is used to restart the execution. It
causes the processor to immediately terminate its present activity. This
signal is active high for the first 4 clock cycles to RESET the microprocessor.
13. Read(RD)
It is available at pin 32 and is used to read signal for
Read operation.
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
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
4. 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
1.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.
2. HLDA
It stands for Hold Acknowledgement signal
and is available at pin 30. This signal acknowledges
the HOLD signal.
3. HOLD
This signal indicates to the processor that
external devices are requesting to access the
address/data buses. It is available at pin 31.
4.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.
5. 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.
6. 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.
7. 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
University Questions
Today’s Target
✓ Instruction Set (Data Transfer, Arithmetic & Logical Instructions)
✓ AKTU PYQs
Types of Instructions in 8086
String Instructions
Instruction Description
ADD Adds data to the accumulator i.e. AL or AX register or memory
locations.
ADC Adds specified operands and the carry status (i.e. carry of the
previous stage).
SUB Subtract immediate data from accumulator, memory or register.
SBB Subtract immediate data with borrow from accumulator, memory or
register.
MUL Unsigned 8-bit or 16-bit multiplication.
IMUL Signed 8-bit or 16-bit multiplication.
DIV Unsigned 8-bit or 16-bit division.
IDIV Signed 8-bit or 16-bit division.
INC Increment Register or memory by 1.
DEC Decrement register or memory by 1.
DAA Decimal Adjust after BCD Addition: When two BCD numbers are added,
the DAA is used after ADD or ADC instruction to get correct answer in BCD.
DAS Decimal Adjust after BCD Subtraction: When two BCD numbers are
added, the DAS is used after SUB or SBB instruction to get correct answer in
BCD.
AAA ASCII Adjust for Addition: When ASCII codes of two decimal digits are
added, the AAA is used after addition to get correct answer in unpacked
BCD.
AAD Adjust AX Register for Division: It converts two unpacked BCD digits in AX
to the equivalent binary number. This adjustment is done before dividing
two unpacked BCD digits in AX by an unpacked BCD byte.
AAM Adjust result of BCD Multiplication: This instruction is used after the
multiplication of two unpacked BCD.
AAS ASCII Adjust for Subtraction: This instruction is used to get the correct
result in unpacked BCD after the subtraction of the ASCII code of a number
from ASCII code another number.
ADD ADC
Eg.- Eg.-
If the LS hex digit is >9, or if AC flag is set to 1, it adds 6 to the LS hex digit of A. If
carry results, then it increments the MS hex digit if this addition resulted in a carry
to the MS digit position. In this process, the Cy flag will be set to 1 if the MS hex digit
was incremented from F to 0.
If the MS hex digit is <= 9 and Cy flag is 0, the MS hex digit will not be altered, and Cy
flag is reset to 0.
If the MS hex digit is > 9, or if Cy flag is set to 1, it adds 6 to the MS hex digit of A and
sets Cy flag to 1.
38 0011 1000
+ 45 0100 0101
---- ------------- 1
75 0111 0101
- 46 0100 0110
---- -------------
You use AAA only after executing the form of an add instruction that stores a
two-BCD-digit byte result in the AL register. AAA then adjusts AL to contain
the correct decimal result. The top nibble of AL is set to 0. To convert AL to
an ASCII result, follow the AAA instruction with:
Carry Action
decimal carry AH + 1; CF and AF set to 1
Today’s Target
✓ Instruction Set (Rotate & Shift instructions)
✓ AKTU PYQs
ROTATE & SHIFT INSTRUCTIONS
Rotate Instructions
Instruction Description
Rotate all bits of the operand left by specified number of bits through
carry flag.
Rotate all bits of the operand right by specified number of bits through
carry flag.
Instruction Description
Today’s Target
✓ Instruction Set (Branch Control, String and Flag Manipulation
Instructions)
✓ AKTU PYQs
BRANCH CONTROL INSTRUCTIONS
OF
8086 MICROPROCESSOR
Branch Instructions
Normally the processor executes the program in a sequential manner, due to
continuous increment of IP (instruction pointer ).
i)RCR (2016-17)
Today’s Target
✓ Instruction format, Addressing Modes of 8086
✓ AKTU PYQs
8086(Machine Language Instruction Formats)
2. Register to Register
D7 D6 D5 D4 D3 D2 D1 D0
OPCODE REG
2. Register to Register:
This format is 2 bytes long
The first byte of the code specifies the operation code and width of the operand
specified by ‘w’ bit.
The second byte of the code shows the register operands and R/M field, as shown
below .
The register represented by the REG field is one of the operands.
The R/M field specifies another register or memory location i.e. the other operand.
Eg:- MOV AX, BX
ADD AX, BX
3. Register to/from memory with no displacement:
This format is also 2 bytes long and similar to the Register to Register format
except for the MOD field as shown.
The MOD field shows the mode of addressing. The MOD, R/M, REG and the ‘W’
fields are decided in Table.
Eg:- MOV AX, [SI]
4. Register to/from Memory with Displacement:
This type of instruction format requires 3 or 4 bytes for coding.
This type of instruction format contains 1 or 2 additional bytes for displacement
along with 2 byte format of the register to/from memory without displacement.
The format is as shown below.
Eg:- MOV AX, [SI+2000H]
5. Immediate Operand to Register:
This type of instruction format requires 3 or 4 bytes for coding.
In this format, the first byte as well as the 3-bits from the second byte which are
used for REG field in case of register to register format are used for opcode.
It also contains one or two bytes of immediate data. The complete instruction
format is as shown below.
Eg:- MOV AX, 1234H
6. Immediate Operand to Memory with 16-bit displacement:
This type of instruction format requires 5 or 6 bytes for coding.
The first 2 bytes contain the information regarding OPCODE, MOD and R/M
fields. The remaining 4 bytes contain 2 bytes of displacement and 2 bytes of
data as shown.
Eg:-
The MOD field shows the mode of addressing. The MOD, R/M, REG and the ‘W’
fields are decided in Table
W-bit : Some instructions of 8086 can operate on byte or a word. The W-bit in the
opcode of such instruction specify whether instruction is a byte instruction (W = 0) or
a word instruction (W = 1).
D-bit : The D-bit in the opcode of the instruction indicates that the register specified
within the instruction is a source register (D = 0) or destination register (D =1).
ADDRESSING MODES
Sometimes, the address of the memory location which contains data or operand is
determined in an indirect way, using the offset registers. This mode of addressing is
known as register indirect mode
The default segment is either DS or ES. The data is supposed to be available at the
address pointed to by the content of any of the above registers in the default data
segment.
In this addressing mode, offset of the operand is stored in one of the Index registers.
In the case of string instructions DS and ES are default segments for SI and DI
respectively.
This mode is a special case of the above discussed register indirect addressing mode
The effective address of the data is formed, in this addressing mode, by adding the
content of a base register (any one of BX or BP) to the content of an index register
(any one of SI or DI)
The effective address is formed by adding an 8-bit or 16-bit displacement with the
sum of contents of anyone of the base registers (BX or BP) and any one of the index
registers (SI or DI), in a default segment.
3. Explain the instruction format of 8086? Explain the function of special bits
used in instruction format? (2016-17)
Unit-3 Lecture-8
Today’s Target
✓ Hardware and software Interrupts of 8086.
✓ Minimum & Maximum operating Modes 8086
✓ AKTU PYQs
8086 INTERRUPTS
An interrupt is a condition that halts the microprocessor temporarily to work
on a different task and then return to its previous task. Interrupt is an event
or signal that request to attention of CPU. This halt allows peripheral devices
to access the microprocessor.
1. Hardware Interrupts
Hardware interrupts are those interrupts which are caused by any peripheral device by
sending a signal through a specified pin to the microprocessor. There are two hardware
interrupts in 8086 microprocessor. They are:
(A) NMI (Non Maskable Interrupt) – It is a single pin non maskable hardware interrupt which
cannot be disabled. It is the highest priority interrupt in 8086 microprocessor. After its
execution, this interrupt generates a TYPE 2 interrupt. IP is loaded from word location 00008
H and CS is loaded from the word location 0000A H.
(B) INTR (Interrupt Request) – It provides a single interrupt request and is activated by I/O
port. This interrupt can be masked or delayed. It is a level triggered interrupt. It can receive
any interrupt type, so the value of IP and CS will change on the interrupt type received.
2. Software Interrupts
These are instructions that are inserted within the
program to generate interrupts. There are 256
software interrupts in 8086 microprocessor. The
instructions are of the format INT type where type
ranges from 00 to FF. The starting address ranges
from 00000 H to 003FF H. These are 2 byte
instructions.
It is 2-byte instruction. First byte provides the op-code and the second byte
provides the interrupt type number. There are 256 interrupt types under this
group.
(B) TYPE 1 is used for single step execution for debugging of program.
It is a 1-byte instruction and their mnemonic INTO. The op-code for this
instruction is CEH. As the name suggests it is a conditional interrupt
instruction, i.e. it is active only when the overflow flag is set to 1 and
branches to the interrupt handler whose interrupt type number is 4. If the
overflow flag is reset then, the execution continues to the next instruction.
Interrupt Service Routine
1. How many types of interrupts in 8086? Give its significance/Give the explanation
in details? (2016-17, 2023-24)
6. Explain minimum and maximum operating modes of 8086 with timing diagram
(2017-18, 2022-23)
For more Subject/pdf Notes
Download Gateway Classes Application
From Google Play store
Link in Description