diff options
Diffstat (limited to 'apps/codecs/libatrac/fixp_math.h')
-rw-r--r-- | apps/codecs/libatrac/fixp_math.h | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h index ac53310cd2..8d2e0783b8 100644 --- a/apps/codecs/libatrac/fixp_math.h +++ b/apps/codecs/libatrac/fixp_math.h | |||
@@ -31,30 +31,33 @@ | |||
31 | /* Fixed point math routines for use in atrac3.c */ | 31 | /* Fixed point math routines for use in atrac3.c */ |
32 | 32 | ||
33 | #if defined(CPU_ARM) | 33 | #if defined(CPU_ARM) |
34 | /* Calculates: result = (X*Y)>>16 */ | ||
34 | #define fixmul16(X,Y) \ | 35 | #define fixmul16(X,Y) \ |
35 | ({ \ | 36 | ({ \ |
36 | int32_t low; \ | 37 | int32_t lo; \ |
37 | int32_t high; \ | 38 | int32_t hi; \ |
38 | asm volatile ( /* calculates: result = (X*Y)>>16 */ \ | 39 | asm volatile ( \ |
39 | "smull %0,%1,%2,%3 \n\t" /* 64 = 32x32 multiply */ \ | 40 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
40 | "mov %0, %0, lsr #16 \n\t" /* %0 = %0 >> 16 */ \ | 41 | "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ |
41 | "orr %0, %0, %1, lsl #16 \n\t"/* result = %0 OR (%1 << 16) */ \ | 42 | "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ |
42 | : "=&r"(low), "=&r" (high) \ | 43 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
43 | : "r"(X),"r"(Y)); \ | 44 | : [x]"r"(X), [y]"r"(Y)); \ |
44 | low; \ | 45 | lo; \ |
45 | }) | 46 | }) |
46 | 47 | ||
48 | /* Calculates: result = (X*Y)>>31 */ | ||
49 | /* Use scratch register r12 */ | ||
47 | #define fixmul31(X,Y) \ | 50 | #define fixmul31(X,Y) \ |
48 | ({ \ | 51 | ({ \ |
49 | int32_t low; \ | 52 | int32_t lo; \ |
50 | int32_t high; \ | 53 | int32_t hi; \ |
51 | asm volatile ( /* calculates: result = (X*Y)>>31 */ \ | 54 | asm volatile ( \ |
52 | "smull %0,%1,%2,%3 \n\t" /* 64 = 32x32 multiply */ \ | 55 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
53 | "mov %0, %0, lsr #31 \n\t" /* %0 = %0 >> 31 */ \ | 56 | "mov %[lo], %[lo], lsr #31 \n\t" /* lo >>= 31 */ \ |
54 | "orr %0, %0, %1, lsl #1 \n\t" /* result = %0 OR (%1 << 1) */ \ | 57 | "orr %[lo], %[lo], %[hi], lsl #1" /* lo |= (hi << 1) */ \ |
55 | : "=&r"(low), "=&r" (high) \ | 58 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
56 | : "r"(X),"r"(Y)); \ | 59 | : [x]"r"(X), [y]"r"(Y)); \ |
57 | low; \ | 60 | lo; \ |
58 | }) | 61 | }) |
59 | #elif defined(CPU_COLDFIRE) | 62 | #elif defined(CPU_COLDFIRE) |
60 | #define fixmul16(X,Y) \ | 63 | #define fixmul16(X,Y) \ |