Saturating instructions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User5327
Level 4
Level 4
Can anyone advise me How to use Saturating instructions? (in XMC4500)

Is there any application that could do work with Saturating instructions?
Is there any manual or else description of Saturating instructions?


Thanks.

Best regards
Koumak
0 Likes
1 Reply
User5327
Level 4
Level 4
Can someone help me how to use these instruction in C code?

SSAT Signed Saturate SSAT and USAT
SSAT16 Signed Saturate Halfword SSAT16 and USAT16
USAT Unsigned Saturate SSAT and USAT
USAT16 Unsigned Saturate Halfword SSAT16 and USAT16
QADD Saturating Add QADD and QSUB
QSUB Saturating Subtract QADD and QSUB
QSUB16 Saturating Subtract 16 QADD and QSUB
QASX Saturating Add and Subtract with Exchange QASX and QSAX
QSAX Saturating Subtract and Add with Exchange QASX and QSAX
QDADD Saturating Double and Add QDADD and QDSUB
QDSUB Saturating Double and Subtract QDADD and QDSUB
UQADD16 Unsigned Saturating Add 16 UQADD and UQSUB
UQADD8 Unsigned Saturating Add 8 UQADD and UQSUB
UQASX Unsigned Saturating Add and Subtract with Exchange UQASX and UQSAX
UQSAX Unsigned Saturating Subtract and Add with Exchange UQASX and UQSAX
UQSUB16 Unsigned Saturating Subtract 16 UQADD and UQSUB
UQSUB8 Unsigned Saturating Subtract 8 UQADD and UQSUB


Is there some example? Or is there any library?


My problem is:
int16_t a = 25000;
int16_t b = 20000;
int16_t c;

c = a + b;


How can I use QADD16 instead of ADD in my example? Please

I tried:
c = __QADD16(a, b);

- but it does not work 😕

Best regards
Koumak
0 Likes