Improve mulU8X16toH16 accordingly
parent
aefa962cc3
commit
f2b65ebda2
|
|
@ -14,19 +14,17 @@ static inline uint16_t mulU8X16toH16(const uint8_t charIn1, const uint16_t intIn
|
|||
intRes = ((uint32_t)charIn1 * (uint32_t)intIn2) >> 8;
|
||||
#else
|
||||
asm volatile(
|
||||
"clr r26 \n\t"
|
||||
"mul %A1, %B2 \n\t"
|
||||
"movw %A0, r0 \n\t"
|
||||
"mul %A1, %A2 \n\t"
|
||||
"add %A0, r1 \n\t"
|
||||
"adc %B0, r26 \n\t"
|
||||
"lsr r0 \n\t"
|
||||
"adc %A0, r26 \n\t"
|
||||
"adc %B0, r26 \n\t"
|
||||
"clr r1 \n\t"
|
||||
"mul %B2, %A1 \n\t"
|
||||
"movw %0, r0 \n\t"
|
||||
"mul %A2, %A1 \n\t"
|
||||
"lsl r0 \n\t" //push MSB to carry for rounding
|
||||
"adc %A0, r1 \n\t" //add with carry (for rounding)
|
||||
"clr r1 \n\t" //make r1 __zero_reg__ again
|
||||
"adc %B0, r1 \n\t" //propagate carry of addition (add 0 with carry)
|
||||
: "=&r"(intRes)
|
||||
: "d"(charIn1), "d"(intIn2)
|
||||
: "r26");
|
||||
: "r"(charIn1), "r"(intIn2)
|
||||
: "r0", "r1" //clobbers: Technically these are either scratch registers or always 0 registers, but I'm making sure the compiler knows just in case.
|
||||
);
|
||||
#endif
|
||||
return intRes;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue