8086 Instruction Set
These marks are used to show the state of the flags:
1 - instruction sets this flag to 1.
0 - instruction sets this flag to 0.
r - Flag value depends on result of the instruction.
? - Flag value is undefined (maybe 1 or 0).
Instruction
|
Operands
|
|||||||||||||||
AAA
|
No operands
|
ASCII Adjust after
Addition.
Corrects result in AH and AL after addition when working with BCD values.
|
||||||||||||||
AAD
|
No operands
|
ASCII Adjust before Division.
Prepares two BCD values for division.
|
||||||||||||||
AAM
|
No operands
|
ASCII Adjust after
Multiplication.
Corrects the result of multiplication of two BCD values.
|
||||||||||||||
AAS
|
No operands
|
ASCII Adjust after
Subtraction.
Corrects result in AH and AL after subtraction when working with BCD values.
|
||||||||||||||
ADC
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Add with Carry.
|
||||||||||||||
ADD
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Add.
|
||||||||||||||
AND
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Logical AND between
all bits of two operands. Result is stored in operand1.
|
||||||||||||||
CALL
|
procedure name
label 4-byte address |
Transfers control to
procedure, return address is (IP) is pushed to stack. 4-byte address
may be entered in this form: 1234h:5678h, first value is a segment second
value is an offset (this is a far call, so CS is also pushed to stack).
|
||||||||||||||
CBW
|
No operands
|
Convert byte into
word.
|
||||||||||||||
CLC
|
No operands
|
Clear Carry flag.
|
||||||||||||||
CLD
|
No operands
|
Clear Direction flag.
SI and DI will be incremented by chain instructions: CMPSB, CMPSW, LODSB,
LODSW, MOVSB, MOVSW, STOSB, STOSW.
|
||||||||||||||
CLI
|
No operands
|
Clear Interrupt enable
flag. This disables hardware interrupts.
|
||||||||||||||
CMC
|
No operands
|
Complement Carry flag.
Inverts value of CF.
|
||||||||||||||
CMP
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Compare.
|
||||||||||||||
CMPSB
|
No operands
|
Compare bytes: ES:[DI] from DS:[SI].
|
||||||||||||||
CMPSW
|
No operands
|
Compare words: ES:[DI] from DS:[SI].
|
||||||||||||||
CWD
|
No operands
|
Convert Word to Double word.
|
||||||||||||||
DAA
|
No operands
|
Decimal adjust After Addition.
Corrects the result of addition of two packed BCD values.
|
||||||||||||||
DAS
|
No operands
|
Decimal adjust After Subtraction.
Corrects the result of subtraction of two packed BCD values.
|
||||||||||||||
DEC
|
REG
memory |
Decrement.
|
||||||||||||||
DIV
|
REG
memory |
Unsigned divide.
|
||||||||||||||
HLT
|
No operands
|
Halt the System.
|
||||||||||||||
IDIV
|
REG
memory |
Signed divide.
|
||||||||||||||
IMUL
|
REG
memory |
Signed multiply.
|
||||||||||||||
IN
|
AL, im.byte
AL, DX AX, im.byte AX, DX |
Input from port into AL
or AX.
Second operand is a port number. If required to access port number over 255 - DX register should be used.
|
||||||||||||||
INC
|
REG
memory |
Increment.
|
||||||||||||||
INT
|
immediate byte
|
Interrupt numbered by immediate byte (0..255).
|
||||||||||||||
INTO
|
No operands
|
Interrupt 4 if
Overflow flag is 1.
|
||||||||||||||
IRET
|
No operands
|
Interrupt Return.
|
||||||||||||||
JA
|
label
|
Short Jump if first
operand is Above second operand (as set by CMP instruction). Unsigned.
|
||||||||||||||
JAE
|
label
|
Short Jump if first
operand is Above or Equal to second operand (as set by CMP instruction).
Unsigned.
|
||||||||||||||
JB
|
label
|
Short Jump if first
operand is Below second operand (as set by CMP instruction). Unsigned.
|
||||||||||||||
JBE
|
label
|
Short Jump if first
operand is Below or Equal to second operand (as set by CMP instruction).
Unsigned.
|
||||||||||||||
JC
|
label
|
Short Jump if Carry
flag is set to 1.
|
||||||||||||||
JCXZ
|
label
|
Short Jump if CX
register is 0.
|
||||||||||||||
JE
|
label
|
Short Jump if first
operand is Equal to second operand (as set by CMP instruction).
Signed/Unsigned.
|
||||||||||||||
JG
|
label
|
Short Jump if first
operand is Greater then second operand (as set by CMP instruction). Signed.
|
||||||||||||||
JGE
|
label
|
Short Jump if first
operand is Greater or Equal to second operand (as set by CMP instruction).
Signed.
|
||||||||||||||
JL
|
label
|
Short Jump if first
operand is Less then second operand (as set by CMP instruction). Signed.
|
||||||||||||||
JLE
|
label
|
Short Jump if first
operand is Less or Equal to second operand (as set by CMP instruction).
Signed.
|
||||||||||||||
JMP
|
label
4-byte address |
Unconditional Jump.
Transfers control to another part of the program. 4-byte address may
be entered in this form: 1234h:5678h, first value is a segment second value
is an offset.
|
||||||||||||||
JNA
|
label
|
Short Jump if first
operand is Not Above second operand (as set by CMP instruction). Unsigned.
|
||||||||||||||
JNAE
|
label
|
Short Jump if first
operand is Not Above and Not Equal to second operand (as set by CMP
instruction). Unsigned.
|
||||||||||||||
JNB
|
label
|
Short Jump if first
operand is Not Below second operand (as set by CMP instruction). Unsigned.
|
||||||||||||||
JNBE
|
label
|
Short Jump if first
operand is Not Below and Not Equal to second operand (as set by CMP
instruction). Unsigned.
|
||||||||||||||
JNC
|
label
|
Short Jump if Carry
flag is set to 0.
|
||||||||||||||
JNE
|
label
|
Short Jump if first
operand is Not Equal to second operand (as set by CMP instruction).
Signed/Unsigned.
|
||||||||||||||
JNG
|
label
|
Short Jump if first
operand is Not Greater then second operand (as set by CMP instruction).
Signed.
|
||||||||||||||
JNGE
|
label
|
Short Jump if first
operand is Not Greater and Not Equal to second operand (as set by CMP
instruction). Signed.
|
||||||||||||||
JNL
|
label
|
Short Jump if first
operand is Not Less then second operand (as set by CMP instruction). Signed.
|
||||||||||||||
JNLE
|
label
|
Short Jump if first
operand is Not Less and Not Equal to second operand (as set by CMP
instruction). Signed.
|
||||||||||||||
JNO
|
label
|
Short Jump if Not
Overflow.
|
||||||||||||||
JNP
|
label
|
Short Jump if No
Parity (odd). Only 8 low bits of result are checked. Set by CMP, SUB, ADD,
TEST, AND, OR, XOR instructions.
|
||||||||||||||
JNS
|
label
|
Short Jump if Not
Signed (if positive). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
|
||||||||||||||
JNZ
|
label
|
Short Jump if Not Zero
(not equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
|
||||||||||||||
JO
|
label
|
Short Jump if
Overflow.
|
||||||||||||||
JP
|
label
|
Short Jump if Parity
(even). Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST,
AND, OR, XOR instructions.
|
||||||||||||||
JPE
|
label
|
Short Jump if Parity
Even. Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND,
OR, XOR instructions.
|
||||||||||||||
JPO
|
label
|
Short Jump if Parity
Odd. Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND,
OR, XOR instructions.
|
||||||||||||||
JS
|
label
|
Short Jump if Signed
(if negative). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
|
||||||||||||||
JZ
|
label
|
Short Jump if Zero
(equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
|
||||||||||||||
LAHF
|
No operands
|
Load AH from 8 low
bits of Flags register.
|
||||||||||||||
LDS
|
REG, memory
|
Load memory double word into word register and
DS.
|
||||||||||||||
LEA
|
REG, memory
|
Load Effective
Address.
|
||||||||||||||
LES
|
REG, memory
|
Load memory double word into word register and
ES.
|
||||||||||||||
LODSB
|
No operands
|
Load byte at DS:[SI] into AL. Update SI.
|
||||||||||||||
LODSW
|
No operands
|
Load word at DS:[SI] into AX. Update SI.
|
||||||||||||||
LOOP
|
label
|
Decrease CX, jump to label if CX not zero.
|
||||||||||||||
LOOPE
|
label
|
Decrease CX, jump to label if CX not zero and
Equal (ZF = 1).
|
||||||||||||||
LOOPNE
|
label
|
Decrease CX, jump to label if CX not zero and
Not Equal (ZF = 0).
|
||||||||||||||
LOOPNZ
|
label
|
Decrease CX, jump to label if CX not zero and
ZF = 0.
|
||||||||||||||
LOOPZ
|
label
|
Decrease CX, jump to label if CX not zero and
ZF = 1.
|
||||||||||||||
MOV
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate SREG, memory memory, SREG REG, SREG SREG, REG |
Copy operand2 to
operand1.
The MOV instruction cannot:
·
Set the value of the CS and IP registers.
·
Copy value of one segment register to another segment register
(should copy to general register first).
·
Copy immediate value to segment register (should copy to general
register first).
|
||||||||||||||
MOVSB
|
No operands
|
Copy byte at DS:[SI] to ES:[DI]. Update SI and
DI.
|
||||||||||||||
MOVSW
|
No operands
|
Copy word at DS:[SI] to ES:[DI]. Update
SI and DI.
|
||||||||||||||
MUL
|
REG
memory |
Unsigned multiply.
|
||||||||||||||
NEG
|
REG
memory |
Negate. Makes operand negative (two's
complement).
|
||||||||||||||
NOP
|
No operands
|
No Operation.
|
||||||||||||||
NOT
|
REG
memory |
Invert each bit of the operand.
|
||||||||||||||
OR
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Logical OR between all
bits of two operands. Result is stored in first operand.
|
||||||||||||||
OUT
|
im.byte, AL
im.byte, AX DX, AL DX, AX |
Output from AL
or AX to port.
First operand is a port number. If required to access port number over 255 - DX register should be used.
|
||||||||||||||
POP
|
REG
SREG memory |
Get 16 bit value from the stack.
|
||||||||||||||
POPF
|
No operands
|
Get flags register from the stack.
|
||||||||||||||
PUSH
|
REG
SREG memory immediate |
Store 16 bit value in the stack.
Note: PUSH immediate works only on 80186 CPU and later!
|
||||||||||||||
PUSHF
|
No operands
|
Store flags register in the stack.
|
||||||||||||||
RCL
|
memory, immediate
REG, immediate memory, CL REG, CL |
Rotate operand1 left
through Carry Flag. The number of rotates is set by operand2.
When immediate is greater then 1, assembler generates several RCL xx, 1 instructions because 8086 has machine code only for this instruction (the same principle works for all other shift/rotate instructions).
|
||||||||||||||
RCR
|
memory, immediate
REG, immediate memory, CL REG, CL |
Rotate operand1 right
through Carry Flag. The number of rotates is set by operand2.
|
||||||||||||||
REP
|
chain instruction
|
Repeat following MOVSB, MOVSW, LODSB, LODSW,
STOSB, STOSW instructions CX times.
|
||||||||||||||
REPE
|
chain instruction
|
Repeat following CMPSB, CMPSW, SCASB, SCASW
instructions while ZF = 1 (result is Equal), maximum CX times.
|
||||||||||||||
REPNE
|
chain instruction
|
Repeat following CMPSB, CMPSW, SCASB, SCASW
instructions while ZF = 0 (result is Not Equal), maximum CX times.
|
||||||||||||||
REPNZ
|
chain instruction
|
Repeat following
CMPSB, CMPSW, SCASB, SCASW instructions while ZF = 0 (result is Not Zero),
maximum CX times.
|
||||||||||||||
REPZ
|
chain instruction
|
Repeat following CMPSB, CMPSW, SCASB, SCASW
instructions while ZF = 1 (result is Zero), maximum CX times.
|
||||||||||||||
RET
|
No operands
or even immediate |
Return from near
procedure.
|
||||||||||||||
RETF
|
No operands
or even immediate |
Return from Far procedure.
|
||||||||||||||
ROL
|
memory, immediate
REG, immediate memory, CL REG, CL |
Rotate operand1 left.
The number of rotates is set by operand2.
|
||||||||||||||
ROR
|
memory, immediate
REG, immediate memory, CL REG, CL |
Rotate operand1 right.
The number of rotates is set by operand2.
|
||||||||||||||
SAHF
|
No operands
|
Store AH registers
into low 8 bits of Flags register.
|
||||||||||||||
SAL
|
memory, immediate
REG, immediate memory, CL REG, CL |
Shift Arithmetic
operand1 Left. The number of shifts is set by operand2.
|
||||||||||||||
SAR
|
memory, immediate
REG, immediate memory, CL REG, CL |
Shift Arithmetic
operand1 Right. The number of shifts is set by operand2.
|
||||||||||||||
SBB
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Subtract with Borrow.
|
||||||||||||||
SCASB
|
No operands
|
Compare bytes: AL from ES:[DI].
|
||||||||||||||
SCASW
|
No operands
|
Compare words: AX from ES:[DI].
|
||||||||||||||
SHL
|
memory, immediate
REG, immediate memory, CL REG, CL |
Shift operand1 Left.
The number of shifts is set by operand2.
|
||||||||||||||
SHR
|
memory, immediate
REG, immediate memory, CL REG, CL |
Shift operand1 Right.
The number of shifts is set by operand2.
|
||||||||||||||
STC
|
No operands
|
Set Carry flag.
|
||||||||||||||
STD
|
No operands
|
Set Direction flag. SI
and DI will be decremented by chain instructions: CMPSB, CMPSW, LODSB, LODSW,
MOVSB, MOVSW, STOSB, STOSW.
|
||||||||||||||
STI
|
No operands
|
Set Interrupt enables
flag. This enables hardware interrupts.
|
||||||||||||||
STOSB
|
No operands
|
Store byte in AL into
ES:[DI]. Update DI.
|
||||||||||||||
STOSW
|
No operands
|
Store word in AX into
ES:[DI]. Update DI.
|
||||||||||||||
SUB
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Subtract.
|
||||||||||||||
TEST
|
REG, memory
memory, REG REG, REG memory, immediate REG, immediate |
Logical AND between
all bits of two operands for flags only. These flags are affected: ZF, SF,
PF. Result is not stored anywhere.
|
||||||||||||||
XCHG
|
REG, memory
memory, REG REG, REG |
Exchange values of two
operands.
|
||||||||||||||
XLATB
|
No operands
|
Translate byte from
table.
Copy value of memory byte at DS:[BX + unsigned AL] to AL register.
|
||||||||||||||
XOR
|
REG, memory
memory, REG REG, REG memory, immediate |
Logical XOR (Exclusive
OR) between all bits of two operands. Result is stored in first operand.
|
canonical cover
ReplyDelete8086 pin diagram
doubly linked list
Absolute Loaders
Three Dimensional Display Methods
Storage allocation strategies
Different Loading Schemes
Relocation: Linking Concept