This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am developing application on MSP430F4784. It has a 16x16 hardware multiplier.
Development IDE is Code Composer Studiio v 5.4.
I want to perform following multiplication:
unsigned int temp1;
unsogned long temp2;
temp2 = temp1 * 100000;
16 x 16 hadrware multiplier cannot multiply numbers beyond 16-bit.
How can i perform above mentioned multiplication using 16 x 16 multiplier in MSP430F4784 ?
Is there any software library available to perform arithmetic calculations in Code Composer Studio v 5.4 ?
Thank you,
Sunil
Break the 32-bit number into 16-bit parts. Do the 2 multiplications with the 16-bit number, and then add the results (with 16-bit left shift of the upper product).
Wrap this into it's own function, something like:
unsigned long mulU16xU32(unsigned op16, unsigned long op32) { unsigned long result = 0; // Your code here.... return(result); }
If you make this a generic function, then you need to make sure to handle that the output could be 48-bits (16+32). So what to return if the calculation overflows?
I have used the method you mentioned to multiply 2, 32-bit numbers.
The method is working well for unsigned numbers.
What about signed numbers ?
I mean how to multiply 2, 32-bit signed numbers ?
Keep it stupid and simple. (a) Figure out the sign of the result, (b) take the absolute values and multiply them (unsigned * unsigned), and (c) apply the sign of the result.
**Attention** This is a public forum