| ??? 05/21/03 23:02 Read: times |
#46302 - RE: 8-bit*16-bit multiplication Responding to: ???'s previous message |
Hi Lee,
I imagine the actual integer promotion rules are compiler dependent...I would expect my compiler to promote to int, not long. The 32 bit multiply sounds normal for a PC compiler though. The most efficient way would be to create an assembler 8x16 multiply. Create a skeleton function in C: unsigned long mult_8x16(unsigned char x, unsigned int y) { return (unsigned long)(x * y); } Compile, take the asm output, modify it so it does *your* 8x16 asm multiply instead of calling the library multiply functions, then call this new function from your program. (See your compiler manual for the exact method of interfacing asm to C.) As to how your compiler does its promotions, you should be able to tell easily by looking at the compiler generated asm. If you get a compiler warning about lost precision you know it expects you to cast to longs before the multiply. Dennis |



