Instruction Set of 8086
Instruction Set of 8086
2
Classification of Instruction Set
Data Transfer Instructions
Arithmetic Instructions
Logical Instructions
Control Transfer Instructions
String Manipulation Instructions
Processor Control Instructions
3
Instruction Format
The size of 8086 instruction is one to six bytes
depending upon the addressing modes used for
instructions.
The general Instruction format that most of
the instructions of the 8086 microprocessor follow
is:
Format Contd…
The Opcode stands for Operation Code.
Every Instruction has a unique 6-bit opcode.
For example, the opcode for MOV is 100010.
D stands for direction
If D=0, then the direction is from the register
If D=1, then the direction is to the register
W stands for word
If W=0, then only a byte is being transferred, i.e. 8 bits
If W=1, them a whole word is being transferred, i.e. 16 bits
The 2 bit mod field defines the method of addressing
the operand specified by the r/m field.
11
Data Transfer Instructions
MOV Des, Src:
Src operand can be register, memory location or immediate
operand.
Des can be register or memory operand.
12
Data Transfer Instructions
PUSH Operand:
It pushes the operand into top of stack.
E.g.: PUSH BX
POP Des:
It pops the operand from top of stack to Des.
13
Data Transfer Instructions
XCHG Des, Src:
This instruction exchanges Src with Des.
14
Data Transfer Instructions
IN Accumulator, Port Address:
It transfers the operand from specified port to accumulator
register.
15
Data Transfer Instructions
LEA Register, Src:
It loads a 16-bit register with the offset
address of the data specified by the Src.
E.g.: LEA BX, [DI]
This instruction loads the contents of DI
(offset) into the BX register.
16
Data Transfer Instructions
LDS Des, Src:
This instruction copies a word from two
memory locations into the register specified in
the instruction.
It then copies a word from the next two memory
locations into the DS register. It is useful for
pointing to SI and DS at the start of a string
before using a string instruction.
E.g.: LDS BX, [0301 H]
17
Data Transfer Instructions
LES Des, Src:
This instruction copies a word from two memory
locations into the register specified in
the instruction.
It then copies a word from the next two memory
locations into the ES register.
It is useful for pointing to DI and ES at the start of a
string before using a string instruction.
E.g.: LES BX, [0301 H]
18
Data Transfer Instructions
LAHF:
SAHF:
It copies the contents of AH to lower byte of flag register.
PUSHF:
Pushes flag register to top of stack.
POPF:
19
Arithmetic Instructions
ADD Des, Src:
It adds a byte to byte or a word to word.
E.g.:
20
Arithmetic Instructions
ADC Des, Src:
It adds the two operands with CF.
E.g.:
21
Arithmetic Instructions
SUB Des, Src:
It subtracts a byte from byte or a word from word.
E.g.:
SUB AL, 74H
SUB DX, AX
SUB AX, [BX]
22
Arithmetic Instructions
SBB Des, Src:
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 DX, AX
SBB AX, [BX]
23
Arithmetic Instructions
INC Src:
It increments the byte or word by one.
CF is not effected.
E.g.: INC AX
24
Arithmetic Instructions
DEC Src:
It decrements the byte or word by one.
CF is not effected.
E.g.: DEC AX
25
Arithmetic Instructions
AAA (ASCII Adjust after Addition):
The data entered from the terminal is in ASCII format.
26
Arithmetic Instructions
DAA (Decimal Adjust after Addition)
It is used to make sure that the result of adding two BCD
numbers is adjusted to be a correct BCD number.
It only works on AL register.
27
Arithmetic Instructions
NEG Src:
It creates 2’s complement of a given
number.
That means, it changes the sign of a
number.
28
Arithmetic Instructions
CMP Des, Src:
It compares two specified bytes or words.
29
Arithmetic Instructions
MUL Src:
It is an unsigned multiplication instruction.
DX : AX = AX * Src
IMUL Src:
It is a signed multiplication instruction.
30
Arithmetic Instructions
DIV Src:
It is an unsigned division instruction.
IDIV Src:
It is a signed division instruction.
31
Arithmetic Instructions
CBW (Convert Byte to Word):
This instruction converts byte in AL to word in AX.
33
Logical Instructions
NOT Src:
It complements each bit of Src to produce 1’s
complement of the specified operand.
The operand can be a register or memory location.
34
Logical Instructions
AND Des, Src:
It performs AND operation of Des and Src.
35
Logical Instructions
OR Des, Src:
It performs OR operation of Des and Src.
36
Logical Instructions
XOR Des, Src:
It performs XOR operation of Des and Src.
37
Logical Instructions
SHL Des, Count:
It shift bits of byte or word left, by count.
38
Logical Instructions
SHR Des, Count:
It shift bits of byte or word right, by count.
39
Logical Instructions
ROL Des, Count:
It rotates bits of byte or word left, by count.
40
Logical Instructions
ROR Des, Count:
It rotates bits of byte or word right, by count.
41
Control Transfer Instructions
These instructions cause change in the sequence of the
execution of instruction.
This change can be through a condition or sometimes
unconditional.
The conditions are represented by flags.
42
Control Transfer Instructions
CALL Des:
This instruction is used to call a subroutine or function
or procedure.
The address of next instruction after CALL is saved onto
stack.
RET:
It returns the control from procedure to calling program.
43
Control Transfer Instructions
JMP Des:
This instruction is used for unconditional jump from
one place to another.
44
Conditional Jump Table
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
45
Control Transfer Instructions
Loop Des:
This is a looping instruction.
46
String Manipulation
Instructions
47
String Manipulation
Instructions
CMPS Des, Src:
It compares the string bytes or words.
SCAS String:
It scans a string.
48
String Manipulation
Instructions
MOVS / MOVSB / MOVSW:
It causes moving of byte or word from one string to
another.
In this instruction, the source string is in Data Segment
and destination string is in Extra Segment.
SI and DI store the offset values for source and
destination index.
49
String Manipulation
Instructions
REP (Repeat):
This is an instruction prefix.
51
Processor Control Instructions
STC:
It sets the carry flag to 1.
CLC:
It clears the carry flag to 0.
CMC:
It complements the carry flag.
52
Processor Control Instructions
STD:
It sets the direction flag to 1.
CLD:
It clears the direction flag to 0.