Uploaded by Abdelrahman khaled

8086instructions A4

advertisement
Mnemonic and
Description
8086
ARITHMETIC
Instruction Code
76543210
76543210
76543210
76543210
data if s w e 01
ADD e Add (|ODITSZAPC| = |*---*****|)
Table 2 Instruction Set Summary
Mnemonic and
Description
Instruction Code
DATA TRANSFER
MOV e Move (|ODITSZAPC|=|---------|) 7 6 5 4 3 2 1 0
76543210
RegisterMemory tofrom Register
100010dw
mod
Immediate to RegisterMemory
1100011w
RegMemory with Register to Either
000000dw
mod reg rm
Immediate to RegisterMemory
100000sw
mod 0 0 0 rm
data
Immediate to Accumulator
0000010w
data
data if w e 1
ADC e Add with Carry (|ODITSZAPC| = |*---*****|)
76543210
76543210
mod 0 0 0 rm
data
data if w e 1
1 0 1 1 w reg
data
data if w e 1
Memory to Accumulator
1010000w
addr-low
addr-high
INC e Increment (|ODITSZAPC| = |*---****-|)
Accumulator to Memory
1010001w
addr-low
addr-high
RegisterMemory
RegisterMemory to Segment Register
10001110
mod 0 reg rm
Register
Segment Register to RegisterMemory
10001100
mod 0 reg rm
AAA e ASCII Adjust for Add
00110111
(|ODITSZAPC| = |?---??*?*|)
DAA e Decimal Adjust for Add
00100111
(|ODITSZAPC| = |?---*****|)
Immediate to Register
reg
rm
PUSH e Push (|ODITSZAPC| = |---------|)
RegisterMemory
11111111
Register
RegMemory with Register to Either
000100dw
mod reg rm
Immediate to RegisterMemory
100000sw
mod 0 1 0 rm
data
Immediate to Accumulator
0001010w
data
data if w e 1
1111111w
mod 0 0 0 rm
0 1 0 0 0 reg
SUB e Subtract (|ODITSZAPC| = |*---*****|)
mod 1 1 0 rm
RegMemory and Register to Either
001010dw
mod reg rm
Immediate from RegisterMemory
100000sw
mod 1 0 1 rm
data
Immediate from Accumulator
0010110w
data
data if w e 1
0 1 0 1 0 reg
Segment Register
0 0 0 reg 1 1 0
POP e Pop (|ODITSZAPC| = |---------|)
RegisterMemory
Register
mod 0 0 0 rm
0 1 0 1 1 reg
0 0 0 reg 1 1 1
1000011w
Register with Accumulator
Variable Port
1110110w
Variable Port
1110111w
XLAT e Translate Byte to AL
11010111
LEA e Load EA to Register
10001101
mod reg rm
(|ODITSZAPC| = |---------|)
LDS e Load Pointer to DS
port
11000101
mod reg rm
(|ODITSZAPC| = |---------|)
(|ODITSZAPC| = |---------|)
LES e Load Pointer to ES
11000100
LAHF e Load AH with Flags
10011111
(|ODITSZAPC| = |---------|)
SAHF e Store AH into Flags
10011110
(|ODITSZAPC| = |----*****|)
PUSHF e Push Flags
10011100
(|ODITSZAPC| = |---------|)
POPF e Pop Flags
10011101
(|ODITSZAPC| = |*********|)
mod reg rm
Mnemonic and
Description
(|ODITSZAPC| = |---------|)
data if w e 1
NOT e Invert
1111011w
mod 0 1 0 rm
(|ODITSZAPC| = |---------|)
SHLSAL e Shift LogicalArithmetic Left
110100vw
mod 1 0 0 rm
(|ODITSZAPC| = |*---**?**|)
SHR e Shift Logical Right
110100vw
mod 1 0 1 rm
(|ODITSZAPC| = |*---**?**|)
SAR e Shift Arithmetic Right
110100vw
mod 1 1 1 rm
(|ODITSZAPC| = |*---**?**|)
ROL e Rotate Left
110100vw
mod 0 0 0 rm
(|ODITSZAPC| = |-------- |)
ROR e Rotate Right
110100vw
mod 0 0 1 rm
(|ODITSZAPC| = |*-------*|)
RCL e Rotate Through Carry Flag Left
110100vw
mod 0 1 0 rm
(|ODITSZAPC| = |*-------*|)
RCR e Rotate Through Carry Right
110100vw
mod 0 1 1 rm
(|ODITSZAPC| = |*-------*|)
76543210
76543210
76543210
AND e And (|ODITSZAPC| = |*---**?**|)
RegMemory and Register to Either
001000dw
mod reg rm
Immediate to RegisterMemory
1000000w
mod 1 0 0 rm
data
Immediate to Accumulator
0010010w
data
data if w e 1
data if w e 1
TEST e And Function to Flags No Result (|ODITSZAPC| = |*---**?**|)
mod reg rm
Immediate Data and RegisterMemory
1111011w
mod 0 0 0 rm
data
Immediate Data and Accumulator
1010100w
data
data if w e 1
data if w e 1
OR e Or (|ODITSZAPC| = |*---**?**|)
RegMemory and Register to Either
000010dw
mod reg rm
Immediate to RegisterMemory
1000000w
mod 0 0 1 rm
data
Immediate to Accumulator
0000110w
data
data if w e 1
data if w e 1
(|ODITSZAPC| = |*---**?**|)
RegMemory and Register to Either
001100dw
mod reg rm
Immediate to RegisterMemory
1000000w
mod 1 1 0 rm
data
Immediate to Accumulator
0011010w
data
data if w e 1
STRING MANIPULATION
REP e Repeat
1111001z
(|ODITSZAPC| = |---------|)
MOVS e Move ByteWord
1010010w
(|ODITSZAPC| = |---------|)
CMPS e Compare ByteWord
1010011w
(|ODITSZAPC| = |*---*****|)
SCAS e Scan ByteWord
1010111w
(|ODITSZAPC| = |*---*****|)
1010110w
1010101w
1111111w
mod 0 0 1 rm
0 1 0 0 1 reg
1111011w
mod 0 1 1 rm
(|ODITSZAPC| = |*---*****|)
001110dw
mod reg rm
Immediate with RegisterMemory
100000sw
mod 1 1 1 rm
data
Immediate with Accumulator
0011110w
data
data if w e 1
AAS e ASCII Adjust for Subtract
00111111
DAS e Decimal Adjust for Subtract
00101111
MUL e Multiply (Unsigned)
1111011w
mod 1 0 0 rm
IMUL e Integer Multiply (Signed)
1111011w
mod 1 0 1 rm
(|ODITSZAPC| = |*---????*|)
AAM e ASCII Adjust for Multiply
11010100
00001010
(|ODITSZAPC| = |?---**?*?|)
(|ODITSZAPC| = |---------|)
(|ODITSZAPC| = |---------|)
CONTROL TRANSFER
CALL e Call (|ODITSZAPC| = |---------|)
Direct within Segment
11101000
disp-low
disp-high
Indirect within Segment
11111111
mod 0 1 0 rm
Direct Intersegment
10011010
offset-low
offset-high
seg-low
seg-high
Indirect Intersegment
11111111
mod 0 1 1 rm
data if w e 1
data if s w e 01
(|ODITSZAPC| = |?---??*?*|)
(|ODITSZAPC| = |?---*****|)
(|ODITSZAPC| = |*---????*|)
DIV e Divide (Unsigned)
1111011w
mod 1 1 0 rm
(|ODITSZAPC| = |?---?????|)
IDIV e Integer Divide (Signed)
1111011w
mod 1 1 1 rm
(|ODITSZAPC| = |?---?????|)
AAD e ASCII Adjust for Divide
11010101
00001010
(|ODITSZAPC| = |?---**?*?|)
CBW e Convert Byte to Word
10011000
(|ODITSZAPC| = |---------|)
CWD e Convert Word to Double Word
10011001
(|ODITSZAPC| = |---------|)
Mnemonic and
Description
76543210
1000010w
data if s w e 01
RegisterMemory and Register
Instruction Code
LOGIC
STOS e Stor ByteWd from ALA
data
CMP e Compare (|ODITSZAPC| = |*---*****|)
1110011w
LODS e Load ByteWd to ALAX
data
000111w
NEG e Change sign
port
Fixed Port
XOR e Exclusive or
mod 0 1 1 rm
Register
OUT e Output to (|ODITSZAPC| = |---------|)
RegisterMemory and Register
mod reg rm
100000sw
Registermemory
IN e Input from (|ODITSZAPC| = |---------|)
1110010w
000110dw
Immediate from RegisterMemory
DEC e Decrement (|ODITSZAPC| = |*---****-|)
mod reg rm
1 0 0 1 0 reg
Fixed Port
RegMemory and Register to Either
Immediate from Accumulator
XCHG e Exchange (|ODITSZAPC| = |---------|)
RegisterMemory with Register
data if s w e 01
SBB e Subtract with Borrow: (|ODITSZAPC| = |*---*****|)
10001111
Segment Register
data if s w e 01
Instruction Code
JMP e Unconditional Jump: (|---------|) 7 6 5 4 3 2 1 0
76543210
76543210
Direct within Segment
11101001
disp-low
disp-high
Direct within Segment-Short
11101011
disp
Indirect within Segment
11111111
mod 1 0 0 rm
Direct Intersegment
11101010
offset-low
offset-high
seg-low
seg-high
Indirect Intersegment
11111111
mod 1 0 1 rm
RET e Return from CALL (|ODITSZAPC| = |---------|)
Within Segment
11000011
Within Seg Adding Immed to SP
11000010
Intersegment
11001011
data-low
Intersegment Adding Immediate to SP
11001010
data-low
JEJZ e Jump on EqualZero
01110100
disp
01111100
disp
01111110
disp
01110010
disp
JLJNGE e Jump on LessNot Greater
or Equal
JLEJNG e Jump on Less or Equal
Not Greater
JBJNAE e Jump on BelowNot Above
or Equal
JBEJNA e Jump on Below or Equal
Not Above
JPJPE e Jump on ParityParity Even
01110110
disp
01111010
disp
JO e Jump on Overflow
01110000
disp
JS e Jump on Sign
01111000
disp
JNEJNZ e Jump on Not EqualNot Zero
01110101
disp
01111101
disp
01111111
disp
01110011
disp
JNLJGE e Jump on Not LessGreater
or Equal
JNLEJG e Jump on Not Less or Equal
Greater
JNBJAE e Jump on Not BelowAbove
or Equal
JNBEJA e Jump on Not Below or
EqualAbove
JNPJPO e Jump on Not ParPar Odd
01110111
disp
01111011
disp
JNO e Jump on Not Overflow
01110001
disp
JNS e Jump on Not Sign
01111001
disp
LOOP e Loop CX Times
11100010
disp
LOOPZLOOPE e Loop While ZeroEqual
11100001
disp
LOOPNZLOOPNE e Loop While Not
ZeroEqual
JCXZ e Jump on CX Zero
11100000
disp
11100011
disp
data-high
data-high
(|ODITSZAPC| = |---------|)
(|ODITSZAPC| = |---------|)
(|ODITSZAPC| = |---------|)
INT e Interrupt: (|ODITSZAPC| = |--00-----|)
Type Specified
11001101
Type 3
11001100
type
INTO e Interrupt on Overflow
11001110
(|ODITSZAPC| = |--**-----|)
IRET e Interrupt Return
11001111
(|ODITSZAPC| = |*********|)
Mnemonic and
Description
Instruction Code
76543210
8086 Registers
Pin Diagram
76543210
PROCESSOR CONTROL
CLC e Clear Carry
11111000
(|ODITSZAPC| = |--------0|)
CMC e Complement Carry
11110101
(|ODITSZAPC| = |--------*|)
STC e Set Carry
11111001
(|ODITSZAPC| = |--------1|)
CLD e Clear Direction
11111100
(|ODITSZAPC| = |-0-------|)
STD e Set Direction
11111101
(|ODITSZAPC| = |-1-------|)
CLI e Clear Interrupt
11111010
(|ODITSZAPC| = |--0------|)
STI e Set Interrupt
11111011
(|ODITSZAPC| = |--1------|)
HLT e Halt
11110100
(|ODITSZAPC| = |---------|)
WAIT e Wait
10011011
(|ODITSZAPC| = |---------|)
ESC e Escape (to External Device)
11011xxx
LOCK e Bus Lock Prefix
11110000
NOTES
AL e 8-bit accumulator
AX e 16-bit accumulator
CX e Count register
DS e Data segment
ES e Extra segment
Abovebelow refers to unsigned value
Greater e more positive
Less e less positive (more negative) signed values
if d e 1 then ‘‘to’’ reg if d e 0 then ‘‘from’’ reg
if w e 1 then word instruction if w e 0 then byte instruction
if mod e 11 then rm is treated as a REG field
if mod e 00 then DISP e 0 disp-low and disp-high are
absent
if mod e 01 then DISP e disp-low sign-extended to
16 bits disp-high is absent
if mod e 10 then DISP e disp-high disp-low
if rm e 000 then EA e (BX) a (SI) a DISP
if rm e 001 then EA e (BX) a (DI) a DISP
if rm e 010 then EA e (BP) a (SI) a DISP
if rm e 011 then EA e (BP) a (DI) a DISP
if rm e 100 then EA e (SI) a DISP
if rm e 101 then EA e (DI) a DISP
if rm e 110 then EA e (BP) a DISP
if rm e 111 then EA e (BX) a DISP
DISP follows 2nd byte of instruction (before data if required)
except if mod e 00 and rm e 110 then EA e disp-high
disp-low
The codes used for 'Affected Flags' column are: |-*01?
mod x x x rm
(|ODITSZAPC| = |---------|)
(|ODITSZAPC| = |---------|)
if s w e 01 then 16 bits of immediate data form the operand
if s w e 11 then an immediate data byte is sign extended
to form the 16-bit operand
if v e 0 then ‘‘count’’ e 1 if v e 1 then ‘‘count’’ in (CL)
x e don’t care
z is used for string primitives for comparison with ZF FLAG
Rotate Instructions
CF
RCL
SEGMENT OVERRIDE PREFIX
0 0 1 reg 1 1 0
CF
REG is assigned according to the following table
16-Bit (w e 1)
000
001
010
011
100
101
110
111
AX
CX
DX
BX
SP
BP
SI
DI
8-Bit (w e 0)
000
001
010
011
100
101
110
111
AL
CL
DL
BL
AH
CH
DH
BH
ROL
Segment
CF
00 ES
01 CS
10 SS
11 DS
Instructions which reference the flag register file as a 16-bit
object use the symbol FLAGS to represent the file
FLAGS e XXXX(OF)(DF)(IF)(TF)(SF)(ZF)X(AF)X(PF)X(CF)
0
SHL
CF
0
SAL
CF
RCR
Intentionally
Blank
CF
ROR
CF
0
| Unaffected/Affected/Reset/Set/Unknown
SHR
NOTES:
CF
SAR
Tabulated and Edited by Dr. Mohammed Hawa, University of Jordan.
Version 1.1, June, 2005.
ASCII Character Set
Conditional Jump Instructions
Instruction
Description
JC
Jump if carry
JNC
Jump if no carry
JZ
Jump if zero
JNZ
Jump if not zero
JS
Jump if sign
JNS
Jump if no sign
JO
Jump if overflow
JNO
Jump if no overflow
JP
Jump if parity
JPE
Jump if parity even
JNP
Jump if no parity
JPO
Jump if parity odd
Instruction
JA
JNBE
JAE
JNB
JB
JNAE
JBE
JNA
JE
JNE
Condition
Carry = 1
Carry = 0
Zero = 1
Zero = 0
Sign = 1
Sign = 0
Overflow = 1
Overflow = 0
Parity = 1
Parity = 1
Parity = 0
Parity = 0
Aliases
JB, JNAE
JNB, JAE
JE
JNE
JPE
JP
JPO
JNP
Unsigned Comparisons
Description
Condition
Jump if above (>)
Carry = 0, Zero = 0
Jump if not below nor equal (not <=)
Carry = 0, Zero = 0
Jump if above or equal (>=)
Carry = 0
Jump if not below (not <)
Carry = 0
Jump if below (<)
Carry = 1
Jump if not above nor equal (not >=)
Carry = 1
Jump if below or equal (<=)
Carry = 1 or Zero = 1
Jump if not above (not >)
Carry = 1 or Zero = 1
Jump if equal (=)
Zero = 1
Jump if not equal ()
Zero = 0
Opposite
JNC
JC
JNZ
JZ
JNS
JS
JNO
JO
JNP
JPO
JP
JPE
Aliases Opposite
JNBE
JNA
JA
JBE
JNC, JNB JNAE
JNC, JAE
JB
JC, JNAE
JNB
JC, JB
JAE
JNA
JNBE
JBE
JA
JZ
JNE
JNZ
JE
Signed Comparisons
Instruction
Description
Condition
Aliases Opposite
JG
Jump if greater (>)
Sign = Overflow or Zero = 0 JNLE
JNG
JNLE
Jump if not less than nor equal (not <=) Sign = Overflow or Zero = 0
JG
JLE
JGE
Jump if greater than or equal (>=)
Sign = Overflow
JNL
JGE
JNL
Jump if not less than (not <)
Sign = Overflow
JGE
JL
JL
Jump if less than (<)
Sign Overflow
JNGE
JNL
JNGE
Jump if not greater nor equal (not >=)
Sign Overflow
JL
JGE
JLE
Jump if less than or equal (<=)
Sign Overflow or Zero = 1
JNG
JNLE
JNG
Jump if not greater than (not >)
Sign Overflow or Zero = 1
JLE
JG
JE
Jump if equal (=)
Zero = 1
JZ
JNE
JNE
Jump if not equal ()
Zero = 0
JNZ
JE
8086 Flags Register
|ODITSZAPC|
Overflow Flag, Direction Flag, Interrupt Flag, Trap Flag,
Sign Flag, Zero Flag, Auxilary carry Flag, Parity Flag,
Carry Flag
Intentionally
Blank
Assembler Directives
ALIGN
ASSUME sr:sy(,...)
ASSUME NOTHING
DB
e(,...)
DBS
e
DD
e(,...)
DDS
e
DW
e(,...)
DWS
e
EXT
(sr:)sy(t)
LABEL t
PROC
t
ABS
BYTE
DWORD
FAR
HIGH
LENGTH
LOW
NEAR
OFFSET
PTR
SEG
SHORT
SIZE
THIS
TYPE
WORD
Align to word boundary
Assume segment register name(s)
Remove all former assumptions
Define Byte(s)
Define Byte Storage
Define Double Word(s)
Define Double Word Storage
Define Word(s)
Define Word Storage
External(s)(t=ABS/BYTE/DWORD/FAR/NEAR/WORD)
Label
(t=BYTE/DWORD/FAR/NEAR/WORD)
Procedure
(t=FAR/NEAR, default NEAR)
Absolute value of operand
Byte type operation
Double Word operation
IP and CS registers altered
High-order 8 bits of 16-bit value
Number of basic units
Low-order 8 bit of 16-bit value
Only IP register need be altered
Offset portion of an address
Create a variable or label
Segment of address
One byte for a JMP operation
Number of bytes defined by statement
Create a variable/label of specified type
Number of bytes in the unit defined
Word operation
Download