0% found this document useful (0 votes)
78 views25 pages

L5 8086 Instructions 1

The document provides an overview of the Intel 8086 microprocessor instruction set, detailing various types of instructions including data movement, arithmetic, and program control instructions. It explains the syntax and functions of specific instructions such as MOV, ADD, and JMP, along with examples of their usage. The document emphasizes the importance of these low-level instructions in executing higher-level programming languages and the role of assemblers and compilers in converting them to binary representation.

Uploaded by

adityagupta.ahd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views25 pages

L5 8086 Instructions 1

The document provides an overview of the Intel 8086 microprocessor instruction set, detailing various types of instructions including data movement, arithmetic, and program control instructions. It explains the syntax and functions of specific instructions such as MOV, ADD, and JMP, along with examples of their usage. The document emphasizes the importance of these low-level instructions in executing higher-level programming languages and the role of assemblers and compilers in converting them to binary representation.

Uploaded by

adityagupta.ahd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Intel 8086

Microprocessor
Instruction Set Part-1
Instructions

o An instruction causes the circuit inside a processor to perform a set


of operations
o For example, instruction
MOV AX,BX
activates circuits to read from BX register and write that value to AX
register
o As we discussed in introduction, instructions written in mnemonics
are converted into binary, which controls muxes and encoders and
state machines inside processor with help of control logic
o Thus, control logic decodes an instruction 2
Instruction Set

o Set of all instructions supported by a processor


o Any program written in any programming language needs to be
ultimately converted to instructions from instruction set of that
processor to execute it
o All your word processing software, image editors, web browsers and
games are ultimately composed of these low-level instructions
o We use assemblers to convert assembly-level programs to binary
representation of instructions and compilers to convert high-level
language codes to binary instructions
o But your assemblers and compilers are also built using these
3
instructions!!
Data Movement Instructions

o Data Movement instructions are used to transfer data between


registers, memory and I/O ports
1.MOV
Function: Copies data from a source to destination
Syntax: MOV destination, source
Eg: MOV AX, BX ;copy data from Bx register to Ax
MOV [5000], AX ;copy data from Ax register to
memory offset address 5000
MOV AL, [SI] ;copy one byte data pointed by
contents of ds:SI to AL register 4
Data Movement 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

o A compare operation is usually followed by jump instruction


13
Eg: CMP AX,BX
Arithmetic Instructions

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

Eg: Add 5 1-byte data starting from memory 2000H


MOV CX,5 ;used as loop control
MOV AL,0 ;initialize accumulator to 0
MOV BX,2000 ;Will use as memory pointer
loop:
ADD AL,[BX]
INC BX
DEC CX
JNZ loop ;check loop variable became 0 23
Program Control Instructions

o In the example loop is a label


o They are used as a place holder for address
o It will be difficult to manually calculate the offset address for the
jump instruction
o Instead, we use a label to represent that address
o During assembling, assembler will replace the label with the
corresponding address

24
Thank you
any questions

25

You might also like