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

What's hot

8086 Microprocessor Instruction set
8086 Microprocessor Instruction set8086 Microprocessor Instruction set
8086 Microprocessor Instruction set
Vijay Kumar
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
Robert Almazan
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
Irfan Anjum
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
Mahalakshmiv11
 
Push down automata
Push down automataPush down automata
Push down automata
Ratnakar Mikkili
 
Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor
Velalar College of Engineering and Technology
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registers
warda aziz
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
Robert Almazan
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Tirumalesh Nizampatnam
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
Ravinder Rautela
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
Kartik Sharma
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
warda aziz
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
warda aziz
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
meenakshi_l
 
8086 alp
8086 alp8086 alp
Pda
PdaPda
push down automata
push down automatapush down automata
push down automata
Christopher Chizoba
 

What's hot (20)

8086 Microprocessor Instruction set
8086 Microprocessor Instruction set8086 Microprocessor Instruction set
8086 Microprocessor Instruction set
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
Push down automata
Push down automataPush down automata
Push down automata
 
Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registers
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
8086 alp
8086 alp8086 alp
8086 alp
 
Pda
PdaPda
Pda
 
push down automata
push down automatapush down automata
push down automata
 

Similar to Arithmetic instrctions

Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
HarshitParkar6677
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
AmitPaliwal20
 
Instruction set
Instruction setInstruction set
Instruction set
Kamini Benare
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
NishatNishu5
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
sravanithonta79
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
Alamin Hossain Miraje
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
Dr. Thippeswamy S.
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
Dr. Thippeswamy S.
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instruction
ramya marichamy
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction description
Dheeraj Suri
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
HebaEng
 
Topic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdfTopic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdf
ezaldeen2013
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.ppt
inian2
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
RLJIT
 
Notes all instructions
Notes all instructionsNotes all instructions
Notes all instructions
HarshitParkar6677
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
RLJIT
 

Similar to Arithmetic instrctions (20)

Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
Instruction set
Instruction setInstruction set
Instruction set
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instruction
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction description
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
 
Topic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdfTopic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdf
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.ppt
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
 
Notes all instructions
Notes all instructionsNotes all instructions
Notes all instructions
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
 

More from HarshitParkar6677

Wi fi hacking
Wi fi hackingWi fi hacking
Wi fi hacking
HarshitParkar6677
 
D dos attack
D dos attackD dos attack
D dos attack
HarshitParkar6677
 
Notes chapter 6
Notes chapter  6Notes chapter  6
Notes chapter 6
HarshitParkar6677
 
Interface notes
Interface notesInterface notes
Interface notes
HarshitParkar6677
 
Chapter6 2
Chapter6 2Chapter6 2
Chapter6 2
HarshitParkar6677
 
Chapter6
Chapter6Chapter6
8086 cpu 1
8086 cpu 18086 cpu 1
8086 cpu 1
HarshitParkar6677
 
Chapter 6 notes
Chapter 6 notesChapter 6 notes
Chapter 6 notes
HarshitParkar6677
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
HarshitParkar6677
 
Chap6 procedures & macros
Chap6 procedures & macrosChap6 procedures & macros
Chap6 procedures & macros
HarshitParkar6677
 
Chapter 5 notes new
Chapter 5 notes newChapter 5 notes new
Chapter 5 notes new
HarshitParkar6677
 
Notes aaa aa
Notes aaa aaNotes aaa aa
Notes aaa aa
HarshitParkar6677
 
Notes 8086 instruction format
Notes 8086 instruction formatNotes 8086 instruction format
Notes 8086 instruction format
HarshitParkar6677
 
Misc
MiscMisc
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
HarshitParkar6677
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
HarshitParkar6677
 
Chapter3 program flow control instructions
Chapter3 program flow control instructionsChapter3 program flow control instructions
Chapter3 program flow control instructions
HarshitParkar6677
 
Chapter3 8086inst stringsl
Chapter3 8086inst stringslChapter3 8086inst stringsl
Chapter3 8086inst stringsl
HarshitParkar6677
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
HarshitParkar6677
 
Chap3 program flow control instructions
Chap3 program flow control instructionsChap3 program flow control instructions
Chap3 program flow control instructions
HarshitParkar6677
 

More from HarshitParkar6677 (20)

Wi fi hacking
Wi fi hackingWi fi hacking
Wi fi hacking
 
D dos attack
D dos attackD dos attack
D dos attack
 
Notes chapter 6
Notes chapter  6Notes chapter  6
Notes chapter 6
 
Interface notes
Interface notesInterface notes
Interface notes
 
Chapter6 2
Chapter6 2Chapter6 2
Chapter6 2
 
Chapter6
Chapter6Chapter6
Chapter6
 
8086 cpu 1
8086 cpu 18086 cpu 1
8086 cpu 1
 
Chapter 6 notes
Chapter 6 notesChapter 6 notes
Chapter 6 notes
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
 
Chap6 procedures & macros
Chap6 procedures & macrosChap6 procedures & macros
Chap6 procedures & macros
 
Chapter 5 notes new
Chapter 5 notes newChapter 5 notes new
Chapter 5 notes new
 
Notes aaa aa
Notes aaa aaNotes aaa aa
Notes aaa aa
 
Notes 8086 instruction format
Notes 8086 instruction formatNotes 8086 instruction format
Notes 8086 instruction format
 
Misc
MiscMisc
Misc
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
Chapter3 program flow control instructions
Chapter3 program flow control instructionsChapter3 program flow control instructions
Chapter3 program flow control instructions
 
Chapter3 8086inst stringsl
Chapter3 8086inst stringslChapter3 8086inst stringsl
Chapter3 8086inst stringsl
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
 
Chap3 program flow control instructions
Chap3 program flow control instructionsChap3 program flow control instructions
Chap3 program flow control instructions
 

Recently uploaded

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 

Recently uploaded (20)

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 

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