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 446 of file math8.h.

446 {
447#if MUL8_C == 1
448 return ((int)i * (int)(j)) & 0xFF;
449#elif MUL8_AVRASM == 1
450 asm volatile(
451 /* Multiply 8-bit i * 8-bit j, giving 16-bit r1,r0 */
452 "mul %0, %1 \n\t"
453 /* Extract the LOW 8-bits (r0) */
454 "mov %0, r0 \n\t"
455 /* Restore r1 to "0"; it's expected to always be that */
456 "clr __zero_reg__ \n\t"
457 : "+r"(i)
458 : "r"(j)
459 : "r0", "r1");
460 return i;
461#else
462#error "No implementation for mul8 available."
463#endif
464}

References LIB8STATIC_ALWAYS_INLINE.