| ??? 05/21/03 22:40 Read: times |
#46297 - 8-bit*16-bit multiplication |
Here is the math operation I would like to do in Keil C51:
RESULT = COEFFICIENT * INPUT; Where: * RESULT is an unsigned long * COEFFICIENT is an unsigned int * INPUT is an unsigned char It is my understanding that C automatically "promotes" the 16-bit int and 8-bit char to 32-bit longs BEFORE the multiplication. The multiply that is carried out is a 32-bit unsigned multiply. This wastes time because all I need is an 8-bit*16-bit multiply, then convert the 24-bit result to 32-bits (insert a null byte). Is my understanding of C correct? If so, is it efficient to do the desired multiply in C (and how is it done)? The application is an undergraduate electronics lab board. It shows basic A/D concepts and implements a basic FIR filter. I tried coding it in assembly, but the math never came out quite right. - Lee |



