Professional Documents
Culture Documents
ch2 - Lec3 - 8086 Instruction Set - 1 (Data Movement)
ch2 - Lec3 - 8086 Instruction Set - 1 (Data Movement)
ch2 - Lec3 - 8086 Instruction Set - 1 (Data Movement)
Interfacing
Ch2_lec3_ Instruction Set: Data
Movement Instructions
Kassahun Tamir 1
Instruction Sets
8086 instruction set is categorized into:-
Kassahun Tamir 3
MOV:- Move
This data transfer instruction transfers data from one
register/memory location to another register/memory
location.
Kassahun Tamir 4
MOV:- Move
Example
MOV AX, 2000H
MOV DS, AX
MOV AX, [2000H]
MOV [BX], CX
MOV CS, DS Illegal:
segment registers can’t be together
Kassahun Tamir 5
PUSH:- Push to Stack
This instruction pushes the contents of the specified
register/memory location on to the stack.
The stack pointer is decremented by 2, after each
execution of the instruction.
Example
PUSH AX
PUSH DS
PUSH AL Illegal, must push a word
Kassahun Tamir 6
PUSHF:- Push Flags to Stack
Kassahun Tamir 7
POP:- Pop from Stack
When this instruction is executed, it loads the specified
register/memory location with the contents of the
memory location of which the address is formed using
the current stack segment and stack pointer as usual.
The stack pointer is incremented by 2.
Example
POP AX
POP DS
POP CS Just Illegal
Kassahun Tamir 8
POPF:- Pop Flags from Stack
The pop flags instructions loads the flag register
completely (both byte) from the word contents of the
memory location currently addressed by SP and SS.
Kassahun Tamir 9
XCHG:- Exchange
This instruction exchanges the contents of the specified
source and destination operands, which may be a
registers or one of them may be memory location.
However, exchange of data contents of two memory
location is not permitted.
Example
XCHG [5000H], AX
XCHG BL, CH
Kassahun Tamir 10
XCHG:- Exchange
MOV AX, 125AH
MOV AH, 23H
XCHG AL, AH
Example:
LEA BP, SS:STACK_TOP ;Load BP with offset of
;STACK_TOP in SS
Kassahun Tamir 17
LAHF:- Load AH from lower byte of
Flag
This instruction loads the AH register with the lower
bye of the flag register.
Kassahun Tamir 18
SAHF:- Store AH from lower byte of
Flag
This instruction sets or resets the condition code
flags (except overflow) in the lower byte of the flag
register depending upon the corresponding bit
positions in AH.
Kassahun Tamir 19
Example
Explain what does the following set of instructions do?
Solution:
MOV AX, 5000H
MOV DS, AX
MOV AX, [1000H]
MOV DX, 25H
OUT DX, AX Kassahun Tamir 24
Questions?
Kassahun Tamir 25