SlideShare a Scribd company logo
1 of 25
Download to read offline
Nipun Thapa
Chapter 8
Computer Arithmetic
https://genuinenotes.com
Computer Arithmetic
Nipun Thapa - (CO : Unit-09)
2
 Arithmetic instructions manipulate data to produce
solution for computational problems.
 The four basic arithmetic operations are addition,
subtraction, multiplication and division. From these 4,
it is possible to formulate other specific problems by
means of numerical analysis methods.
 There are three ways of representing negative fixed-
point binary numbers: signed magnitude, signed 1’s
complement and signed 2’s complement. Signed 2’s
complemented form is used most but occasionally we
deal with signed magnitude representation.
https://genuinenotes.com
8.1 Addition and Subtraction of Signed-
Magnitude Data
Nipun Thapa - (CO : Unit-09)
3
 When two signed numbers A and B are added and subtracted, we find
8 different conditions to consider as described in the following table:
Table: addition and subtraction of signed-magnitude numbers
https://genuinenotes.com
8.1 Addition and Subtraction of Signed-
Magnitude Data
Nipun Thapa - (CO : Unit-09)
4
Addition (subtraction) algorithm:
 When the signs of A and B are identical (different), add
magnitudes and attach the sign of A to the result.
 When the signs of A and B are different (identical),
compare the magnitudes and subtract the smaller from
larger.
Hardware implementation
 To implement the two arithmetic operations with
hardware, we have to store numbers into two registers A
and B. Let As and Bs be two flip-flops that hold the
corresponding signs. The results are transferred to A and
As. A and As together form an accumulator.
https://genuinenotes.com
8.1 Addition and Subtraction of Signed-
Magnitude Data
Nipun Thapa - (CO : Unit-09)
5
Fig: Hardware for signed-magnitude data addition and subtraction
https://genuinenotes.com
8.1 Addition and Subtraction of Signed-
Magnitude Data
Nipun Thapa - (CO : Unit-09)
6
We need:
 Two registers A and B and sign flip-flops As and Bs
 A magnitude comparator: to check if A>B, A<B, or A=B
 A parallel adder: to perform A+B
 Two parallel subtractions: for A-B and B-A
 The sign relationships are determined from an X-OR gate with As and Bs as inputs.
Block Diagram Description
 Hardware above consists of registers A and B and sign flip-flops As and Bs.
 The complementary provides an output of B or B’ depending on mode input M.
 When M=0, the output of B is transferred to the adder, the input carry is 0 and thus
output of adder is A+B. Output carry is transferred to flip-flop E, where it can be checked
to determine overflow. When E=1, it is overflow, otherwise, not. The E=1 is transferred
to the AVF (add-overflow-flip-flop) which holds the overflow bit when A ns B are added.
 When M=1, 1’s complement of B is applied to the adder, input carry is 1 and output is
S=A+B’+1 (i.e. A-B). Output carry is transferred to flip-flop E, where it can be checked to
determine the relative magnitude of two numbers.
https://genuinenotes.com
8.1 Addition and Subtraction of Signed-
Magnitude Data
Nipun Thapa - (CO : Unit-09)
7
Hardware Algorithm
 The flowchart for the hardware algorithm is given below:
 As and Bs are compared by an X-OR gate. If output=0, signs are identical, if
1, signs are different.
 For add operation, identical signs dictate addition of magnitudes. For
subtraction, different signs dictate magnitudes be added.
 Magnitudes are with a micro operation E A A+B (E A is register that combines
E and A). If E=1, overflow occurs and is transferred to AVF.
 Two magnitudes are subtracted if signs are different for add operation and
identical for subtract operation.
 Magnitudes are subtracted with a micro operation E A A+B’+1.
 No overflow occurs if the numbers are subtracted, so AVF is cleared to 0.
 If E=1, it indicates A≥B and the result in A is correct. If the number in A is 0, the
sign As must be made positive (As=0) to avoid negative zero.
 If E=0, it indicates that A<B for which it is necessary to take 2’s complement of
value in A. the micro operation is A A’+1. The sign of As must be sign of Bs
(i.e. AsAs’).
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
8
Fig: Flowchart for add and subtract operations with signed-magnitude data
https://genuinenotes.com
8.2.Addition and Subtraction of Signed
2’s Complement Data
Nipun Thapa - (CO : Unit-09)
9
 In signed 2’s complement representation, the leftmost bit
represents sign (0 for positive and 1 for negative). If sign
bit is 1, entire number is represented in 2’s complement
form.
 Addition: Sign bit is treated as other bits of the number.
Carry out of the sign bit is discarded.
 Subtraction: It consists of first taking 2’s complement of
subtrahend and then adding it to minuend. When two
numbers of n-digit each are added, the sum occupies n+1
bits. Overflow occurs which is detected by applying last
two carries out of the addition to XOR gate. The overflow
occurs only if output of the gate is 1.
https://genuinenotes.com
8.2.Addition and Subtraction of Signed
2’s Complement Data
Nipun Thapa - (CO : Unit-09)
10
Hardware Implementation
Fig: Hardware for signed-2’s complement data addition and subtraction
https://genuinenotes.com
8.2.Addition and Subtraction of Signed
2’s Complement Data
Nipun Thapa - (CO : Unit-09)
11
Hardware Implementation..
 Register configuration is same as signed-magnitude
representation except sign bits are not separated. The
leftmost bits in AC and BR represent sign bits.
 Significant Difference: Sign bits are added together
with the other bits in complementer and parallel
adder. The overflow flip-flop V is set to 1 if there is an
overflow. Output carry in this case is discarded.
https://genuinenotes.com
8.2.Addition and Subtraction of Signed
2’s Complement Data
Nipun Thapa - (CO : Unit-09)
12
Hardware Algorithm
Fig: Algorithm for signed-2’s complement data addition and subtraction
https://genuinenotes.com
8.2.Addition and Subtraction of Signed
2’s Complement Data
Nipun Thapa - (CO : Unit-09)
13
Hardware Algorithm
 Comparing this with its signed-magnitude
counterpart, it is much easier to add and subtract
numbers. For this reason, most computers adopt this
representation over the more familiar signed-
magnitude.
Example: 33+(-35)
AC = 33 = 00100001
BR = -35 = 2’s complement of 35 = 11011101
AC+BR = 11111110 = -2
https://genuinenotes.com
8.3 Multiplication of Signed-Magnitude
Data
Nipun Thapa - (CO : Unit-09)
14
For this representation, multiplication is done by a process of successive shift and adds
operations. As an example:
Process consists of looking successive bits of the multiplier, least significant bits first.
• If the multiplier bit is 1, the multiplicand bit is copied down; otherwise zeroes are
copied down.
• Numbers copies down in successive lines are shifted one position left. Finally,
numbers are added to form a product.
The sign of the product is determined from the signs of the multiplicand and multiplier.
• If they are alike, the sign of the product is positive.
• If they are unlike, the sign of the product is negative.
https://genuinenotes.com
8.3 Multiplication of Signed-Magnitude
Data
Nipun Thapa - (CO : Unit-09)
15
Hardware Implementation
• Bmultiplicand, Bssign
• Qmultiplier, Qssign
• Successively accumulate partial products and shift
it right
• SCno. of bits in multiplier (magnitude only)
• SC is decremented after forming each partial
product. When SC is 0, process halts and final
product is formed.
• Sum of A and B forms a partial product.
Fig: Hardware for signed-magnitude multiply operation
https://genuinenotes.com
8.3 Multiplication of Signed-Magnitude
Data
Nipun Thapa - (CO : Unit-09)
16
Fig: Algorithm for signed-magnitude multiply operation
https://genuinenotes.com
8.4 Multiplication of Signed 2’s Complement
Data (Booth Multiplication Algorithm)
Nipun Thapa - (CO : Unit-09)
17
Booth algorithm is used to multiply binary numbers in
signed-2’s complement form.
Rules:
i) The partial product doesn’t change when the multiplier bit is
identical to the previous multiplier bit. ( Qn Qn+1 = 00 or 11)
ii) The multiplicand is added to the partial product if LSB is 0 in
the string of 0’s in the multiplier. ( Qn Qn+1 = 01)
iii) The multiplicand is subtracted from the partial product if LSB
is 1 in the string of 1’s in the multiplier. ( Qn Qn+1 = 10)
iv) After each addition/subtraction, the partial product is shifted
right using arithmetic shift.
This algorithm can be used for both the positive and negative
multiplier in 2’s complement form.
https://genuinenotes.com
Hardware for Booth Algorithm
Nipun Thapa - (CO : Unit-09)
18
 Here, sign bits are not separated.
 Registers A, B and Q are renamed to AC, BR and QR respectively.
 Extra flip-flop Qn+1 appended to QR is needed to store almost lost
right shifted bit to the multiplier (which along with current Qn gives
information about bit sequencing of multiplier).
 Pair QnQn+1 inspect double bits of the multiplier.
https://genuinenotes.com
Hardware Booth Algorithm
Nipun Thapa - (CO : Unit-09)
19
Fig: Flowchart for Booth Algorithm for signed-2’s complement data multiplication
https://genuinenotes.com
Finished
Unit 8
Nipun Thapa - (CO : Unit-09)
20
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
21
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
22
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
23
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
24
https://genuinenotes.com
Nipun Thapa - (CO : Unit-09)
25
https://genuinenotes.com

More Related Content

What's hot

Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxImranBhatti58
 
Computer instruction
Computer instructionComputer instruction
Computer instructionSanjeev Patel
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithmGaurav Subham
 
Addition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manoAddition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manocs19club
 
8086 Interrupts & With DOS and BIOS by vijay
8086 Interrupts &  With DOS and BIOS  by vijay8086 Interrupts &  With DOS and BIOS  by vijay
8086 Interrupts & With DOS and BIOS by vijayVijay Kumar
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operationsLakshya Sharma
 
Computer arithmetics (computer organisation &amp; arithmetics) ppt
Computer arithmetics (computer organisation &amp; arithmetics) pptComputer arithmetics (computer organisation &amp; arithmetics) ppt
Computer arithmetics (computer organisation &amp; arithmetics) pptSuryaKumarSahani
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Instruction cycle presentation
Instruction   cycle presentationInstruction   cycle presentation
Instruction cycle presentationMoniba Irfan
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
Register transfer &amp; microoperations moris mano ch 04
Register transfer &amp; microoperations    moris mano ch 04Register transfer &amp; microoperations    moris mano ch 04
Register transfer &amp; microoperations moris mano ch 04thearticlenow
 
Computer Architecture and organization ppt.
Computer Architecture and organization ppt.Computer Architecture and organization ppt.
Computer Architecture and organization ppt.mali yogesh kumar
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operationsVATSAL TRIVEDI
 

What's hot (20)

Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptx
 
Arithmetic and logic unit
Arithmetic and logic unitArithmetic and logic unit
Arithmetic and logic unit
 
Computer instruction
Computer instructionComputer instruction
Computer instruction
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
Addition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manoAddition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (mano
 
09 Arithmetic
09  Arithmetic09  Arithmetic
09 Arithmetic
 
8086 Interrupts & With DOS and BIOS by vijay
8086 Interrupts &  With DOS and BIOS  by vijay8086 Interrupts &  With DOS and BIOS  by vijay
8086 Interrupts & With DOS and BIOS by vijay
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
 
Computer arithmetics (computer organisation &amp; arithmetics) ppt
Computer arithmetics (computer organisation &amp; arithmetics) pptComputer arithmetics (computer organisation &amp; arithmetics) ppt
Computer arithmetics (computer organisation &amp; arithmetics) ppt
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Instruction cycle presentation
Instruction   cycle presentationInstruction   cycle presentation
Instruction cycle presentation
 
Instruction code
Instruction codeInstruction code
Instruction code
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Register transfer &amp; microoperations moris mano ch 04
Register transfer &amp; microoperations    moris mano ch 04Register transfer &amp; microoperations    moris mano ch 04
Register transfer &amp; microoperations moris mano ch 04
 
Lecture 37
Lecture 37Lecture 37
Lecture 37
 
Computer Architecture and organization ppt.
Computer Architecture and organization ppt.Computer Architecture and organization ppt.
Computer Architecture and organization ppt.
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operations
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 

Similar to Unit-8-Computer-Arithmetic.pdf

Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...mayurjagdale4
 
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...mayurjagdale4
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual Shankar Gangaju
 
Arithmetic Unit Addition Subtraction Multiplication and Division
Arithmetic Unit Addition Subtraction Multiplication and DivisionArithmetic Unit Addition Subtraction Multiplication and Division
Arithmetic Unit Addition Subtraction Multiplication and DivisionRNShukla7
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6Dr.MAYA NAYAK
 
Computer arithmetics coa project pdf version
Computer arithmetics coa project pdf versionComputer arithmetics coa project pdf version
Computer arithmetics coa project pdf versionSuryaKumarSahani
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logicDeepak John
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsArti Parab Academics
 
Integer represention
Integer representionInteger represention
Integer representionSaif Ullah
 
Arithmetic Microoperation.pdf
Arithmetic Microoperation.pdfArithmetic Microoperation.pdf
Arithmetic Microoperation.pdfHarshitJ4
 
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...inventionjournals
 
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...Asst.prof M.Gokilavani
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...Arti Parab Academics
 
Arithmatic Ch 10 (4).pdf
Arithmatic Ch 10 (4).pdfArithmatic Ch 10 (4).pdf
Arithmatic Ch 10 (4).pdfSahilSarda2
 
ARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptRAJESH S
 

Similar to Unit-8-Computer-Arithmetic.pdf (20)

Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
 
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...
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
computer arithmatic
computer arithmaticcomputer arithmatic
computer arithmatic
 
COA(Unit_3.pptx)
COA(Unit_3.pptx)COA(Unit_3.pptx)
COA(Unit_3.pptx)
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
 
Arithmetic Unit Addition Subtraction Multiplication and Division
Arithmetic Unit Addition Subtraction Multiplication and DivisionArithmetic Unit Addition Subtraction Multiplication and Division
Arithmetic Unit Addition Subtraction Multiplication and Division
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6
 
Computer arithmetics coa project pdf version
Computer arithmetics coa project pdf versionComputer arithmetics coa project pdf version
Computer arithmetics coa project pdf version
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logic
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
 
Integer represention
Integer representionInteger represention
Integer represention
 
UNIT-3 Complete PPT.pptx
UNIT-3 Complete PPT.pptxUNIT-3 Complete PPT.pptx
UNIT-3 Complete PPT.pptx
 
Arithmetic Microoperation.pdf
Arithmetic Microoperation.pdfArithmetic Microoperation.pdf
Arithmetic Microoperation.pdf
 
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...
Implementation and Simulation of Ieee 754 Single-Precision Floating Point Mul...
 
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
Arithmatic Ch 10 (4).pdf
Arithmatic Ch 10 (4).pdfArithmatic Ch 10 (4).pdf
Arithmatic Ch 10 (4).pdf
 
ARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.ppt
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

Unit-8-Computer-Arithmetic.pdf

  • 1. Nipun Thapa Chapter 8 Computer Arithmetic https://genuinenotes.com
  • 2. Computer Arithmetic Nipun Thapa - (CO : Unit-09) 2  Arithmetic instructions manipulate data to produce solution for computational problems.  The four basic arithmetic operations are addition, subtraction, multiplication and division. From these 4, it is possible to formulate other specific problems by means of numerical analysis methods.  There are three ways of representing negative fixed- point binary numbers: signed magnitude, signed 1’s complement and signed 2’s complement. Signed 2’s complemented form is used most but occasionally we deal with signed magnitude representation. https://genuinenotes.com
  • 3. 8.1 Addition and Subtraction of Signed- Magnitude Data Nipun Thapa - (CO : Unit-09) 3  When two signed numbers A and B are added and subtracted, we find 8 different conditions to consider as described in the following table: Table: addition and subtraction of signed-magnitude numbers https://genuinenotes.com
  • 4. 8.1 Addition and Subtraction of Signed- Magnitude Data Nipun Thapa - (CO : Unit-09) 4 Addition (subtraction) algorithm:  When the signs of A and B are identical (different), add magnitudes and attach the sign of A to the result.  When the signs of A and B are different (identical), compare the magnitudes and subtract the smaller from larger. Hardware implementation  To implement the two arithmetic operations with hardware, we have to store numbers into two registers A and B. Let As and Bs be two flip-flops that hold the corresponding signs. The results are transferred to A and As. A and As together form an accumulator. https://genuinenotes.com
  • 5. 8.1 Addition and Subtraction of Signed- Magnitude Data Nipun Thapa - (CO : Unit-09) 5 Fig: Hardware for signed-magnitude data addition and subtraction https://genuinenotes.com
  • 6. 8.1 Addition and Subtraction of Signed- Magnitude Data Nipun Thapa - (CO : Unit-09) 6 We need:  Two registers A and B and sign flip-flops As and Bs  A magnitude comparator: to check if A>B, A<B, or A=B  A parallel adder: to perform A+B  Two parallel subtractions: for A-B and B-A  The sign relationships are determined from an X-OR gate with As and Bs as inputs. Block Diagram Description  Hardware above consists of registers A and B and sign flip-flops As and Bs.  The complementary provides an output of B or B’ depending on mode input M.  When M=0, the output of B is transferred to the adder, the input carry is 0 and thus output of adder is A+B. Output carry is transferred to flip-flop E, where it can be checked to determine overflow. When E=1, it is overflow, otherwise, not. The E=1 is transferred to the AVF (add-overflow-flip-flop) which holds the overflow bit when A ns B are added.  When M=1, 1’s complement of B is applied to the adder, input carry is 1 and output is S=A+B’+1 (i.e. A-B). Output carry is transferred to flip-flop E, where it can be checked to determine the relative magnitude of two numbers. https://genuinenotes.com
  • 7. 8.1 Addition and Subtraction of Signed- Magnitude Data Nipun Thapa - (CO : Unit-09) 7 Hardware Algorithm  The flowchart for the hardware algorithm is given below:  As and Bs are compared by an X-OR gate. If output=0, signs are identical, if 1, signs are different.  For add operation, identical signs dictate addition of magnitudes. For subtraction, different signs dictate magnitudes be added.  Magnitudes are with a micro operation E A A+B (E A is register that combines E and A). If E=1, overflow occurs and is transferred to AVF.  Two magnitudes are subtracted if signs are different for add operation and identical for subtract operation.  Magnitudes are subtracted with a micro operation E A A+B’+1.  No overflow occurs if the numbers are subtracted, so AVF is cleared to 0.  If E=1, it indicates A≥B and the result in A is correct. If the number in A is 0, the sign As must be made positive (As=0) to avoid negative zero.  If E=0, it indicates that A<B for which it is necessary to take 2’s complement of value in A. the micro operation is A A’+1. The sign of As must be sign of Bs (i.e. AsAs’). https://genuinenotes.com
  • 8. Nipun Thapa - (CO : Unit-09) 8 Fig: Flowchart for add and subtract operations with signed-magnitude data https://genuinenotes.com
  • 9. 8.2.Addition and Subtraction of Signed 2’s Complement Data Nipun Thapa - (CO : Unit-09) 9  In signed 2’s complement representation, the leftmost bit represents sign (0 for positive and 1 for negative). If sign bit is 1, entire number is represented in 2’s complement form.  Addition: Sign bit is treated as other bits of the number. Carry out of the sign bit is discarded.  Subtraction: It consists of first taking 2’s complement of subtrahend and then adding it to minuend. When two numbers of n-digit each are added, the sum occupies n+1 bits. Overflow occurs which is detected by applying last two carries out of the addition to XOR gate. The overflow occurs only if output of the gate is 1. https://genuinenotes.com
  • 10. 8.2.Addition and Subtraction of Signed 2’s Complement Data Nipun Thapa - (CO : Unit-09) 10 Hardware Implementation Fig: Hardware for signed-2’s complement data addition and subtraction https://genuinenotes.com
  • 11. 8.2.Addition and Subtraction of Signed 2’s Complement Data Nipun Thapa - (CO : Unit-09) 11 Hardware Implementation..  Register configuration is same as signed-magnitude representation except sign bits are not separated. The leftmost bits in AC and BR represent sign bits.  Significant Difference: Sign bits are added together with the other bits in complementer and parallel adder. The overflow flip-flop V is set to 1 if there is an overflow. Output carry in this case is discarded. https://genuinenotes.com
  • 12. 8.2.Addition and Subtraction of Signed 2’s Complement Data Nipun Thapa - (CO : Unit-09) 12 Hardware Algorithm Fig: Algorithm for signed-2’s complement data addition and subtraction https://genuinenotes.com
  • 13. 8.2.Addition and Subtraction of Signed 2’s Complement Data Nipun Thapa - (CO : Unit-09) 13 Hardware Algorithm  Comparing this with its signed-magnitude counterpart, it is much easier to add and subtract numbers. For this reason, most computers adopt this representation over the more familiar signed- magnitude. Example: 33+(-35) AC = 33 = 00100001 BR = -35 = 2’s complement of 35 = 11011101 AC+BR = 11111110 = -2 https://genuinenotes.com
  • 14. 8.3 Multiplication of Signed-Magnitude Data Nipun Thapa - (CO : Unit-09) 14 For this representation, multiplication is done by a process of successive shift and adds operations. As an example: Process consists of looking successive bits of the multiplier, least significant bits first. • If the multiplier bit is 1, the multiplicand bit is copied down; otherwise zeroes are copied down. • Numbers copies down in successive lines are shifted one position left. Finally, numbers are added to form a product. The sign of the product is determined from the signs of the multiplicand and multiplier. • If they are alike, the sign of the product is positive. • If they are unlike, the sign of the product is negative. https://genuinenotes.com
  • 15. 8.3 Multiplication of Signed-Magnitude Data Nipun Thapa - (CO : Unit-09) 15 Hardware Implementation • Bmultiplicand, Bssign • Qmultiplier, Qssign • Successively accumulate partial products and shift it right • SCno. of bits in multiplier (magnitude only) • SC is decremented after forming each partial product. When SC is 0, process halts and final product is formed. • Sum of A and B forms a partial product. Fig: Hardware for signed-magnitude multiply operation https://genuinenotes.com
  • 16. 8.3 Multiplication of Signed-Magnitude Data Nipun Thapa - (CO : Unit-09) 16 Fig: Algorithm for signed-magnitude multiply operation https://genuinenotes.com
  • 17. 8.4 Multiplication of Signed 2’s Complement Data (Booth Multiplication Algorithm) Nipun Thapa - (CO : Unit-09) 17 Booth algorithm is used to multiply binary numbers in signed-2’s complement form. Rules: i) The partial product doesn’t change when the multiplier bit is identical to the previous multiplier bit. ( Qn Qn+1 = 00 or 11) ii) The multiplicand is added to the partial product if LSB is 0 in the string of 0’s in the multiplier. ( Qn Qn+1 = 01) iii) The multiplicand is subtracted from the partial product if LSB is 1 in the string of 1’s in the multiplier. ( Qn Qn+1 = 10) iv) After each addition/subtraction, the partial product is shifted right using arithmetic shift. This algorithm can be used for both the positive and negative multiplier in 2’s complement form. https://genuinenotes.com
  • 18. Hardware for Booth Algorithm Nipun Thapa - (CO : Unit-09) 18  Here, sign bits are not separated.  Registers A, B and Q are renamed to AC, BR and QR respectively.  Extra flip-flop Qn+1 appended to QR is needed to store almost lost right shifted bit to the multiplier (which along with current Qn gives information about bit sequencing of multiplier).  Pair QnQn+1 inspect double bits of the multiplier. https://genuinenotes.com
  • 19. Hardware Booth Algorithm Nipun Thapa - (CO : Unit-09) 19 Fig: Flowchart for Booth Algorithm for signed-2’s complement data multiplication https://genuinenotes.com
  • 20. Finished Unit 8 Nipun Thapa - (CO : Unit-09) 20 https://genuinenotes.com
  • 21. Nipun Thapa - (CO : Unit-09) 21 https://genuinenotes.com
  • 22. Nipun Thapa - (CO : Unit-09) 22 https://genuinenotes.com
  • 23. Nipun Thapa - (CO : Unit-09) 23 https://genuinenotes.com
  • 24. Nipun Thapa - (CO : Unit-09) 24 https://genuinenotes.com
  • 25. Nipun Thapa - (CO : Unit-09) 25 https://genuinenotes.com