0% found this document useful (0 votes)
25 views40 pages

MM 1

The document discusses various data movement instructions in microprocessors 8086/8088, including MOV, PUSH, POP, LEA, and LDS. MOV copies data between registers or memory. PUSH decrements the stack pointer and stores data. POP increments the stack pointer and loads data. LEA loads an effective address without copying data. LDS loads a 32-bit pointer with the offset in the destination register and segment in DS. These instructions transfer data between sources and destinations using registers, memory addresses, and I/O ports.

Uploaded by

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

MM 1

The document discusses various data movement instructions in microprocessors 8086/8088, including MOV, PUSH, POP, LEA, and LDS. MOV copies data between registers or memory. PUSH decrements the stack pointer and stores data. POP increments the stack pointer and loads data. LEA loads an effective address without copying data. LDS loads a 32-bit pointer with the offset in the destination register and segment in DS. These instructions transfer data between sources and destinations using registers, memory addresses, and I/O ports.

Uploaded by

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

Data Movement Instructions

in Microprocessor
8086/8088

Prof. Munish Vashishath


Department of Electronics Engineering
J.C.Bose University of Science & Technology
YMCA,Faridabad
Objectives of Data Movement
Instructions in Microprocessor 8086/8088

Upon completion of this chapter, you will be able to:

Explain the operation of each data movement


instruction with applicable addressing modes.
Select the appropriate assembly language
instruction to accomplish a specific data
movement task.
Data Movement Instructions in
Microprocessor 8086/8088

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.

8-bit 8-bit 8-bit


OP CODE OPERAND
1 byte 1 to 2 byte
Data Movement Instructions
MOV
❖ MOV Des, Src
❖ 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.
❖ Example:
MOV CX, 037AH
MOV AL, BL
MOV BX, [0301H]
Data Movement Instructions
MOV
MOV Des, Src
Example: DS=ACDEH, SI=0724H
MOV AX, [SI]
072CH 18H AD5FCH
AH AL 072BH A3H AD5FBH

072AH 7EH AD5FAH


55 02
0729H 69H AD5F9H

❖ Physical Address 0728H AAH AD5F8H

0727H 2EH AD5F7H


= ACEDx10H + 0724H 0726H 00H AD5F6H

= AD5F4H, AD5F5H 0725H 55H AD5F5H

0724H 02H AD5F4H

0723H 72H AD5F3H


AX=5502H 0722H 11H AD5F2H
Data Movement Instructions
PUSH and POP
PUSH and POP Instructions
❖ Both are important to store and retrieve data
from the LIFO structure (stack).
❖ PUSH Operand
❖ It pushes the operand into top of stack.
❖ Example:
PUSH BX
❖ POP Des
❖ It pops the operand from top of stack to Des.
❖ Example:
POP AX
Data Movement Instructions
PUSH
PUSH:
In 8088 and 8086 PUSH always transfer 2
bytes of data to the stack.
It has the following syntax:
PUSH src
Src could be any 2 byte register or memory
location or immediate value.
Data Movement Instructions
PUSH
How does PUSH executes?
Simply when we push 2 bytes of data to
the stack, the most significant byte is
stored in stack segment pointed to by SP-1,
and the least significant to location pointed
by SP-2, see the following example
Example:
Let AX=31F2H, SP=100H, SS=2000H,
CX=FFFFH, BX=413AH
Data Movement Instructions
PUSH
PUSH AX
SS:[SP-1] ← AH, 1st(most significant) byte.
SS:[SP-2] ← AL, 2nd(least significant) byte.
After PUSH operation, SP ← SP - 2

SS:SP-2 =2000:00FEH F2
AX
SS:SP-1 =2000:00FFH 31
31 F2
SS:SP =2000:0100H

Least Significant Byte


Most Significant Byte
Data Movement Instructions
PUSH

The effect of the PUSH AX instruction on SP and stack


memory locations 37FFH and 37FEH. AX=6AB3H
Data Movement Instructions
POP
How does POP executes?
❖POP : performs the inverse operation of PUSH
❖POP : removes data from stack and place it into
target 16-bit register.
POP BX
❖BL ← SS:[SP]
❖BH ← SS:[SP+1]
❖after POP operation, SP← SP+2
POP CS ; is not a valid instruction
Data Movement Instructions
POP
POP BX
BL ← SS:[SP]
BH ← SS:[SP+1]
After POP operation, SP ← SP + 2
BX
SS:SP+2 =3000:0102H
DF 54
SS:SP+1 =3000:0101H DF
SS:SP =3000:0100H 54

Least Significant Byte


Most Significant Byte
Data Movement Instructions
POP
Example:
Let BX=DF54H, SP=100H, SS=3000H
POP BX

BL=54 H at SP=0100H
BH=DF at SP+1=0101H
After POP operation, SP← SP+2=0102H
Data Movement Instructions
POP

The POP BX instruction, showing how data


are removed from the stack. POP BX
Data Movement Instructions
PUSH
CH CL
Example: SSololuuttiionon::
FF 67
Let
AX=31F2H SS:SP-6 =ACED:0724

SP=072AH SS:SP-5 =ACED:0725


BH BL
SS=ACEDH
41 3A
CX=FF67H
BX=413AH SS:SP-4 =ACED:0726
SS:SP-3 =ACED:0727
AH AL
PUSH AX 31 F2
PUSH BX SS:SP-2 =ACED:0728
PUSH CX SS:SP-1 =ACED:0729
SS:SP =ACED:072A
Data Movement Instructions
PUSH
before after
072CH 18H AD5FCH 072CH 18H AD5FCH

072BH A3H AD5FBH 072BH A3H AD5FBH

072AH 7EH AD5FAH 072AH 7EH AD5FAH

0729H 69H AD5F9H 0729H 31H AD5F9H

0728H AAH AD5F8H 0728H F2H AD5F8H

0727H 2EH AD5F7H 0727H 41H AD5F7H

0726H 00H AD5F6H 0726H 3AH AD5F6H

0725H 55H AD5F5H 0725H FFH AD5F5H

0724H 02H AD5F4H 0724H 67H AD5F4H

0723H 72H AD5F3H 0723H 72H AD5F3H

0722H 11H AD5F2H 0722H 11H AD5F2H

Stack Stack
Data Movement Instructions
PUSH BX

•The high-order 8 bits are placed in the location addressed by SP – 1


•The low-order 8 bits are placed in the location addressed by SP – 2
•After the data are stored by a PUSH, the contents of the SP register
decremProe
f. n
Fat
yezb
F.y
M. t
Elw
-Soo
usy
Data Movement Instructions
POP
Example: CH CL
Let FF 67
SP=0724H SS:SP =ACED:0724
SS=ACEDH SS:SP+1 =ACED:0725
BH BL
POP CX 41 3A
POP BX SS:SP+2 =ACED:0726
POP AX AH AL SS:SP+3 =ACED:0727

31 F2
SS:SP+4 =ACED:0728

Prof. Fayez F. M. El-Sousy


SS:SP+5 =ACED:0729
Data Movement Instructions
POP
CH CL Solution:
FF 67 072CH 18H AD5FCH

072BH A3H AD5FBH


SS:SP =ACED:0724
072AH 7EH AD5FAH
SS:SP+1 =ACED:0725
0729H 31H AD5F9H
BH BL 0728H F2H AD5F8H

41 3A 0727H 41H AD5F7H

0726H 3AH AD5F6H


SS:SP+2 =ACED:0726 0725H FFH AD5F5H

AH AL SS:SP+3 =ACED:0727 0724H 67H AD5F4H


0723H 72H AD5F3H
31 F2 0722H 11H AD5F2H

SS:SP+4 =ACED:0728 Stack


Prof. Fayez F. M. El-Sousy SS:SP+5 =ACED:0729
Data Movement Instructions
POP CX

•The low-order 8 bits are removed from the location addressed by SP.
•The high-order 8 bits are removed from the location addressed by
SP+1
• The SPProf. Fraeyegz Fi.sMt. Eel-rSouissy incremented by 2
Data Movement Instructions
LEA
❖ Load-Effective Address (LEA)
❖ LEA stands for load effective address.
LEA Register, Src
❖ It loads a 16-bit register with the offset address
of the data specified by the Src.
LEA AX, NUMB
❖ AX ← operand offset address MUMB
Data Movement Instructions
LEA
Example:
LEA BX, [DI] ; loads offset address
specified by [DI] (contents
of DI) into BX register
MOV BX, [DI] ; loads the data stored at
the memory location
addressed by [DI] into BX
register

MOV BX, DI
= LEA BX, [DI]
Data Movement Instructions
LEA
MOV BX, DI performs in less time and is often
preferred to LEA BX, [DI]

Example:
LEA SI, [BX+DI]
If BX = 1000H, DI = 2000
Solution:
SI=BX+DI
=1000+2000=3000H (16-bit offset
address)
Data Movement Instructions
LEA
The sum generated by this instruction
LEA SI, [BX+DI]
is a modulo-64K sum drops any carry out of the
16-bit result
Example:
LEA SI, [BX+DI]
If BX = 1000H, DI = FF00H, SI = 0F00H
Solution:
SI=BX+DI
=1000+FF00=0F00 H instead of 10F00H
Data Movement Instructions
LDS

❖ LDS Des, Src


❖ It loads 32-bit pointer from memory source to
destination register and DS.
❖ The offset is placed in the destination register
and the segment is placed in DS.
❖ To use this instruction the word at the lower
memory address must contain the offset and the
word at the higher address must contain the
segment.
Data Movement Instructions
LDS

❖ LDS Des, Src


❖ Example:
LDS BX, [DI]

❖ If DS= 1000H, DI = 1000H


❖ The LDS BX, [DI] instruction loads register BX
from addresses 11000H and 11001H and register
DS from locations 11002H and 11003H. This
instruction is shown at the point just before DS
changes to 3000H and BX changes to 127AH.
Data Movement Instructions
LDS
Data Movement Instructions
LES
❖ LES Des, Src
❖ It loads 32-bit pointer from memory source to
destination register and ES.
❖ The offset is placed in the destination register
and the segment is placed in ES.
❖ To use this instruction the word at the lower
memory address must contain the offset and the
word at the higher address must contain the
segment.
❖ This instruction is very similar to LDS except
that it initializes ES instead of DS.
Data Movement Instructions
LES

❖ LES Des, Src


❖ Example:
LES BX, [DI]

❖ If ES= 1000H, DI = 1000H


❖ The LES BX, [DI] instruction loads register BX
from addresses 11000H and 11001H and register
ES from locations 11002H and 11003H. This
instruction is shown at the point just before ES
changes to 3000H and BX changes to 127AH.
Data Movement Instructions
LES
Data Movement Instructions
LAHF, SAHF, PUSHF, POPF
❖ LAHF:
❖ It transfer the lower byte of flag register to AH.
AH ← FLAG (Lower 8-bit)
❖ SAHF:
❖ It transfer the contents of AH to lower byte of
flag register.
FLAG (Lower 8-bit) ← AH
❖ PUSHF:
❖ Pushes flag register to top of stack.

❖ POPF:
❖ Pops the stack top to flag register.
Prof. Fayez F. M. El-Sousy
Data Movement Instructions
XCHG
XCHG Des, Src
❖ This instruction exchanges Src with Des.
❖ It Exchanges contents of a register with any other
register or memory location.
❖ It can not exchange segment registers.
❖ It can not exchange two memory locations directly.
❖ Use any addressing mode except immediate.
❖ Example:
XCHG DX, AX
DX= 3000H, AX = 1000H
❖ After Execution this Instruction
DX= 1000H, AX = 3000H
Data Movement Instructions
XCHG
Example:
XCHG DX, AX
XCHG AL, CL
XCHG CX, BP
XCHG DX, SI
XCHG AL, [DI]
Data Movement Instructions
XLAT (Translate)

XLAT
❖ This instruction Converts the contents of the AL
register into a number stored in a memory table.
❖ It performs the direct table lookup technique often
used to convert one code to another.
❖ An XLAT instruction first adds the contents of AL to
BX to form a memory address within the data segment.
❖ It copies the contents of this address into AL.
❖ It is only instruction that adds an 8-bit to a 16-bit
number
❖ Example:
AL ← DS:[BX + AL]
Data Movement Instructions
XLAT (Translate)

The operation of the XLAT instruction at the point just before


6DH Pirosf. Flaoyeaz Fd. Me.dEl-Sionusyto AL.
Data Movement Instructions
IN and OUT

❖ IN Accumulator, Port Address


❖ This instruction transfers the operand from specified
port to accumulator register.
IN AX, 0028 H
❖ An IN instruction transfers data from an external I/O
device into AL or AX
❖ OUT Port Address, Accumulator
❖ This instruction transfers the operand from accumulator
to specified port.
OUT 0028 H, AX
❖ An OUT transfers data from AL or AX to an external
I/O device.
Data Movement Instructions
IN and OUT
IN & OUT instructions perform I/O operations.
Contents of AL or AX are transferred only
between I/O device and microprocessor.
Two forms of I/O device (port) addressing:
Fixed-port addressing allows data transfer
between AL, or AX using an 8-bit I/O port
address.
Port number follows the instruction’s opcode.
IN AX, 0028 H
OUT 0028 H, AX
Data Movement Instructions
IN and OUT
Variable-port addressing allows data transfers
between AL or AX and a 16-bit port address.
The I/O port number is stored in register DX,
which can be changed (varied) during the
execution of a program.

MOV DX, 0028H


IN AX, DX
OUT DX, AX
Data Movement Instructions
IN and OUT

The signals found in the microprocessor-based system for an OUT


19H, AX instruction.
Data Movement Instructions
IN and OUT

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