8086 Instruction Set
8086 Instruction Set
6/3/21 1
8086 INSTRUCTION SET
1. Data Copy / Transfer Instructions
2. Arithmetic Instructions
3. Logical Instructions
4. Shift and Rotate Instructions
5. String Manipulation Instructions
6. Branch and Loop Instructions
5. Flag Manipulation Instructions
6. Machine Control Instructions
6/3/21 2
Instruction Set (continued...)
1. DATA TRANSFER INSTRUCTIONS
Transfers data from one register or memory
location to another register or memory location
Source: Seg.Register /
Gen.Register /Mem.location
Destination: Seg.Register /
Gen.Register /Mem.location
Note: Both Source and
Destination cannot be
Mem.Locn
6/3/21 3
Instruction Set (continued...)
General purpose byte or word transfer instructions
MOV Copy byte or word from specified source to specified
destination
PUSH Copy specified word to top of stack
POP Copy word from top of stack to specified
location
XCHG Exchange bytes or exchange words
XLAT Translate a byte in AL using a table in
memory
Simple input and output port transfer instructions
IN Copy a byte or word from specified port to
accumulator
OUT Copy a byte or word from accumulator to
specified port
6/3/21 4
Instruction Set (continued...)
Special address transfer instructions:
LEA Load effective address of operand into specified
register
LDS Load DS register and other specified register from
memory
LES Load ES register and other specified register from
memory
Flag transfer instructions
LAHF Load (copy to ) AH with the low byte of the flag
register
SAHF Store (copy) AH register to low byte of flag
register
PUSHF Copy flag register to top of stack
POPF Copy word at top of stack to flag register
Example 1 :
*Knowing that,
DS=2042H.
SI=500H, AH AL
AX=214E, 21 4E
SI=500
DS=2042H DS=20420H
AH AL 20000 SS = 2000
88 44 SP =
44 2FFFB FFFB
88 2FFFC FFFC
XX 2FFFD FFFD
XX 2FFFE FFFE
XX 2FFFF FFFF
AH AL 20000 SS = 2000
xx
88 xx
44 SP =
44 2FFFB FFFB
88 2FFFC FFFC
XX 2FFFD FFFD
2FFFE FFFE
2FFFF FFFF
dddd+mmmm data
AL=dddd
BX=mmmm AL=data
for the example slides do not click the mouse to see the full animation
LUT
-
-
-
LUT- Mem.Seg
Example 5 :
Program using XLAT Comments
Performs
Addition,
Subtraction,
Multiplication,
Division,
Increment,
Decrement
DEC Decrement
1. DEC AX 1. Register addressing
2. DEC [BX] 2. Register indirect addressing
3. DEC [5000H] 3. Direct addressing
SUB Subtract
1. SUB AX, 0100H 1. Immediate addressing
2. SUB AX, BX 2. Register addressing
3. SUB AX, [SI] 3. Indexed / indirect addressing
4. SUB AX, [5000H] 4. Direct addressing
5. SUB [5000H], 0100H 5. Immediate addressing
CMP Compare
1. CMP AX, 0100H 1. Immediate addressing
2. CMP BX, 0100H 2. Immediate addressing
3. CMP BX, [SI] 3. Indexed / indirect addressing
4. CMP BX, CX 4. Register addressing
5. CMP [5000H], 0100H 5. Direct/Immediate addressing
ALHIGH ALLOW
Logical Instructions:
NOT Logical Invert: Invert each bit of a byte or word
in another byte or word
AND Logical AND: AND each bit in a byte or word with
the corresponding bit
OR Logical OR: OR each bit in a byte or word with the
corresponding bit in another byte or word
XOR Logical XOR: Exclusive OR each bit in a byte or
word with the corresponding bit in another byte or
word
TEST Logical Compare: AND operation to update flags,
[OF, CF, SF, ZF, PF] but don’t change operands
Logical Instructions:
NOT NOT AX;
NOT [5000H];
AND AND AX, 0008H;
AND AX, BX;
AND [5000H], DX;
OR OR AX, 0008H;
OR AX, BX;
OR DX, [5000H];
XOR XOR AX, 0098H; XOR AX, BX; XOR AX, [5000H];
TEST TEST AX, BX; TEST [5000H] 06H;
TEST [BX][DI], CX
1 Carry Flag
MSB LSB
SHL / SAL
2nd execution 1 0 1 0 0 1 0 0
Carry Flag
x
1
0
MSB LSB
RCL
1 1
0 0 0
1 0
1 1
0 x
0 0
1 1 1
x x
0
321 execution
rd
nd
st
execution