Page 1
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 1
Gursharan Singh
mailme@gursharansingh.in
Maninder Kaur
mailme@maninderkaur.in
www.eazynotes.com
Instruction Set of 8086
? An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
? The entire group of instructions that a
microprocessor supports is called
Instruction Set.
? 8086 has more than 20,000 instructions.
12-Dec-11 2
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Classification of Instruction Set
? Data Transfer Instructions
? Arithmetic Instructions
? Bit Manipulation Instructions
? Program Execution Transfer Instructions
? String Instructions
? Processor Control Instructions
12-Dec-11 3
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? These instructions are used to transfer data
from source to destination.
? The operand can be a constant, memory
location, register or I/O port address.
12-Dec-11 4
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? MOV Des, Src:
? Src operand can be register, memory location or immediate
operand.
? Des can be register or memory operand.
? Both Src and Des cannot be memory location at the same
time.
? E.g.:
? MOV CX, 037A H
? MOV AL, BL
? MOV BX, [0301 H]
12-Dec-11 5
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? PUSH Operand:
? It pushes the operand into top of stack.
? E.g.: PUSH BX
? POP Des:
? It pops the operand from top of stack to Des.
? Des can be a general purpose register, segment register
(except CS) or memory location.
? E.g.: POP AX
12-Dec-11 6
Gursharan Singh
Maninder Kaur
Page 2
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 1
Gursharan Singh
mailme@gursharansingh.in
Maninder Kaur
mailme@maninderkaur.in
www.eazynotes.com
Instruction Set of 8086
? An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
? The entire group of instructions that a
microprocessor supports is called
Instruction Set.
? 8086 has more than 20,000 instructions.
12-Dec-11 2
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Classification of Instruction Set
? Data Transfer Instructions
? Arithmetic Instructions
? Bit Manipulation Instructions
? Program Execution Transfer Instructions
? String Instructions
? Processor Control Instructions
12-Dec-11 3
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? These instructions are used to transfer data
from source to destination.
? The operand can be a constant, memory
location, register or I/O port address.
12-Dec-11 4
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? MOV Des, Src:
? Src operand can be register, memory location or immediate
operand.
? Des can be register or memory operand.
? Both Src and Des cannot be memory location at the same
time.
? E.g.:
? MOV CX, 037A H
? MOV AL, BL
? MOV BX, [0301 H]
12-Dec-11 5
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? PUSH Operand:
? It pushes the operand into top of stack.
? E.g.: PUSH BX
? POP Des:
? It pops the operand from top of stack to Des.
? Des can be a general purpose register, segment register
(except CS) or memory location.
? E.g.: POP AX
12-Dec-11 6
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 2
www.eazynotes.com
Data Transfer Instructions
? XCHG Des, Src:
? This instruction exchanges Src with Des.
? It cannot exchange two memory locations directly.
? E.g.: XCHG DX, AX
12-Dec-11 7
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? IN Accumulator, Port Address:
? It transfers the operand from specified port to accumulator
register.
? E.g.: IN AX, 0028 H
? OUT Port Address, Accumulator:
? It transfers the operand from accumulator to specified port.
? E.g.: OUT 0028 H, AX
12-Dec-11 8
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
?LEA Register, Src:
? It loads a 16-bit register with the offset
address of the data specified by the Src.
? E.g.: LEA BX, [DI]
? This instruction loads the contents of DI
(offset) into the BX register.
12-Dec-11 9
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LDS Des, Src:
? It loads 32-bit pointer from memory source to
destination register and DS.
? The offset is placed in the destination register and the
segment is placed in DS.
? To use this instruction the word at the lower memory
address must contain the offset and the word at the
higher address must contain the segment.
? E.g.: LDS BX, [0301 H]
12-Dec-11 10
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? LES Des, Src:
? It loads 32-bit pointer from memory source to
destination register and ES.
? The offset is placed in the destination register and the
segment is placed in ES.
? This instruction is very similar to LDS except that it
initializes ES instead of DS.
? E.g.: LES BX, [0301 H]
12-Dec-11 11
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LAHF:
? It copies the lower byte of flag register to AH.
? SAHF:
? It copies the contents of AH to lower byte of flag register.
? PUSHF:
? Pushes flag register to top of stack.
? POPF:
? Pops the stack top to flag register.
12-Dec-11 12
Gursharan Singh
Maninder Kaur
Page 3
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 1
Gursharan Singh
mailme@gursharansingh.in
Maninder Kaur
mailme@maninderkaur.in
www.eazynotes.com
Instruction Set of 8086
? An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
? The entire group of instructions that a
microprocessor supports is called
Instruction Set.
? 8086 has more than 20,000 instructions.
12-Dec-11 2
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Classification of Instruction Set
? Data Transfer Instructions
? Arithmetic Instructions
? Bit Manipulation Instructions
? Program Execution Transfer Instructions
? String Instructions
? Processor Control Instructions
12-Dec-11 3
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? These instructions are used to transfer data
from source to destination.
? The operand can be a constant, memory
location, register or I/O port address.
12-Dec-11 4
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? MOV Des, Src:
? Src operand can be register, memory location or immediate
operand.
? Des can be register or memory operand.
? Both Src and Des cannot be memory location at the same
time.
? E.g.:
? MOV CX, 037A H
? MOV AL, BL
? MOV BX, [0301 H]
12-Dec-11 5
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? PUSH Operand:
? It pushes the operand into top of stack.
? E.g.: PUSH BX
? POP Des:
? It pops the operand from top of stack to Des.
? Des can be a general purpose register, segment register
(except CS) or memory location.
? E.g.: POP AX
12-Dec-11 6
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 2
www.eazynotes.com
Data Transfer Instructions
? XCHG Des, Src:
? This instruction exchanges Src with Des.
? It cannot exchange two memory locations directly.
? E.g.: XCHG DX, AX
12-Dec-11 7
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? IN Accumulator, Port Address:
? It transfers the operand from specified port to accumulator
register.
? E.g.: IN AX, 0028 H
? OUT Port Address, Accumulator:
? It transfers the operand from accumulator to specified port.
? E.g.: OUT 0028 H, AX
12-Dec-11 8
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
?LEA Register, Src:
? It loads a 16-bit register with the offset
address of the data specified by the Src.
? E.g.: LEA BX, [DI]
? This instruction loads the contents of DI
(offset) into the BX register.
12-Dec-11 9
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LDS Des, Src:
? It loads 32-bit pointer from memory source to
destination register and DS.
? The offset is placed in the destination register and the
segment is placed in DS.
? To use this instruction the word at the lower memory
address must contain the offset and the word at the
higher address must contain the segment.
? E.g.: LDS BX, [0301 H]
12-Dec-11 10
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? LES Des, Src:
? It loads 32-bit pointer from memory source to
destination register and ES.
? The offset is placed in the destination register and the
segment is placed in ES.
? This instruction is very similar to LDS except that it
initializes ES instead of DS.
? E.g.: LES BX, [0301 H]
12-Dec-11 11
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LAHF:
? It copies the lower byte of flag register to AH.
? SAHF:
? It copies the contents of AH to lower byte of flag register.
? PUSHF:
? Pushes flag register to top of stack.
? POPF:
? Pops the stack top to flag register.
12-Dec-11 12
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 3
www.eazynotes.com
Arithmetic Instructions
? ADD Des, Src:
? It adds a byte to byte or a word to word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADD AL, 74H
? ADD DX, AX
? ADD AX, [BX]
12-Dec-11 13
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? ADC Des, Src:
? It adds the two operands with CF.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADC AL, 74H
? ADC DX, AX
? ADC AX, [BX]
12-Dec-11 14
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? SUB Des, Src:
? It subtracts a byte from byte or a word from word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? For subtraction, CF acts as borrow flag.
? E.g.:
? SUB AL, 74H
? SUB DX, AX
? SUB AX, [BX]
12-Dec-11 15
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? SBB Des, Src:
? It subtracts the two operands and also the
borrow from the result.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? SBB AL, 74H
? SBB DX, AX
? SBB AX, [BX]
12-Dec-11 16
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? INC Src:
? It increments the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: INC AX
12-Dec-11 17
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DEC Src:
? It decrements the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: DEC AX
12-Dec-11 18
Gursharan Singh
Maninder Kaur
Page 4
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 1
Gursharan Singh
mailme@gursharansingh.in
Maninder Kaur
mailme@maninderkaur.in
www.eazynotes.com
Instruction Set of 8086
? An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
? The entire group of instructions that a
microprocessor supports is called
Instruction Set.
? 8086 has more than 20,000 instructions.
12-Dec-11 2
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Classification of Instruction Set
? Data Transfer Instructions
? Arithmetic Instructions
? Bit Manipulation Instructions
? Program Execution Transfer Instructions
? String Instructions
? Processor Control Instructions
12-Dec-11 3
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? These instructions are used to transfer data
from source to destination.
? The operand can be a constant, memory
location, register or I/O port address.
12-Dec-11 4
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? MOV Des, Src:
? Src operand can be register, memory location or immediate
operand.
? Des can be register or memory operand.
? Both Src and Des cannot be memory location at the same
time.
? E.g.:
? MOV CX, 037A H
? MOV AL, BL
? MOV BX, [0301 H]
12-Dec-11 5
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? PUSH Operand:
? It pushes the operand into top of stack.
? E.g.: PUSH BX
? POP Des:
? It pops the operand from top of stack to Des.
? Des can be a general purpose register, segment register
(except CS) or memory location.
? E.g.: POP AX
12-Dec-11 6
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 2
www.eazynotes.com
Data Transfer Instructions
? XCHG Des, Src:
? This instruction exchanges Src with Des.
? It cannot exchange two memory locations directly.
? E.g.: XCHG DX, AX
12-Dec-11 7
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? IN Accumulator, Port Address:
? It transfers the operand from specified port to accumulator
register.
? E.g.: IN AX, 0028 H
? OUT Port Address, Accumulator:
? It transfers the operand from accumulator to specified port.
? E.g.: OUT 0028 H, AX
12-Dec-11 8
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
?LEA Register, Src:
? It loads a 16-bit register with the offset
address of the data specified by the Src.
? E.g.: LEA BX, [DI]
? This instruction loads the contents of DI
(offset) into the BX register.
12-Dec-11 9
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LDS Des, Src:
? It loads 32-bit pointer from memory source to
destination register and DS.
? The offset is placed in the destination register and the
segment is placed in DS.
? To use this instruction the word at the lower memory
address must contain the offset and the word at the
higher address must contain the segment.
? E.g.: LDS BX, [0301 H]
12-Dec-11 10
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? LES Des, Src:
? It loads 32-bit pointer from memory source to
destination register and ES.
? The offset is placed in the destination register and the
segment is placed in ES.
? This instruction is very similar to LDS except that it
initializes ES instead of DS.
? E.g.: LES BX, [0301 H]
12-Dec-11 11
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LAHF:
? It copies the lower byte of flag register to AH.
? SAHF:
? It copies the contents of AH to lower byte of flag register.
? PUSHF:
? Pushes flag register to top of stack.
? POPF:
? Pops the stack top to flag register.
12-Dec-11 12
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 3
www.eazynotes.com
Arithmetic Instructions
? ADD Des, Src:
? It adds a byte to byte or a word to word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADD AL, 74H
? ADD DX, AX
? ADD AX, [BX]
12-Dec-11 13
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? ADC Des, Src:
? It adds the two operands with CF.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADC AL, 74H
? ADC DX, AX
? ADC AX, [BX]
12-Dec-11 14
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? SUB Des, Src:
? It subtracts a byte from byte or a word from word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? For subtraction, CF acts as borrow flag.
? E.g.:
? SUB AL, 74H
? SUB DX, AX
? SUB AX, [BX]
12-Dec-11 15
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? SBB Des, Src:
? It subtracts the two operands and also the
borrow from the result.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? SBB AL, 74H
? SBB DX, AX
? SBB AX, [BX]
12-Dec-11 16
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? INC Src:
? It increments the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: INC AX
12-Dec-11 17
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DEC Src:
? It decrements the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: DEC AX
12-Dec-11 18
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 4
www.eazynotes.com
Arithmetic Instructions
? AAA (ASCII Adjust after Addition):
? The data entered from the terminal is in ASCII format.
? In ASCII, 0 – 9 are represented by 30H – 39H.
? This instruction allows us to add the ASCII codes.
? This instruction does not have any operand.
? Other ASCII Instructions:
? AAS (ASCII Adjust after Subtraction)
? AAM (ASCII Adjust after Multiplication)
? AAD (ASCII Adjust Before Division)
12-Dec-11 19
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DAA (Decimal Adjust after Addition)
? It is used to make sure that the result of adding two BCD
numbers is adjusted to be a correct BCD number.
? It only works on AL register.
? DAS (Decimal Adjust after Subtraction)
? It is used to make sure that the result of subtracting two
BCD numbers is adjusted to be a correct BCD number.
? It only works on AL register.
12-Dec-11 20
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? NEG Src:
? It creates 2’s complement of a given
number.
? That means, it changes the sign of a
number.
12-Dec-11 21
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? CMP Des, Src:
? It compares two specified bytes or words.
? The Src and Des can be a constant, register or memory
location.
? Both operands cannot be a memory location at the same
time.
? The comparison is done simply by internally subtracting
the source from destination.
? The value of source and destination does not change, but
the flags are modified to indicate the result.
12-Dec-11 22
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? MUL Src:
? It is an unsigned multiplication instruction.
? It multiplies two bytes to produce a word or two words to
produce a double word.
? AX = AL * Src
? DX : AX = AX * Src
? This instruction assumes one of the operand in AL or AX.
? Src can be a register or memory location.
? IMUL Src:
? It is a signed multiplication instruction.
12-Dec-11 23
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DIV Src:
? It is an unsigned division instruction.
? It divides word by byte or double word by word.
? The operand is stored in AX, divisor is Src and the
result is stored as:
? AH = remainder AL = quotient
? IDIV Src:
? It is a signed division instruction.
12-Dec-11 24
Gursharan Singh
Maninder Kaur
Page 5
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 1
Gursharan Singh
mailme@gursharansingh.in
Maninder Kaur
mailme@maninderkaur.in
www.eazynotes.com
Instruction Set of 8086
? An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
? The entire group of instructions that a
microprocessor supports is called
Instruction Set.
? 8086 has more than 20,000 instructions.
12-Dec-11 2
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Classification of Instruction Set
? Data Transfer Instructions
? Arithmetic Instructions
? Bit Manipulation Instructions
? Program Execution Transfer Instructions
? String Instructions
? Processor Control Instructions
12-Dec-11 3
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? These instructions are used to transfer data
from source to destination.
? The operand can be a constant, memory
location, register or I/O port address.
12-Dec-11 4
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? MOV Des, Src:
? Src operand can be register, memory location or immediate
operand.
? Des can be register or memory operand.
? Both Src and Des cannot be memory location at the same
time.
? E.g.:
? MOV CX, 037A H
? MOV AL, BL
? MOV BX, [0301 H]
12-Dec-11 5
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? PUSH Operand:
? It pushes the operand into top of stack.
? E.g.: PUSH BX
? POP Des:
? It pops the operand from top of stack to Des.
? Des can be a general purpose register, segment register
(except CS) or memory location.
? E.g.: POP AX
12-Dec-11 6
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 2
www.eazynotes.com
Data Transfer Instructions
? XCHG Des, Src:
? This instruction exchanges Src with Des.
? It cannot exchange two memory locations directly.
? E.g.: XCHG DX, AX
12-Dec-11 7
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? IN Accumulator, Port Address:
? It transfers the operand from specified port to accumulator
register.
? E.g.: IN AX, 0028 H
? OUT Port Address, Accumulator:
? It transfers the operand from accumulator to specified port.
? E.g.: OUT 0028 H, AX
12-Dec-11 8
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
?LEA Register, Src:
? It loads a 16-bit register with the offset
address of the data specified by the Src.
? E.g.: LEA BX, [DI]
? This instruction loads the contents of DI
(offset) into the BX register.
12-Dec-11 9
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LDS Des, Src:
? It loads 32-bit pointer from memory source to
destination register and DS.
? The offset is placed in the destination register and the
segment is placed in DS.
? To use this instruction the word at the lower memory
address must contain the offset and the word at the
higher address must contain the segment.
? E.g.: LDS BX, [0301 H]
12-Dec-11 10
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Data Transfer Instructions
? LES Des, Src:
? It loads 32-bit pointer from memory source to
destination register and ES.
? The offset is placed in the destination register and the
segment is placed in ES.
? This instruction is very similar to LDS except that it
initializes ES instead of DS.
? E.g.: LES BX, [0301 H]
12-Dec-11 11
Gursharan Singh
Maninder Kaur www.eazynotes.com
Data Transfer Instructions
? LAHF:
? It copies the lower byte of flag register to AH.
? SAHF:
? It copies the contents of AH to lower byte of flag register.
? PUSHF:
? Pushes flag register to top of stack.
? POPF:
? Pops the stack top to flag register.
12-Dec-11 12
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 3
www.eazynotes.com
Arithmetic Instructions
? ADD Des, Src:
? It adds a byte to byte or a word to word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADD AL, 74H
? ADD DX, AX
? ADD AX, [BX]
12-Dec-11 13
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? ADC Des, Src:
? It adds the two operands with CF.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? ADC AL, 74H
? ADC DX, AX
? ADC AX, [BX]
12-Dec-11 14
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? SUB Des, Src:
? It subtracts a byte from byte or a word from word.
? It effects AF, CF, OF, PF, SF, ZF flags.
? For subtraction, CF acts as borrow flag.
? E.g.:
? SUB AL, 74H
? SUB DX, AX
? SUB AX, [BX]
12-Dec-11 15
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? SBB Des, Src:
? It subtracts the two operands and also the
borrow from the result.
? It effects AF, CF, OF, PF, SF, ZF flags.
? E.g.:
? SBB AL, 74H
? SBB DX, AX
? SBB AX, [BX]
12-Dec-11 16
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? INC Src:
? It increments the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: INC AX
12-Dec-11 17
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DEC Src:
? It decrements the byte or word by one.
? The operand can be a register or memory
location.
? It effects AF, OF, PF, SF, ZF flags.
? CF is not effected.
? E.g.: DEC AX
12-Dec-11 18
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 4
www.eazynotes.com
Arithmetic Instructions
? AAA (ASCII Adjust after Addition):
? The data entered from the terminal is in ASCII format.
? In ASCII, 0 – 9 are represented by 30H – 39H.
? This instruction allows us to add the ASCII codes.
? This instruction does not have any operand.
? Other ASCII Instructions:
? AAS (ASCII Adjust after Subtraction)
? AAM (ASCII Adjust after Multiplication)
? AAD (ASCII Adjust Before Division)
12-Dec-11 19
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DAA (Decimal Adjust after Addition)
? It is used to make sure that the result of adding two BCD
numbers is adjusted to be a correct BCD number.
? It only works on AL register.
? DAS (Decimal Adjust after Subtraction)
? It is used to make sure that the result of subtracting two
BCD numbers is adjusted to be a correct BCD number.
? It only works on AL register.
12-Dec-11 20
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? NEG Src:
? It creates 2’s complement of a given
number.
? That means, it changes the sign of a
number.
12-Dec-11 21
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? CMP Des, Src:
? It compares two specified bytes or words.
? The Src and Des can be a constant, register or memory
location.
? Both operands cannot be a memory location at the same
time.
? The comparison is done simply by internally subtracting
the source from destination.
? The value of source and destination does not change, but
the flags are modified to indicate the result.
12-Dec-11 22
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Arithmetic Instructions
? MUL Src:
? It is an unsigned multiplication instruction.
? It multiplies two bytes to produce a word or two words to
produce a double word.
? AX = AL * Src
? DX : AX = AX * Src
? This instruction assumes one of the operand in AL or AX.
? Src can be a register or memory location.
? IMUL Src:
? It is a signed multiplication instruction.
12-Dec-11 23
Gursharan Singh
Maninder Kaur www.eazynotes.com
Arithmetic Instructions
? DIV Src:
? It is an unsigned division instruction.
? It divides word by byte or double word by word.
? The operand is stored in AX, divisor is Src and the
result is stored as:
? AH = remainder AL = quotient
? IDIV Src:
? It is a signed division instruction.
12-Dec-11 24
Gursharan Singh
Maninder Kaur
Gursharan Singh
Maninder Kaur
12-Dec-11
www.eazynotes.com 5
www.eazynotes.com
Arithmetic Instructions
? CBW (Convert Byte to Word):
? This instruction converts byte in AL to word in AX.
? The conversion is done by extending the sign bit of AL
throughout AH.
? CWD (Convert Word to Double Word):
? This instruction converts word in AX to double word in
DX : AX.
? The conversion is done by extending the sign bit of AX
throughout DX.
12-Dec-11 25
Gursharan Singh
Maninder Kaur www.eazynotes.com
Bit Manipulation Instructions
? These instructions are used at the bit level.
? These instructions can be used for:
? Testing a zero bit
? Set or reset a bit
? Shift bits across registers
12-Dec-11 26
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Bit Manipulation Instructions
? NOT Src:
? It complements each bit of Src to produce 1’s
complement of the specified operand.
? The operand can be a register or memory location.
12-Dec-11 27
Gursharan Singh
Maninder Kaur www.eazynotes.com
Bit Manipulation Instructions
? AND Des, Src:
? It performs AND operation of Des and Src.
? Src can be immediate number, register or memory
location.
? Des can be register or memory location.
? Both operands cannot be memory locations at the same
time.
? CF and OF become zero after the operation.
? PF, SF and ZF are updated.
12-Dec-11 28
Gursharan Singh
Maninder Kaur
www.eazynotes.com
Bit Manipulation Instructions
? OR Des, Src:
? It performs OR operation of Des and Src.
? Src can be immediate number, register or memory
location.
? Des can be register or memory location.
? Both operands cannot be memory locations at the same
time.
? CF and OF become zero after the operation.
? PF, SF and ZF are updated.
12-Dec-11 29
Gursharan Singh
Maninder Kaur www.eazynotes.com
Bit Manipulation Instructions
? XOR Des, Src:
? It performs XOR operation of Des and Src.
? Src can be immediate number, register or memory
location.
? Des can be register or memory location.
? Both operands cannot be memory locations at the same
time.
? CF and OF become zero after the operation.
? PF, SF and ZF are updated.
12-Dec-11 30
Gursharan Singh
Maninder Kaur
Read More