aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-03-04 12:42:58 +0000
committerflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-03-04 12:42:58 +0000
commit98bbaf3b175930ad6b01ade27409b7dda899f88e (patch)
tree36b1fbfe5ee47cd2f061c711de0096ac16ece02e
parent5fd33d1f980dc32467bef87b31c6bacd30cab740 (diff)
downloadlibfixmath-98bbaf3b175930ad6b01ade27409b7dda899f88e.tar.gz
Added ARM specific fix16_mul which should be faster, this is untested however so if somebody with an ARM target could compile and check it then I'd be greatful.
-rw-r--r--libfixmath/fix16.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libfixmath/fix16.c b/libfixmath/fix16.c
index 91c5841..a557ef1 100644
--- a/libfixmath/fix16.c
+++ b/libfixmath/fix16.c
@@ -14,6 +14,22 @@ fix16_t fix16_sadd(fix16_t inArg0, fix16_t inArg1) {
+#if defined(__arm__) || defined(_ARM)
+fix16_t fix16_mul(int32_t inArg0, int32_t inArg1) {
+ fix16_t res;
+ asm(
+ "smull %1, r0, %2, %3\n\t"
+ #ifndef FIXMATH_NO_ROUNDING
+ "add %1, %1, #0x8000\n\t"
+ #endif
+ "mov %1, %1, LSR #16\n\t"
+ "or %1, %1, r0, LSL #16"
+ : "=r"(res)
+ : "r"(inArg0), "r"(inArg1)
+ : "r0");
+ return res;
+}
+#else
fix16_t fix16_mul(fix16_t inArg0, fix16_t inArg1) {
#ifndef FIXMATH_NO_64BIT
int64_t tempResult = ((int64_t)inArg0 * (int64_t)inArg1);
@@ -39,6 +55,7 @@ fix16_t fix16_mul(fix16_t inArg0, fix16_t inArg1) {
return r_md;
#endif
}
+#endif
fix16_t fix16_smul(fix16_t inArg0, fix16_t inArg1) {
#ifndef FIXMATH_NO_64BIT