> Right, so the problem is that the unsigned inline code Ian posted is never > used. Maybe using unsigned arithmetic would work better. Try this: > > #include <stdint.h> > > inline int xxMULH(int a, int b) > { > uint32_t au = a; > uint32_t bu = b; > > uint64_t res = (uint64_t)au * (uint64_t)bu; > uint32_t res2 = res >> 32; > > if (a < 0) > res2 -= bu; > if (b < 0) > res2 -= au; > > return (int)res2; > } #NO_APP .text .even .globl _xxMULH _xxMULH: lea (-20,sp),sp move.l 24(sp),(sp) move.l 28(sp),4(sp) move.l (sp),d1 clr.l d0 move.l 4(sp),a1 lea 0.w,a0 move.l a1,-(sp) move.l a0,-(sp) move.l d1,-(sp) move.l d0,-(sp) jsr ___muldi3 lea (16,sp),sp move.l d0,8(sp) move.l d1,12(sp) move.l 8(sp),d0 move.l 12(sp),d1 move.l d0,d1 clr.l d0 move.l d1,16(sp) tst.l 24(sp) jge L2 move.l 4(sp),d0 sub.l d0,16(sp) L2: tst.l 28(sp) jge L3 move.l (sp),d0 sub.l d0,16(sp) L3: move.l 16(sp),d0 lea (20,sp),sp rts