From 31b913cddb36f9df03c7d8cebea22303b8d3fcf7 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 4 Jul 2021 17:03:45 +0200 Subject: [PATCH] Correct the C implementation for MultiU16X8toH16 The comment behind the ASM MultiU16X8toH16 was misleading. It actually computes ((a<<8)*b)>>16, or (a*b)>>8. Correct the comment and C reference implementation accordingly. --- Firmware/speed_lookuptable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/speed_lookuptable.h b/Firmware/speed_lookuptable.h index 21c6c767f..b72eb18b8 100644 --- a/Firmware/speed_lookuptable.h +++ b/Firmware/speed_lookuptable.h @@ -8,7 +8,7 @@ extern const uint16_t speed_lookuptable_slow[256][2] PROGMEM; #ifndef _NO_ASM -// intRes = intIn1 * intIn2 >> 16 +// intRes = intIn1 * intIn2 >> 8 // uses: // r26 to store 0 // r27 to store the byte 1 of the 24 bit result @@ -82,7 +82,7 @@ asm volatile ( \ static inline void MultiU16X8toH16(uint16_t& intRes, uint8_t& charIn1, uint16_t& intIn2) { - intRes = ((uint32_t)charIn1 * (uint32_t)intIn2) >> 16; + intRes = ((uint32_t)charIn1 * (uint32_t)intIn2) >> 8; } static inline void MultiU24X24toH16(uint16_t& intRes, uint32_t& longIn1, uint32_t& longIn2)