1 / 7

Division

Division. Perform binary division of two numbers. Define dividend, divisor, quotient, and remainder. Explain how division is accomplished in computer hardware. Construct a simple program which uses MIPS integer multiplication and division . Definitions (Pg 237). Dividend

omar
Download Presentation

Division

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Division Perform binary division of two numbers. Define dividend, divisor, quotient, and remainder. Explain how division is accomplished in computer hardware. Construct a simple program which uses MIPS integer multiplication and division

  2. Definitions (Pg 237) • Dividend • The first operand of a divide operation • Divisor • The second operand of a divide operation • Quotient • The primary result of a divide operation • Remainder • The secondary result ofa division operation 14 / 5 = 2rem4 CS2710 Computer Organization

  3. Division (Long Approach) • Solve the following CS2710 Computer Organization

  4. Division Algorithm • Check for 0 divisor first! • Long division approach • If divisor ≤ dividend bits • 1 bit in quotient, subtract • Otherwise • 0 bit in quotient, bring down next dividend bit • Restoring division • Do the subtract, and if remainder goes < 0, add divisor back • Signed division • Divide using absolute values • Adjust sign of quotient and remainder as required CS2710 Computer Organization

  5. Faster Division • Can’t use parallel hardware as in multiplier • In multiplication, we can compute partial products simultaneously • In division, we have to compute differences at each step • Faster dividers (e.g. SRT division) generate multiple quotient bits per step • Still require multiple steps, using guesses and corrections • Uses a lookup table that must be precomputed • Source of infamous 1994 Pentium flaw

  6. MIPS Division • Use HI/LO registers for result • HI: 32-bit remainder • LO: 32-bit quotient • Instructions • div rs, rt / divurs, rt • No overflow or divide-by-0 checking! • Software must perform checks if required • Use mfhi, mflo to access result • $hi and $lo are left unchanged during divide-by-0! • They contain whatever values they had prior to divide-by-0 Chapter 3 — Arithmetic for Computers — 6

  7. In Class Example • Write an assembly program which will perform the following: • Read two integer numbers from the user • Print out their product • Print out their quotient • Print out the remainder (If the numbers are not evenly divisible) CS2710 Computer Organization

More Related