2.1 2.2 8086 Addressing Modes and Instruction Set
2.1 2.2 8086 Addressing Modes and Instruction Set
Rutvi Thakar
Immediate addressing mode:
For example:
Rutvi Thakar
Register addressing mode:
For example:
MOV CX, AX; copies the contents of the 16-bit AX
register into the 16-bit CX register),
ADD BX, AX
Rutvi Thakar
Direct addressing mode:
For example:
Rutvi Thakar
Register indirect addressing mode
This addressing mode allows data to be addressed at any
memory location through an offset address held in any of the
following registers: BP, BX, DI& SI.
For example:
Rutvi Thakar
Based addressing mode:
For example:
Rutvi Thakar
Indexed addressing mode:
For example:
Rutvi Thakar
Based-index addressing mode:
For example:
Rutvi Thakar
Based indexed with displacement mode:
For example:
Rutvi Thakar
Instruction Set of 8086
10
Instruction Set of 8086
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.
11
Classification of Instruction Set
Data Transfer Instructions
Arithmetic Instructions
String Instructions
12
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 port address.
13
Data Transfer Instructions
MOV Des, Src:
Src operand can be register, memory location or
immediate operand.
Des can be register or memory operand.
Both Src and Des cannot be memory location at the
same time.
E.g.:
MOV CX, 037A H
MOV AL, BL
MOV BX, [0301 H]
14
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.
16
Data Transfer Instructions
IN Accumulator, Port Address:
17
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.
18
Data Transfer Instructions
LDS Des, Src:
It loads 32-bit pointer from memory source to destination
register and DS.
The offset is placed in the destination register and the
segment is placed in DS.
To use this instruction the word at the lower memory address
must contain the offset and the word at the higher address
must contain the segment.
E.g.: LDS BX, [0301 H]
19
Data Transfer Instructions
LES Des, Src:
It loads 32-bit pointer from memory source to destination
register and ES.
The offset is placed in the destination register and the
segment is placed in ES.
This instruction is very similar to LDS except that it
initializes ES instead of DS.
E.g.: LES BX, [0301 H]
20
Data Transfer Instructions
LAHF:
SAHF:
PUSHF:
POPF:
21
Arithmetic Instructions
ADD Des, Src:
It adds a byte to byte or a word to word.
E.g.:
ADD AL, 74H
ADD DX, AX
22
Arithmetic Instructions
ADC Des, Src:
It adds the two operands with CF.
E.g.:
ADC AL, 74H
ADC DX, AX
23
Arithmetic Instructions
SUB Des, Src:
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 DX, AX
24
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
CF is not effected.
E.g.: INC AX
26
Arithmetic Instructions
DEC Src:
It decrements the byte or word by one.
CF is not effected.
E.g.: DEC AX
27
Arithmetic Instructions
AAA (ASCII Adjust after Addition):
The data entered from the terminal is in ASCII format.
In ASCII, 0 – 9 are represented by 30H – 39H.
This instruction allows us to add the ASCII codes.
This instruction does not have any operand.
29
Arithmetic Instructions
NEG Src:
It creates 2’s complement of a given number.
That means, it changes the sign of a number.
30
Arithmetic Instructions
CMP Des, Src:
It compares two specified bytes or words.
The Src and Des can be a constant, register or memory
location.
Both operands cannot be a memory location at the same
time.
The comparison is done simply by internally subtracting
the source from destination.
The value of source and destination does not change, but
the flags are modified to indicate the result.
31
Arithmetic Instructions
MUL Src:
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 one of the operand in AL or AX.
Src can be a register or memory location.
IMUL Src:
It is a signed multiplication instruction.
32
Arithmetic Instructions
DIV Src:
It is an unsigned division instruction.
It divides word by byte or double word by word.
The operand is stored in AX, divisor is Src and the
result is stored as:
AH = remainder AL = quotient
IDIV Src:
It is a signed division instruction.
33
Arithmetic Instructions
CBW (Convert Byte to Word):
This instruction converts byte in AL to word in AX.
35
Bit Manipulation Instructions
NOT Src:
36
Bit Manipulation Instructions
AND Des, Src:
37
Bit Manipulation Instructions
OR Des, Src:
38
Bit Manipulation Instructions
XOR Des, Src:
39
Bit Manipulation Instructions
SHL Des, Count:
40
Bit Manipulation Instructions
SHR Des, Count:
41
Bit Manipulation Instructions
ROL Des, Count:
42
Bit Manipulation Instructions
ROR Des, Count:
43
Program Execution 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.
44
Program Execution Transfer Instructions
CALL Des:
RET:
45
Program Execution Transfer Instructions
JMP Des:
46
Conditional Jump Table
Mnemonic Meaning Jump Condition
JB Jump if Below CF = 1
JC Jump if Carry CF = 1
JE Jump if Equal ZF = 1
47 JZ Jump if Zero ZF = 1
Program Execution Transfer Instructions
Loop Des:
48
Processor Control Instructions
These instructions control the processor itself.
49
Processor Control Instructions
STC:
CLC:
CMC:
CLD:
It clears the direction flag to 0.
52
String Instructions
CMPS Des, Src:
SCAS String:
It scans a string.
53
String Instructions
MOVS / MOVSB / MOVSW:
54
String Instructions
REP (Repeat):
55