Brian Whitman <[EMAIL PROTECTED]> wrote:
> #pragma parameter __D0 WordMul(__D0, __D1)
> ULong WordMul(Word a, Word b) = {0xC0C1}; // mulu.w d1,d0 => long result in d0
The GCC equivalent is (and it's well documented!):
static __inline__ ULong WordMul (Word a, Word b) {
ULong result;
asm ("mulu.w %2,%0" : "=d" (result) : "0" (a), "g" (b) : "cc");
return result;
}
(Geez... doesn't CodeWarrior come with an assembler? Why do you have to
figure out the opcode by hand?!)
Or, in fact, you could just use:
static __inline__ ULong WordMul (Word a, Word b) { return ((ULong) a) * b; }
With -O2, the optimizer is good enough to emit the same code (ie, just
the u16 x u16 -> u32 mult, no extra size conversion code).
John "and, bizarrely, 'Word' is unsigned :-)"