Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.

Slides:



Advertisements
Similar presentations
CMPE 325 Computer Architecture II
Advertisements

Integer division Pencil and paper binary division (dividend)(divisor) 1000.
THE ARITHMETIC-LOGIC UNIT. BINARY HALF-ADDER BINARY HALF-ADDER condt Half adder InputOutput XYSC
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Binary Addition Rules Adding Binary Numbers = = 1
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
Fixed-Point Arithmetics: Part I
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
Computer Arithmetic.
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
Multiplication of signed-operands
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
Partial Quotient Method In this division algorithm the children record on the right side of the problem. The first thing they do is divide. They ask themselves.
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Operations Computer Organization and Assembly Language: Module 5.
Ch. 4 Computer Arithmetic
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
More Binary Arithmetic - Multiplication
Multiplication and Division basics
CSCI206 - Computer Organization & Programming
CDA 3101 Summer 2007 Introduction to Computer Organization
William Stallings Computer Organization and Architecture 7th Edition
Computer Organization and ASSEMBLY LANGUAGE
CSCI206 - Computer Organization & Programming
Topic 3c Integer Multiply and Divide
Computation in Other Bases
ECEG-3202 Computer Architecture and Organization
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Chapter 8 Computer Arithmetic
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division

Multiplication Complex Work out partial product for each digit Take care with place value (column) Add partial products

Multiplication Example (unsigned) (long hand) 1011 Multiplicand (11 dec) x 1101 Multiplier (13 dec) 1011 Partial products Note: if multiplier bit is 1 copy multiplicand (place value) otherwise zero Product (143 dec) Note: need double length result

Flowchart for Unsigned Binary Multiplication

Execution of Example

Multiplying Negative Numbers This does not work! Solution 1 —Convert to positive if required —Multiply as above —If signs were different, negate answer Solution 2 —Booth’s algorithm

Booth’s Algorithm

Example of Booth’s Algorithm 3*7 First setup the columns and initial values. This case 3 is in Q and M is 7. —But could put 7 in Q and M as 3

Example of Booth’s Algorithm First cycle: Now look at Q 0 and Q -1 With a 10, we Sub (A=A-M), then shift (always to the right) Second cycle: looking at Q 0 and Q -1 —With a 11, we only shift.

Example of Booth’s Algorithm 2 nd cycle Result Third cycle, Q 0 and Q -1 have 01 —So we will Add (A=A+M), then shift

3 nd cycle Result 4 th cycle, Q 0 and Q -1 have 00 —So we only shift Example of Booth’s Algorithm

4 nd cycle Result 5 th cycle, Q 0 and Q -1 have 00 —So we only shift Example of Booth’s Algorithm

5 th cycle Result Since we are working in 5 bits, we only repeat 5 times

Example of Booth’s Algorithm Result is A and Q so which is 21. Note: The sign bit is the last bit in A.

Division More complex than multiplication Negative numbers are really bad! Based on long division

Division of Unsigned Binary Integers Quotient Dividend Remainder Partial Remainders Divisor

Flowchart for Unsigned Binary Division

Signed Division 1. Load divisor into M and the dividend into A, Q registers. Dividend must be 2n-bit twos complement number —0111 (7) becomes —1001 (-7) becomes Shift A, Q left 1 bit position 3. If M and A have the same signs, A  A –M else A  A+M

4. Step 3 is successful if sign of A is the same as before step 3 and at the end of step 3 A.if successful or (A=0 AND Q=0) then set Q0  1 B.if unsuccessful and (A  0 OR Q  0) then restore the previous value of A 5. Repeat steps 2 through 4 as many times as there are bit positions in Q. 6. The reminder is in A. If the signs are of Divisor and dividend were the same, the quotient is in Q, otherwise the correct quotient is the twos complement of Q.

Examples of division (signed) AQM=0011AQ Initial Value Initial Value shift shift 1101subtract0010Add restore Restore shift Shift 1110subtract0001Add restore Restore shift Shift 0000subtract1111Add set Q0 = Q0 = Shift Shift 1110subtract0010Add restore Restore (a) 7/3(b) -7/3

Q A &