SlideShare a Scribd company logo
1 of 32
Download to read offline
UNIT II Arithmetic
Addition and Subtraction
 Digits are added bit by bit from right to left , with carries passed
to the next digit to the left , just as you would do by hand.
 Subtraction uses addition: the appropriate operand is simply
negated before being added.
 Binary Addition and Subtraction
 Let’s try adding 6 to 7 in binary and then subtracting 6 from 7
in binary.
 Subtracting 6 ten from 7 ten can be done directly:
 or via addition using the two’s complement representation of 6:
 When adding operands with different signs, overflow cannot
occur.
 The reason is the sum must be no larger than one of the
operands.
 when the signs of the operands are the same, overflow cannot
occur
 The lack of a 33rd bit means that when overflow occurs, the sign
bit is set with the value of the result instead of the proper sign of
the result
 overflow occurs when adding two positive numbers and the sum
is negative, or vice versa.This spurious sum mean a carry out
occurred into the sign bit.
 Overflow occurs in subtraction when we subtract a negative
number from a positive number and get a negative result, or
when we subtract a positive number from a negative number and
get a positive result.
 Such a ridiculous result means a borrow occurred from the sign
bit.
 We have just seen how to detect overflow for two’s complement
numbers in a computer.What about overflow with unsigned
integers? Unsigned integers are commonly used for memory
addresses where overflows are ignored.
 The computer designer must therefore provide a way to ignore
overflow in some cases and to recognize it in others.
 The MIPS solution is to have two kinds of arithmetic instructions to
recognize the two choices:
 Add (add), add immediate (addi), and subtract (sub) cause
exceptions on overflow.
 Add unsigned (addu), add immediate unsigned (addiu), and
subtract unsigned (subu) do not cause exceptions on overflow.
 MIPS detects overflow with an exception, also called an
interrupt on many computers.
 An exception or interrupt is essentially an unscheduled procedure
call.
 The address of the instruction that overflowed is saved in a
register, and the computer jumps to a predefined address to invoke
the appropriate routine for that exception.
 The interrupted address is saved so that in some situations the
program can continue after corrective code is executed.
 MIPS includes a register called the exception program counter
(EPC) to contain the address of the instruction that caused the
exception.
Multiplication
 1. Multiplying 1000 ten by 1001ten :
 The first operand is called the multiplicand and the second the
multiplier.The final result is called the product.
 The first observation is that the number of digits in the product
is considerably larger than the number in either the multiplicand
or the multiplier
 if we ignore the sign bits, the length of the multiplication of an n-
bit multiplicand and an m-bit multiplier is a product that is n m
bits long.
 That is, n m bits are required to represent all possible products
like add, multiply must cope with overflow because we
frequently want a 32-bit product as the result of multiplying two
32-bit numbers.
 we restricted the decimal digits to 0 and 1.With only two
choices, each step of the multiplication is simple:
 1. Just place a copy of the multiplicand (1 multiplicand) in the
proper place if the multiplier digit is a 1, or
 2. Place 0 (0 multiplicand) in the proper place if the digit is 0.
Sequential Version of the Multiplication
Algorithm and Hardware
Refined version of the multiplication
hardware.
 A Multiply Algorithm Using 4-bit numbers to save space,
multiply 2tenX 3ten, or 0010twoX 0011two.
Division
 Th e example is dividing 1,001,010ten by 1000ten:
 Divide’s two operands, called the dividend and divisor, and
the result, called the quotient, are accompanied by a
second result, called the remainder. Here is another way
to express the relationship between the components:
 Dividend = Quotient * Divisor+ Remainder
A Division Algorithm and Hardware
A Divide Algorithm
 Using a 4-bit version of the algorithm to save pages, let’s try
dividing 7ten,or 0000 0111two by 0010two by 2ten
An improved version of the division
hardware.
Divide in MIPS
 To handle both signed integers and unsigned integers, MIPS
has two instructions: divide (div) and divide unsigned (divu)
Restoring Division
 Divisor is loaded into the register M
 Dividend loaded in to the register Q
 Initial value of register A is 0
 1000/11
Non Restoring
 Divisor is loaded into the register M
 Dividend loaded in to the register Q
 Initial value of register A is 0
Fast Adder –Carry Look ahead Adder
Faster Multiplication
Booth Multiplication -Signed Number
Multiply in MIPS
 MIPS provides a separate pair of 32-bit registers to contain
the 64-bit product, called Hi and Lo.To produce a properly
signed or unsigned product, MIPS has two instructions:
multiply (mult) and multiply unsigned (multu).

More Related Content

What's hot

Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmeticIIUI
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operationsgueste99d9a
 
Integer represention
Integer representionInteger represention
Integer representionSaif Ullah
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And SubtractionKeyur Vadodariya
 
1122230 question
1122230 question1122230 question
1122230 questionlpss0513
 
Advantage of binary number system
Advantage of binary number systemAdvantage of binary number system
Advantage of binary number systemSooraj Maurya
 
Hennchthree 160912095304
Hennchthree 160912095304Hennchthree 160912095304
Hennchthree 160912095304marangburu42
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computersBảo Hoang
 
Number Systems
Number SystemsNumber Systems
Number SystemsGaditek
 
Fractions keynote for explaining
Fractions keynote for explainingFractions keynote for explaining
Fractions keynote for explaininggrade5a
 
Chapter iii: Number System
Chapter iii: Number SystemChapter iii: Number System
Chapter iii: Number Systemkclove
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation Kamal Acharya
 

What's hot (20)

Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operations
 
Integer represention
Integer representionInteger represention
Integer represention
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
1122230 question
1122230 question1122230 question
1122230 question
 
Integers
IntegersIntegers
Integers
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Advantage of binary number system
Advantage of binary number systemAdvantage of binary number system
Advantage of binary number system
 
Hennchthree 160912095304
Hennchthree 160912095304Hennchthree 160912095304
Hennchthree 160912095304
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
 
Number system
Number systemNumber system
Number system
 
Hennchthree
HennchthreeHennchthree
Hennchthree
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Fractions keynote for explaining
Fractions keynote for explainingFractions keynote for explaining
Fractions keynote for explaining
 
Chapter iii: Number System
Chapter iii: Number SystemChapter iii: Number System
Chapter iii: Number System
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 

Similar to Unit ii ca--arithmetic

Arithmetic for Computers.ppt
Arithmetic for Computers.pptArithmetic for Computers.ppt
Arithmetic for Computers.pptJEEVANANTHAMG6
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptxbmangesh
 
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 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
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptxssusera6fdd5
 
Manoch1raw 160512091436
Manoch1raw 160512091436Manoch1raw 160512091436
Manoch1raw 160512091436marangburu42
 
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
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.pptzorogoh2
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015Aron Kondoro
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4wajanga
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2Dr.MAYA NAYAK
 
Four bit Signed Calculator.pptx
Four bit Signed Calculator.pptxFour bit Signed Calculator.pptx
Four bit Signed Calculator.pptxSUGAMRAJPUT2
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfGafryMahmoud
 
Data representation
Data representationData representation
Data representationManish Kumar
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdfmiftah88
 
micro proj4.V2odt
micro proj4.V2odtmicro proj4.V2odt
micro proj4.V2odtBruno Diaz
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationScilab
 
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
 

Similar to Unit ii ca--arithmetic (20)

Arithmetic for Computers.ppt
Arithmetic for Computers.pptArithmetic for Computers.ppt
Arithmetic for Computers.ppt
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
 
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 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...
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptx
 
Manoch1raw 160512091436
Manoch1raw 160512091436Manoch1raw 160512091436
Manoch1raw 160512091436
 
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...
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2
 
Four bit Signed Calculator.pptx
Four bit Signed Calculator.pptxFour bit Signed Calculator.pptx
Four bit Signed Calculator.pptx
 
crc_checksum.pdf
crc_checksum.pdfcrc_checksum.pdf
crc_checksum.pdf
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
 
Data representation
Data representationData representation
Data representation
 
Chapter 9.pdf
Chapter 9.pdfChapter 9.pdf
Chapter 9.pdf
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
micro proj4.V2odt
micro proj4.V2odtmicro proj4.V2odt
micro proj4.V2odt
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagation
 
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...
 

Recently uploaded

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
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
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
 
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
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
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
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
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
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

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
 
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
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
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
 
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
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
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
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
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
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Unit ii ca--arithmetic

  • 2. Addition and Subtraction  Digits are added bit by bit from right to left , with carries passed to the next digit to the left , just as you would do by hand.  Subtraction uses addition: the appropriate operand is simply negated before being added.  Binary Addition and Subtraction  Let’s try adding 6 to 7 in binary and then subtracting 6 from 7 in binary.
  • 3.  Subtracting 6 ten from 7 ten can be done directly:  or via addition using the two’s complement representation of 6:  When adding operands with different signs, overflow cannot occur.  The reason is the sum must be no larger than one of the operands.
  • 4.  when the signs of the operands are the same, overflow cannot occur  The lack of a 33rd bit means that when overflow occurs, the sign bit is set with the value of the result instead of the proper sign of the result  overflow occurs when adding two positive numbers and the sum is negative, or vice versa.This spurious sum mean a carry out occurred into the sign bit.  Overflow occurs in subtraction when we subtract a negative number from a positive number and get a negative result, or when we subtract a positive number from a negative number and get a positive result.  Such a ridiculous result means a borrow occurred from the sign bit.
  • 5.  We have just seen how to detect overflow for two’s complement numbers in a computer.What about overflow with unsigned integers? Unsigned integers are commonly used for memory addresses where overflows are ignored.  The computer designer must therefore provide a way to ignore overflow in some cases and to recognize it in others.  The MIPS solution is to have two kinds of arithmetic instructions to recognize the two choices:
  • 6.  Add (add), add immediate (addi), and subtract (sub) cause exceptions on overflow.  Add unsigned (addu), add immediate unsigned (addiu), and subtract unsigned (subu) do not cause exceptions on overflow.  MIPS detects overflow with an exception, also called an interrupt on many computers.  An exception or interrupt is essentially an unscheduled procedure call.  The address of the instruction that overflowed is saved in a register, and the computer jumps to a predefined address to invoke the appropriate routine for that exception.  The interrupted address is saved so that in some situations the program can continue after corrective code is executed.
  • 7.  MIPS includes a register called the exception program counter (EPC) to contain the address of the instruction that caused the exception.
  • 8.
  • 9.
  • 10. Multiplication  1. Multiplying 1000 ten by 1001ten :  The first operand is called the multiplicand and the second the multiplier.The final result is called the product.  The first observation is that the number of digits in the product is considerably larger than the number in either the multiplicand or the multiplier
  • 11.  if we ignore the sign bits, the length of the multiplication of an n- bit multiplicand and an m-bit multiplier is a product that is n m bits long.  That is, n m bits are required to represent all possible products like add, multiply must cope with overflow because we frequently want a 32-bit product as the result of multiplying two 32-bit numbers.  we restricted the decimal digits to 0 and 1.With only two choices, each step of the multiplication is simple:  1. Just place a copy of the multiplicand (1 multiplicand) in the proper place if the multiplier digit is a 1, or  2. Place 0 (0 multiplicand) in the proper place if the digit is 0.
  • 12. Sequential Version of the Multiplication Algorithm and Hardware
  • 13.
  • 14. Refined version of the multiplication hardware.
  • 15.  A Multiply Algorithm Using 4-bit numbers to save space, multiply 2tenX 3ten, or 0010twoX 0011two.
  • 16. Division  Th e example is dividing 1,001,010ten by 1000ten:  Divide’s two operands, called the dividend and divisor, and the result, called the quotient, are accompanied by a second result, called the remainder. Here is another way to express the relationship between the components:  Dividend = Quotient * Divisor+ Remainder
  • 17.
  • 18. A Division Algorithm and Hardware
  • 19. A Divide Algorithm  Using a 4-bit version of the algorithm to save pages, let’s try dividing 7ten,or 0000 0111two by 0010two by 2ten
  • 20. An improved version of the division hardware.
  • 21. Divide in MIPS  To handle both signed integers and unsigned integers, MIPS has two instructions: divide (div) and divide unsigned (divu)
  • 22. Restoring Division  Divisor is loaded into the register M  Dividend loaded in to the register Q  Initial value of register A is 0
  • 24.
  • 25. Non Restoring  Divisor is loaded into the register M  Dividend loaded in to the register Q  Initial value of register A is 0
  • 26.
  • 27. Fast Adder –Carry Look ahead Adder
  • 28.
  • 29.
  • 32. Multiply in MIPS  MIPS provides a separate pair of 32-bit registers to contain the 64-bit product, called Hi and Lo.To produce a properly signed or unsigned product, MIPS has two instructions: multiply (mult) and multiply unsigned (multu).