0% found this document useful (0 votes)
5 views18 pages

Lecture4 Thirdmicroprocessorc

The document provides details about the 8086 instruction set as taught in a lecture. It is divided into six groups: data transfer instructions, arithmetic instructions, bit manipulation instructions, string instructions, program execution transfer instructions, and process control instructions. Data transfer instructions move data and are further classified. Common instructions like MOV, LEA, LDS, PUSH, and POP are described. [END SUMMARY]

Uploaded by

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

Lecture4 Thirdmicroprocessorc

The document provides details about the 8086 instruction set as taught in a lecture. It is divided into six groups: data transfer instructions, arithmetic instructions, bit manipulation instructions, string instructions, program execution transfer instructions, and process control instructions. Data transfer instructions move data and are further classified. Common instructions like MOV, LEA, LDS, PUSH, and POP are described. [END SUMMARY]

Uploaded by

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

University of Technology

Department of Electrical Engineering


Microprocessor Engineering
Third Class

Lecture Four
8086 Instruction Set

Assist. Prof. Dr. Hadeel Nasrat Abdullah


8086 instructions Set

The instructions of 8086 are classified into SIX groups.


They are:
1. DATA TRANSFER INSTRUCTIONS
2. ARITHMETIC INSTRUCTIONS
3. BIT MANIPULATION INSTRUCTIONS
4. STRING INSTRUCTIONS
5. PROGRAM EXECUTION TRANSFER INSTRUCTIONS
6. PROCESS CONTROL INSTRUCTIONS

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah 2
DATA TRANSFER INSTRUCTIONS
The DATA TRANSFER INSTRUCTIONS are those, which transfers
the DATA from any one source to any one destination. The data’s
may be of any type. They are again classified into four groups. They
are:

General – Purpose Byte Special Address Simple Input And Flag Transfer
Or Word Transfer Transfer Output Port Instructions
Instructions Instruction Transfer
Instruction
MOV LEA IN LAHF
XCHG LDS OUT SAHF
XLAT LES PUSHF
PUSH POPF
POP

Lecture 4: 8086 Instruction Set 3


Assist. Prof. Dr. Hadeel N. Abdullah
MOV
Instruction
The MOV instruction copies a word or a byte of data from a specified
source to a specified destination. Data can be moved between general purpose-
registers, between a general purpose-register and a segment register, between a
general purpose-register or segment register and memory, or between a
memory location and the accumulator. Note that memory-to-memory transfers
are note allowed.

Mnemonic Meaning Format Operation Flags Effected

MOV Move MOV D,S (S)  (D) none

Example:
MOV CX, 037AH ; Move 037AH into the CX; 037A  CX
MOV AX, BX ; Copy the contents of register BX to AX ; BX  AX
MOV DL,[BX] ; Copy byte from memory at BX to DL ; DS*10+BX  DL

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah
LEA, LDS, and LES (Load Effective Address) Instructions
These instructions load a segment and general purpose registers with an
address directly from memory. The general forms of these instructions are as
shown below:
Flags
Mnem. Meaning Format Operation Effected
Load register with Effective
LEA LEA reg16, EA EA  (reg16) none
Address
Load register and Ds with [PA]  (reg16)
LDS LDS reg16, EA none
words from memory [PA+2]  (DS)
Load register and ES with [PA]  (reg16)
LES LES reg16, EA None
words from memory [PA+2]  (ES)
Example4:
LEA BX, PRICE ;Load BX with offset of PRICE in DS
LEA BP, SS:STAK ;Load BP with offset of STACK in SS
LEA CX, [BX][DI] ;Load CX with EA=BX + DI
LDS BX, [4326] ; copy the contents of the memory at displacement 4326H in DS to
BL, contents of the 4327H to BH. Copy contents of 4328H and 4329H in DS to DS register.

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah 5
Example 5: Assuming that (BX)=100H, DI=200H, DS=1200H, SI=
F002H, AX= 0105H, and the following memory content. what is the
result of executing the following instructions?
Solution:
a. LEA SI , [ DI + BX +2H
SI = (DI) + (BX) + 2H= 0200H+0100H+0002H= 0302H

b. MOV SI , [DI+BX+2H] Memory Memory


EA=(DI+BX+2H)= 0302H address content
12300 11
PA=DS*10+EA=1200*10+0302=12302 12301 AA
SI = 80EFH 12302 EF
12303 80
c. LDS CX , [300] 12304 47
PA = DS*10+EA= 1200H*10+300H = 12300H 12305 8D
CX= AA11H and DS=80EFH 12306 5A
12307 92
d. LES BX , [DI+AX] 12308 C5
EA = (DI+AX)= 0200H+0105H =0305H
PA= DS*10+EA = 1200H*10+0305H = 12305H
BX = 5A8DH and ES = C592H
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah 6
XCHG Instruction - Exchange XCHG destination, source

The Exchange instruction exchanges the contents of the register with the
contents of another register (or) the contents of the register with the
contents of the memory location. Direct memory to memory exchanges are
not supported. The both operands must be the same size and one of the
operand must always be a register.
Mnemonic Meaning Format Operation Flags Effected

XCHG Excchange MOV DS (D)  (S) none

Example:
XCHG CX, [037A]H ; [(DS* 10)+ 037A]  CX
XCHG AX, [BX] ; [(DS* 10)+ BX]  AX
XCHG DL, [BP+200H] ; [(SS* 10)+ BP +200]  DL

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah 7
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah 8
XLAT/XLATB Instruction - Translate a byte in AL

XLAT exchanges the byte in AL register from the user table index to the
table entry, addressed by BX. It transfers 16 bit information at a time. The
no-operands form (XLATB) provides a "short form" of the XLAT instructions.

Mnemonic Meaning Format Operation Flags Effected

XLAT Translate XLAT AL  (DS*10+(AL)+(BX)) none

Lecture 4: 8086 Instruction Set 9


Assist. Prof. Dr. Hadeel N. Abdullah
Lecture 4: 8086 Instruction Set 10
Assist. Prof. Dr. Hadeel N. Abdullah
The
The stack is implemented in the
Stack
memory and it is used for temporary
storage of information such as data and
addresses. The stack is 64Kbytes long
and is organized from a software point
of view as 32Kwords.
• SS register points to the lowest
address word in the stack
• SP and BP points to the address
within stack
• Data transferred to and from the
stack are word-wide, not byte-wide.
• The first address in the Stack
segment (SS : 0000) is called End of
Stack.
• The last address in the Stack
segment (SS : FFFE) is called Bottom of
Stack.
• The
Lecture address
4: 8086 Instruction (SS:SP)
Set is called Top
ofAssist.
Stack. Prof. Dr. Hadeel N. Abdullah 11
PUSH and POP Instructions

The PUSH and POP instructions are important instructions that store and retrieve
data from the LIFO (Last In First Out) stack memory. The general forms of PUSH and POP
instructions are as shown below:
Flags
Mnem. Meaning Format Operation Effected
PUSH Push word onto the stack PUSH S (SP)  (SP-2) none
((SP))  (S)
POP Pop word off stack POP D D  ((SP)) none
(SP) = (SP+2)

POP instruction is used to read word from the stack.


• PUSH instruction is used to write word to the stack.
• When a word is to be pushed onto the top of the stack:
o The value of SP is first automatically decremented by two
o and then the contents of the register written into the stack.
• When a word is to be popped from the top of the stack the
o the contents are first moved out the stack to the specific register
o then the value of SP is incremented by two.
12
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah
Example 3: let AX=1234H, SS=0105H and SP=0006H. Figure below shows the
state of stack prior and after the execution of next program instructions:
PUSH AX
POP BX
POP AX

13
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah
IN and OUT Instruction

There are two different forms of IN and OUT instructions: the direct I/O
instructions and variable I/O instructions. Either of these two types of instructions can
be used to transfer a byte or a word of data. All data transfers take place between an
I/O device and the MPU’s accumulator register. The general form of this instruction is as
shown below:
Flags
Mnem. Meaning Format Operation Effected

IN Input direct IN Acc, Port (Acc)  (Port) none


Input variable IN Acc, DX (Acc)  (DX)
OUT Output direct OUT Port, Acc (Port)  (Acc) none
Output variable OUT DX , Acc (DX)  (Acc)

Example:
IN AL,0C8H ;Input a byte from port 0C8H to AL
IN AX, 34H ;Input a word from port 34H to AX
OUT 3BH, AL ;Copy the contents of the AL to port 3Bh
OUT 2CH,AX ;Copy the contents of the AX to port 2Ch

Lecture 4: 8086 Instruction Set 14


Assist. Prof. Dr. Hadeel N. Abdullah
LAHF Instruction - Load Register AH From Flags
LAHF instruction copies the value of SF, ZF, AF, PF, and CF, into bits of 7, 6, 4,
2, 0 respectively of AH register. This LAHF instruction was provided to make
conversion of assembly language programs written for 8080 and 8085 to 8086
easier.

SAHF instruction - Store AH Register into FLAGS


SAHF instruction transfers the bits 0-7 of AH of SF, ZF, AF, PF, and CF, into the
Flag register.

PUSHF Instruction - Push flag register on the stack


This instruction decrements the SP by 2 and copies the word in flag register
to the memory location pointed to by SP.

POPF Instruction - Pop word from top of stack to flag - register.


This instruction copies a word from the two memory location at the top of
the stack to flag register and increments the stack pointer by 2.

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah 15
Homework
1) Write a single instruction that will load AX from address 0460H and ES
from address 0462H.
2) Write an instruction sequence that will initialize the DS register with the
immediate value 1020H
3) Write a single instruction that will load AX from address 0400H and DS
from address 0402H.
4) The instruction that is used to transfer the data from source operand to
destination operand is
a) data copy/transfer instruction
b) branch instruction
c) arithmetic/logical instruction
d) string instruction

Lecture 4: 8086 Instruction Set


Assist. Prof. Dr. Hadeel N. Abdullah 16
Homework
5. Which of the following is not a data copy/transfer instruction?
a) MOV
b) PUSH
c) DAS
d) POP
6. Which of the following instruction is not valid?
a) MOV AX, BX
b) MOV DS, 5000H
c) MOV AX, 5000H
d) PUSH AX
7. In PUSH instruction, after each execution of the instruction, the stack
pointer is
a) incremented by 1
b) decremented by 1
c) incremented by 2
d) decremented by 2
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah 17
Homework
8. In POP instruction, after each execution of the instruction, the stack pointer is
a) incremented by 1
b) decremented by 1
c) incremented by 2
d) decremented by 2
9. The instructions that are used for reading an input port and writing an output
port respectively are
a) MOV, XCHG
b) MOV, IN
c) IN, MOV
d) IN, OUT
10. The instruction that loads effective address formed by destination
operand into the specified source register is
a) LEA
b) LDS
c) LES
d) LAHF
Lecture 4: 8086 Instruction Set
Assist. Prof. Dr. Hadeel N. Abdullah 18

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy