ADD | ADC | INC | ||||||||
SUB | SBB | DEC | ||||||||
NEG | CMP | |||||||||
MUL | IMUL | |||||||||
DAA | DAS | AAA | AAS | |||||||
AND | OR | XOR | NOT | TEST | ||||||
SHL | SHR | SAL | SAR | |||||||
ROL | ROR | RCL | RCR | |||||||
MOV | MOVSB | MOVSW | STOSB | STOSW | LODSB | LODSW | REP | CLD | STD | |
CMPSB | CMPSW | SCASB | SCASW | REPE | REPNE | REPZ | REPNZ | |||
IN |
OUT |
|||||||||
JMP | JZ | JNZ | JS | JNS | JO | JNO | JP | JNP | JB | JNB |
状态标志说明: |
||||||||||||||
指令 | 操作数 | 描述 | ||||||||||||
ADD | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Add. Algorithm: operand1 = operand1 + operand2 Example:
|
||||||||||||
ADC | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Add with Carry. Algorithm: operand1 = operand1 + operand2 + CF Example:
|
||||||||||||
INC | REG memory |
Increment. Algorithm: operand = operand + 1 Example:
|
||||||||||||
SUB | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Subtract. Algorithm: operand1 = operand1 - operand2 Example:
|
||||||||||||
SBB | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Subtract with Borrow. Algorithm: operand1 = operand1 - operand2 - CF Example:
|
||||||||||||
DEC | REG memory |
Decrement. Algorithm: operand = operand - 1 Example:
|
||||||||||||
NEG | REG memory |
Negate. Makes operand negative (two's complement). Algorithm:
|
||||||||||||
CMP | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Compare. Algorithm: operand1 - operand2 result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to result. Example:
|
||||||||||||
MUL | REG memory |
Unsigned multiply. Algorithm: when operand is a byte: when operand is a word:Example:
|
||||||||||||
IMUL | REG memory |
Signed multiply. Algorithm: when operand is a byte: when operand is a word:Example:
|
||||||||||||
DAA | No operands | Decimal adjust After Addition. Corrects the result of addition of two packed BCD values. Algorithm: if low nibble of AL > 9 or AF = 1 then:
|
||||||||||||
DAS | No operands | Decimal adjust After Subtraction. Corrects the result of subtraction of two packed BCD values. Algorithm: if low nibble of AL > 9 or AF = 1 then:
|
||||||||||||
AAA | No operands | ASCII Adjust after Addition. Corrects result in AH and AL after addition when working with BCD values. It works according to the following Algorithm: if low nibble of AL > 9 or AF = 1 then:
clear the high nibble of AL. Example:
|
||||||||||||
AAS | No operands | ASCII Adjust after Subtraction. Corrects result in AH and AL after subtraction when working with BCD values. Algorithm: if low nibble of AL > 9 or AF = 1 then:
clear the high nibble of AL. Example:
|
||||||||||||
AND | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Logical AND between all bits of two operands. Result is stored in operand1. These rules apply: 1 AND 1 = 1 1 AND 0 = 0 0 AND 1 = 0 0 AND 0 = 0 Example:
|
||||||||||||
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. These rules apply: 1 OR 1 = 1 1 OR 0 = 1 0 OR 1 = 1 0 OR 0 = 0 Example:
|
||||||||||||
XOR | REG, memory memory, REG REG, REG memory, immediate REG, immediate |
Logical XOR (Exclusive OR) between all bits of two operands. Result is stored in first operand. These rules apply: 1 XOR 1 = 0 1 XOR 0 = 1 0 XOR 1 = 1 0 XOR 0 = 0 Example:
|
||||||||||||
NOT | REG memory |
Invert each bit of the operand. Algorithm:
|
||||||||||||
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 effected: ZF, SF, PF. Result is not stored anywhere. These rules apply: 1 AND 1 = 1 1 AND 0 = 0 0 AND 1 = 0 0 AND 0 = 0 Example:
|
||||||||||||
SHL | memory, immediate REG, immediate memory, CL REG, CL |
Shift operand1 Left. The number of shifts is set by operand2. Algorithm:
|
||||||||||||
SHR | memory, immediate REG, immediate memory, CL REG, CL |
Shift operand1 Right. The number of shifts is set by operand2. Algorithm:
|
||||||||||||
SAL | memory, immediate REG, immediate memory, CL REG, CL |
Shift Arithmetic operand1 Left. The number of shifts is set by operand2. Algorithm:
|
||||||||||||
SAR | memory, immediate REG, immediate memory, CL REG, CL |
Shift Arithmetic operand1 Right. The number of shifts is set by operand2. Algorithm:
|
||||||||||||
ROL | memory, immediate REG, immediate memory, CL REG, CL |
Rotate operand1 left. The number of rotates is set by operand2. Algorithm: shift all bits left, the bit that goes off is set to CF and the same bit is inserted to the right-most position. Example:
|
||||||||||||
ROR | memory, immediate REG, immediate memory, CL REG, CL |
Rotate operand1 right. The number of rotates is set by operand2. Algorithm: shift all bits right, the bit that goes off is set to CF and the same bit is inserted to the left-most position. Example:
|
||||||||||||
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). Algorithm: shift all bits left, the bit that goes off is set to CF and previous value of CF is inserted to the right-most position. Example:
|
||||||||||||
RCR | memory, immediate REG, immediate memory, CL REG, CL |
Rotate operand1 right through Carry Flag. The number of rotates is set by operand2. Algorithm: shift all bits right, the bit that goes off is set to CF and previous value of CF is inserted to the left-most position. Example:
|
||||||||||||
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:
operand1 = operand2Example:
|
||||||||||||
MOVSB | No operands | Copy byte at DS:[SI] to ES:[DI]. Update SI and DI. Algorithm:
|
||||||||||||
MOVSW | No operands | Copy word at DS:[SI] to ES:[DI]. Update SI and DI. Algorithm:
|
||||||||||||
STOSB | No operands | Store byte in AL into ES:[DI]. Update SI. Algorithm:
|
||||||||||||
STOSW | No operands | Store word in AX into ES:[DI]. Update SI. Algorithm:
|
||||||||||||
LODSB | No operands | Load byte at DS:[SI] into AL. Update SI. Algorithm:
|
||||||||||||
LODSW | No operands | Load word at DS:[SI] into AX. Update SI. Algorithm:
|
||||||||||||
REP | chain instruction |
Repeat following MOVSB, MOVSW, LODSB, LODSW, STOSB, STOSW instructions CX times. Algorithm: check_cx: if CX <> 0 then
|
||||||||||||
CLD | No operands | Clear Direction flag. SI and DI will be incremented by chain instructions: CMPSB, CMPSW, LODSB, LODSW, MOVSB, MOVSW, STOSB, STOSW. Algorithm: DF = 0
|
||||||||||||
STD | No operands | Set Direction flag. SI and DI will be decremented by chain instructions: CMPSB, CMPSW, LODSB, LODSW, MOVSB, MOVSW, STOSB, STOSW. Algorithm: DF = 1
|
||||||||||||
CMPSB | No operands | Compare bytes: ES:[DI] from DS:[SI]. Algorithm:
see cmpsb.asm in Samples.
|
||||||||||||
CMPSW | No operands | Compare words: ES:[DI] from DS:[SI]. Algorithm:
see cmpsw.asm in Samples.
|
||||||||||||
SCASB | No operands | Compare bytes: AL from ES:[DI]. Algorithm:
|
||||||||||||
SCASW | No operands | Compare words: AX from ES:[DI]. Algorithm:
|
||||||||||||
REPE | chain instruction |
Repeat following CMPSB, CMPSW, SCASB, SCASW instructions while ZF = 1 (result is Equal), maximum CX times. Algorithm: check_cx: if CX <> 0 then
see cmpsb.asm in Samples.
|
||||||||||||
REPNE | chain instruction |
Repeat following CMPSB, CMPSW, SCASB, SCASW instructions while ZF = 0 (result is Not Equal), maximum CX times. Algorithm: check_cx: if CX <> 0 then
|
||||||||||||
REPZ | chain instruction |
Repeat following CMPSB, CMPSW, SCASB, SCASW instructions while ZF = 1 (result is Zero), maximum CX times. Algorithm: check_cx: if CX <> 0 then
|
||||||||||||
REPNZ | chain instruction |
Repeat following CMPSB, CMPSW, SCASB, SCASW instructions while ZF = 0 (result is Not Zero), maximum CX times. Algorithm: check_cx: if CX <> 0 then
|
||||||||||||
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. Example:
|
||||||||||||
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. Example:
|
||||||||||||
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. Algorithm: always jump Example:
|
||||||||||||
JZ | label | Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. Algorithm: if ZF = 1 then jump Example:
|
||||||||||||
JNZ | label | Short Jump if Not Zero (not equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. Algorithm: if ZF = 0 then jump Example:
|
||||||||||||
JS | label | Short Jump if Signed (if negative). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. Algorithm: if SF = 1 then jump Example:
|
||||||||||||
JNS | label | Short Jump if Not Signed (if positive). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. Algorithm: if SF = 0 then jump Example:
|
||||||||||||
JO | label | Short Jump if Overflow. Algorithm: if OF = 1 then jump Example:
|
||||||||||||
JNO | label | Short Jump if Not Overflow. Algorithm: if OF = 0 then jump Example:
|
||||||||||||
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. Algorithm: if PF = 1 then jump Example:
|
||||||||||||
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. Algorithm: if PF = 0 then jump Example:
|
||||||||||||
JB | label | Short Jump if first operand is Below second operand (as set by CMP instruction). Unsigned. Algorithm: if CF = 1 then jump Example:
|
||||||||||||
JNB | label | Short Jump if first operand is Not Below second operand (as set by CMP instruction). Unsigned. Algorithm: if CF = 0 then jump Example:
|
||||||||||||