The STM32 Cortex-M4 instruction set
3.7
Saturating instructions
This section describes the saturating instructions.
Mnemonic
SSAT
Signed Saturate
SSAT16
Signed Saturate Halfword
USAT
Unsigned Saturate
USAT16
Unsigned Saturate Halfword
QADD
Saturating Add
QSUB
Saturating Subtract
QSUB16
Saturating Subtract 16
QASX
Saturating Add and Subtract with Exchange
QSAX
Saturating Subtract and Add with Exchange
QDADD
Saturating Double and Add
QDSUB
Saturating Double and Subtract
UQADD16
Unsigned Saturating Add 16
UQADD8
Unsigned Saturating Add 8
UQASX
Unsigned Saturating Add and Subtract with Exchange
UQSAX
Unsigned Saturating Subtract and Add with Exchange
UQSUB16
Unsigned Saturating Subtract 16
UQSUB8
Unsigned Saturating Subtract 8
For signed n-bit saturation, this means that:
•
if the value to be saturated is less than -2
•
if the value to be saturated is greater than 2
•
otherwise, the result returned is the same as the value to be saturated.
For unsigned n-bit saturation, this means that:
•
if the value to be saturated is less than 0, the result returned is 0
•
if the value to be saturated is greater than 2
•
otherwise, the result returned is the same as the value to be saturated.
If the returned result is different from the value to be saturated, it is called saturation. If
saturation occurs, the instruction sets the Q flag to 1 in the APSR. Otherwise, it leaves the Q
flag unchanged. To clear the Q flag to 0, you must use the MSR instruction, see
page
186.
To read the state of the Q flag, use the MRS instruction, see
124/260
Table 29. Saturating instructions
Brief description
DocID022708 Rev 6
SSAT and USAT on page 125
SSAT16 and USAT16 on page 126
SSAT and USAT on page 125
SSAT16 and USAT16 on page 126
QADD and QSUB on page 127
QADD and QSUB on page 127
QADD and QSUB on page 127
QASX and QSAX on page 128
QASX and QSAX on page 128
QDADD and QDSUB on page 129
QDADD and QDSUB on page 129
UQADD and UQSUB on page 131
UQADD and UQSUB on page 131
UQASX and UQSAX on page 130
UQASX and UQSAX on page 130
UQADD and UQSUB on page 131
UQADD and UQSUB on page 131
n-1
, the result returned is -2
n-1
-1, the result returned is 2
n-1
, the result returned is 2
MRS on page
PM0214
See
n-1
n-1
-1
n-1
MSR on
185.
Need help?
Do you have a question about the STM32F4 Series and is the answer not in the manual?
Questions and answers