Instruction Set
Data Transfer Instructions Overview
| General Purpose Data Transfer | |
MOV |
Move a byte or a word |
PUSH |
Push word onto stack |
POP |
Pop word off stack |
XCHG |
Exchange bytes or words |
XLAT |
Table lookup-translation |
| IN/OUT Instruction | |
IN |
Input |
OUT |
Output |
| Address Object Transfer | |
LEA |
Least effective address |
LDS |
Load pointer using DS |
LES |
Load pointer using ES |
| Flag Transfer | |
LAHF |
Load AH from flags |
SAHF |
Store AH into flags |
PUSHF |
Push flags onto stack |
POPF |
Pop flags off stack |
General Purpose Data Transfer
MOV
Copy data from source to destination.
Usage:
MOV D, SThe following situations are not allowed to use MOV:
- Memory → Memory
- Immediate → Segment Register
- Segment Register → Segment Register
PUSH
Usage:
PUSH SRCProcess:
SP <- SP - 2(SP + 1, SP) <- SRC
POP
Usage:
POP DESTProcess:
DST <- (SP + 1, SP)SP <- SP + 2
It loads bits content from SS:SP to DST.
XCHG
Usage:
XCHG OPR1, OPR2It exchanges values between two operands.
XCHG is not allowed:
- Memory ↔ Memory
- Segment ↔ Registers
XLAT
Usage:
XLATProcess:
AL <- DS:[BX + AL]
Address Object Transfer
LEA
Load effective address.
Usage:
LEA REG, SRCProcess:
REG <- SRC
LDS
Load pointer into DS.
Usage:
LDS REG, SRCProcess:
REG <- SRCDS <- SRC + 2
LES
Load pointer into ES.
Usage:
LES REG, SRCProcess:
REG <- SRCES <- SRC + 2
Flag Transfer
| Instruction | Meaning | Process |
|---|---|---|
LAHF |
Load AH with flags |
AH <- (Low byte of PSW) |
SAHF |
Store AH into flags |
(Low byte of PSW) <- AH |
PUSHF |
Push the flags |
1. SP <- SP - 2 2. (SP + 1, SP) <- PSW |
POPF |
Pop the flags | 1. PSW <- (SP + 1, SP) 2. SP <- SP + 2 |
IN/OUT Instructions
Usage:
IN REG, PORT
OUT PORT, REGThe PORT ranges from to .
Arithmetic Instructions
| Addition | |
ADD |
Add byte or word |
ADC |
Add byte or word with carry |
INC |
Increment byte or word by 1 |
AAA |
ASCII adjust for addition |
DAA |
Decimal adjust for addition |
| Subtraction | |
SUB |
Subtract byte or word |
SBB |
Subtract byte or word with borrow |
DEC |
Decrement byte or word by 1 |
CMP |
Compare |
NEG |
Negate byte or word |
AAS |
ASCII adjust for subtraction |
DAS |
Decimal adjust for subtraction |
| Multiplication | |
MUL |
Multiply byte of word unsigned |
IMUL |
Integer multiply byte or word |
AAM |
ASCII adjust for multiply |
| Division | |
DIV |
Divide byte or word unsigned |
IDIV |
Integer divide byte or word |
AAD |
ASCII adjust for division |
CBW |
Convert byte to word |
CWD |
Convert word to double word |
Addition
| Instructions | Usage | Process |
|---|---|---|
ADD |
ADD DEST, SRC |
DST <- DST + SRC |
ADC |
ADC DEST, SRC |
DST <- DST + SRC + CF |
INC |
INC DEST |
DEST <- (DEST) + 1 |
Subtraction
| Instructions | Usage | Process |
|---|---|---|
SUB |
SUB DST, SRC |
DST <- DST - SRC |
SBB |
SBB DST, SRC |
DST <- DST - SRC - CF |
DEC |
DEC OPR |
OPR <- (OPR) - 1 |
NEG |
NEG OPR |
OPR <- 0 - OPR |
CMP |
CMP OPR1, OPXR2 |
OPR1 - OPR2 |
Multiplication
| Instructions | Usage | Process |
|---|---|---|
MUL |
MUL SRC |
1. AX <- AL * SRC 2. (DX, AX) <- AX * SRC |
IMUL |
IMUL SRC |
1. AX <- AL * SRC 2. (DX, AX) <- AX * SRC |
Division
| Instructions | Usage | Process |
|---|---|---|
DIV |
DIV SRC |
1. AL <- AX / SRC 2. AH <- AX % SRC |
IDIV |
IDIV SRC |
1. AX <- (DX, AX) / SRC 2. DX <- (DX, AX) % SRC |
CBW
Usage:
CBWProcess:
AL -> AX.
If MSB of AL is , then AH = 255. Otherwise, AH = 0.
CWD
Usage:
CWDProcess:
AX -> (DX, AX)
If MSB of AX is , then DX = 65535. Otherwise, DX = 0.
Adjusting Instruction of BCD Code
DAA and DAS
These two instructions are used in packed BCD.
DAA: Decimal Adjust after AdditionDAS: Decimal Adjust after Subtraction
If or AF = 1, then and AF = 1.
If or CF = 1, then and CF = 1.
AAA and AAS
These two instructions are used in unpacked BCD.
AAA: ASCII Adjust after AdditionAAS: ASCII Adjust after Subtraction
If or AF = 1, then the adjustment happens, and AF = CF = 1.