8086 : INSTRUCTION SET
Md. Sazzad Hossain (173-15-10447)
Categories of Instructions
⚫ The instruction set are categorized into the following
types
1. Data Copy or Transfer instructions
2. Arithmetic and Logical instructions
3. Branch instructions
4. Loop instructions
5. Machine Control instructions
6. Flag Manipulation instructions
7. Shift and Rotate instructions
8. String 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 port address.
Data Transfer Instructions
MOV DES, SRC:
⮚ This instruction copies a word or a byte of data from some
source to a destination.
⮚ The destination can be a register or a memory location. The
source can be a register, a memory location, or an immediate
number.
⮚ 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.
Data Transfer Instructions
⚫Examples
⮚ MOV AX, BX
⮚ MOV AX, 500H
⮚ MOV AX, [SI]
⮚ MOV AX, [2000H]
⮚ MOV AX, 50H[BX]
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.
Arithmetic Instructions
ADD Des, Src
⚫It adds a byte to byte or a word to word.
⚫It effects AF, CF, OF, PF, SF, ZF flags.
⚫E.g.
⮚ ADD AX, 0100H
⮚ ADD AX, BX
⮚ ADD AX, [SI]
⮚ ADD AX, [5000H]
⮚ ADD [5000H], 0100H
⮚ ADD 0100H
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 AX, 0100H
⮚ SUB AX, BX
⮚ SUB AX, [5000H]
⮚ SUB [5000H], 0100H
Arithmetic Instructions
INC Src:
⚫It increments the byte or word by one.
⚫The operand can be a register or memory location.
⚫It effects AF, OF, PF, SF, ZF flags.
⚫CF is not effected.
⚫E.g.:
⮚ INC AX
⮚ INC [BX]
⮚ INC [5000H]
Arithmetic Instructions
DEC Src:
⚫It decrements the byte or word by one.
⚫The operand can be a register or memory location.
⚫It effects AF, OF, PF, SF, ZF flags.
⚫CF is not effected.
⚫E.g.:
⮚ DEC AX
⮚ DEC [5000H]
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.
⚫ E.g.:
⮚ CMP AX, 0100H
⮚ CMP BX, CX
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.
⚫ E.g.:
⮚ MUL BH ; (AX) (AL) x (BH)
⮚ MUL CX ; (DX)(AX) (AX) x (CX)
⮚ MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI])
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.
⚫ E.g.
⮚ DIV CL ; Word in AX / byte in CL
; Quotient in AL, remainder in AH
⮚ DIV CX ; Double word in DX and AX / word
; in CX, and Quotient in AX,
; remainder in DX
⚫ IDIV Src:
⚫ It is a signed division instruction.
Branch Instructions
⚫Branch Instructions transfers the flow of execution
of the program to a new address specified in the
instruction directly or indirectly.
⚫When this type of instruction is executed, the CS and
IP registers get loaded with new values of CS and IP
corresponding to the location to be transferred.
⚫The conditions are represented by flags.
⚫The Branch Instructions are classified into two types
⮚ Unconditional Branch Instructions.
⮚ Conditional Branch Instructions.
Conditional Branch Instructions
Conditional LOOP Instructions
LOOPZ / LOOPE Label
⚫Loop through a sequence of instructions from label
while ZF=1 and CX=0.
LOOPNZ / LOOPENE Label
⚫Loop through a sequence of instructions from label
while ZF=1 and CX=0.
String Instructions
⚫String in assembly language is just a sequentially
stored bytes or words.
⚫By using these string instructions, the size of the
program is considerably reduced.
⚫The 8086 supports a set of more powerful
instructions for string manipulations.
⚫For referring to a string, two parameters are
required.
⮚ Starting and End Address of the String.
⮚ Length of the String.
String Instructions
CMPS Des, Src:
⚫It compares the string bytes or words.
SCAS String:
⚫It scans a string.
⚫It compares the String with byte in AL or with word
in AX.
Flag Manipulation and a Processor Control
Instructions
⚫These instructions control the functioning of the
available hardware inside the processor chip.
⚫These instructions are categorized into two types:
1. Flag Manipulation instructions.
2. Machine Control instructions.
Flag Manipulation instructions
⚫The Flag manipulation instructions directly modify
some of the Flags of 8086.
i. CLC – Clear Carry Flag.
ii. CMC – Complement Carry Flag.
iii. STC – Set Carry Flag.
iv. CLD – Clear Direction Flag.
v. STD – Set Direction Flag.
vi. CLI – Clear Interrupt Flag.
vii. STI – Set Interrupt Flag.
Machine Control instructions
⚫The Machine control instructions control the bus
usage and execution
i. WAIT – Wait for Test input pin to go low.
ii. HLT – Halt the process.
iii. NOP – No operation.
iv. ESC – Escape to external device like NDP
v. LOCK – Bus lock instruction prefix.
Logical Instructions
AND Des, Src : Logical AND
⚫This instruction bit by bit ANDs the source operand
to the destination operand.
⚫The result is stored in the destination operand.
⚫E.g.:
⮚ AND AX, 0008H
⮚ AND AX, BX
Logical Instructions
OR Des, Src : Logical OR
⚫This instruction bit by bit ORs the source operand to
the destination operand.
⚫The result is stored in the destination operand.
⚫E.g.
⮚ OR AX, 0008H
⮚ OR AX, BX
Logical Instructions
NOT Src: Logical Invert
⚫This instruction complements the contents of an
operand bit by bit.
⚫The operand can be a register or memory location
⚫E.g.
⮚ NOT AX
⮚ NOT [5000H]
Processor Control Instructions
⚫These instructions control the processor itself.
⚫8086 allows to control certain control flags that:
⮚ causes the processing in a certain direction
⮚ processor synchronization if more than one microprocessor
attached.
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.
Processor Control Instructions
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.
Thank You

8086 instruction set

  • 1.
    8086 : INSTRUCTIONSET Md. Sazzad Hossain (173-15-10447)
  • 2.
    Categories of Instructions ⚫The instruction set are categorized into the following types 1. Data Copy or Transfer instructions 2. Arithmetic and Logical instructions 3. Branch instructions 4. Loop instructions 5. Machine Control instructions 6. Flag Manipulation instructions 7. Shift and Rotate instructions 8. String instructions
  • 3.
    Data Transfer Instructions ⚫Theseinstructions are used to transfer data from source to destination. ⚫The operand can be a constant, memory location, register or I/O port address.
  • 4.
    Data Transfer Instructions MOVDES, SRC: ⮚ This instruction copies a word or a byte of data from some source to a destination. ⮚ The destination can be a register or a memory location. The source can be a register, a memory location, or an immediate number. ⮚ 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.
  • 5.
    Data Transfer Instructions ⚫Examples ⮚MOV AX, BX ⮚ MOV AX, 500H ⮚ MOV AX, [SI] ⮚ MOV AX, [2000H] ⮚ MOV AX, 50H[BX]
  • 6.
    Data Transfer Instructions LEARegister, 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.
  • 7.
    Arithmetic Instructions ADD Des,Src ⚫It adds a byte to byte or a word to word. ⚫It effects AF, CF, OF, PF, SF, ZF flags. ⚫E.g. ⮚ ADD AX, 0100H ⮚ ADD AX, BX ⮚ ADD AX, [SI] ⮚ ADD AX, [5000H] ⮚ ADD [5000H], 0100H ⮚ ADD 0100H
  • 8.
    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 AX, 0100H ⮚ SUB AX, BX ⮚ SUB AX, [5000H] ⮚ SUB [5000H], 0100H
  • 9.
    Arithmetic Instructions INC Src: ⚫Itincrements the byte or word by one. ⚫The operand can be a register or memory location. ⚫It effects AF, OF, PF, SF, ZF flags. ⚫CF is not effected. ⚫E.g.: ⮚ INC AX ⮚ INC [BX] ⮚ INC [5000H]
  • 10.
    Arithmetic Instructions DEC Src: ⚫Itdecrements the byte or word by one. ⚫The operand can be a register or memory location. ⚫It effects AF, OF, PF, SF, ZF flags. ⚫CF is not effected. ⚫E.g.: ⮚ DEC AX ⮚ DEC [5000H]
  • 11.
    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. ⚫ E.g.: ⮚ CMP AX, 0100H ⮚ CMP BX, CX
  • 12.
    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. ⚫ E.g.: ⮚ MUL BH ; (AX) (AL) x (BH) ⮚ MUL CX ; (DX)(AX) (AX) x (CX) ⮚ MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI])
  • 13.
    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. ⚫ E.g. ⮚ DIV CL ; Word in AX / byte in CL ; Quotient in AL, remainder in AH ⮚ DIV CX ; Double word in DX and AX / word ; in CX, and Quotient in AX, ; remainder in DX ⚫ IDIV Src: ⚫ It is a signed division instruction.
  • 14.
    Branch Instructions ⚫Branch Instructionstransfers the flow of execution of the program to a new address specified in the instruction directly or indirectly. ⚫When this type of instruction is executed, the CS and IP registers get loaded with new values of CS and IP corresponding to the location to be transferred. ⚫The conditions are represented by flags. ⚫The Branch Instructions are classified into two types ⮚ Unconditional Branch Instructions. ⮚ Conditional Branch Instructions.
  • 15.
  • 16.
    Conditional LOOP Instructions LOOPZ/ LOOPE Label ⚫Loop through a sequence of instructions from label while ZF=1 and CX=0. LOOPNZ / LOOPENE Label ⚫Loop through a sequence of instructions from label while ZF=1 and CX=0.
  • 17.
    String Instructions ⚫String inassembly language is just a sequentially stored bytes or words. ⚫By using these string instructions, the size of the program is considerably reduced. ⚫The 8086 supports a set of more powerful instructions for string manipulations. ⚫For referring to a string, two parameters are required. ⮚ Starting and End Address of the String. ⮚ Length of the String.
  • 18.
    String Instructions CMPS Des,Src: ⚫It compares the string bytes or words. SCAS String: ⚫It scans a string. ⚫It compares the String with byte in AL or with word in AX.
  • 19.
    Flag Manipulation anda Processor Control Instructions ⚫These instructions control the functioning of the available hardware inside the processor chip. ⚫These instructions are categorized into two types: 1. Flag Manipulation instructions. 2. Machine Control instructions.
  • 20.
    Flag Manipulation instructions ⚫TheFlag manipulation instructions directly modify some of the Flags of 8086. i. CLC – Clear Carry Flag. ii. CMC – Complement Carry Flag. iii. STC – Set Carry Flag. iv. CLD – Clear Direction Flag. v. STD – Set Direction Flag. vi. CLI – Clear Interrupt Flag. vii. STI – Set Interrupt Flag.
  • 21.
    Machine Control instructions ⚫TheMachine control instructions control the bus usage and execution i. WAIT – Wait for Test input pin to go low. ii. HLT – Halt the process. iii. NOP – No operation. iv. ESC – Escape to external device like NDP v. LOCK – Bus lock instruction prefix.
  • 22.
    Logical Instructions AND Des,Src : Logical AND ⚫This instruction bit by bit ANDs the source operand to the destination operand. ⚫The result is stored in the destination operand. ⚫E.g.: ⮚ AND AX, 0008H ⮚ AND AX, BX
  • 23.
    Logical Instructions OR Des,Src : Logical OR ⚫This instruction bit by bit ORs the source operand to the destination operand. ⚫The result is stored in the destination operand. ⚫E.g. ⮚ OR AX, 0008H ⮚ OR AX, BX
  • 24.
    Logical Instructions NOT Src:Logical Invert ⚫This instruction complements the contents of an operand bit by bit. ⚫The operand can be a register or memory location ⚫E.g. ⮚ NOT AX ⮚ NOT [5000H]
  • 25.
    Processor Control Instructions ⚫Theseinstructions control the processor itself. ⚫8086 allows to control certain control flags that: ⮚ causes the processing in a certain direction ⮚ processor synchronization if more than one microprocessor attached.
  • 26.
    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.
  • 27.
    Processor Control Instructions 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.
  • 28.