I have a question about the __sat() intrinsic as mentioned in SPRU514C.
The document just says it translates into "SAT ACC". Is this really all it does, to add a "SAT ACC" instruction at the end of whatever it encloses?
It seems like in order for the __sat() instruction to perform correctly, there needs to be a "ZAP OVC" inserted by the compiler at the beginning of the outermost calculation, e.g.
int16_t a = ...;
int16_t b = ...;
int32_t c = ...;
int16_t d = ...;
int16_t e = ...;
c = __sat(c + (int32_t)a*b + (int32_t)d*f(e));
which a good compiler would turn into
// assemble tmp = f(e);
ZAP OVC
// load c into accumulator
// multiply a*b, add to accumulator
// multiply d*tmp, add to accumulator
SAT ACC
// load accumulator into c
Does it do this? Or are there conditions under which __sat() will not reset the overflow counter properly and therefore yield an incorrect result?