0% found this document useful (0 votes)
119 views30 pages

8086 Instruction Set Overview

The document discusses the 8086 instruction set, categorizing it into different types including data transfer, arithmetic/logic, program control, and string instructions. It provides examples and explanations of common data transfer instructions like MOV, PUSH, POP, LEA, LDS, LES, and string instructions MOVS, LODS, STOS. Other instructions covered include XCHG, LAHF, SAHF, XLAT, IN, and OUT. The goal is to explain the machine language format and various instruction sets of the 8086 microprocessor.

Uploaded by

cudarun
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)
119 views30 pages

8086 Instruction Set Overview

The document discusses the 8086 instruction set, categorizing it into different types including data transfer, arithmetic/logic, program control, and string instructions. It provides examples and explanations of common data transfer instructions like MOV, PUSH, POP, LEA, LDS, LES, and string instructions MOVS, LODS, STOS. Other instructions covered include XCHG, LAHF, SAHF, XLAT, IN, and OUT. The goal is to explain the machine language format and various instruction sets of the 8086 microprocessor.

Uploaded by

cudarun
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

Department of Electrical and computer Engineering

College of Engineering and Technology


Jimma University

CHAPTER 3.1
8086 INSTRUCTION SET
CHAPTER OBJECTIVE
 Machine Language format
 8086 microprocessors instruction
sets which includes
Data transfer instruction
Arithmetic and logic
instruction
Program control instruction
String instruction and so on
2
WHAT IS INSTRUCTION SET?
 It is the set of instruction that the processor
is designed to decode
 It is the language that the processor can
understand
 In 8086 there are around 117 instruction that
can be used more than 20,000 permutation
of operand
 8086 is a CISC type processor whose
instruction set are many with different clock
cycle

3
4
5
MAJOR TYPES OF 8086
INSTRUCTION CATEGORIES?
 8086 instruction sets may be categorized into
the following types
 Data movement instruction set
 Arithmetic and logic Instruction set
 String type instruction set
 Program control instruction set
 Processor control instruction set
 Interrupt instruction
 And so on
 In this lecture we will see only 8086 Data
movement instruction set
6
DATA TRANSFER INSTRUCTION
SET : MOV INSTRUCTION
 Syntax: MOV Destination, Source
 Description:
Copy content of source into destination
 Valid source destination combination
REG, memory
memory, REG
REG, REG
memory, immediate
REG, immediate
SREG, memory
memory, SREG
REG, SREG
SREG, REG

7
MOVE (MOV) EXAMPLE
 MOV AX,100h
 MOV BX,AX
 MOV DX,BX
 MOV AX,1234h
 MOV DX,5678h
 MOV AL,DL
 MOV BH,DH

8
MOV EXAMPLE(CONTINUED)
 MOV AX,1000h
 MOV [100h],AX
 MOV BX,[100h]
 MOV BYTE PTR [200h],10h
 MOV WORD PTR [300h],10h
 MOV AX,2300h
 MOV DS,AX

9
10
NOTE ABOUT MOV INSTRUCTION
 No flag value is changed because of move
instruction
 Both operand must be in the same size.
 To put immediate value directly to memory,
we have to specify its size. (Byte/Word PTR)
 There is no instruction to put immediate
value directly to segment register.
Use accumulator (AX) to accomplish this.
 Mov instruction cannot alter the value of IP and CS
 You cannot move from one segment register to
another segment registor
11
4–2  PUSH/POP INSTRUCTION
 Push instruction : push a 16 bit value (2 memory) into the stack register
 Syntax
 push operand
 Algorithm
 SP = SP – 2
 SS:[SP] (top of the stack) = operand
 Operand type
 REG
 SREG
 Memory
 IMMEDIET VALUE
 pop operand
 operand = SS:[SP] (top of the stack)
 SP = SP + 2
 operand type
 REG
 SREG
 Memory
 No flag is changed in both case
EXAMPLE POP AND PUSH
EXAMPLES
 Example 1
 MOV AX, 1234h
 PUSH AX
 POP DX ; DX = 1234h
 Example 2
 MOV AX, 16554h
 PUSH ax
 POP bx

13
LEA (LOAD EFFECTIVE ADDRESS)
 Syntax: LEA registers, memory
 Load Effective Address.
 REG = address of memory (offset)
 Example
m DW 1234h
 LEA AX, m
 No flag is affacted

14
LDS LES
 LDS
 LDS (Load data segment )
 Syntax :
 LDS REG, memory
 Load memory double word into word register and DS.
 After the execution
 REG = first word
 DS = second word
 Example LDS AX, m
LES (LOAD EXTRA SEGMENT)
 Syntax
 LES REG, memory
 Load memory double word into word register
and ES
 After execution
 REG = first word
 ES = second word
 Example
 LES AX, m

16
STRING DATA TRANSFERS
MOVS, LODS, STOS,.
 These instructions works with
 Flag register(D flag, direction flag)
 Destination index (DI)
 Source index (SI)
 The direction flag (D, located in the flag register)
selects the auto-increment or the auto-
decrement operation for the DI and SI registers
during string operations.
CONTINUED
 The CLD instruction clears the D flag and the STD
instruction sets it .
 CLDinstruction selects the auto-increment mode and
STD selects the auto-decrement mode
 DI and SI
 During execution of string instruction, memory
accesses occur through DI and SI registers.
 DI offset address accesses data in the extra segment for
all string instructions that use it
 SI offset address accesses data by default
in the data segment
LODSW OR LODSB
 Syntax :LODSb
 Operation
 Load byte at DS:[SI] into AL. Update SI.
 After excution
 Al = DS:[SI]
 if DF = 0 then
 SI = SI + 1
 Else
 SI = SI – 1

 LODSW bring string from DS:[SI] to AX registers


STOS
 Types
 STOSB and STOSW
 Syntax
 STOSB
 STOSW
 After the operation
 For STOSB
 ES:[DI] = AL

if DF = 0 then
 DI = DI + 1
Else
 DI = DI – 1
CONTINUED
For STOSW
 ES:[DI] = AX

if DF = 0 then
 DI = DI + 2

Else
 DI = DI - 2
 STOSB (stores a byte) stores the byte in AL at
the extra segment memory location addressed
by DI.
 STOSW (stores a word) stores AX in the
memory location addressed by DI
21
STOS WITH A REP
 The repeat prefix (REP) is added to any string
data transfer instruction except LODS.
 REPprefix causes CX to decrement by 1 each time
the string instruction executes;
 after CX decrements, the string instruction repeats
 If CX reaches a value of 0, the instruction
terminates and the program continues.
 If CX is loaded with 100 and a REP STOSB
instruction executes, the microprocessor
automatically repeats the STOSB 100 times
MOVS
 Opration
 Copy byte at DS:[SI] to ES:[DI]. Update SI and DI.
 After operation
 ES:[DI] = DS:[SI]
 if DF = 0 then

 SI = SI + 1
 DI = DI + 1
 Else

 SI = SI – 1
 DI = DI – 1
 Example
 LEA SI, a1
 LEA DI, a2
 MOV CX, 5
 REP MOVSB
MISCELLANEOUS DATA TRANSFER INSTRUCTIONS
XCHG, LAHF, SAHF, XLAT, IN, OUT
 XCHG
 Exchange values of two operands.
 Syntax: xchg operand1, operand2
 Operand combination
 REG, memory
memory, REG
REG, REG
 Example:
 MOVAL, 5
MOV AH, 2
XCHG AL, AH ; AL = 2, AH = 5
XCHG AL, AH ; AL = 5, AH = 2
LAHF AND SAHF
LAHF

Load
 AH from 8 low bits of Flags register
Syntax: LAHF

After operation

AH = flags register
SAHF

Store AH register into low 8 bits of Flags register.



After operation

flags register = AH
XLAT
 Translate byte from table. Copy value of memory
byte at DS:[BX + unsigned AL] to AL register.
 AL = DS:[BX + unsigned AL]
 Example
 LEA BX, dat
MOV AL, 2
XLATB ; AL = 33h
 dat DB 11h, 22h, 33h, 44h, 55h
IN AND OUT
 IN
Input from port into AL or AX.
Second operand is a port number. If required to access
port number over 255 - DX register should be used.
Example:
IN AX, 4 ; get status of traffic lights.
IN AL, 7 ; get status of stepper-motor
Syntax: IN operand1, operand2
Operand operation
AL, im.byte

AL, DX
AX, im.byte
AX, DX
IN AND OUT
 OUT
 SyntaxOUT operand1, operand2
 Operand
 im.byte, AL
 im.byte, AX
 DX, AL
 DX, AX
 Output from AL or AX to port.
 First operand is a port number.
 If required to access port number over 255 - DX register
should be used.
 Example
 MOV AX, 0FFFh ; Turn on all
 OUT 4, AX ; traffic lights.
 MOV AL, 100b ; Turn on the third
 OUT 7, AL ; magnet of the stepper-motor

28
READINGS

 8086 arithmetic and logic


instructions
 Data control instructions

CS 477/677 - Lecture 1 29
End!

30

You might also like