8086 Instruction Set
8086 Instruction Set
INSTRUCTION SET
OF 8086
MICROPROCESSOR
8086 Instruction Set
An instruction is a binary pattern
designed inside a microprocessor to
perform a specific function.
The entire group of instructions that a
microprocessor supports is called
Instruction Set.
8086 has more than 20,000
instructions.
Classif ication of Instruction Set
Data Transfer Instructions
Arithmetic and Logical Instructions
String Instructions
Program Control transfer Instructions
Iteration control Instructions
Machine control and Miscellaneous
Instructions
Interrupt Instructions
Data Transfer Instructions
These instructions are used to transfer data
from source to destination.
The operand can be a constant, memory
location, register or I/O por t address.
It can be classified as
MOV Instructions
PUSH/POP Instructions
Load Effective Address Instructions
String Data transfer Instructions
Miscellaneous Data transfer Instructions
MOV Instructions
Syntax
MOV Destination, Source
Copies a word or a byte of data from source to destination.
Source operand can be register, memory location or
immediate operand.
Destination can be register or memory operand.
Both Source and Destination cannot be memory location at
the same time.
E.g.:
MOV CX, 037A H
MOV AL, BL
• MOV BX, [3001 H]
PUSH/POP Instructions
PUSH
Syntax
PUSH Source
E.g.: PUSH BX
POP
Syntax
POP Destination
E.g.: POP AX
PUSHF:
Syntax
PUSHF Source
POPF:
Syntax
POPF Destination
OUT
Syntax
OUT Port Address, Accumulator:
It transfers the operand from accumulator to specified port.
E.g.: OUT 0028 H, AX
Arithmetic Instructions
ADD
Syntax ADD Destination, Source
It adds a byte to byte or a word to word.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
ADD AL, 74H
ADD AX, DX
ADD AX, [BX]
ADC
Syntax
ADC Destination, Source
It adds the two operands with CF.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
ADC AL, 74H
ADC AX, DX
ADC AX, [BX]
SUB
Syntax
SUB Destination, Source
It subtracts a byte from byte or a word from word.
It effects AF, CF, OF, PF, SF, ZF flags.
For subtraction, CF acts as borrow flag.
E.g.:
SUB AL, 74H
SUB AX, DX
SUB AX, [BX]
SBB
Syntax
SBB Destination, Source
It subtracts the two operands and also the borrow
from the result.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
SBB AL, 74H
SBB AX, DX
SBB AX, [BX]
MUL
Syntax
MUL Source
It is an unsigned multiplication instruction.
It multiplies two bytes to produce a word or two words to produce a double word.
AX = AL * Src
DX : AX = AX * Src
This instruction assumes o ne of the o perand in AL or AX.acts as a source
If BL
Src can be a register or memo ry location. then the operation will be
Eg: MUL BX AL*BL and the O/P LSB
IMUL will be in AL and MSB will
Syntax be in AH
If BX acts as a source
IMUL Source
then the operation will be
It is a signed multiplication instruction.
AX*BX and the O/P LSB
will be in AX and the MSB
will be in DX
DIV
Syntax
DIV Source
The operand is stored in AX, divisor is Src a nd the result is stored as:
Eg: DIV BX
IDIV
Syntax
IDIV Source
SAL and SHL are two mnemonics for the same instruction.
This instruction shifts each bit in the specified destination
some number of bit positions to the left. As a bit is shifted
out of the LSB operation, a 0 is put in the LSB position. The
MSB will be shifted into CF. In the case of multi-bit shift,
CF will contain the bit most recently shifted out from the
MSB. Bits shifted into CF previously will be lost.
CF MSB LSB 0
SHR
Syntax SHR Destination, Count
This instruction shifts each bit in the specified destination
some number of bit positions to the right. As a bit is
shifted out of the MSB position, a 0 is put in its place. The
bit shifted out of the LSB position goes to CF. In the case
of multi-bit shifts, CF will contain the bit most recently
shifted out from the LSB. Bits shifted into CF previously
will be lost.
0 MSB LSB CF
SAR
Syntax SAR Destination, Count
CF MSB LSB
ROL
Syntax ROL Destination, Count
CF MSB LSB
ROR
Syntax ROR Destination, Count
This instruction rotates all the bits in a specified word or
byte some number of bit positions to right. The operation
is desired as a rotate rather than shift, because the bit
moved out of the LSB is rotated around into the MSB.
The data bit moved out of the LSB is also copied into CF.
In the case of multiple bit rotates, CF will contain a copy
of the bit most recently moved out of the LSB.
CF MSB LSB
Program Control transfer
Instructions
Control transfer Instructions are
Unconditional Jump
Conditional Jump
CALL Instructions
RET Instructions
Iteration Control Instructions
Unconditional Jump
JMP (UNCONDITIONAL JUMP TO
SPECIFIED DESTINATION)
Syntax
JMP CONTINUE
This instruction fetches the next
instruction from address at label CONTINUE.
Conditional Jump
Mnemonic Meaning Jump Condition
JA Jump if Above CF = 0 and ZF = 0
JAE Jump if Above or Equal CF = 0
JB Jump if Below CF = 1
JBE Jump if Below or Equal CF = 1 or ZF = 1
JC Jump if Carry CF = 1
JE Jump if Equal ZF = 1
JNC Jump if Not Carry CF = 0
JNE Jump if Not Equal ZF = 0
JNZ Jump if Not Zero ZF = 0
JPE Jump if Parity Even PF = 1
JPO Jump if Parity Odd PF = 0
JZ Jump if Zero ZF = 1
CALL Instruction
Syntax
CALL Destination
This instruction is used to call a
subroutine or function or procedure.
The address of next instruction after CALL
is saved onto stack.
Eg: CALL CX
There are two types of CALL
Near CALL
Far CALL
A Near CALL is a call to a procedure
which is in the same code segment from
that which contains the CALL instruction.
A Far CALL is a call to a procedure
which is in the different code segment from
that which contains the CALL instruction.
RET Instruction
Syntax
RET
It returns the control from procedure to
calling program.
Every CALL instruction should have a
RET.
Iteration Control Instructions
LOOP
Syntax
LOOP Destination
This is a looping instruction.
The number of times looping is required is
placed in the CX register.
With each iteration, the contents of CX are
decremented.
ZF is checked whether to loop again or not.
LOOPE/LOOPZ
Loop through a sequence of instruction
is equal or loop through a sequence of
instruction is zero.
here CX=0 ZF=0
LOOPNE/LOOPNZ
Loop through a sequence of
instruction is not equal or not zero
here CX=0 or ZF=1
Machine control and
Miscellaneous Instructions
STC:
It sets the carry flag to 1.
CLC:
It clears the carry flag to 0.
CMC:
It complements the carry flag.
STD:
It sets the direction flag to 1.
If it is set, string bytes are accessed from higher
memory address to lower memory address.
CLD:
It clears the direction flag to 0.
If it is reset, the string bytes are accessed from
lower memory address to higher memory address.
STI
Set the interrupt flag
CLI
Reset the interrupt flag
HLT
Stop the program or to stop fetching and
executing instruction
WAIT
When this instruction execute, 8086 enters
an ideal condition where it is doing no
processing
CBW (Convert Byte to Word):
This instruction converts byte in AL to word in AX.
The conversion is done by extending the sign bit of
AL throughout AH.