Hi Kef,
> yes, adjusting accumulator on overflows is absolutely necessary.
> When adding +ve to +ve overflows to -ve, acc should be adjusted and kept +ve,
> else next time you add +ve to -ve(which should be +ve but is -ve due previous overlow),
> overflow wan't happen when it has to happen and guard count will be lost.
I cannot follow, what is +ve? Some huge value which overflows when added?
I consider that guard counts the number of overflows outside of the 32 bit signed range. It gets incremented when the addition results in a value >= 2^31, it gets decremented when the result is < -2^31. When the 32 bit accumulator crosses 0 from -ve to +ve no overflow takes place, seems expected and ok to me.
The guard count is not just some additional bits for the sum, instead the value is
val = sval32 + 2^32*guard
with sval32 the signed accumulator and guard the overflow count (incremented for overflow, decremented for underflow, initially 0).
For val = 40000, sval32 would be -25536 and guard == 1. The guard is not the same as bits 32..39 of the summand, it is off by one if sval32 < 0.
So appart from having to treat guard properly in the end when comparing the final result with a 40 bit value, I don't see why there adjustment is necessary.
Still wondering if I miss something here.