This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use MIN and MAX in C on CLA and C28x ?



Hi,

I am trying to do a "saturation" of a variable in C, both in the CLA and in the C28x (on a piccolo 28035), but I didn't find in C an efficient way to do it, that would use the "min" and "max" assembly and process the instructions quickly.

What I am doing now : 

Variable = (Variable > MaxValue) ? MaxValue : Variable;

Variable = (Variable < MinValue) ? MinValue : Variable;

This is compiled as if/then, which is terrible for the pipeline. 

Is there a way to do it efficiently, both in CLA and C28x ? (I need both, preferably in C).

Thank you very much in advance,

Adrien