Microprocessor 8086 New
Microprocessor 8086 New
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.
The flag register is one of the special purpose register. The flag bits are changed to
0 or 1 depending upon the value of result after arithmetic or logical operations.
8086 has 16-bit flag register, and there are 9 valid flag bits. The format of flag
register is like below.
Flags O D I T S Z AC P CY
We can divide the flag bits into two sections. The Status Flags, and the Control
Flags.
Status Flags
In 8086 there are 6 different flags which are set or reset after 8-bit or 16-bit
operations. These flags and their functions are listed below.
Control Flags
In 8086 there are 3 different flags which are used to enable or disable some basic
operations of the microprocessor. These flags and their functions are listed below.
Flag Function
Bit
D This is directional flag. This is used in string related operations. D = 1,
then the string will be accessed from higher memory address to lower
memory address, and if D = 0, it will do the reverse.
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.
Addressing Mode:
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 −
Immediate addressing mode
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.
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 −
Arithmetic Instructions
These instructions are used to perform arithmetic operations like addition, subtraction, multiplication, division,
etc.
Following is the list of instructions under this group −
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.
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