L5 8086 Instructions 1
L5 8086 Instructions 1
Microprocessor
Instruction Set Part-1
Instructions
2.XCHG
Function: Exchanges the contents of two operands
Syntax: XCHG destination, source
Eg: XCHG AX, BX ;swaps data between Ax and Bx
registers
XCHG [5000], AX ;swaps data between Ax register
and memory offset address 5000
XCHG AL, [SI] ;swaps one byte data pointed by
contents of ds:SI and AL register
5
Data Movement Instructions
3.LEA
Function: Load Effective Address. Used to load a 16 bit register with
the effective offset address
Syntax: LEA 16-bit destination register, source
Eg: LEA BX, [SI+DI] ;store SI+DI in BX register
o This instruction is widely used for initializing pointers
o Note that the destination should be always a 16-bit register
6
Arithmetic Instructions
o Arithmetic instructions are used to perform various arithmetic operations such
as addition, subtraction, multiplication, division etc.
o Based on the result, flag register bits are modified
1.ADD
Function: Adds two operands and stores the result in the destination operand
Syntax: ADD destination, source
Eg: ADD AX,BX ;adds data from Ax register to Bx
register and stores the result in Ax register
ADD AL,20 ;adds constant 20 to AL register and stores
result in AL register
ADD [BP],Bx ;add content of Bx register with memory
7
pointed by BP and store result in memory pointed by BP
Arithmetic Instructions
2.ADC
Function: Adds two operands along with carry and stores the result in
the destination operand
Syntax: ADD destination, source
Eg: ADC AX,BX ;adds data from Ax register and Bx
Register wity carry and stores the result in Ax
register
ADC AL,20 ;adds constant 20 and AL register
with carry and stores result in AL register
8
Arithmetic Instructions
3.SUB
Function: Subtracts source operand from destination and stores the
result in the destination operand
Syntax: ADD destination, source
Eg: SUB AX,BX ;subtracts BX register content from
Ax register and stores the result in Ax register
SUB AL,20 ;subtracts constant 20 from AL
register and stores result in AL register
9
Arithmetic Instructions
4.SBB
Function: Subtracts source operand and borrow flag bit from
destination and stores the result in the destination operand
Syntax: SBB destination, source
Eg: SBB AX,BX ;subtracts BX and borrow bit from Ax
register stores result in AX register
SBB AL,20 ;subtracts constant 20 and borrow bit
from AL register and stores result in AL register
10
Arithmetic Instructions
4.INC
Function: Increments (adds 1) to register or memory location
Syntax: INC destination
o When incrementing memory content, size of data must be described
using the BYTE PTR, WORD PTR directives
o INC instruction doesn’t affect the carry flag bit
Eg: INC BL
INC SP
11
INC BYTE PTR[BX]
Arithmetic Instructions
5.DEC
Function: Decrements (subtracts 1) from register or memory location
Syntax: DEC destination
o When incrementing memory content, size of data must be described
using the BYTE PTR, WORD PTR directives
o DEC instruction doesn’t affect the carry flag bit
Eg: DEC BL
DEC SP
12
DEC BYTE PTR[BX]
Arithmetic Instructions
6.CMP
Function: Compares two operands. Internally processor does a
subtraction
Syntax: CMP destination, source
o results are reflected in the flag register
Condition Zero flag Carry flag
destination==source 1 0
destination>source 0 0
destination<source 0 1
7.MUL
Function: Performs unsigned multiplication
Syntax: MUL source
o One implicit operand will be always AX or AL (depending on size of
source) other could be memory or register but not immediate value
o If MUL is used with 8-bit operands, the 16-bit product will be stored
in AX register
o If MUL is used with 16-bit operands, the 32-bit product will be
stored in DX:AX register pair (DX upper 16 bits, AX lower 16 bits)
Eg: MUL BX 14
Arithmetic Instructions
8.IMUL
Function: Performs signed multiplication
Syntax: MUL source
o One implicit operand will be always AX or AL (depending on size of
source) other could be memory or register but not immediate value
o If IMUL is used with 8-bit operands, the 16-bit product will be stored
in AX register
o If IMUL is used with 16-bit operands, the 32-bit product will be
stored in DX:AX register pair (DX upper 16 bits, AX lower 16 bits)
Eg: IMUL BX 15
Arithmetic Instructions
9.DIV
Function: Performs unsigned division
Syntax: DIV source
o The dividend will be always AX register or DX:AX register pair and source
operand acts as the divisor
o Divisor could be memory or register but not immediate value
o If DIV is used with 8-bit source, the 8-bit quotient (AX/source) will be
stored in AL register and the 8-bit reminder (AL%source) in AH register
o If DIV is used with 16-bit source, the 16-bit quotient (DX:AX/source) will
be stored in AX register and 16-bit reminder (DX:AX%source) will be
stored in DX register 16
Eg: DIV BX
Arithmetic Instructions
10.IDIV
Function: Performs signed division
Syntax: IDIV source
o The dividend will be always AX register or DX:AX register pair and source
operand acts as the divisor
o Divisor could be memory or register but not immediate value
o If IDIV is used with 8-bit source, the 8-bit quotient (AX/source) will be
stored in AL register and the 8-bit reminder (AX%source) in AH register
o If IDIV is used with 16-bit source, the 16-bit quotient (DX:AX/source) will
be stored in AX register and 16-bit reminder (DX:AX%source) will be
stored in DX register 17
Eg: IDIV BX
Program Control Instructions
JUMP Group
o Allows the programmer to skip sections of a program and branch to
any part of the memory for the next instruction
o A conditional jump instruction allows decisions based upon
numerical tests
o Results of numerical tests are held in the flag bits, which are then
tested by conditional jump instructions
o Syntax: JMP_Instruction label (address)
18
Program Control Instructions
JUMP Group
o Unconditional jump: Makes a jump without checking for any condition
o Syntax JMP Label (address)
o Short jump: 2 Byte instruction. Allows jump within memory address +127
to -128 bytes from the address of JMP instruction+2
o Near jump: 3 Byte instruction. Allows jump within -32KB to +32KB-1
from the address where jump instruction is stored (jump is within the
current code segment)
o Far jump: 5 Byte instruction. Allows jumping to anywhere in the memory
(1MB)
19
Program Control Instructions
JUMP Group
o Conditional jump instructions: Makes a jump only if certain condition is
met
o A conditional jump instruction follows an arithmetic/logical instruction
Menumonic Tested Condition Operation
JA Z = 0 and C = 0 Jump if above
JAE C=0 Jump if above or equal
JB C=1 Jump if below
JBE Z=1 Jump if below or equal
JC C=1 Jump if carry
JE or JZ Z=1 Jump if equal or jump if
zero
20
Program Control Instructions
Menumonic Tested Condition Operation
JG Z = 0 and S = 0 Jump if greater than
JGE S=0 Jump if greater than or
equal
JL S != 0 Jump if less than
JLE Z = 1 or S != 0 Jump if less than or equal
JNC C=0 Jump if no carry
JNE Z=0 Jump if not equal or jump
if not zero
JNO O=0 Jump if no overflow
JNS S=0 Jump if no sign (positive)
JNP or JPO P=0 Jump if no parity or jump
21
if parity odd
Program Control Instructions
Menumonic Tested Condition Operation
JO O=1 Jump if overflow
JP or JPE P=1 Jump if parity or jump if
parity even
JS S=1 Jump if sign (negative)
JCXZ CX = 0 Jump if CX is zero
22
Program Control Instructions
24
Thank you
any questions
25