diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dsp.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index f9d4bf16d5..0c376a14ea 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -119,6 +119,39 @@ | |||
119 | 119 | ||
120 | #define ACC_INIT(acc, x, y) ACC(acc, x, y) | 120 | #define ACC_INIT(acc, x, y) ACC(acc, x, y) |
121 | 121 | ||
122 | #elif defined(CPU_ARM) && !defined(SIMULATOR) | ||
123 | |||
124 | /* Multiply two S.31 fractional integers and return the sign bit and the | ||
125 | * 31 most significant bits of the result. | ||
126 | */ | ||
127 | #define FRACMUL(x, y) \ | ||
128 | ({ \ | ||
129 | long t; \ | ||
130 | asm volatile ("smull r0, r1, %[a], %[b]\n\t" \ | ||
131 | "mov %[t], r1, asl #1\n\t" \ | ||
132 | "orr %[t], %[t], r0, lsr #31\n\t" \ | ||
133 | : [t] "=r" (t) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \ | ||
134 | t; \ | ||
135 | }) | ||
136 | |||
137 | #define ACC_INIT(acc, x, y) acc = FRACMUL(x, y) | ||
138 | #define ACC(acc, x, y) acc += FRACMUL(x, y) | ||
139 | #define GET_ACC(acc) acc | ||
140 | |||
141 | /* Multiply one S.31-bit and one S8.23 fractional integer and store the | ||
142 | * sign bit and the 31 most significant bits of the result to d (and | ||
143 | * increase d). Load next value to multiply with into x from s (and | ||
144 | * increase s); x must contain the initial value. | ||
145 | */ | ||
146 | #define FRACMUL_8_LOOP(x, y, s, d) \ | ||
147 | ({ \ | ||
148 | asm volatile ("smull r0, r1, %[a], %[b]\n\t" \ | ||
149 | "mov %[t], r1, asl #9\n\t" \ | ||
150 | "orr %[t], %[t], r0, lsr #23\n\t" \ | ||
151 | : [t] "=r" (*(d)++) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \ | ||
152 | x = *(s)++; \ | ||
153 | }) | ||
154 | |||
122 | #else | 155 | #else |
123 | 156 | ||
124 | #define ACC_INIT(acc, x, y) acc = FRACMUL(x, y) | 157 | #define ACC_INIT(acc, x, y) acc = FRACMUL(x, y) |