SlideShare a Scribd company logo
Arithmetic Instructions
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]
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]
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]
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]
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
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
DAA (Decimal Adjust Accumulator)
Syntax :-- DAA
• This instruction is used to convert the result of the
addition of two packed BCD numbers to a valid BCD
number.
• The result has to be only in AL.
• After addition if the lower nibble is greater than 9 or
AF =1, it will add 06H to the lower nibble in AL.
• After this addition, if the upper nibble is greater than
9 or if CF = 1, DAA instruction adds 60H to AL.
• DAA instruction affects AF,CF,PF and ZF. OF is
undefined.
DAA Instruction contd..
• Operation Performed :--
– If lower nibble of AL > 9 or AF =1 then AL = AL +06
– If higher nibble of AL > 9 or CF =1 then AL = AL +60
Numeric Examples
AL = 53H, CL = 29H
ADD AL,CL ; AL  (AL) + (CL)
;AL  53 + 29
;AL  7CH
DAA ; AL 7C +06 (as C>9)
;AL 82
Numeric Examples
AL = 73H, CL = 29H
ADD AL,CL ; AL  (AL) + (CL)
;AL  73 + 29
;AL  9CH
DAA ; AL 02 and CF = 1 (as C>9)
DAS (Decimal Adjust After Subtraction)
Syntax :-- DAS
• This instruction is used to convert the result of the
subtraction of two packed BCD numbers to a valid BCD
number.
• The subtraction has to be only in AL.
• After subtraction if the lower nibble is greater than 9
or AF =1, it will subtract 06H from the lower nibble in
AL.
• If the result of the subtraction sets the carry flag or if
the upper nibble is greater than 9, DAS instruction
subtracts 60H from AL.
• DAS instruction affects AF,CF,PF and ZF. OF is
undefined.
DAS Instruction contd..
• Operation Performed :--
– If lower nibble of AL > 9 or AF =1 then AL = AL -06
– If higher nibble of AL > 9 or CF =1 then AL = AL -60
Numeric Examples
AL = 75, BH = 46
SUB AL,BH ; AL  (AL) - (BH)
;AL  75 - 46
;AL  2FH
; AF = 1
DAS ; AL 2F - 06 (as F>9)
;AL 29
Numeric Examples
AL = 38, BH = 61
SUB AL,BH ; AL  (AL) - (BH)
;AL  38 - 61
;AL  D7H
; CF = 1
DAS ; AL D7 - 60 (as D>9)
;AL 77
NEG ( Negate )
Syntax :-- NEG destination
• This instruction replaces the number in the
destination with the 2’s complement of that number.
• For obtaining the 2’s complement, it subtracts the
contents of destination from zero.
•The result is stored back in the destination which may
be a register or a memory location
• If OF =1, it indicates that the operation could not be
completed successfully.
• NEG instruction affects all conditional flags.
MUL (Unsigned multiplication)
Syntax :-- MUL source
• This instruction multiplies an unsigned byte
from source with an unsigned byte in AL
register
or
unsigned word from source with an unsigned
word in AX register.
• The source can be a register or memory
location but cannot be an immediate data.
MUL (Unsigned multiplication) Contd..
•When a byte is multiplied with a byte in AL, the
result is stored in AX.
• When a word is multiplied with a word in AX, the
MSW (Most Significant Word ) of the result is stored
in DX and the LSW (Least Significant Word ) of the
result is stored in AX.
• If MS Byte or Word of the result is zero, CF and OF
both will be set.
•All other flags are modified depending upon the
result
• Operation Performed :--
– If source is byte then AX  AL * unsigned 8 bit
source
– If source is word then DX, AX  AX * unsigned 16
bit source
Examples :--
1. MUL BL ; Multiply AL by BL & the result in AX
2. MUL CX ; Multiply AX by CX & the result in DX,AX
3. MUL Byte PTR [SI] ; AX  AL * [SI]
MUL (Unsigned multiplication) Contd..
IMUL (Signed multiplication)
Syntax :-- IMUL source
• This instruction multiplies a signed byte from
source with a signed byte in AL register
or
signed word from source with an signed word
in AX register.
• The source can be a register, general purpose,
base or index, or memory location, but cannot
be an immediate data.
IMUL (Signed multiplication) Contd..
•When a byte is multiplied with a byte in
AL, the result is stored in AX.
• When a word is multiplied with a word
in AX, the MSW (Most Significant Word )
of the result is stored in DX and the LSW
(Least Significant Word ) of the result is
stored in AX.
IMUL (Signed multiplication) Contd..
•If the magnitude of the product does not
require all the bits of the destination, the
unused bits are filled with copies of the sign
bit.
•If AH and DX contain parts of the 16 & 32 bit
results, CF and OF are set, If the unused bits
are filled by the sign bit, OF and CF are
cleared.
• Operation Performed :--
– If source is byte then AX  AL * signed 8 bit
source
– If source is word then DX, AX  AX * signed 16 bit
source
Examples :--
1. IMUL BL ; Multiply AL by BL & the result in AX
2. IMUL CX ; Multiply AX by CX & the result in DX,AX
3. IMUL Byte PTR [SI] ; AX  AL * [SI]
IMUL (Signed multiplication) Contd..
DIV (Unsigned Division)
Syntax :-- DIV source
• This instruction divides an unsigned word (16Bits)
in AX register by an unsigned byte (8Bits) from
source
or
an unsigned double word (32 bits) in DX & AX
register by an unsigned word (16bits) from source
• The source can be a register or memory location
but cannot be an immediate data.
DIV (Unsigned Division)Contd..
•When a word in AX is divided by a byte,
AL will contain the 8 bit quotient and AH
will contain an 8 bit remainder.
• When a double word in DX (MSW) &
AX (LSW) is divided by a word, AX will
contain the 16 bit quotient and DX will
contain an 16 bit remainder.
DIV (Unsigned Division)Contd..
•If a byte is to be divided by a byte, AL is
loaded with dividend and AH is filled with all
0’s.
•If a word is to be divided by a word, Ax is
loaded with dividend and DX is filled with all
0’s.
•If an attempt is made to divide by 0, or the
quotient is too large (FF or FFFF), type 0
interrupt is generated.
•No flags are affected.
• Operation Performed :--
–If source is byte then
• AL  AX / unsigned 8 bit source ; (quotient)
• AH  AX MOD unsigned 8 bit source ;
(remainder)
–If source is word then
• AX  DX:AX / unsigned 16 bit source ;
(quotient)
• DX  DX:AX MOD unsigned 16 bit source ;
(remainder)
DIV (Unsigned Division)Contd..
Examples :--
1. DIV BL ; Divide word in AX by byte in
BL, Quotient in AL, remainder
in AH.
2. DIV CX ; Divide double word in DX:AX
by word in CX, Quotient in AX,
Remainder in DX.
3. DIV [BX] ; Divide word in AX by byte in
memory location pointer by
BX.
DIV (Unsigned Division)Contd..
CBW (Convert Signed Byte to Word)
Syntax :-- CBW
• This instruction converts a signed byte
to a signed word.
•This instruction copies the sign of a byte
in AL to all the bits in AH.
• AH is then said to be the sign extension
of AL.
•CBW operation is done before
performing division of a signed byte in
the AL by another signed byte with IDIV
instruction.
CBW (Convert Signed Byte to Word) contd..
Operation :--
• AH  filled with 8th bit of AL i.e., D7
This does not affect any flags.
Example :--
If AX = 009BH, (00000000 10011011
After CBW Instruction,
AX =FF9B (11111111 10011011)
CWD (Convert Signed Word to Double Word)
Syntax :-- CWD
• This instruction copies the sign bit of a
word in AX to all the bits in DX.
• Thus the sign of AX is said to be
extended to DX.
•CWD operation is done before
performing division of a signed word in
the AX by another signed word with IDIV
instruction.
CWD (Convert Signed Word to Double Word) contd..
Operation :--
• DX filled with 16th bit of AX i.e., D15
This does not affect any flags.
Example :--
If DX = 0000H (00000000 00000000)
If AX = F0C7H, (11110000 11000111)
After CWD Instruction,
DX = FFFFH (11111111 11111111)
AX =F0C7 (11110000 11000111)
IDIV (Signed Division)
Syntax :-- IDIV source
• This instruction divides an signed word
(16Bits) in AX register by an signed byte (8Bits)
from source
or
An signed double word (32 bits) in DX & AX
register by an signed word (16bits) from
source
• The source can be a register or memory
location but cannot be an immediate data.
IDIV (Signed Division)Contd..
•When a word in AX is divided by a byte,
AL will contain the 8 bit quotient and AH
will contain an 8 bit remainder.
• When a double word in DX (MSW) &
AX (LSW) is divided by a word, AX will
contain the 16 bit quotient and DX will
contain an 16 bit remainder.
IDIV (Signed Division)Contd..
•If a byte is to be divided by a byte, AL is
loaded with dividend and AH is filled with all
0’s.
•If a word is to be divided by a word, Ax is
loaded with dividend and DX is filled with all
0’s.
•If an attempt is made to divide by 0, or the
quotient is too large (FF or FFFF), type 0
interrupt is generated.
•No flags are affected.
• Operation Performed :--
–If source is byte then
• AL  AX / unsigned 8 bit source ; (quotient)
• AH  AX MOD unsigned 8 bit source ;
(remainder)
–If source is byte then
• AX  DX:AX / unsigned 16 bit source ;
(quotient)
• DX  DX:AX MOD unsigned 16 bit source ;
(remainder)
IDIV (Signed Division)Contd..
Examples :--
1. IDIV BL ; Divide signed word in AX by
signed byte in BL, Quotient in
AL, remainder in AH.
2. IDIV CX ; Divide signed double word in
DX:AX by signed word in CX,
Quotient in AX, Remainder in
DX.
3. IDIV [BX] ; Divide signed word in AX by
signed byte in memory
location pointer by BX.
IDIV (Signed Division)Contd..
Example of division of a signed byte with
signed byte :--
MOV BL,divisor ; Load signed byte divisor in BL
MOV AL,dividend ; Load signed byte dividend in AL
CBW ;Extend sign of AL into AH
IDIV BL ; Byte division, Remainder in AH
and quotient in AL

More Related Content

PPTX
8086 ins2 math
PPTX
Chap3 8086 artithmetic
DOCX
Notes arithmetic instructions
PDF
8086 instruction set
PPTX
DAA AND DAS
PPTX
8086 Instruction set
PPTX
Ascii adjust & decimal adjust
PPT
Shift rotate
8086 ins2 math
Chap3 8086 artithmetic
Notes arithmetic instructions
8086 instruction set
DAA AND DAS
8086 Instruction set
Ascii adjust & decimal adjust
Shift rotate

What's hot (20)

PDF
8086 Microprocessor Instruction set
PPT
Assignment on alp
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
PPTX
Arithmetic and logical instructions set
PPTX
Logical instructions (and, or, xor, not, test)
PPTX
Instruction sets of 8086
PPTX
Push down automata
DOCX
Instruction set of 8086 Microprocessor
PDF
Chapter 5The proessor status and the FLAGS registers
PPTX
Arithmetic instructions
PPT
Instruction set of 8086
PDF
8086 instruction set with types
PDF
Unit 3 – assembly language programming
PDF
chapter 7 Logic, shift and rotate instructions
PDF
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
PDF
8086 instruction set
PPTX
PPTX
push down automata
8086 Microprocessor Instruction set
Assignment on alp
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Arithmetic and logical instructions set
Logical instructions (and, or, xor, not, test)
Instruction sets of 8086
Push down automata
Instruction set of 8086 Microprocessor
Chapter 5The proessor status and the FLAGS registers
Arithmetic instructions
Instruction set of 8086
8086 instruction set with types
Unit 3 – assembly language programming
chapter 7 Logic, shift and rotate instructions
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
8086 instruction set
push down automata
Ad

Similar to Arithmetic instrctions (20)

PPTX
Chapter 3 8086 ins2 math
PDF
8086 instructions
PDF
Instructionsetof8086 180224060745(3)
DOCX
Instruction set of 8086
PPT
Unit 2 8086 Instruction set.ppt notes good
PPT
Instruction set
PDF
Chapter 4 instruction set of 8086 microprocessor.pdf
PDF
Chapter 5 and 6 instructions and program control instructions.pdf
PPTX
instructionsetsofjdtufgmictfgfjh8086.pptx
PPT
Cha_2b_8086-Instruction-set-ppt microprocessor
PPTX
Microprocessor.pptx
PPTX
Mastering Assembly Language: Programming with 8086
PDF
8086 instruction set
PPTX
Mod-2.pptx
PDF
PDF
Lecture5(1)
PPT
Instruction set Madha Insstitute of Engineering
PPTX
Module 2 (1).pptx
PPTX
microcomputer architecture - Arithmetic instruction
PPTX
Microprocessor 8086 instruction description
Chapter 3 8086 ins2 math
8086 instructions
Instructionsetof8086 180224060745(3)
Instruction set of 8086
Unit 2 8086 Instruction set.ppt notes good
Instruction set
Chapter 4 instruction set of 8086 microprocessor.pdf
Chapter 5 and 6 instructions and program control instructions.pdf
instructionsetsofjdtufgmictfgfjh8086.pptx
Cha_2b_8086-Instruction-set-ppt microprocessor
Microprocessor.pptx
Mastering Assembly Language: Programming with 8086
8086 instruction set
Mod-2.pptx
Lecture5(1)
Instruction set Madha Insstitute of Engineering
Module 2 (1).pptx
microcomputer architecture - Arithmetic instruction
Microprocessor 8086 instruction description
Ad

More from HarshitParkar6677 (20)

PPTX
Wi fi hacking
PPT
D dos attack
DOCX
Notes chapter 6
DOC
Interface notes
PPTX
Chapter6 2
PPTX
PPT
8086 cpu 1
DOC
Chapter 6 notes
DOC
Chapter 5 notes
PPTX
Chap6 procedures & macros
DOC
Chapter 5 notes new
DOCX
Notes all instructions
DOCX
Notes aaa aa
DOCX
Notes 8086 instruction format
PPTX
Copy of 8086inst logical
PPT
Copy of 8086inst logical
PPTX
Chapter3 program flow control instructions
PPTX
Chapter3 8086inst stringsl
PPTX
Chapter3 8086inst logical 2
Wi fi hacking
D dos attack
Notes chapter 6
Interface notes
Chapter6 2
8086 cpu 1
Chapter 6 notes
Chapter 5 notes
Chap6 procedures & macros
Chapter 5 notes new
Notes all instructions
Notes aaa aa
Notes 8086 instruction format
Copy of 8086inst logical
Copy of 8086inst logical
Chapter3 program flow control instructions
Chapter3 8086inst stringsl
Chapter3 8086inst logical 2

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Well-logging-methods_new................
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Sustainable Sites - Green Building Construction
PDF
composite construction of structures.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Welding lecture in detail for understanding
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
Project quality management in manufacturing
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Digital Logic Computer Design lecture notes
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Model Code of Practice - Construction Work - 21102022 .pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Well-logging-methods_new................
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Sustainable Sites - Green Building Construction
composite construction of structures.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
Welding lecture in detail for understanding
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Project quality management in manufacturing
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Foundation to blockchain - A guide to Blockchain Tech
CH1 Production IntroductoryConcepts.pptx
OOP with Java - Java Introduction (Basics)
Digital Logic Computer Design lecture notes
CYBER-CRIMES AND SECURITY A guide to understanding

Arithmetic instrctions

  • 2. 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]
  • 3. 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]
  • 4. 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]
  • 5. 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]
  • 6. 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
  • 7. 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
  • 8. DAA (Decimal Adjust Accumulator) Syntax :-- DAA • This instruction is used to convert the result of the addition of two packed BCD numbers to a valid BCD number. • The result has to be only in AL. • After addition if the lower nibble is greater than 9 or AF =1, it will add 06H to the lower nibble in AL. • After this addition, if the upper nibble is greater than 9 or if CF = 1, DAA instruction adds 60H to AL. • DAA instruction affects AF,CF,PF and ZF. OF is undefined.
  • 9. DAA Instruction contd.. • Operation Performed :-- – If lower nibble of AL > 9 or AF =1 then AL = AL +06 – If higher nibble of AL > 9 or CF =1 then AL = AL +60
  • 10. Numeric Examples AL = 53H, CL = 29H ADD AL,CL ; AL  (AL) + (CL) ;AL  53 + 29 ;AL  7CH DAA ; AL 7C +06 (as C>9) ;AL 82
  • 11. Numeric Examples AL = 73H, CL = 29H ADD AL,CL ; AL  (AL) + (CL) ;AL  73 + 29 ;AL  9CH DAA ; AL 02 and CF = 1 (as C>9)
  • 12. DAS (Decimal Adjust After Subtraction) Syntax :-- DAS • This instruction is used to convert the result of the subtraction of two packed BCD numbers to a valid BCD number. • The subtraction has to be only in AL. • After subtraction if the lower nibble is greater than 9 or AF =1, it will subtract 06H from the lower nibble in AL. • If the result of the subtraction sets the carry flag or if the upper nibble is greater than 9, DAS instruction subtracts 60H from AL. • DAS instruction affects AF,CF,PF and ZF. OF is undefined.
  • 13. DAS Instruction contd.. • Operation Performed :-- – If lower nibble of AL > 9 or AF =1 then AL = AL -06 – If higher nibble of AL > 9 or CF =1 then AL = AL -60
  • 14. Numeric Examples AL = 75, BH = 46 SUB AL,BH ; AL  (AL) - (BH) ;AL  75 - 46 ;AL  2FH ; AF = 1 DAS ; AL 2F - 06 (as F>9) ;AL 29
  • 15. Numeric Examples AL = 38, BH = 61 SUB AL,BH ; AL  (AL) - (BH) ;AL  38 - 61 ;AL  D7H ; CF = 1 DAS ; AL D7 - 60 (as D>9) ;AL 77
  • 16. NEG ( Negate ) Syntax :-- NEG destination • This instruction replaces the number in the destination with the 2’s complement of that number. • For obtaining the 2’s complement, it subtracts the contents of destination from zero. •The result is stored back in the destination which may be a register or a memory location • If OF =1, it indicates that the operation could not be completed successfully. • NEG instruction affects all conditional flags.
  • 17. MUL (Unsigned multiplication) Syntax :-- MUL source • This instruction multiplies an unsigned byte from source with an unsigned byte in AL register or unsigned word from source with an unsigned word in AX register. • The source can be a register or memory location but cannot be an immediate data.
  • 18. MUL (Unsigned multiplication) Contd.. •When a byte is multiplied with a byte in AL, the result is stored in AX. • When a word is multiplied with a word in AX, the MSW (Most Significant Word ) of the result is stored in DX and the LSW (Least Significant Word ) of the result is stored in AX. • If MS Byte or Word of the result is zero, CF and OF both will be set. •All other flags are modified depending upon the result
  • 19. • Operation Performed :-- – If source is byte then AX  AL * unsigned 8 bit source – If source is word then DX, AX  AX * unsigned 16 bit source Examples :-- 1. MUL BL ; Multiply AL by BL & the result in AX 2. MUL CX ; Multiply AX by CX & the result in DX,AX 3. MUL Byte PTR [SI] ; AX  AL * [SI] MUL (Unsigned multiplication) Contd..
  • 20. IMUL (Signed multiplication) Syntax :-- IMUL source • This instruction multiplies a signed byte from source with a signed byte in AL register or signed word from source with an signed word in AX register. • The source can be a register, general purpose, base or index, or memory location, but cannot be an immediate data.
  • 21. IMUL (Signed multiplication) Contd.. •When a byte is multiplied with a byte in AL, the result is stored in AX. • When a word is multiplied with a word in AX, the MSW (Most Significant Word ) of the result is stored in DX and the LSW (Least Significant Word ) of the result is stored in AX.
  • 22. IMUL (Signed multiplication) Contd.. •If the magnitude of the product does not require all the bits of the destination, the unused bits are filled with copies of the sign bit. •If AH and DX contain parts of the 16 & 32 bit results, CF and OF are set, If the unused bits are filled by the sign bit, OF and CF are cleared.
  • 23. • Operation Performed :-- – If source is byte then AX  AL * signed 8 bit source – If source is word then DX, AX  AX * signed 16 bit source Examples :-- 1. IMUL BL ; Multiply AL by BL & the result in AX 2. IMUL CX ; Multiply AX by CX & the result in DX,AX 3. IMUL Byte PTR [SI] ; AX  AL * [SI] IMUL (Signed multiplication) Contd..
  • 24. DIV (Unsigned Division) Syntax :-- DIV source • This instruction divides an unsigned word (16Bits) in AX register by an unsigned byte (8Bits) from source or an unsigned double word (32 bits) in DX & AX register by an unsigned word (16bits) from source • The source can be a register or memory location but cannot be an immediate data.
  • 25. DIV (Unsigned Division)Contd.. •When a word in AX is divided by a byte, AL will contain the 8 bit quotient and AH will contain an 8 bit remainder. • When a double word in DX (MSW) & AX (LSW) is divided by a word, AX will contain the 16 bit quotient and DX will contain an 16 bit remainder.
  • 26. DIV (Unsigned Division)Contd.. •If a byte is to be divided by a byte, AL is loaded with dividend and AH is filled with all 0’s. •If a word is to be divided by a word, Ax is loaded with dividend and DX is filled with all 0’s. •If an attempt is made to divide by 0, or the quotient is too large (FF or FFFF), type 0 interrupt is generated. •No flags are affected.
  • 27. • Operation Performed :-- –If source is byte then • AL  AX / unsigned 8 bit source ; (quotient) • AH  AX MOD unsigned 8 bit source ; (remainder) –If source is word then • AX  DX:AX / unsigned 16 bit source ; (quotient) • DX  DX:AX MOD unsigned 16 bit source ; (remainder) DIV (Unsigned Division)Contd..
  • 28. Examples :-- 1. DIV BL ; Divide word in AX by byte in BL, Quotient in AL, remainder in AH. 2. DIV CX ; Divide double word in DX:AX by word in CX, Quotient in AX, Remainder in DX. 3. DIV [BX] ; Divide word in AX by byte in memory location pointer by BX. DIV (Unsigned Division)Contd..
  • 29. CBW (Convert Signed Byte to Word) Syntax :-- CBW • This instruction converts a signed byte to a signed word. •This instruction copies the sign of a byte in AL to all the bits in AH. • AH is then said to be the sign extension of AL. •CBW operation is done before performing division of a signed byte in the AL by another signed byte with IDIV instruction.
  • 30. CBW (Convert Signed Byte to Word) contd.. Operation :-- • AH  filled with 8th bit of AL i.e., D7 This does not affect any flags. Example :-- If AX = 009BH, (00000000 10011011 After CBW Instruction, AX =FF9B (11111111 10011011)
  • 31. CWD (Convert Signed Word to Double Word) Syntax :-- CWD • This instruction copies the sign bit of a word in AX to all the bits in DX. • Thus the sign of AX is said to be extended to DX. •CWD operation is done before performing division of a signed word in the AX by another signed word with IDIV instruction.
  • 32. CWD (Convert Signed Word to Double Word) contd.. Operation :-- • DX filled with 16th bit of AX i.e., D15 This does not affect any flags. Example :-- If DX = 0000H (00000000 00000000) If AX = F0C7H, (11110000 11000111) After CWD Instruction, DX = FFFFH (11111111 11111111) AX =F0C7 (11110000 11000111)
  • 33. IDIV (Signed Division) Syntax :-- IDIV source • This instruction divides an signed word (16Bits) in AX register by an signed byte (8Bits) from source or An signed double word (32 bits) in DX & AX register by an signed word (16bits) from source • The source can be a register or memory location but cannot be an immediate data.
  • 34. IDIV (Signed Division)Contd.. •When a word in AX is divided by a byte, AL will contain the 8 bit quotient and AH will contain an 8 bit remainder. • When a double word in DX (MSW) & AX (LSW) is divided by a word, AX will contain the 16 bit quotient and DX will contain an 16 bit remainder.
  • 35. IDIV (Signed Division)Contd.. •If a byte is to be divided by a byte, AL is loaded with dividend and AH is filled with all 0’s. •If a word is to be divided by a word, Ax is loaded with dividend and DX is filled with all 0’s. •If an attempt is made to divide by 0, or the quotient is too large (FF or FFFF), type 0 interrupt is generated. •No flags are affected.
  • 36. • Operation Performed :-- –If source is byte then • AL  AX / unsigned 8 bit source ; (quotient) • AH  AX MOD unsigned 8 bit source ; (remainder) –If source is byte then • AX  DX:AX / unsigned 16 bit source ; (quotient) • DX  DX:AX MOD unsigned 16 bit source ; (remainder) IDIV (Signed Division)Contd..
  • 37. Examples :-- 1. IDIV BL ; Divide signed word in AX by signed byte in BL, Quotient in AL, remainder in AH. 2. IDIV CX ; Divide signed double word in DX:AX by signed word in CX, Quotient in AX, Remainder in DX. 3. IDIV [BX] ; Divide signed word in AX by signed byte in memory location pointer by BX. IDIV (Signed Division)Contd..
  • 38. Example of division of a signed byte with signed byte :-- MOV BL,divisor ; Load signed byte divisor in BL MOV AL,dividend ; Load signed byte dividend in AL CBW ;Extend sign of AL into AH IDIV BL ; Byte division, Remainder in AH and quotient in AL