SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
01KTP – Microprocessor-based systems




 48/32-
 48/32-bit
 division algorithm

             Vittorio GIOVARA
              Alberto GRAND
Formulation of the problem

 Our goal is to find an algorithm that is able
 to compute the residual of the division
 between a 48-bit dividend and a 32-bit
 divisor using an 8086 machine.

 Input numbers are expressed according to
 the module and sign representation.
Invariance property (I)

 The invariance property holds true when
 dividing two real numbers.
 In general, given a, b ∈ R, the result of the
 division a / b will not change if we multiply or
 divide both the dividend and the divisor by a
 given number k other than 0.

 Example: 84 / 6 = (84 / 3) / (6 / 3)
                 = 28 / 2
                 = 12
Invariance property (II)

 How can this property be useful to the solution of
 our problem?
 Since the 8086 processor has built-in capabilities
 for handling 32-bit/16-bit divisions, we may
 choose k = 216 , so as to reduce the length of the
 operands A and B to respectively 32 and 16 bits.
 Note that the division by a power of 2 can
 efficiently be implemented through a right shift.
Invariance property (III)

      A       A / 216
          =              =
      B       B / 216

 Is this result correct?
 Are the two operations still equivalent?
Invariance property (IV)
 In general, the answer is no.
 This is because, by performing a right shift,
 we are discarding all the least significant
 bits of the operands.
 Nonetheless, the result we obtain is still
 close to the true quotient.

Example:
184 / 21 = 8, R = 16
(184 / 10) / (21/10) ≅ 18 / 2 = 9
Approximation of the quotient



 The result obtained by dividing the MS 32 bits of
 A by the MS 16 bits of B may thus be used as an
 initial approximation of the true quotient.
The algorithm (I)

 The division between A47…16 and B31…16 is
 initially performed, regardless of the sign of the
 operands.
 The approximated quotient Q is then multiplied
 by the divisor B, in order to obtain A* .
 A* is subsequently compared with A.
The algorithm (II)
 If A > A*, then we check if their difference
 is larger than B, i.e. we check whether B
 fits one more time in A.
 ◦ If this is the case, A* is incremented by B and
   we go back to the initial test.
 ◦ Otherwise, the difference is the sought
   residual.
 If A > A*, then A* is decremented by B
 and we go back to the initial test.
 Otherwise, A = A*, so the sought residual
 is 0.
Handling of signed values (I)

 The sign of the operands is stored in a
 register (which is then pushed onto the stack)
 and later retrieved to adjust the result.
 This is achieved by means of an AND
 operation between the 8 MSBs of the two
 operands and the bitmask 80H.
Handling of signed values (II)


 Both operands are then made positive by forcing
 a 0 in their MSB, by means of an AND operation
 between the 8 MSBs and the bitmask 7FH.
 The algorithm therefore treats the operands as if
 they were positive.
Adjustment of the residual (I)
 Note that:
17 / 4 = 4, R = 1 = R*

                        BUT

(-17) / 4 = -5, R = 3 = 4 – R*

17 / (-4) = -4, R = 1

(-17) / (-4) = 5, R = 3 = 4 – R*
Adjustment of the residual (II)
 We can infer the rule from the previous
 example:
 ◦ If the dividend is positive, the residual is the
   computed one
 ◦ If the dividend is negative, the residual is the
   complement to the divisor of the computed one.


 The residual is therefore adjusted if the
 dividend is negative.
 The original sign of the operands is finally
 restored.
…that’s all, folks!
…that’s all, folks!

Weitere ähnliche Inhalte

Was ist angesagt?

Csc1100 lecture10 ch08_pt1
Csc1100 lecture10 ch08_pt1Csc1100 lecture10 ch08_pt1
Csc1100 lecture10 ch08_pt1
IIUM
 

Was ist angesagt? (20)

Magnitude comparator
Magnitude comparatorMagnitude comparator
Magnitude comparator
 
6 2 magnitudecomparator ibit and 2 bit converted
6 2 magnitudecomparator ibit and 2 bit converted6 2 magnitudecomparator ibit and 2 bit converted
6 2 magnitudecomparator ibit and 2 bit converted
 
Low Power VLSI Design of Modified Booth Multiplier
Low Power VLSI Design of Modified Booth MultiplierLow Power VLSI Design of Modified Booth Multiplier
Low Power VLSI Design of Modified Booth Multiplier
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 
Sequential circuit multiplier
Sequential circuit multiplierSequential circuit multiplier
Sequential circuit multiplier
 
4-bit camparator
4-bit camparator4-bit camparator
4-bit camparator
 
Operators and it's type
Operators and it's type Operators and it's type
Operators and it's type
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
Natural Language Processing - Writing Grammar
Natural Language Processing - Writing GrammarNatural Language Processing - Writing Grammar
Natural Language Processing - Writing Grammar
 
Digital logic design lecture 3
Digital logic design lecture 3Digital logic design lecture 3
Digital logic design lecture 3
 
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etcBOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
 
Multiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchartMultiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchart
 
Csci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeCsci101 lect09 vectorized_code
Csci101 lect09 vectorized_code
 
Digital logic design lecture 2
Digital logic design lecture 2Digital logic design lecture 2
Digital logic design lecture 2
 
The BUT and NBUT Boolean logic
The BUT and NBUT Boolean logicThe BUT and NBUT Boolean logic
The BUT and NBUT Boolean logic
 
Conversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad balochConversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad baloch
 
Session03 operators
Session03 operatorsSession03 operators
Session03 operators
 
Csc1100 lecture10 ch08_pt1
Csc1100 lecture10 ch08_pt1Csc1100 lecture10 ch08_pt1
Csc1100 lecture10 ch08_pt1
 
C –imp points
C –imp pointsC –imp points
C –imp points
 
Boothmultiplication
BoothmultiplicationBoothmultiplication
Boothmultiplication
 

Andere mochten auch

Algorithms,graph theory and combinatorics
Algorithms,graph theory and combinatoricsAlgorithms,graph theory and combinatorics
Algorithms,graph theory and combinatorics
Prof.Dr.Hanumanthappa J
 
the division algorithm
the division algorithmthe division algorithm
the division algorithm
Jeneva Clark
 
Module 2 lessson 14
Module 2 lessson 14Module 2 lessson 14
Module 2 lessson 14
mlabuski
 
Number theory
Number theory Number theory
Number theory
tes31
 
History of Number Theory
History of Number TheoryHistory of Number Theory
History of Number Theory
Volkan Nazife
 
Wireless power theft monitoring
Wireless power theft monitoringWireless power theft monitoring
Wireless power theft monitoring
Biswajit Pratihari
 

Andere mochten auch (20)

Euclid's division algorithm
Euclid's division algorithmEuclid's division algorithm
Euclid's division algorithm
 
Algorithms,graph theory and combinatorics
Algorithms,graph theory and combinatoricsAlgorithms,graph theory and combinatorics
Algorithms,graph theory and combinatorics
 
the division algorithm
the division algorithmthe division algorithm
the division algorithm
 
Module 2 lessson 14
Module 2 lessson 14Module 2 lessson 14
Module 2 lessson 14
 
introduction to division algorithm
introduction to division algorithmintroduction to division algorithm
introduction to division algorithm
 
Eucledian algorithm for gcd of integers and polynomials
Eucledian algorithm for gcd of integers and polynomialsEucledian algorithm for gcd of integers and polynomials
Eucledian algorithm for gcd of integers and polynomials
 
Abel - A great mathematician
Abel - A great mathematicianAbel - A great mathematician
Abel - A great mathematician
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 
Number theory
Number theory Number theory
Number theory
 
Number theory Grade 7, 8 and 9
Number theory Grade 7, 8 and 9Number theory Grade 7, 8 and 9
Number theory Grade 7, 8 and 9
 
Number theory
Number theoryNumber theory
Number theory
 
History of Number Theory
History of Number TheoryHistory of Number Theory
History of Number Theory
 
The Number Theory
The Number TheoryThe Number Theory
The Number Theory
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisEuclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
 
Number theory
Number theoryNumber theory
Number theory
 
Remainder theorem
Remainder theoremRemainder theorem
Remainder theorem
 
Password based door lock system using 8051 microcontroller final report
Password based door lock system using 8051 microcontroller final reportPassword based door lock system using 8051 microcontroller final report
Password based door lock system using 8051 microcontroller final report
 
Password based door locking system
Password based door locking systemPassword based door locking system
Password based door locking system
 
Project ppt
Project pptProject ppt
Project ppt
 
Wireless power theft monitoring
Wireless power theft monitoringWireless power theft monitoring
Wireless power theft monitoring
 

Ähnlich wie Microprocessor-based Systems 48/32bit Division Algorithm

Module_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptxModule_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptx
realme6igamerr
 
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
UmerKhan147799
 

Ähnlich wie Microprocessor-based Systems 48/32bit Division Algorithm (20)

Module_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptxModule_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptx
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Fourier Transform Assignment Help
Fourier Transform Assignment HelpFourier Transform Assignment Help
Fourier Transform Assignment Help
 
Ayush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAyush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptx
 
DESIGN OF RADIX-8 BOOTH MULTIPLIER USING KOGGESTONE ADDER FOR HIGH SPEED ARIT...
DESIGN OF RADIX-8 BOOTH MULTIPLIER USING KOGGESTONE ADDER FOR HIGH SPEED ARIT...DESIGN OF RADIX-8 BOOTH MULTIPLIER USING KOGGESTONE ADDER FOR HIGH SPEED ARIT...
DESIGN OF RADIX-8 BOOTH MULTIPLIER USING KOGGESTONE ADDER FOR HIGH SPEED ARIT...
 
IRJET- Realization of Decimal Multiplication using Radix-16 Modified Booth En...
IRJET- Realization of Decimal Multiplication using Radix-16 Modified Booth En...IRJET- Realization of Decimal Multiplication using Radix-16 Modified Booth En...
IRJET- Realization of Decimal Multiplication using Radix-16 Modified Booth En...
 
IRJET- Radix 8 Booth Encoded Interleaved Modular Multiplication
IRJET- Radix 8 Booth Encoded Interleaved Modular MultiplicationIRJET- Radix 8 Booth Encoded Interleaved Modular Multiplication
IRJET- Radix 8 Booth Encoded Interleaved Modular Multiplication
 
Bitwise Operations(1).pdf
Bitwise Operations(1).pdfBitwise Operations(1).pdf
Bitwise Operations(1).pdf
 
IRJET- An Efficient Multiply Accumulate Unit Design using Vedic Mathematics A...
IRJET- An Efficient Multiply Accumulate Unit Design using Vedic Mathematics A...IRJET- An Efficient Multiply Accumulate Unit Design using Vedic Mathematics A...
IRJET- An Efficient Multiply Accumulate Unit Design using Vedic Mathematics A...
 
Calculating garbage value in case of overflow
Calculating garbage value in case of overflowCalculating garbage value in case of overflow
Calculating garbage value in case of overflow
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
 
index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
 
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
 
Chapter 9.pdf
Chapter 9.pdfChapter 9.pdf
Chapter 9.pdf
 
Development of an Algorithm for 16-Bit WTM
Development of an Algorithm for 16-Bit WTMDevelopment of an Algorithm for 16-Bit WTM
Development of an Algorithm for 16-Bit WTM
 
L010137986
L010137986L010137986
L010137986
 
Implementation of Low-Complexity Redundant Multiplier Architecture for Finite...
Implementation of Low-Complexity Redundant Multiplier Architecture for Finite...Implementation of Low-Complexity Redundant Multiplier Architecture for Finite...
Implementation of Low-Complexity Redundant Multiplier Architecture for Finite...
 
Lecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of InstructionsLecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of Instructions
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
 

Mehr von Vittorio Giovara

Mehr von Vittorio Giovara (13)

Color me intrigued: A jaunt through color technology in video
Color me intrigued: A jaunt through color technology in videoColor me intrigued: A jaunt through color technology in video
Color me intrigued: A jaunt through color technology in video
 
An overview on 10 bit video: UHDTV, HDR, and coding efficiency
An overview on 10 bit video: UHDTV, HDR, and coding efficiencyAn overview on 10 bit video: UHDTV, HDR, and coding efficiency
An overview on 10 bit video: UHDTV, HDR, and coding efficiency
 
Introduction to video reverse engineering
Introduction to video reverse engineeringIntroduction to video reverse engineering
Introduction to video reverse engineering
 
Il Caso Ryanair
Il Caso RyanairIl Caso Ryanair
Il Caso Ryanair
 
I Mercati Geografici
I Mercati GeograficiI Mercati Geografici
I Mercati Geografici
 
Block Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For AuthenticationBlock Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For Authentication
 
Crittografia Quantistica
Crittografia QuantisticaCrittografia Quantistica
Crittografia Quantistica
 
Fuzzing Techniques for Software Vulnerability Discovery
Fuzzing Techniques for Software Vulnerability DiscoveryFuzzing Techniques for Software Vulnerability Discovery
Fuzzing Techniques for Software Vulnerability Discovery
 
Parallel and Distributed Computing on Low Latency Clusters
Parallel and Distributed Computing on Low Latency ClustersParallel and Distributed Computing on Low Latency Clusters
Parallel and Distributed Computing on Low Latency Clusters
 
Software Requirements for Safety-related Systems
Software Requirements for Safety-related SystemsSoftware Requirements for Safety-related Systems
Software Requirements for Safety-related Systems
 
Misra C Software Development Standard
Misra C Software Development StandardMisra C Software Development Standard
Misra C Software Development Standard
 
OpenSSL User Manual and Data Format
OpenSSL User Manual and Data FormatOpenSSL User Manual and Data Format
OpenSSL User Manual and Data Format
 
Authenticated Encryption Gcm Ccm
Authenticated Encryption Gcm CcmAuthenticated Encryption Gcm Ccm
Authenticated Encryption Gcm Ccm
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Microprocessor-based Systems 48/32bit Division Algorithm

  • 1. 01KTP – Microprocessor-based systems 48/32- 48/32-bit division algorithm Vittorio GIOVARA Alberto GRAND
  • 2. Formulation of the problem Our goal is to find an algorithm that is able to compute the residual of the division between a 48-bit dividend and a 32-bit divisor using an 8086 machine. Input numbers are expressed according to the module and sign representation.
  • 3. Invariance property (I) The invariance property holds true when dividing two real numbers. In general, given a, b ∈ R, the result of the division a / b will not change if we multiply or divide both the dividend and the divisor by a given number k other than 0. Example: 84 / 6 = (84 / 3) / (6 / 3) = 28 / 2 = 12
  • 4. Invariance property (II) How can this property be useful to the solution of our problem? Since the 8086 processor has built-in capabilities for handling 32-bit/16-bit divisions, we may choose k = 216 , so as to reduce the length of the operands A and B to respectively 32 and 16 bits. Note that the division by a power of 2 can efficiently be implemented through a right shift.
  • 5. Invariance property (III) A A / 216 = = B B / 216 Is this result correct? Are the two operations still equivalent?
  • 6. Invariance property (IV) In general, the answer is no. This is because, by performing a right shift, we are discarding all the least significant bits of the operands. Nonetheless, the result we obtain is still close to the true quotient. Example: 184 / 21 = 8, R = 16 (184 / 10) / (21/10) ≅ 18 / 2 = 9
  • 7. Approximation of the quotient The result obtained by dividing the MS 32 bits of A by the MS 16 bits of B may thus be used as an initial approximation of the true quotient.
  • 8. The algorithm (I) The division between A47…16 and B31…16 is initially performed, regardless of the sign of the operands. The approximated quotient Q is then multiplied by the divisor B, in order to obtain A* . A* is subsequently compared with A.
  • 9. The algorithm (II) If A > A*, then we check if their difference is larger than B, i.e. we check whether B fits one more time in A. ◦ If this is the case, A* is incremented by B and we go back to the initial test. ◦ Otherwise, the difference is the sought residual. If A > A*, then A* is decremented by B and we go back to the initial test. Otherwise, A = A*, so the sought residual is 0.
  • 10. Handling of signed values (I) The sign of the operands is stored in a register (which is then pushed onto the stack) and later retrieved to adjust the result. This is achieved by means of an AND operation between the 8 MSBs of the two operands and the bitmask 80H.
  • 11. Handling of signed values (II) Both operands are then made positive by forcing a 0 in their MSB, by means of an AND operation between the 8 MSBs and the bitmask 7FH. The algorithm therefore treats the operands as if they were positive.
  • 12. Adjustment of the residual (I) Note that: 17 / 4 = 4, R = 1 = R* BUT (-17) / 4 = -5, R = 3 = 4 – R* 17 / (-4) = -4, R = 1 (-17) / (-4) = 5, R = 3 = 4 – R*
  • 13. Adjustment of the residual (II) We can infer the rule from the previous example: ◦ If the dividend is positive, the residual is the computed one ◦ If the dividend is negative, the residual is the complement to the divisor of the computed one. The residual is therefore adjusted if the dividend is negative. The original sign of the operands is finally restored.