SlideShare a Scribd company logo
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 Operations
gueste99d9a
 
Integer represention
Integer representionInteger represention
Integer represention
Saif Ullah
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
Keyur Vadodariya
 
1122230 question
1122230 question1122230 question
1122230 questionlpss0513
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
Usiju Gadzama
 
Advantage of binary number system
Advantage of binary number systemAdvantage of binary number system
Advantage of binary number system
Sooraj Maurya
 
Hennchthree 160912095304
Hennchthree 160912095304Hennchthree 160912095304
Hennchthree 160912095304
marangburu42
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computersBảo Hoang
 
Number system
Number systemNumber system
Number system
Sushil Subedi
 
Hennchthree
HennchthreeHennchthree
Hennchthree
marangburu42
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
mayannpolisticoLNU
 
Number Systems
Number SystemsNumber Systems
Number Systems
Gaditek
 
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 System
kclove
 
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.ppt
JEEVANANTHAMG6
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
 
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.pptx
ssusera6fdd5
 
Manoch1raw 160512091436
Manoch1raw 160512091436Manoch1raw 160512091436
Manoch1raw 160512091436
marangburu42
 
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.ppt
zorogoh2
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
wajanga
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015
Aron Kondoro
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2
Dr.MAYA NAYAK
 
Four bit Signed Calculator.pptx
Four bit Signed Calculator.pptxFour bit Signed Calculator.pptx
Four bit Signed Calculator.pptx
SUGAMRAJPUT2
 
crc_checksum.pdf
crc_checksum.pdfcrc_checksum.pdf
crc_checksum.pdf
ssuser8b4eb21
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
GafryMahmoud
 
Data representation
Data representationData representation
Data representation
Manish Kumar
 
Chapter 9.pdf
Chapter 9.pdfChapter 9.pdf
Chapter 9.pdf
sarojthapa35
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
miftah88
 
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 propagation
Scilab
 
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
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015
 
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

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 

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).