CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©

Slides:



Advertisements
Similar presentations
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Advertisements

Datorteknik IntegerMulDiv bild 1 MIPS mul/div instructions Multiply: mult $2,$3Hi, Lo = $2 x $3;64-bit signed product Multiply unsigned: multu$2,$3Hi,
CMPE 325 Computer Architecture II
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 8 - Multiplication.
THE ARITHMETIC-LOGIC UNIT. BINARY HALF-ADDER BINARY HALF-ADDER condt Half adder InputOutput XYSC
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
Lecture Objectives: 1)Perform binary division of two numbers. 2)Define dividend, divisor, quotient, and remainder. 3)Explain how division is accomplished.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Arithmetic IV CPSC 321 Andreas Klappenecker. Any Questions?
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Computer Organization Multiplication and Division Feb 2005 Reading: Portions of these slides are derived from: Textbook figures © 1998 Morgan Kaufmann.
Chap 3.3~3.5 Construction an Arithmetic Logic Unit (ALU) Jen-Chang Liu, Spring 2006.
Integer Multiplication and Division
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
MIPS Architecture Multiply/Divide Functions & Floating Point Chapter 4
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
Multiplication CPSC 252 Computer Organization Ellen Walker, Hiram College.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Lecture 6: Multiply, Shift, and Divide
Lecture 9: Floating Point
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Integer Multiplication and Division
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Csci 136 Computer Architecture II – Multiplication and Division
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Computer Architecture & Operations I
Integer Multiplication, Division Arithmetic shift
Multiplication and Division basics
Computer Architecture & Operations I
Integer Multiplication and Division
MIPS mul/div instructions
Morgan Kaufmann Publishers Arithmetic for Computers
Lecture 9: Floating Point
CS 314 Computer Organization Fall Chapter 3: Arithmetic for Computers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Lecture 8: Binary Multiplication & Division
Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
CDA 3101 Spring 2016 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
CSCE 350 Computer Architecture
CSCI206 - Computer Organization & Programming
Systems Architecture I
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Arithmetic Multiplication, Floating Point
Morgan Kaufmann Publishers Arithmetic for Computers
Number Representation
Presentation transcript:

CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, © 2014, MK]

2 Multiplication Example Multiplicand 1000 ten Multiplier x 1001 ten Product ten In every step multiplicand is shifted next bit of multiplier is examined (also a shifting step) if this bit is 1, shifted multiplicand is added to the product Length of product is the sum of operand lengths

3 Multiplication Algorithm In every step multiplicand is shifted next bit of multiplier is examined (also a shifting step) if this bit is 1, shifted multiplicand is added to the product

5 Example Multiply 2 ten * 3 ten, or 0010 two * 0011 two

Faster Multiplier Uses multiple adders ▫Cost/performance tradeoff

7 Signed Multiplication The previous algorithm also works for signed numbers (negative numbers in 2’s complement form) We can also convert negative numbers to positive, multiply the magnitudes, and convert to negative if signs disagree

8 MIPS Instructions mult $s2, $s3 computes the product and stores it in two “internal” registers that can be referred to as hi and lo mfhi $s0 moves the value in hi into $s0 mflo $s1 moves the value in lo into $s1 Similarly for multu The product of two 32-bit numbers can be a 64-bit number HI: most-significant 32 bits LO: least-significant 32-bits mul rd, rs, rt Least-significant 32 bits of product –> rd

9 Division At every step, shift divisor right and compare it with current dividend if divisor is larger, shift 0 as the next bit of the quotient if divisor is smaller, subtract to get new dividend and shift 1 as the next bit of the quotient quotient dividend remainder

10 Hardware for Division A comparison requires a subtract; the sign of the result is examined; if the result is negative, the divisor must be added back Initially dividend Initially divisor in left half

Initially dividend Initially divisor in left half

12 Divide Example Divide 7 ten ( two ) by 2 ten (0010 two ) IterStepQuotDivisorRemainder 0Initial values

13 Divide Example Divide 7 ten ( two ) by 2 ten (0010 two )

14 Divisions involving Negatives Simplest solution: convert to positive and adjust sign later Note that multiple solutions exist for the equation: Dividend = Quotient x Divisor + Remainder +7 div +2 Quo = Rem = -7 div +2 Quo = Rem = +7 div -2 Quo = Rem = -7 div -2 Quo = Rem =

15 Divisions involving Negatives Simplest solution: convert to positive and adjust sign later Note that multiple solutions exist for the equation: Dividend = Quotient x Divisor + Remainder +7 div +2 Quo = +3 Rem = div +2 Quo = -3 Rem = div -2 Quo = -3 Rem = div -2 Quo = +3 Rem = -1 Convention: Dividend and remainder have the same sign Quotient is negative if signs disagree These rules fulfil the equation above

MIPS Division Use HI/LO registers for result ▫HI: 32-bit remainder ▫LO: 32-bit quotient Instructions ▫ div rs, rt / divu rs, rt ▫Use mfhi, mflo to access result