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

◆ add8to16()

LIB8STATIC_ALWAYS_INLINE uint16_t add8to16 ( uint8_t i,
uint16_t j )

Add one byte to two bytes, with 16-bit result.

Note
This does not saturate and may overflow!
Parameters
ifirst value to add, 8-bit
jsecond value to add, 16-bit
Returns
the sum of i + j, 16-bit

Definition at line 153 of file math8.h.

153 {
154#if ADD8_C == 1
155 uint16_t t = i + j;
156 return t;
157#elif ADD8_AVRASM == 1
158 // Add i(one byte) to j(two bytes)
159 asm volatile("add %A[j], %[i] \n\t"
160 "adc %B[j], __zero_reg__ \n\t"
161 : [j] "+r"(j)
162 : [i] "r"(i));
163 return i;
164#else
165#error "No implementation for add8to16 available."
166#endif
167}

References LIB8STATIC_ALWAYS_INLINE.