1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
inline int32_t fixmul16(int32_t x, int32_t y) {
  int32_t r;

  asm volatile ("mac.l %[x], %[y], %%acc0;"  /* multiply */
                "mulu.l %[y], %[x];"         /* get lower half, avoid emac stall */
                "movclr.l %%acc0, %[r];"     /* get higher half */
                "asl.l #8, %[r];"
                "asl.l #8, %[r];"
                "lsr.l #8, %[x];"            /* (unsigned)lo >> 16 */
                "lsr.l #8, %[x];"
                "or.l %[x], %[r];"           /* logical-or results */
                : [r] "=&d" (r), [x] "+d" (x)
                : [y] "d" (y)
                : "cc");
  return r;
}