-
Prof. Munish Vashishath
Department of Electronics Engineering
J.C.Bose University of Science & Technology
YMCA,Faridabad
Data Movement Instructions
in Microprocessor
8086/8088
-
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
O P C O D E O P E R A N D
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
0727H
0726H
0725H
0724H
0723H
0722H
Example: DS=ACDEH, SI=0724H
MOV AX, [SI]
072CH
072BH
072AH
0729H
0728H
AD5F4H
AD5F3H
AD5F2H
AD5FCH
AD5FBH
AD5FAH
AD5F9H
AD5F8H
AD5F7H
AD5F6H
AD5F5H
18H
A3H
7EH
69H
AAH
2EH
00H
55H
02H
72H
11H
❖ Physical Address
= ACEDx10H + 0724H
= AD5F4H, AD5F5H
AX=5502H
55 02
AH AL
-
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
31 F2
AX F2
31
Least Significant Byte
Most Significant Byte
SS:SP-2 =2000:00FEH
SS:SP-1 =2000:00FFH
SS:SP =2000:0100H
PUSH AX
SS:[SP-1] ← AH, 1st(most significant) byte.
SS:[SP-2] ← AL, 2nd(least significant) byte.
After PUSH operation, SP ← SP - 2
-
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
DF 54
54
DF
SS:SP =3000:0100H
Least Significant Byte
Most Significant Byte
SS:SP+2 =3000:0102H
SS:SP+1 =3000:0101H
POP BX
BL ← SS:[SP]
BH ← SS:[SP+1]
After POP operation, SP ← SP + 2
BX
-
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
Example:
Let
AX=31F2H
SP=072AH
SS=ACEDH
CX=FF67H
BX=413AH
PUSH AX
PUSH BX
PUSH CXSS:SP-2 =ACED:0728
SS:SP-1 =ACED:0729
CH CL
67FF
31 F2
AH AL
41 3A
BH BL
SS:SP-4 =ACED:0726
SS:SP-3 =ACED:0727
SSololuuttiionon::
SS:SP-6 =ACED:0724
SS:SP-5 =ACED:0725
SS:SP =ACED:072A
-
Data Movement Instructions
PUSH
0727H
0726H
0725H
0724H
0723H
0722H
072CH
072BH
072AH
0729H
0728H
AD5F4H
AD5F3H
AD5F2H
AD5FCH
AD5FBH
AD5FAH
AD5F9H
AD5F8H
AD5F7H
AD5F6H
AD5F5H
18H
A3H
7EH
69H
AAH
2EH
00H
55H
02H
72H
11H
0727H
0726H
0725H
0724H
0723H
0722H
072CH
072BH
072AH
0729H
0728H
AD5F4H
AD5F3H
AD5F2H
AD5FCH
AD5FBH
AD5FAH
AD5F9H
AD5F8H
AD5F7H
AD5F6H
AD5F5H
18H
A3H
7EH
31H
F2H
41H
3AH
FFH
67H
72H
11H
before after
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
decremProef.nFatytezbF.yM. tEtlw-Soouosy
-
Prof. Fayez F. M. El-Sousy
Data Movement Instructions
POP
Example:
Let
SP=0724H
SS=ACEDH
POP CX
POP BX
POPAX
SS:SP+4 =ACED:0728
SS:SP+5 =ACED:0729
CH CL
67FF
31 F2
AH AL
41 3A
BH BL
SS:SP+2 =ACED:0726
SS:SP+3 =ACED:0727
SS:SP =ACED:0724
SS:SP+1 =ACED:0725
-
Prof. Fayez F. M. El-Sousy
Data Movement Instructions
POP
0727H
0726H
0725H
0724H
0723H
0722H
072CH
072BH
072AH
0729H
0728H
AD5F4H
AD5F3H
AD5F2H
AD5FCH
AD5FBH
AD5FAH
AD5F9H
AD5F8H
AD5F7H
AD5F6H
AD5F5H
67H
18H
A3H
7EH
31H
F2H
41H
3AH
FFH
11H
72H
StackSS:SP+4 =ACED:0728
SS:SP+5 =ACED:0729
CH CL
67FF
31 F2
AH AL
41 3A
BH BL
SS:SP+2 =ACED:0726
SS:SP+3 =ACED:0727
SS:SP =ACED:0724
SS:SP+1 =ACED:0725
Solution:
-
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]
MOV BX, [DI]
; loads offset address
specified by [DI] (contents
of DI) into BX register
; 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
-
❖ 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
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.
-
❖ 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
LES
-
❖ 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:
❖Prof. FPayeoz Fp. Ms. El-tSohusye stack top to flag register.
Data Movement Instructions
LAHF, SAHF, PUSHF, POPF
-
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
XCHG
-
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)
-
Data Movement Instructions
XLAT (Translate)
The operation of the XLAT instruction at the point just before
6DH Pirosf. Flaoyeaz Fd. Me.dEl-Sionusyto AL.
-
❖ 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
-
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