SlideShare a Scribd company logo
1 of 27
Batch (014)
 MUHAMMAD ASIM (14093122-007)
 INZMAM TAHIR (14093122-005)
 YASIR ALI (14093122-006)
 ADNAN ASLAM (14093122-003)
 BILAL AMJAD (14093122-004)
 UMAR RASHEED (14093122-002)
PRESENTATION
 In chapter 7 ,we saw how to learn multiplication
and division by shifting the bits in a byte or
word.
 Left and right shift can be used for multiplying
and dividing respectively by powers of 2.
 Process of multiplication and division is different
for signed and unsigned numbers and there are
different instructions used for signed and
unsigned multiplication and division.
 One of the most useful applications of
multiplication and division is to implement
decimal input and output.
 In the case of unsigned multiplication, using
instruction MUL .
 The syntax of this instruction is
MUL source
 Example
AL=128 BL=255
1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0
AX=32640
 In the case of signed multiplication, using
instruction IMUL .
 The syntax of this instruction is
IMUL source
 Example
AL=128 BL=-1
1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0
AX=32640
 In byte multiplication one number is
contained in the source and the other is
assumed to be in AL.
 The 16-bit product will be in AX.
 The source may be a byte register or
memory byte but not a constant.
Multiplicand
Multiplier
Result
AL
AX
 In word multiplication one number is
contained in the source and the other is
assumed to be in AX.
 The most significant 16-bits of the double
word product will in DX and the least
significant 16-bits will be in AX.
DX:AX
 The source may a 16-bit register or memory
word but not a constant.
Source AX
DX AX
 SF,ZF,AF,PF undefined
 CF,OF:
 After MUL, CF/OF =0 if upper half of
the result is zero.
=1 otherwise
 After IMUL, CF/OF =0 the signed bits of
upper and lower
half are same.
=1 otherwise
F F h BL
8 0 h AL
MUL BL IMUL BL
8 07 F
AH AL
1
CF/OF CF/OF
F F h BL
8 0 h AL
8 00 0
AH AL
1
0 0 0 1 h AX
F F F F h BX
MUL BX IMUL BX
F F F F0 0 0 0
DX AX
0
CF/OF
0 0 0 1 h AX
F F F F h BX
F F F FF F F F
DX AX
0
CF/OF
 Translate the high level language assignment
statement A= 5*A-12*B into assembly
code remember A and B are word variable.
 sol:
MOV AX = 5 ;AX =5
IMUL A ;AX=5*A
MOV A , AX ;A=5*A
MOV AX, 12 ;AX=12
IMUL B ;AX=12*B
SUB A , AX ;A=5*A-12*B
 When division is performed we obtain two
results the quotient and the remainder.
 In division there are separate instructions for
signed and unsigned division.
 In the case of signed division IDIV (integer
divide)
 The syntax used for signed division
IDIV divisor
 In the case of unsigned division DIV the
syntax used for unsigned division
DIV divisor
 These instructions divide 8 (or 16) bits into
16(or 32) bits.
 The quotient and remainder have same size
as the divisor
 In this case the divisor is an 8-bit register or
memory byte.
 The 16-bit dividend is assume to be in AX.
 After division, 8bit quotient is in AL and 8-bit
remainder is in AH.
 The divisor may not be a constant.
 In this case divisor is a 16-bit register or
memory word.
 The 32-bit dividend is assumed to be in
DX:AX
 after division the 16-bit quotient is in AL and
16-bit remainder is in DX.
 The divisor may not be a constant.
 It is possible that the quotient will be too big
to fit in the specified destination (AL or AX).
 This can happen if the divisor is much smaller
than the dividend.
 When this happens, the program terminates
and the system displays the message “divide
overflow”.
Suppose DX=0000h and AX=0005h and BX=FFFEh
00050000
DX AX
FFFE
BX
0005
0000AX
DX
quotient
remainder
DIV BX
Here dividend is 5 and
divisor =FFFE=65534
After division
quotient =0
and remainder =5
IDIV BX
00050000
DX AX
FFFE
BX
0001
FFFEAX
DX
quotient
remainder
Here in the case of signed
divisor = FFFE = -2 and
dividend =5
After division quotient=-2
and remainder=1
suppose DX=FFFFh and AX=FFFBh and BX=0002h
FFFBFFFF
DX AX
0002
BX
FFFF
FFFEAX
DX
quotient
remainder
DX:AX = FFFFFFFBh = -5,
BX = 2.
IDIV DX
-5 divided by 2 gives a
quotient of -2 = FFFEh and a
remainder of -1 = FFFFh.
FFFBFFFF
DX AX
0002
BX For DIV, the dividend
DX:AX = FFFFFFFBh =
4294967291 and the
divisor= 2.
DIVIDE OVERFLOW
DIV BX
The actual quotient is
2147483646 = 7FFFFFFEh.
This is too big
to fit in AX.
 Word Division
the dividend is in DX:AX even if the actual
dividend will fit in AX. In this case DX should
be prepared as
1. For DIV ,DX should be cleared.
2. For IDIV,DX should me made the sign
extension of AX. The instruction CWD will
do the extension.
 Divide -1250 by 7
Sol:-
MOV AX,-1250 ;AX gets dividend
CWD ;extend sign to DX
MOV BX,7 ;BX has divisor
IDIV BX ;AX get quot. DX has rem.
 The dividend is in AX. If the actual dividend
is a byte then AH should be prepared as
1. For DIV,AH should be cleared.
2. For IDIV,AH should the sign extension of AL.
the instruction CWB will do the extension.
 Divide the signed value of the byte variable
XBYTE by -7
 Sol:-
MOV AL,XBYTE ;AL has dividend
CBW ;extend sign to AH
MOV BL,-7 ;BL has divisor
IDIV BL ;AL has quot. AH has rem.
 There is no effect of CBW and CWD on the
flags.

More Related Content

What's hot

Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)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
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly languagewarda aziz
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computerswarda aziz
 
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 instructionswarda 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
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructionswarda aziz
 
Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1warda aziz
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5Motaz Saad
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with typesRavinder Rautela
 
Assembly language
Assembly language Assembly language
Assembly language Usama ahmad
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)Hareem Aslam
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programmingKartik Sharma
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 

What's hot (20)

Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
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,...
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
 
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...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
 
Assembly language
Assembly language Assembly language
Assembly language
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
DAA AND DAS
DAA AND DASDAA AND DAS
DAA AND DAS
 

Viewers also liked

assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...Bilal Amjad
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instructionkashif Shafqat
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copymkazree
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 

Viewers also liked (7)

assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
05 multiply divide
05 multiply divide05 multiply divide
05 multiply divide
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 

Similar to assembly language programming organization of IBM PC chapter 9 part-1(MULTIPLICATION AND DIVISION IN ASSEMBLY LANGUAGE)

instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptssuser2b759d
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionDheeraj Suri
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2RLJIT
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.pptinian2
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086sravanithonta79
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architectureSaurabh Jain
 

Similar to assembly language programming organization of IBM PC chapter 9 part-1(MULTIPLICATION AND DIVISION IN ASSEMBLY LANGUAGE) (20)

instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction description
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.ppt
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
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)
 
126.pptx
126.pptx126.pptx
126.pptx
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
8086 architecture
8086 architecture8086 architecture
8086 architecture
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture26677766 8086-microprocessor-architecture
26677766 8086-microprocessor-architecture
 
assembly flag resister
assembly flag resisterassembly flag resister
assembly flag resister
 

More from Bilal Amjad

IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino Bilal Amjad
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Bilal Amjad
 
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...Bilal Amjad
 
Big Data in Smart Grid
Big Data in Smart GridBig Data in Smart Grid
Big Data in Smart GridBilal Amjad
 
Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Bilal Amjad
 
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languagebubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languageBilal Amjad
 
Limit of complex number
Limit of complex numberLimit of complex number
Limit of complex numberBilal Amjad
 
simple combinational lock
simple combinational locksimple combinational lock
simple combinational lockBilal Amjad
 
4-bit camparator
4-bit camparator4-bit camparator
4-bit camparatorBilal Amjad
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectoriesBilal Amjad
 

More from Bilal Amjad (13)

IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
 
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
 
Big Data in Smart Grid
Big Data in Smart GridBig Data in Smart Grid
Big Data in Smart Grid
 
Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
 
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languagebubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly language
 
Limit of complex number
Limit of complex numberLimit of complex number
Limit of complex number
 
simple combinational lock
simple combinational locksimple combinational lock
simple combinational lock
 
4-bit camparator
4-bit camparator4-bit camparator
4-bit camparator
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectories
 

Recently uploaded

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 

assembly language programming organization of IBM PC chapter 9 part-1(MULTIPLICATION AND DIVISION IN ASSEMBLY LANGUAGE)

  • 1.
  • 3.
  • 4.  MUHAMMAD ASIM (14093122-007)  INZMAM TAHIR (14093122-005)  YASIR ALI (14093122-006)  ADNAN ASLAM (14093122-003)  BILAL AMJAD (14093122-004)  UMAR RASHEED (14093122-002)
  • 6.  In chapter 7 ,we saw how to learn multiplication and division by shifting the bits in a byte or word.  Left and right shift can be used for multiplying and dividing respectively by powers of 2.  Process of multiplication and division is different for signed and unsigned numbers and there are different instructions used for signed and unsigned multiplication and division.  One of the most useful applications of multiplication and division is to implement decimal input and output.
  • 7.  In the case of unsigned multiplication, using instruction MUL .  The syntax of this instruction is MUL source  Example AL=128 BL=255 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 AX=32640
  • 8.  In the case of signed multiplication, using instruction IMUL .  The syntax of this instruction is IMUL source  Example AL=128 BL=-1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 AX=32640
  • 9.  In byte multiplication one number is contained in the source and the other is assumed to be in AL.  The 16-bit product will be in AX.  The source may be a byte register or memory byte but not a constant. Multiplicand Multiplier Result AL AX
  • 10.  In word multiplication one number is contained in the source and the other is assumed to be in AX.  The most significant 16-bits of the double word product will in DX and the least significant 16-bits will be in AX. DX:AX  The source may a 16-bit register or memory word but not a constant. Source AX DX AX
  • 11.  SF,ZF,AF,PF undefined  CF,OF:  After MUL, CF/OF =0 if upper half of the result is zero. =1 otherwise  After IMUL, CF/OF =0 the signed bits of upper and lower half are same. =1 otherwise
  • 12. F F h BL 8 0 h AL MUL BL IMUL BL 8 07 F AH AL 1 CF/OF CF/OF F F h BL 8 0 h AL 8 00 0 AH AL 1
  • 13. 0 0 0 1 h AX F F F F h BX MUL BX IMUL BX F F F F0 0 0 0 DX AX 0 CF/OF 0 0 0 1 h AX F F F F h BX F F F FF F F F DX AX 0 CF/OF
  • 14.  Translate the high level language assignment statement A= 5*A-12*B into assembly code remember A and B are word variable.  sol: MOV AX = 5 ;AX =5 IMUL A ;AX=5*A MOV A , AX ;A=5*A MOV AX, 12 ;AX=12 IMUL B ;AX=12*B SUB A , AX ;A=5*A-12*B
  • 15.  When division is performed we obtain two results the quotient and the remainder.  In division there are separate instructions for signed and unsigned division.
  • 16.  In the case of signed division IDIV (integer divide)  The syntax used for signed division IDIV divisor  In the case of unsigned division DIV the syntax used for unsigned division DIV divisor  These instructions divide 8 (or 16) bits into 16(or 32) bits.  The quotient and remainder have same size as the divisor
  • 17.  In this case the divisor is an 8-bit register or memory byte.  The 16-bit dividend is assume to be in AX.  After division, 8bit quotient is in AL and 8-bit remainder is in AH.  The divisor may not be a constant.
  • 18.  In this case divisor is a 16-bit register or memory word.  The 32-bit dividend is assumed to be in DX:AX  after division the 16-bit quotient is in AL and 16-bit remainder is in DX.  The divisor may not be a constant.
  • 19.  It is possible that the quotient will be too big to fit in the specified destination (AL or AX).  This can happen if the divisor is much smaller than the dividend.  When this happens, the program terminates and the system displays the message “divide overflow”.
  • 20. Suppose DX=0000h and AX=0005h and BX=FFFEh 00050000 DX AX FFFE BX 0005 0000AX DX quotient remainder DIV BX Here dividend is 5 and divisor =FFFE=65534 After division quotient =0 and remainder =5
  • 21. IDIV BX 00050000 DX AX FFFE BX 0001 FFFEAX DX quotient remainder Here in the case of signed divisor = FFFE = -2 and dividend =5 After division quotient=-2 and remainder=1
  • 22. suppose DX=FFFFh and AX=FFFBh and BX=0002h FFFBFFFF DX AX 0002 BX FFFF FFFEAX DX quotient remainder DX:AX = FFFFFFFBh = -5, BX = 2. IDIV DX -5 divided by 2 gives a quotient of -2 = FFFEh and a remainder of -1 = FFFFh.
  • 23. FFFBFFFF DX AX 0002 BX For DIV, the dividend DX:AX = FFFFFFFBh = 4294967291 and the divisor= 2. DIVIDE OVERFLOW DIV BX The actual quotient is 2147483646 = 7FFFFFFEh. This is too big to fit in AX.
  • 24.  Word Division the dividend is in DX:AX even if the actual dividend will fit in AX. In this case DX should be prepared as 1. For DIV ,DX should be cleared. 2. For IDIV,DX should me made the sign extension of AX. The instruction CWD will do the extension.
  • 25.  Divide -1250 by 7 Sol:- MOV AX,-1250 ;AX gets dividend CWD ;extend sign to DX MOV BX,7 ;BX has divisor IDIV BX ;AX get quot. DX has rem.
  • 26.  The dividend is in AX. If the actual dividend is a byte then AH should be prepared as 1. For DIV,AH should be cleared. 2. For IDIV,AH should the sign extension of AL. the instruction CWB will do the extension.
  • 27.  Divide the signed value of the byte variable XBYTE by -7  Sol:- MOV AL,XBYTE ;AL has dividend CBW ;extend sign to AH MOV BL,-7 ;BL has divisor IDIV BL ;AL has quot. AH has rem.  There is no effect of CBW and CWD on the flags.