1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* calculate the 32-bit product of unsigned 16-bit value op16 and 32-bit value op32 */
#define MULU16_32(op16, op32) \
({ \
    unsigned t1, r; \
    asm ( \
        "mulu   %[a], %[b]   \n" \
        "swap.w %[b], %[b]   \n" \
        "sts    macl, %[r]   \n" \
        "mulu   %[a], %[b]   \n" \
        "sts    macl, %[t1]  \n" \
        "shll16 %[t1]        \n" \
        "add    %[t1], %[r]  \n" \
        : [r]  "=&r" (r),    \
          [t1] "=&r" (t1),   \
          [t2] "=&r" (t2),   \
        : [a]  "r"   (op16), \
          [b]  "r"   (op32), \
    ); \
    r; \
})