FastLED 3.9.15
Loading...
Searching...
No Matches

◆ qmul8()

LIB8STATIC_ALWAYS_INLINE uint8_t qmul8 ( uint8_t i,
uint8_t j )

8x8 bit multiplication with 8-bit result, saturating at 0xFF.

Parameters
ifirst byte to multiply
jsecond byte to multiply
Returns
the product of i * j, capping at 0xFF

Definition at line 470 of file math8.h.

470 {
471#if QMUL8_C == 1
472 unsigned p = (unsigned)i * (unsigned)j;
473 if (p > 255)
474 p = 255;
475 return p;
476#elif QMUL8_AVRASM == 1
477 asm volatile(
478 /* Multiply 8-bit i * 8-bit j, giving 16-bit r1,r0 */
479 " mul %0, %1 \n\t"
480 /* Extract the LOW 8-bits (r0) */
481 " mov %0, r0 \n\t"
482 /* If high byte of result is zero, all is well. */
483 " tst r1 \n\t"
484 " breq Lnospill_%= \n\t"
485 /* If high byte of result > 0, saturate to 0xFF */
486 " ldi %0, 0xFF \n\t"
487 "Lnospill_%=: \n\t"
488 /* Restore r1 to "0"; it's expected to always be that */
489 " clr __zero_reg__ \n\t"
490 : "+d"(i) // r16-r31, restricted by ldi
491 : "r"(j)
492 : "r0", "r1");
493 return i;
494#else
495#error "No implementation for qmul8 available."
496#endif
497}
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
Definition noise.cpp:56

References LIB8STATIC_ALWAYS_INLINE, and p.

Referenced by operator*(), and CRGB::operator*=().

+ Here is the caller graph for this function: