diff options
author | Jens Arnold <amiconn@rockbox.org> | 2009-02-15 17:07:18 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2009-02-15 17:07:18 +0000 |
commit | 789b0a2eb9ae94a10abd590c91e3ae8588137e37 (patch) | |
tree | 5ad1fd1d69ffe5852ba7d14072498c93497ec8ba /apps | |
parent | d70902feb8e2689080d0360f504ffc4772cc0dc6 (diff) | |
download | rockbox-789b0a2eb9ae94a10abd590c91e3ae8588137e37.tar.gz rockbox-789b0a2eb9ae94a10abd590c91e3ae8588137e37.zip |
Add an unsigned 32*32->top32 bit multiply for resizing on SH1, and switch to 32 bit precision using that.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20012 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/resize.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 4e71fb8732..d1dabaae09 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h | |||
@@ -59,7 +59,47 @@ | |||
59 | t; \ | 59 | t; \ |
60 | }) | 60 | }) |
61 | #elif (CONFIG_CPU == SH7034) | 61 | #elif (CONFIG_CPU == SH7034) |
62 | #define SC_SHIFT 24 | 62 | /* multiply two unsigned 32 bit values and return the top 32 bit |
63 | * of the 64 bit result */ | ||
64 | static inline unsigned sc_mul32(unsigned a, unsigned b) | ||
65 | { | ||
66 | unsigned r, t1, t2, t3; | ||
67 | |||
68 | asm ( | ||
69 | "swap.w %[a], %[t1] \n" /* t1 = ba */ | ||
70 | "mulu %[t1], %[b] \n" /* a * d */ | ||
71 | "swap.w %[b], %[t3] \n" /* t3 = dc */ | ||
72 | "sts macl, %[t2] \n" /* t2 = a * d */ | ||
73 | "mulu %[t1], %[t3] \n" /* a * c */ | ||
74 | "sts macl, %[r] \n" /* hi = a * c */ | ||
75 | "mulu %[a], %[t3] \n" /* b * c */ | ||
76 | "clrt \n" | ||
77 | "sts macl, %[t3] \n" /* t3 = b * c */ | ||
78 | "addc %[t2], %[t3] \n" /* t3 += t2, carry -> t2 */ | ||
79 | "movt %[t2] \n" | ||
80 | "mulu %[a], %[b] \n" /* b * d */ | ||
81 | "mov %[t3], %[t1] \n" /* t2t3 <<= 16 */ | ||
82 | "xtrct %[t2], %[t1] \n" | ||
83 | "mov %[t1], %[t2] \n" | ||
84 | "shll16 %[t3] \n" | ||
85 | "sts macl, %[t1] \n" /* lo = b * d */ | ||
86 | "clrt \n" /* hi.lo += t2t3 */ | ||
87 | "addc %[t3], %[t1] \n" | ||
88 | "addc %[t2], %[r] \n" | ||
89 | : /* outputs */ | ||
90 | [r] "=&r"(r), | ||
91 | [t1]"=&r"(t1), | ||
92 | [t2]"=&r"(t2), | ||
93 | [t3]"=&r"(t3) | ||
94 | : /* inputs */ | ||
95 | [a] "r" (a), | ||
96 | [b] "r" (b) | ||
97 | ); | ||
98 | return r; | ||
99 | } | ||
100 | #define SC_MUL(x, y) sc_mul32(x, y) | ||
101 | #define SC_MUL_INIT | ||
102 | #define SC_MUL_END | ||
63 | #endif | 103 | #endif |
64 | 104 | ||
65 | #ifndef SC_SHIFT | 105 | #ifndef SC_SHIFT |