Add one byte to another, saturating at 0x7F and -0x80.
- Parameters
-
i | first byte to add |
j | second byte to add |
- Returns
- the sum of i + j, capped at 0x7F and -0x80
Definition at line 73 of file math8.h.
73 {
74#if QADD7_C == 1
80 return static_cast<int8_t
>(
t);
81#elif QADD7_AVRASM == 1
82 asm volatile(
83
84 "add %0, %1 \n\t"
85
86
87
88
89
90 "brvc L_%= \n\t"
91 "ldi %0, 0x7F \n\t"
92
93
94
95 "adc %0, __zero_reg__\n\t"
96 "L_%=: "
97 : "+d"(i)
98 : "r"(j));
99 return i;
100#elif QADD7_ARM_DSP_ASM == 1
101 asm volatile("qadd8 %0, %0, %1" : "+r"(i) : "r"(j));
102 return i;
103#else
104#error "No implementation for qadd7 available."
105#endif
106}
References LIB8STATIC_ALWAYS_INLINE, and t.