diff --git a/include/mtl/fixed.hpp b/include/mtl/fixed.hpp index 02b84e3..59e0a06 100644 --- a/include/mtl/fixed.hpp +++ b/include/mtl/fixed.hpp @@ -125,25 +125,11 @@ public: /** * \brief Fixed point multiplication - * - * Uses an assembly implementation to multiply the two numbers. */ - fixed operator*(fixed rhs) const { - int32_t raw_result; - asm( - ".arm;" - "smull r8, r9, %[a], %[b];" - "lsr %[res], r8, #6;" - "orr %[res], r9, lsl #26;" - : [res] "=r" (raw_result) - : [a] "r" (x), - [b] "r" (rhs.x) - : "r8", "r9" - ); - - return from_raw(raw_result); + constexpr fixed operator*(fixed rhs) const { + return from_raw(((int64_t)x * rhs.x) >> 6); } - fixed& operator*=(fixed rhs) { + constexpr fixed& operator*=(fixed rhs) { *this = *this * rhs; return *this; }