Instruction Set of 8086

Instructions are classified on the basis of functions they perform. They are categorized into the following main types:

Data Transfer instruction

All the instructions which perform data movement come under this category. The source data may be a register, memory location, port etc. the destination may be a register, memory location or port. The following instructions come under this category:

InstructionDescription
MOVMoves data from register to register, register to memory, memory to register, memory to accumulator, accumulator to memory, etc.
LDSLoads a word from the specified memory locations into specified register. It also loads a word from the next two memory locations into DS register.
LESLoads a word from the specified memory locations into the specified register. It also loads a word from next two memory locations into ES register.
LEALoads offset address into the specified register.
LAHFLoads low order 8-bits of the flag register into AH register.
SAHFStores the content of AH register into low order bits of the flags register.
XLAT/XLATBReads a byte from the lookup table.
XCHGExchanges the contents of the 16-bit or 8-bit specified register with the contents of AX register, specified register or memory locations.
PUSHPushes (sends, writes or moves) the content of a specified register or memory location(s) onto the top of the stack.
POPPops (reads) two bytes from the top of the stack and keeps them in a specified register, or memory location(s).
POPFPops (reads) two bytes from the top of the stack and keeps them in the flag register.
INTransfers data from a port to the accumulator or AX, DX or AL register.
OUTTransfers data from accumulator or AL or AX register to an I/O port identified by the second byte of the instruction.

Arithmetic Instructions

Instructions of this group perform addition, subtraction, multiplication, division, increment, decrement, comparison, ASCII and decimal adjustment etc.

The following instructions come under this category:

InstructionDescription
ADDAdds data to the accumulator i.e. AL or AX register or memory locations.
ADCAdds specified operands and the carry status (i.e. carry of the previous stage).
SUBSubtract immediate data from accumulator, memory or register.
SBBSubtract immediate data with borrow from accumulator, memory or register.
MULUnsigned 8-bit or 16-bit multiplication.
IMULSigned 8-bit or 16-bit multiplication.
DIVUnsigned 8-bit or 16-bit division.
IDIVSigned 8-bit or 16-bit division.
INCIncrement Register or memory by 1.
DECDecrement register or memory by 1.
DAADecimal Adjust after BCD Addition: When two BCD numbers are added, the DAA is used after ADD or ADC instruction to get correct answer in BCD.
DASDecimal Adjust after BCD Subtraction: When two BCD numbers are added, the DAS is used after SUB or SBB instruction to get correct answer in BCD.
AAAASCII Adjust for Addition: When ASCII codes of two decimal digits are added, the AAA is used after addition to get correct answer in unpacked BCD.
AADAdjust AX Register for Division: It converts two unpacked BCD digits in AX to the equivalent binary number. This adjustment is done before dividing two unpacked BCD digits in AX by an unpacked BCD byte.
AAMAdjust result of BCD Multiplication: This instruction is used after the multiplication of two unpacked BCD.
AASASCII Adjust for Subtraction: This instruction is used to get the correct result in unpacked BCD after the subtraction of the ASCII code of a number from ASCII code another number.
CBWConvert signed Byte to signed Word.
CWDConvert signed Word to signed Doubleword.
NEGObtains 2's complement (i.e. negative) of the content of an 8-bit or 16-bit specified register or memory location(s).
CMPCompare Immediate data, register or memory with accumulator, register or memory location(s).

Logical Instructions

Instruction of this group perform logical AND, OR, XOR, NOT and TEST operations. The following instructions come under this category:

InstructionDescription
ANDPerforms bit by bit logical AND operation of two operands and places the result in the specified destination.
ORPerforms bit by bit logical OR operation of two operands and places the result in the specified destination.
XORPerforms bit by bit logical XOR operation of two operands and places the result in the specified destination.
NOTTakes one's complement of the content of a specified register or memory location(s).
TESTPerform logical AND operation of a specified operand with another specified operand.

Rotate Instructions

The following instructions come under this category:

InstructionDescription
RCLRotate all bits of the operand left by specified number of bits through carry flag.
RCRRotate all bits of the operand right by specified number of bits through carry flag.
ROLRotate all bits of the operand left by specified number of bits.
RORRotate all bits of the operand right by specified number of bits.

Shift Instructions

The following instructions come under this category:

InstructionDescription
SAL or SHLShifts each bit of operand left by specified number of bits and put zero in LSB position.
SARShift each bit of any operand right by specified number of bits. Copy old MSB into new MSB.
SHRShift each bit of operand right by specified number of bits and put zero in MSB position.

Branch Instructions

It is also called program execution transfer instruction. Instructions of this group transfer program execution from the normal sequence of instructions to the specified destination or target. The following instructions come under this category:

InstructionDescription
JA or JNBEJump if above, not below, or equal i.e. when CF and ZF = 0
JAE/JNB/JNCJump if above, not below, equal or no carry i.e. when CF = 0
JB/JNAE/JCJump if below, not above, equal or carry i.e. when CF = 0
JBE/JNAJump if below, not above, or equal i.e. when CF and ZF = 1
JCXZJump if CX register = 0
JE/JZJump if zero or equal i.e. when ZF = 1
JG/JNLEJump if greater, not less or equal i.e. when ZF = 0 and CF = OF
JGE/JNLJump if greater, not less or equal i.e. when SF = OF
JL/JNGEJump if less, not greater than or equal i.e. when SF ≠ OF
JLE/JNGJump if less, equal or not greater i.e. when ZF = 1 and SF ≠ OF
JMPCauses the program execution to jump unconditionally to the memory address or label given in the instruction.
CALLCalls a procedure whose address is given in the instruction and saves their return address to the stack.
RETReturns program execution from a procedure (subroutine) to the next instruction or main program.
IRETReturns program execution from an interrupt service procedure (subroutine) to the main program.
INTUsed to generate software interrupt at the desired point in a program.
INTOSoftware interrupts to indicate overflow after arithmetic operation.
LOOPJump to defined label until CX = 0.
LOOPZ/LOOPEDecrement CX register and jump if CX ≠ 0 and ZF = 1.
LOOPNZ/LOOPNEDecrement CX register and jump if CX ≠ 0 and ZF = 0.

Here, CF = Carry Flag
ZF = Zero Flag
OF = Overflow Flag
SF = Sign Flag
CX = Register

Flag Manipulation and Processor Control Instructions

Instructions of this instruction set are related to flag manipulation and machine control. The following instructions come under this category:

InstructionDescription
CLCClear Carry Flag: This instruction resets the carry flag CF to 0.
CLDClear Direction Flag: This instruction resets the direction flag DF to 0.
CLIClear Interrupt Flag: This instruction resets the interrupt flag IF to 0.
CMCThis instruction take complement of carry flag CF.
STCSet carry flag CF to 1.
STDSet direction flag to 1.
STISet interrupt flag IF to 1.
HLTHalt processing. It stops program execution.
NOPPerforms no operation.
ESCEscape: makes bus free for external master like a coprocessor or peripheral device.
WAITWhen WAIT instruction is executed, the processor enters an idle state in which the processor does no processing.
LOCKIt is a prefix instruction. It makes the LOCK pin low till the execution of the next instruction.

String Instructions

String is series of bytes or series of words stored in sequential memory locations. The 8086 provides some instructions which handle string operations such as string movement, comparison, scan, load and store.

The following instructions come under this category:

InstructionDescription
MOVS/MOVSB/MOVSWMoves 8-bit or 16-bit data from the memory location(s) addressed by SI register to the memory location addressed by DI register.
CMPS/CMPSB/CMPSWCompares the content of memory location addressed by DI register with the content of memory location addressed by SI register.
SCAS/SCASB/SCASWCompares the content of accumulator with the content of memory location addressed by DI register in the extra segment ES.
LODS/LODSB/LODSWLoads 8-bit or 16-bit data from memory location addressed by SI register into AL or AX register.
STOS/STOSB/STOSWStores 8-bit or 16-bit data from AL or AX register in the memory location addressed by DI register.
REPRepeats the given instruction until CX ≠ 0
REPE/ REPZRepeats the given instruction till CX ≠ 0 and ZF = 1
REPNE/REPNZRepeats the given instruction till CX ≠ 0 and ZF = 0

Next Topic#




Latest Courses