Re: Optimizing a 16-bit * 8-bit -> 24-bit multiplication

2006-12-04 Thread David Nicol
here's an ignorant, naive, and very likely wrong attempt: what happens if you mask off the high and low bytes of the larger number, do two 8,8->16 multiplies, left shift the result of the result of the higher one, and add, as a macro? #define _mul8x16(c,s) ( \ (long int) ((c) * (unsigned

Optimizing a 16-bit * 8-bit -> 24-bit multiplication

2006-12-01 Thread Shaun Jackman
I would like to multiply a 16-bit number by an 8-bit number and produce a 24-bit result on the AVR. The AVR has a hardware 8-bit * 8-bit -> 16-bit multiplier. If I multiply a 16-bit number by a 16-bit number, it produces a 16-bit result, which isn't wide enough to hold the result. If I cast one