The Signed Multiplication Conventional Way - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

The Signed Multiplication Conventional Way

Description:

Employ Signed Magnitude Scheme: Treat sign & magnitude separately. Perform unsigned multiplication of the magnitudes of the multiplicand (MPD) [A] ... – PowerPoint PPT presentation

Number of Views:124
Avg rating:3.0/5.0
Slides: 27
Provided by: parthasa
Category:

less

Transcript and Presenter's Notes

Title: The Signed Multiplication Conventional Way


1
The Signed Multiplication Conventional Way
  • Employ Signed Magnitude Scheme
  • Treat sign magnitude separately.
  • Perform unsigned multiplication of the magnitudes
    of the multiplicand (MPD) A the multiplier
    (MPR) B to produce the result C magnitude.
  • Note multiplicand (MPD) A multiplier (MPR)
    B signs.
  • If the signs are same then assign sign of Result
    C Sign of the MPD A.
  • If the signs are different then assign sign of
    Result C -ve.

2
The Signed MultiplicationUsing rs Complement
Scheme - 1
  • Task at hand
  • Given the multiplicand (MPD) operand A m
    digit, rs complement
  • Given the multiplier (MPR) Operand B m digit ,
    rs complement
  • Produce the 2m digit Result R ? A X B. Composed
    of two (2) m digit halves.
  • Key Issues
  • 1) In each case i.e. for both the m digit
    operands as well as the 2m digit result, the Most
    significant digit holds the sign.
  • 2) One can adopt the same method of Add
    Shift as followed in unsigned multiplication
    with the following modifications as illustrated
    in the next slide.

3
The Signed MultiplicationUsing rs Complement (
Key Issues)
  • a) Start with m digit all zero Upper Half
    m digit MPR lower half.
  • b) Repeated addition of the m digit MPD to
    the m digit upper half is to be done.
  • c) Carry Produced at any stage of
    addition is to be ignored.
  • d) Overflow , if produced at any stage
    during addition of the MPD to the Upper Half of
    the partial result, indicates that the sign digit
    produced is different from that of the MPD sign.
    Once an overflow is produced , it will get
    propagated throughout the entire addition loop
    involving the current MPR digit.

4
The Signed MultiplicationUsing rs Complement (
Key Issues 2)
  • e) On completion of each addition loop i.e.
    after multiplying with each intermediate
    Multiplier Digit one must keep provisions of
    retaining the Current Multiplicand Sign at the
    Most Significant Digit position of the 2m digit
    result i.e. in the Upper m digit half. This can
    be achieved in the following manner.
  • i) If there is no overflow, Right Shift
    Arithmetic the
  • 2m Digit Partial Result. In this case
    the MS digit is retained while the other portion
    gets shifted by one digit to the right.
  • ii) If there is an Overflow , then replace
    carry digit by the MPD sign , then Right Shift
    Logical Cy 2 m Digit Result . MPD sign will
    become the Result sign.

5
The Signed MultiplicationUsing rs Complement (
Key Issues 3)
  • 3) Multiplier Sign ( The Last Step of
    Multiplication) is to be treated in a different
    way as illustrated below
  • a) If the Multiplier Sign is ve (0) ,just
    Right Shift Arithmetic the 2m Digit Partial
    Result . Thereby retaining the sign digit but
    shifting the other part by 1 digit to the right.
  • b) If the Multiplier Sign is ve then Add the
    rs complement of the MPD to the upper half of
    the Partial Result. Ignore carry , Overflow will
    NOT be produced. Then Right Shift Arithmetic the
    2m Digit Partial Result .

6
Signed Multiplication Case Studies
  • Size of MPD (A) MPR (B) m digits.
  • Hence size of Result (C ) 2m digits.
  • Bases used
  • 1. Decimal
  • 2. Binary

7
Signed Multiplication Implementation
  • Use m digit adder .
  • Add only 2 Operands at a time.
  • No need for multiplication table .
  • Consider each multiplier digit starting from
    Least Significant Digit except the Sign digit.
  • Sign digit of the multiplier to be treated
    separately.

8
Signed Multiplication Process - 1
  • Step 1 Initialize Partial Result C 0 0 0 0
  • Upper Half m Digits of the 2m
    Digits result
  • Set up Shift Counter m.
  • Create a copy of the of the Multiplier MPR
    B in E
  • Lower Half m digits of the 2
    digits result
  • Step 2 Consider the current rightmost
    multiplier digit MPRd.
  • Step 3 Set up Addition Counter (ADD_Count) ?
    MPRd k .
  • Step 4 C ? ( C ) PLUS MPD A .
  • Step 5 Ignore any Carry produced .
  • Step 6 Decrement ADD_Count.
  • Step 7 IF (ADD_Count is NON ZERO) GO TO Step 4.

9
Signed Multiplication Process - 2
  • Step 8 ADD_Count is Zero. One Multiplier
    Digit Considered.
  • Check for any overflow .
  • If ( Overflow/ Sign Digit is changed/ invalid)
    THEN
  • a. Replace Cy by the Current Multiplicand Sign
    Digit
  • b. Right Shift Logical Cy C MPR (B) .
  • c. MPD Sign comes in as the Sign Digit of
    the Partial Result C B.
  • d. Right most Digit of C comes to the left
    most place of MPR B.
  • e. Right most Digit of the Multiplier B goes
    out.
  • ELSE ( No Overflow) Right Shift Arithmetic C
    B thereby retaining the sign while right shifting
    the other part.
  • Step 9 Decrement Shift (Operation) Counter.
  • Step 10 If Shift (Operation) Counter gt 1 GOTO
    Step 2 ELSE
  • if Operation Counter 1 GO TO Step 11
    About to consider MPR Bs Sign Digit .
  • Step 11. If MPR B sign Digit is 0 (ve) right
    shift arithmetic CB pair. If MPR B sign is
    ve add rs complement of MPD A to the partial
    result C and then right shift arithmetic
    (Retaining Most Significant / Leftmost / Sign
    DIGIT of C) CB pair. Reduce Operation Counter
    to ZERO.

10
Signed Multiplication in Decimal ( the Example)
- 1A
  • Example
  • -5 (Decimal ) X 8 (Decimal) 40 (Result) 0
    40
  • -5 ? 9 5 in 10s Complement ( 2 Digits)
  • -8 ? 9 2 in 10s Complement . A copy is created
    E 92
  • Here we expect a 4 Digit Result 0 040
  • Operation (Shift ) Counter ? 2
  • 95 X 92 gtCurrent Rightmost Multiplier Digit 2
  • I.e. Add Counter Value ? 2
  • 00 ( Upper Half of Result)
    9 2 ( Lower Half of Result )
  • 95 ( Multiplicand) Added Once
  • -------
  • 95 ( No Overflow) 9 2 Add
    Counter ? 1 ( Reduced)

11
Signed Multiplication in Decimal ( the Example)
- 1B
  • Partial Result 9 5 9 2
  • Multiplicand 9 5 ( Added 1 more time )
  • ------
  • 1 9 0 First
    Multiplier digit (2) multiplied

Carry Produced is ignored. No overflow. Decr.
Add Counter 1 (0)
Right shift Arithmetic Result C B
.Decrement Operation / Shift Counter 2 (1)
Status 9 9 0 9 ( 2 Goes Out) .MPR Sign
is to be Considered Now.
12
Signed Multiplication in Decimal ( the Example)
- 1C
  • Partial Result 9 9 0 9
  • Multiplicand 9 5 ( Multiplier s Sign
    Digit to be Handled )
  • Current Multiplier Digit 9 (The Sign / MS
    Digit) ? (-1)
  • 10s Complement of Multiplicand 05
  • Addition 9 9 0 9
  • 0 5
  • ---------
  • 0 4 0 9( After ignoring Carry
    )
  • After arithmetic right shift ( Preserving the
    Most Significant Digit / Leftmost Digit / Sign
    Digit of the Partial Result C) of
  • Partial Result C MPR B we obtain
  • the Final Result 0 0 4 0

13
Signed Multiplication in Decimal ( the Example)
- 2A
  • Example
  • -5 (Decimal ) X 3 (Decimal) Result -15
  • Result 9 9 8 5 in 4 digit 10s Complement.
  • -5 ? 9 5 in 2 digit 10s Complement
  • 3 ? 0 3 in 2 digit 10s Complement
  • Shift Counter ? 2 , Current Add Counter ? 3
  • 95 X 03 gt 0 0 0 3( Partial Result)
  • 9 5 ( Multiplicand) Added Once
  • -------
  • 9 5 ( No Overflow / Carry ) .
  • Current Add Counter ?2

14
Signed Multiplication in Decimal ( the Example)
- 2B
  • Partial Result 9 5 0 3
  • Multiplicand 9 5 ( 1 more Time to be Added
    )
  • ------
  • 1 9 0 Hence Partial
    Result 9 0 0 3

Carry Produced Ignored
Next Iteration 9 0 0 3
9 5 ( Last Time Added ) Add Counter ? 0
-------- 1
8 5 0 3

. Overflow Occurs . Hence CY replaced by MPD
Sign 9 . Right shift Logical Cy 9 C85 B
03 ? 98 5 0 (3) Goes Out.
15
Signed Multiplication in Decimal ( the Example)
- 2C
  • The current Result 9 8 5 0
  • Current Operation / Shift Counter ? 1 ( MPRs
    Sign Digit to be Handled )
  • Multiplicand 0 3
  • ( Current Multiplier Digit MPR Sign 0 )
  • Do Arithmetic Right Shift C B , preserving the
    Sign of the Partial Result
  • Hence Final Result 9 9 8 5 - 15

16
Signed Multiplication in Decimal ( the Example)
- 3A
  • Example
  • -25 (Decimal ) X 10 (Decimal) Result -250
  • Result 9 9 9 7 5 0 in 6 digit 10s Complement.
  • -25 ? 9 7 5 in 3 digit 10s Complement
  • 10 ? 0 1 0 in 3 digit 10s Complement
  • 975 X 10 gt 0 0 0 0 1 0 ( Partial Result)
  • Shift Counter ? 3 , Current Add Counter ? 0
  • Result C 0 0 0 B 0 1 0
  • Right shift Arithmetic C 0 0 0 B 0 1 0
  • Decrement Operation / Shift Counter 3 (2)
  • Status 0 0 0 0 0 1
  • Current Add Counter ?1

17
Signed Multiplication in Decimal ( the Example)
- 3B
  • Partial Result 0 0 0 0 0 1
  • Multiplicand 9 7 5 Decrement Add
    Counter 1 ( 0 )
  • ------
  • 9 7 5 Hence Partial
    Result 9 7 5 0 0 1
  • There is no Overflow .

  • Right shift Arithmetic C975 MPR B 001
  • 9 9 7 5 0 0 (1) Goes Out.
  • This yields 9 9 7 5 0 0


18
Signed Multiplication in Decimal ( the Example)
- 3C
  • The current Result 9 9 7 5 0 0
  • Current Operation / Shift Counter ? 1 ( MPRs
    Sign Digit to be Handled )
  • Multiplicand 975
  • ( Current Multiplier Digit MPR Sign 0 )
  • Do Arithmetic Right Shift C B , preserving the
    Sign of the Partial Result C
  • Hence Final Result 9 9 9 7 5 0 - 250

19
Signed Multiplication in Binary ( the Example) -
1A
  • No Add Counter needed here.
  • Example
  • -011 (Binary) -3 Decimal X 111 (Binary)-7
    010101 (Result) 21 Decimal
  • -011 ? 1 101 in 4 Bit 2s Complement
  • -111 ? 1 001 in 4 Bit 2s Complement
  • 1101 X 1001 gt Multiplier Digit 1
  • 0 0 0 0 ( Partial Result)
    MS Nibble 1 0 0 1
  • 1 1 0 1 ( Multiplicand) Added
    Once
  • ------------
  • 1 1 0 1 ( No Overflow) .

20
Signed Multiplication in Binary ( the Example) -
1B
  • Partial Result 1 1 0 1 1 0 0 1 .
  • Right Shift Arithmetic Partial Result
  • New Partial Result 1 1 1 0 1 1 0 0
  • One Shifting done , 3 More Shifts to GO
  • Next Multiplier Digit 0 , Hence RIGHT Shift
    Arithmetic Partial Result
  • After shifting new Partial Result 1 1 1 1 0
    1 1 0
  • 2 More Shifts to go
  • Next Multiplier Digit 0, Hence RIGHT Shift
    Arithmetic Partial Result .
  • After shifting New Partial Result 1 1 1 1 1
    0 1 1
  • 1 more shift to go. Sign bit of MPR left which is
    1
  • Add 2s complement of MPD 0 0 1 1 to the MS
    Nibble of the Partial Result 1 1 1 1

21
Signed Multiplication in Binary ( the Example) -
1C
  • Partial Result 1 1 1 1 1 0 1 1
  • PLUS 0 0 1 1
  • ----------- -----------
  • 1 0 0 1 0 1 0 1 1 The
    Result before Last Shift


Ignore Carry

After one Right Arithmetic Shift Result 0 0
0 1 0 1 0 1 0 0 0 1 0 1 0 1 21
(Decimal)
22
Signed Multiplication in Binary ( the Example) -
2A
  • Example
  • -011 -3 X 111 7 Result -21 - 10101
  • Result 1 1 1 0 1 0 1 1 in 8 bit 2s
    Complement.
  • -011 ? 1 101 in 4 bit 2s Complement
  • 111 ? 0 111 in 4 bit 2s Complement
  • 1 101 X 0111 gt 0 0 0 0 ( Partial Result) 0
    1 1 1
  • 1 1 0 1 (
    Multiplicand) Added
  • ----------
  • 1 1 0 1 ( No
    Overflow )

23
Signed Multiplication in Binary ( the Example) -
2B
  • Partial Result 1 1 0 1 0 1 1 1
  • After Arithmetic Right Shift Partial Result 1
    1 1 0 1 0 1 1
  • 3 More Shifts to do . The next Multiplier Digit
    1
  • Hence again we add the MPD to the MS Nibble of
    Partial Result
  • 1 1 1 0 1 0 1 1
  • 1 1 0 1
  • -----------
  • 1 0 1 1 1 0 1 1 ( Ignoring carry. No
    Overflow )



24
Signed Multiplication in Binary ( the Example) -
2C
  • Partial Result 1 0 1 1 1 0 1 1
  • After Arithmetic Right Shift Partial Result 1
    1 0 1 1 1 0 1
  • 2 More Shifts to do . The next Multiplier Digit
    1
  • Hence again we add the MPD to the MS Nibble of
    Partial Result
  • 1 1 0 1 1 1 0 1
  • 1 1 0 1
  • -----------
  • 1 0 1 0 1 1 0 1 ( Ignoring carry. No
    overflow )



25
Signed Multiplication in Binary ( the Example) -
2D
  • Partial Result 1 0 1 0 1 1 0 1
  • After Arithmetic Right Shift Partial Result 1
    1 0 1 0 1 1 0
  • 1 More Shift to do . The next Multiplier Digit
    0
  • Hence we merely Right Shift Arithmetic the
    Partial Result
  • 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 - 21
    Decimal



26
Signed Multiplication in Binary ( Associated
Problems )
  • Each Multiplier bit is to be considered.
  • Essentially two steps
  • Step 1 Add Multiplicand / its 2s Complement to
    the Upper Half of the Partial Result
  • Step 2 If NO Overflow Right Shift Arithmetic
    the Partial Result
  • ELSE (for overflow) replace CY by the MPD sign
    followed by Right Shift Logical Cy Partial
    Result.
  • OR
  • Just Right Shift Arithmetic the Partial Result
    .
  • How to reduce the number of Steps.( Both
    Addition Shifting) to be discussed next.
Write a Comment
User Comments (0)
About PowerShow.com