From 848ad3eeca632356f2c159a7fe10d0beb44c9e24 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 25 Apr 2023 15:55:59 -0400 Subject: [PATCH] Add note about assembly. --- firmware/nixitest1/nixitest1.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/firmware/nixitest1/nixitest1.c b/firmware/nixitest1/nixitest1.c index 417f066..3ec9b24 100644 --- a/firmware/nixitest1/nixitest1.c +++ b/firmware/nixitest1/nixitest1.c @@ -128,6 +128,23 @@ static inline uint32_t FastMultiply( uint32_t big_num, uint32_t small_num ) multiplicand>>=1; } while( multiplicand ); return ret; + + // Which is equivelent to the following assembly (If you were curious) +/* + uint32_t ret = 0; + asm volatile( "\n\ + .option rvc;\n\ + 1: andi t0, %[small], 1\n\ + beqz t0, 2f\n\ + add %[ret], %[ret], %[big]\n\ + 2: srli %[small], %[small], 1\n\ + slli %[big], %[big], 1\n\ + bnez %[small], 1b\n\ + " : + [ret]"=&r"(ret), [big]"+&r"(big_num), [small]"+&r"(small_num) : : + "t0" ); + return ret; +*/ } // FYI You can use functions in ram to make them work faster. The .data