Skip to content

Instruction Set

Data Transfer Instructions Overview

General Purpose Data Transfer
MOVMove a byte or a word
PUSHPush word onto stack
POPPop word off stack
XCHGExchange bytes or words
XLATTable lookup-translation
IN/OUT Instruction
INInput
OUTOutput
Address Object Transfer
LEALeast effective address
LDSLoad pointer using DS
LESLoad pointer using ES
Flag Transfer
LAHFLoad AH from flags
SAHFStore AH into flags
PUSHFPush flags onto stack
POPFPop flags off stack

General Purpose Data Transfer

MOV

Copy data from source to destination.

Usage:

MOV D, S

The following situations are not allowed to use MOV:

  • Memory → Memory
  • Immediate → Segment Register
  • Segment Register → Segment Register

PUSH

Usage:

PUSH SRC

Process:

  1. SP <- SP - 2
  2. (SP + 1, SP) <- SRC

POP

Usage:

POP DEST

Process:

  1. DST <- (SP + 1, SP)
  2. SP <- SP + 2

It loads 1616 bits content from SS:SP to DST.

XCHG

Usage:

XCHG OPR1, OPR2

It exchanges values between two operands.

XCHG is not allowed:

  • Memory ↔ Memory
  • Segment ↔ Registers

XLAT

Usage:

XLAT

Process:

AL <- DS:[BX + AL]

Address Object Transfer

LEA

Load effective address.

Usage:

LEA REG, SRC

Process:

REG <- SRC

LDS

Load pointer into DS.

Usage:

LDS REG, SRC

Process:

  1. REG <- SRC
  2. DS <- SRC + 2

LES

Load pointer into ES.

Usage:

LES REG, SRC

Process:

  1. REG <- SRC
  2. ES <- SRC + 2

Flag Transfer

InstructionMeaningProcess
LAHFLoad AH with flagsAH <- (Low byte of PSW)
SAHFStore AH into flags(Low byte of PSW) <- AH
PUSHFPush the flags1. SP <- SP - 2
2. (SP + 1, SP) <- PSW
POPFPop the flags1. PSW <- (SP + 1, SP)
2. SP <- SP + 2

IN/OUT Instructions

Usage:

IN REG, PORT
OUT PORT, REG

The PORT ranges from 00 to FFH\text{FFH}.

Arithmetic Instructions

Addition
ADDAdd byte or word
ADCAdd byte or word with carry
INCIncrement byte or word by 1
AAAASCII adjust for addition
DAADecimal adjust for addition
Subtraction
SUBSubtract byte or word
SBBSubtract byte or word with borrow
DECDecrement byte or word by 1
CMPCompare
NEGNegate byte or word
AASASCII adjust for subtraction
DASDecimal adjust for subtraction
Multiplication
MULMultiply byte of word unsigned
IMULInteger multiply byte or word
AAMASCII adjust for multiply
Division
DIVDivide byte or word unsigned
IDIVInteger divide byte or word
AADASCII adjust for division
CBWConvert byte to word
CWDConvert word to double word

Addition

InstructionsUsageProcess
ADDADD DEST, SRCDST <- DST + SRC
ADCADC DEST, SRCDST <- DST + SRC + CF
INCINC DESTDEST <- (DEST) + 1

Subtraction

InstructionsUsageProcess
SUBSUB DST, SRCDST <- DST - SRC
SBBSBB DST, SRCDST <- DST - SRC - CF
DECDEC OPROPR <- (OPR) - 1
NEGNEG OPROPR <- 0 - OPR
CMPCMP OPR1, OPXR2OPR1 - OPR2

Multiplication

InstructionsUsageProcess
MULMUL SRC1. AX <- AL * SRC
2. (DX, AX) <- AX * SRC
IMULIMUL SRC1. AX <- AL * SRC
2. (DX, AX) <- AX * SRC

Division

InstructionsUsageProcess
DIVDIV SRC1. AL <- AX / SRC
2. AH <- AX % SRC
IDIVIDIV SRC1. AX <- (DX, AX) / SRC
2. DX <- (DX, AX) % SRC

CBW

Usage:

CBW

Process:

AL -> AX.

If MSB of AL is 11, then AH = 255. Otherwise, AH = 0.

CWD

Usage:

CWD

Process:

AX -> (DX, AX)

If MSB of AX is 11, 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 Addition
  • DAS: Decimal Adjust after Subtraction

If AL  &  0FH>9\text{AL} \; \& \; \text{0FH} > 9 or AF = 1, then AL  ±=06H\text{AL} \; \pm= \text{06H} and AF = 1.

If AL  &  F0H>90H\text{AL} \; \& \; \text{F0H} > \text{90H} or CF = 1, then AL  ±=60F\text{AL} \; \pm= \text{60F} and CF = 1.

AAA and AAS

These two instructions are used in unpacked BCD.

  • AAA: ASCII Adjust after Addition
  • AAS: ASCII Adjust after Subtraction

If AL  &  0FH>9\text{AL} \; \& \; \text{0FH} > 9 or AF = 1, then the adjustment happens, and AF = CF = 1.

AL  ±=6AH  ±=1AL  &=0FH \begin{align*} \text{AL} \; &\pm= 6 \\ \text{AH} \; &\pm= 1 \\ \text{AL} \; &\&= \text{0FH} \end{align*}
Last updated on