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

◆ mul8()

LIB8STATIC_ALWAYS_INLINE uint8_t mul8 ( uint8_t i,
uint8_t j )

8x8 bit multiplication, with 8-bit result.

Parameters
ifirst byte to multiply
jsecond byte to multiply
Returns
the product of i * j
Note
This does not saturate and may overflow!

Definition at line 462 of file math8.h.

462 {
463#if MUL8_C == 1
464 return ((int)i * (int)(j)) & 0xFF;
465#elif MUL8_AVRASM == 1
466 asm volatile(
467 /* Multiply 8-bit i * 8-bit j, giving 16-bit r1,r0 */
468 "mul %0, %1 \n\t"
469 /* Extract the LOW 8-bits (r0) */
470 "mov %0, r0 \n\t"
471 /* Restore r1 to "0"; it's expected to always be that */
472 "clr __zero_reg__ \n\t"
473 : "+r"(i)
474 : "r"(j)
475 : "r0", "r1");
476 return i;
477#else
478#error "No implementation for mul8 available."
479#endif
480}

References LIB8STATIC_ALWAYS_INLINE.