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.

Compiler/TMS320F28377D: How to perform saturating arithmeticwithout resorting to assembly

Part Number: TMS320F28377D


Tool/software: TI C/C++ Compiler

I have read the C28x Optimising Compiler guide (spru514k) and have not determined the best method (i.e. least cycles) for performing saturating arithmetic in C.

Table 7-6 provides the list of intrinsics available in the compiler. Of interest is the __sat intrinsics that would allow me to saturate an arithmetic result based on the OVC bits. But the intrinsics do not provide a method for explicitly performing arithmetic operations that increment/decrement the OVC bits.

I realise I could test for overflow using C but this requires a complex conditional evaluation for the bounds.

Please could you provide a sample of C code that performs saturating arithmetic that is performant.