Download presentation
Presentation is loading. Please wait.
Published byBertina Naomi Crawford Modified over 5 years ago
1
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
2/21/2019 Comp 120 Fall 2001
2
Multiplication Facts N digit number TIMES a M digit number produces: ?
32 bit number TIMES a 32 bit number produces: ? a (N+M) digit number a 64 bit number 123 x 45 615 492 5535 101 x 11 1111 2/21/2019 Comp 120 Fall 2001
3
Multiplication: Implementation
S t a r t D o n e 1 . T s t M u l i p r a A d m c h P g 2 S f b 3 M u l t i p l i e r = 1 M u l t i p l i e r = t N o : < 3 2 r e p e t i t i o n s 3 2 n d r e p e t i t i o n ? Y e s : 3 2 r e p e t i t i o n s 2/21/2019 Comp 120 Fall 2001
4
Second Version 2/21/2019 Comp 120 Fall 2001 S t a r t M u l t i p l i
. T s t M u l i p r a A d m c h f P g 2 S b 3 3 2 b i t s M u l t i p l i e r = 1 M u l t i p l i e r = M u l t i p l i e r 3 2 - b i t A L U S h i f t r i g h t 3 2 b i t s S h i f t r i g h t P r o d u c t C o n t r o l t e s t W r i t e 6 4 b i t s i f t t h e M u l t i p l i e r r e g i s t e r r i g h t 1 b i t N o : < 3 2 r e p e t i t i o n s 3 2 n d r e p e t i t i o n ? Y e s : 3 2 r e p e t i t i o n s 2/21/2019 Comp 120 Fall 2001
5
Example for second version
0010 Test true shift right 4 Test false shift right 3 2 1 1011 Initial Product Multiplicand Multiplier Step Iteration 2/21/2019 Comp 120 Fall 2001
6
Final Version S t a r t D o n e 1 . T s t P r d u c a A m l i p h f g 2 S b 3 M u l t i p l i c a n d 3 2 b i t s P r o d u c t = 1 P r o d u c t = 3 2 - b i t A L U S h i f t r i g h t C o n t r o l P r o d u c t W r i t e t e s t 6 4 b i t s The trick is to use the lower half of the product to hold the multiplier during the operation. N o : < 3 2 r e p e t i t i o n s e p e t i t i o n ? Y e s : 3 2 r e p e t i t i o n s 2/21/2019 Comp 120 Fall 2001
7
What about the sign? Positive numbers are easy.
How about negative numbers? 2/21/2019 Comp 120 Fall 2001
8
Division Start 1. Subtract Divisor from the Remainder leave the result in the Remainder >=0 <0 Test Remainder Restore Remainder by adding Divisor Shift Quotient to the left set its rightmost bit = 0 Shift Quotient to the left set its rightmost bit = 1 Shift Divisor Register right 1 bit Repeat 33 times 2/21/2019 Comp 120 Fall 2001
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.