From f5703af80d347301ad64f1942b181a6741eac508 Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Sat, 25 May 2024 23:03:03 +1000 Subject: [PATCH] core/math/fixed: implement BrFixedLength{2,3,4}() --- core/inc/math_p.h | 6 +++--- core/math/fixed.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/inc/math_p.h b/core/inc/math_p.h index 4d7f8200..8da325ff 100644 --- a/core/inc/math_p.h +++ b/core/inc/math_p.h @@ -57,15 +57,15 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedSqr4(br_fixed_ls a, br_fixed_ls b, br_fixed_l /* result = sqrt(a*a + b*b) */ -br_fixed_ls BR_ASM_CALL BrFixedLength2(br_fixed_ls a, br_fixed_ls b); +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength2(br_fixed_ls a, br_fixed_ls b); /* result = sqrt(a*a + b*b + c*c) */ -br_fixed_ls BR_ASM_CALL BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c); +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c); /* result = sqrt(a*a + b*b + c*c + d*d) */ -br_fixed_ls BR_ASM_CALL BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d); +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d); /* result = 1/sqrt(a*a + b*b) (low precision) */ diff --git a/core/math/fixed.c b/core/math/fixed.c index 9335e018..e79db7a8 100644 --- a/core/math/fixed.c +++ b/core/math/fixed.c @@ -73,6 +73,21 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedSqr4(br_fixed_ls a, br_fixed_ls b, br_fixed_l return BrFixedSqr(a) + BrFixedSqr(b) + BrFixedSqr(c) + BrFixedSqr(d); } +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength2(br_fixed_ls a, br_fixed_ls b) +{ + return BrFixedSqrt(BrFixedSqr2(a, b)); +} + +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c) +{ + return BrFixedSqrt(BrFixedSqr3(a, b, c)); +} + +br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d) +{ + return BrFixedSqrt(BrFixedSqr4(a, b, c, d)); +} + br_fixed_ls BR_PUBLIC_ENTRY BrFixedDiv(br_fixed_ls numerator, br_fixed_ls denominator) { if(denominator == 0)