Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI206 - Computer Organization & Programming

Similar presentations


Presentation on theme: "CSCI206 - Computer Organization & Programming"— Presentation transcript:

1 CSCI206 - Computer Organization & Programming
Integer Divide zyBook: 10.4

2 Division: Similar to multiplication
Algorithm: subtract and shift...

3 Signed Division Same as signed multiply divide absolute values
resulting sign bit: Quotient and remainder have the same sign

4 The Divider Same hardware as multiply! Setup
divisor in left half of divisor register (64 bit for now) remainder register initialized with dividend in right half e.g., would occupy

5 The Divider

6 0111 / 0010 = ???? R ???? Example 1

7 0111 / 0010 = 0011 R 0001 2’s comp of is 2’s comp of is 2’s comp of is 2’s comp of is 2’s comp of is

8 same as optimized multiply hardware
Optimized Divider same as optimized multiply hardware Algorithm HI(Remainder) = 0 LO(Remainder) = Dividend repeat N times: Remainder <<= 1 HI(Remainder) -= Divisor if HI(Remainder) > 0 Remainder[0] = 1 else HI(Remainder) += Divisor Remainder[0] = 0

9 Example with optimized divider
2’s comp 0010 = 1110 Iteration Step Divisor Rem/Quotient Initial values 0010 1 Rem << 1 HI(Rem) -= Div Rem < 0, Rem+Div, Rem[0] = 0 2 3 Rem >= 0, Rem[0] = 1 4 Rem>=0, Rem[0] = 1 The values in read are quotient, the left part of Rem is the remainder.

10 Compared with hand-operation in decimal numbers
Remainder 00000 10970 10970 dividend Quotient ______ 23 |10970 _00476_ 23 |10970 -092 0177 -161 0160 138 22 00000 10970 00023 divisor 00001 09700 00476 00001 09700 quotient 00010 97000 00022 remainder 00010 97000 00109 70000 00017 70004 109-4*23=17 00177 00040 00016 00047 177-7*23=16 00160 00470 Quotient Remainder 00022 00476 160-6*23=22


Download ppt "CSCI206 - Computer Organization & Programming"

Similar presentations


Ads by Google