From 98bbaf3b175930ad6b01ade27409b7dda899f88e Mon Sep 17 00:00:00 2001 From: flatmush Date: Fri, 4 Mar 2011 12:42:58 +0000 Subject: 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. --- libfixmath/fix16.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 -- cgit v1.2.3