Hello,
I am having trouble understanding the goal of the second add.w instruction in the snippet below:
...add.w r1, r4, r5add.w r1, r1, r1, lsr #0x1fasr r1, r1, #1...
I imagine it may have to do with a potential overflow on the first addition. The asr indicates a signed division.So, assuming the following signed variables, it would be:
signed int r1r1 = r4 + r5r1 = r1 + (r1<0 ? 1: 0)r1 = r1 / 2
I do not understand the reason for that check. As anyone seen this kind of idiom before? What could it be used for?
Thank you.
Even with the most careful rounding, fixed-point values represented with a scaling factor S may have an error of up to ±0.5 in the stored integer.