# Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Algorithm for Integer Division The natural (by-hand)

## Presentation on theme: "Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Algorithm for Integer Division The natural (by-hand)"— Presentation transcript:

Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Algorithm for Integer Division The natural (by-hand) algorithm for integer division is essentially an iterated subtract-and-shift. Recall that mathematics says: or: where:

Arithmetic Intro Computer Organization 2 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Division Illustrated 15 divided by 6: 0 0010 +----------- 0110 | 0000 1111 ^^^^ 0000 < 0110 no go ^^^ ^ 0001 < 0110 no go ^^ ^^ 0011 < 0110 no go ^ ^^^ 0111 >= 0110 OK, set quotient bit and subtract 0000 0011 ^^^^ 0011 < 0110 no go, and done divisor remainder quotient 0110 0000 0000 1111* 0000 1010 1111 0000 # negative, retract, shift 0011 0000 1101 1111 0000 # negative, retract, shift 0001 1000 1111 0111 0000 # negative, retract, shift 0000 1100 0000 0011 0001 # OK, keep remainder, shift 0000 0110 1111 1101 0010 # negative, retract, shift

Arithmetic Intro Computer Organization 3 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Division Design 1.0 Divisor Shift right 64-bit ALU 64 bits Remainder Write 64 bits Quotient Shift left Control test 32 bits Look familiar??

Arithmetic Intro Computer Organization 4 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Division Design 2.0 Just as with multiplication, we can optimize the hardware to eliminate most of the 64-bit components used in the first design. Divisor 32-bit ALU Remainder Write Shift right Control test 32 bits 64 bits Shift left

Download ppt "Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 ©2006-08 McQuain Algorithm for Integer Division The natural (by-hand)"

Similar presentations