CMSIS Support for Cortex-M4 SIMD Instructions

This file describes the Cortex-M4 SIMD instructions supported by CMSIS.

Version: 1.00 - 25. November 2010

Information in this file, the accompany manuals, and software is
Copyright © ARM Ltd.
All rights reserved.


Revision History


Contents

  1. About
  2. Cortex-M4 SIMD instruction support
  3. Examples

 

About

CMSIS provides for the Cortex-M4 a set of functions supporting Cortex-M4 SIMD instructions.

 

Cortex-M4 SIMD instruction support

CMSIS supports the following functions for Cortex-M4 instructions:

Name Mnemonic Description
__SADD8 SADD8 GE setting quad 8-bit signed addition
__QADD8 QADD8 Q setting quad 8-bit saturating addition
__SHADD8 SHADD8 Quad 8-bit signed addition with halved results
__UADD8 UADD8 GE setting quad 8-bit unsigned addition
__UQADD8 UQADD8 Quad 8-bit unsigned saturating addition
__UHADD8 UHADD8 Quad 8-bit unsigned addition with halved results
__SSUB8 SSUB8 GE setting quad 8-bit signed subtraction
__QSUB8 QSUB8 Q setting quad 8-bit saturating subtract
__SHSUB8 SHSUB8 Quad 8-bit signed subtraction with halved results
__USUB8 USUB8 GE setting quad 8-bit unsigned subtract
__UQSUB8 UQSUB8 Quad 8-bit unsigned saturating subtraction
__UHSUB8 UHSUB8 Quad 8-bit unsigned subtraction with halved results
__SADD16 SADD16 GE setting dual 16-bit signed addition
__QADD16 QADD16 Q setting dual 16-bit saturating addition
__SHADD16 SHADD16 Dual 16-bit signed addition with halved results
__UADD16 UADD16 GE setting dual 16-bit unsigned addition
__UQADD16 UQADD16 Dual 16-bit unsigned saturating addition
__UHADD16 UHADD16 Dual 16-bit unsigned addition with halved results
__SSUB16 SSUB16 GE setting dual 16-bit signed subtraction
__QSUB16 QSUB16 Q setting dual 16-bit saturating subtract
__SHSUB16 SHSUB16 Dual 16-bit signed subtraction with halved results
__USUB16 USUB16 GE setting dual 16-bit unsigned subtract
__UQSUB16 UQSUB16 Dual 16-bit unsigned saturating subtraction
__UHSUB16 UHSUB16 Dual 16-bit unsigned subtraction with halved results
__SASX SASX GE setting dual 16-bit addition and subtraction with exchange
__QASX QASX Q setting dual 16-bit add and subtract with exchange
__SHASX SHASX Dual 16-bit signed addition and subtraction with halved results
__UASX UASX GE setting dual 16-bit unsigned addition and subtraction with exchange
__UQASX UQASX Dual 16-bit unsigned saturating addition and subtraction with exchange
__UHASX UHASX Dual 16-bit unsigned addition and subtraction with halved results and exchange
__SSAX SSAX GE setting dual 16-bit signed subtraction and addition with exchange
__QSAX QSAX Q setting dual 16-bit subtract and add with exchange
__SHSAX SHSAX Dual 16-bit signed subtraction and addition with halved results
__USAX USAX GE setting dual 16-bit unsigned subtract and add with exchange
__UQSAX UQSAX Dual 16-bit unsigned saturating subtraction and addition with exchange
__UHSAX UHSAX Dual 16-bit unsigned subtraction and addition with halved results and exchange
__USAD8 USAD8 Unsigned sum of quad 8-bit unsigned absolute difference
__USADA8 USADA8 Unsigned sum of quad 8-bit unsigned absolute difference with 32-bit accumulate
__SSAT16 SSAT16 Q setting dual 16-bit saturate
__USAT16 USAT16 Q setting dual 16-bit unsigned saturate
__UXTB16 UXTB16 Dual extract 8-bits and zero-extend to 16-bits
__UXTAB16 UXTAB16 Extracted 16-bit to 32-bit unsigned addition
__SXTB16 SXTB16 Dual extract 8-bits and sign extend each to 16-bits
__SXTAB16 SXTAB16 Dual extracted 8-bit to 16-bit signed addition
__SMUAD SMUAD Q setting sum of dual 16-bit signed multiply
__SMUADX SMUADX Q setting sum of dual 16-bit signed multiply with exchange
__SMLAD SMLAD Q setting dual 16-bit signed multiply with single 32-bit accumulator
__SMLADX SMLADX Q setting pre-exchanged dual 16-bit signed multiply with single 32-bit accumulator
__SMLALD SMLALD Dual 16-bit signed multiply with single 64-bit accumulator
__SMLALDX SMLALDX Dual 16-bit signed multiply with exchange with single 64-bit accumulator
__SMUSD SMUSD Dual 16-bit signed multiply returning difference
__SMUSDX SMUSDX Dual 16-bit signed multiply with exchange returning difference
__SMLSD SMLSD Q setting dual 16-bit signed multiply subtract with 32-bit accumulate
__SMLSDX SMLSDX Q setting dual 16-bit signed multiply with exchange subtract with 32-bit accumulate
__SMLSLD SMLSLD Q setting dual 16-bit signed multiply subtract with 64-bit accumulate
__SMLSLDX SMLSLDX Q setting dual 16-bit signed multiply with exchange subtract with 64-bit accumulate
__SEL SEL Select bytes based on GE bits
__QADD QADD Q setting saturating add
__QSUB QSUB/td> Q setting saturating subtract

Function __SADD8

Summary
uint32_t __SADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four 8-bit signed integer additions.
The GE bits in the APSR are set according to the results of the additions.
Parameter
  • val1: first four 8-bit summands.
  • val2: second four 8-bit summands.
Return Value

The function returns:

  • the addition of the first bytes from each operand, in the first byte of the return value.
  • the addition of the second bytes of each operand, in the second byte of the return value.
  • the addition of the third bytes of each operand, in the third byte of the return value.
  • the addition of the fourth bytes of each operand, in the fourth byte of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[7:0] ≥ 0 then APSR.GE[0] = 1 else 0
  • if res[15:8] ≥ 0 then APSR.GE[1] = 1 else 0
  • if res[23:16] ≥ 0 then APSR.GE[2] = 1 else 0
  • if res[31:24] ≥ 0 then APSR.GE[3] = 1 else 0
Operation
res[7:0]   = val1[7:0]   + val2[7:0]
res[15:8]  = val1[15:8]  + val2[15:8]
res[23:16] = val1[23:16] + val2[23:16]
res[31:24] = val1[31:24] + val2[31:24]

Function __QADD8

Summary
uint32_t __QADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four 8-bit integer additions, saturating the results to the 8-bit signed integer range -27 ≤ x ≤ 27 - 1.
Parameter
  • val1: first four 8-bit summands.
  • val2: second four 8-bit summands.
Return Value

The function returns:

  • the saturated addition of the first byte of each operand in the first byte of the return value.
  • the saturated addition of the second byte of each operand in the second byte of the return value.
  • the saturated addition of the third byte of each operand in the third byte of the return value.
  • the saturated addition of the fourth byte of each operand in the fourth byte of the return value.

The returned results are saturated to the 16-bit signed integer range -27 ≤ x ≤ 27 - 1.

Operation
res[7:0]   = val1[7:0]   + val2[7:0]
res[15:8]  = val1[15:8]  + val2[15:8]
res[23:16] = val1[23:16] + val2[23:16]
res[31:24] = val1[31:24] + val2[31:24]

Function __SHADD8

Summary
uint32_t __SHADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four signed 8-bit integer additions, halving the results.
Parameter
  • val1: first four 8-bit summands.
  • val2: second four 8-bit summands.
Return Value

The function returns:

  • the halved addition of the first bytes from each operand, in the first byte of the return value.
  • the halved addition of the second bytes from each operand, in the second byte of the return value.
  • the halved addition fo the third bytes from each operand, in the third byte of the return value.
  • the halved addition of the fourth bytes from each operand, in the fourth byte of the return value.
Operation
res[7:0]   = (val1[7:0]   + val2[7:0])   >> 1
res[15:8]  = (val1[15:8]  + val2[15:8])  >> 1
res[23:16] = (val1[23:16] + val2[23:16]) >> 1
res[31:24] = (val1[31:24] + val2[31:24]) >> 1

Function __UADD8

Summary
uint32_t __UADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit integer additions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first four 8-bit summands for each addition.
  • val2: second four 8-bit summands for each addition.
Return Value

The function returns:

  • the addition of the first bytes in each operand, in the first byte of the return value.
  • the addition of the second bytes in each operand, in the second byte of the return value.
  • the addition of the third bytes in each operand, in the third byte of the return value.
  • the addition of the fourth bytes in each operand, in the fourth byte of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[7:0] ≥ 0x100 then APSR.GE[0] = 1 else 0
  • if res[15:8] ≥ 0x100 then APSR.GE[1] = 1 else 0
  • if res[23:16] ≥ 0x100 then APSR.GE[2] = 1 else 0
  • if res[31:24] ≥ 0x100 then APSR.GE[3] = 1 else 0
Operation
res[7:0]   = val1[7:0]   + val2[7:0]
res[15:8]  = val1[15:8]  + val2[15:8]
res[23:16] = val1[23:16] + val2[23:16]
res[31:24] = val1[31:24] + val2[31:24]

Function __UQADD8

Summary
uint32_t __UQADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit integer additions, saturating the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 - 1.
Parameter
  • val1: first four 8-bit summands.
  • val2: second four 8-bit summands.
Return Value

The function returns:

  • the addition of the first bytes in each operand, in the first byte of the return value.
  • the addition of the second bytes in each operand, in the second byte of the return value.
  • the addition of the third bytes in each operand, in the third byte of the return value.
  • the addition of the fourth bytes in each operand, in the fourth byte of the return value.

The results are saturated to the 8-bit unsigned integer range 0 ≤ x ≤ 28 - 1.

Operation
res[7:0]   = val1[7:0]   + val2[7:0]
res[15:8]  = val1[15:8]  + val2[15:8]
res[23:16] = val1[23:16] + val2[23:16]
res[31:24] = val1[31:24] + val2[31:24]

Function __UHADD8

Summary
uint32_t __UHADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit integer additions, halving the results.
Parameter
  • val1: first four 8-bit summands.
  • val2: second four 8-bit summands.
Return Value

The function returns:

  • the halved addition of the first bytes in each operand, in the first byte of the return value.
  • the halved addition of the second bytes in each operand, in the second byte of the return value.
  • the halved addition of the third bytes in each operand, in the third byte of the return value.
  • the halved addition of the fourth bytes in each operand, in the fourth byte of the return value.
Operation
res[7:0]   = (val1[7:0]   + val2[7:0])   >> 1
res[15:8]  = (val1[15:8]  + val2[15:8])  >> 1
res[23:16] = (val1[23:16] + val2[23:16]) >> 1
res[31:24] = (val1[31:24] + val2[31:24]) >> 1

Function __SSUB8

Summary
uint32_t __SSUB8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four 8-bit signed integer subtractions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first four 8-bit operands of each subtraction.
  • val2: second four 8-bit operands of each subtraction.
Return Value

The function returns:

  • the subtraction of the first byte in the second operand from the first byte in the first operand, in the first bytes of the return value.
  • the subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation. If res is the return value, then:

  • if res[8:0] ≥ 0 then APSR.GE[0] = 1 else 0
  • if res[15:8] ≥ 0 then APSR.GE[1] = 1 else 0
  • if res[23:16] ≥ 0 then APSR.GE[2] = 1 else 0
  • if res[31:24] ≥ 0 then APSR.GE[3] = 1 else 0
Operation
res[7:0]   = val1[7:0]   - val2[7:0]
res[15:8]  = val1[15:8]  - val2[15:8]
res[23:16] = val1[23:16] - val2[23:16]
res[31:24] = val1[31:24] - val2[31:24]

Function __QSUB8

Summary
uint32_t __QADD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four 8-bit integer subtractions, saturating the results to the 8-bit signed integer range -27 ≤ x ≤ 27 - 1.
Parameter
  • val1: first four 8-bit operands.
  • val2: second four 8-bit operands.
Return Value

The function returns:

  • the subtraction of the first byte in the second operand from the first byte in the first operand, in the first byte of the return value.
  • the subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.

The returned results are saturated to the 8-bit signed integer range -27 ≤ x ≤ 27 - 1.

Operation
res[7:0]   = val1[7:0]   - val2[7:0]
res[15:8]  = val1[15:8]  - val2[15:8]
res[23:16] = val1[23:16] - val2[23:16]
res[31:24] = val1[31:24] - val2[31:24]

Function __SHSUB8

Summary
uint32_t __SHSUB8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four signed 8-bit integer subtractions, halving the results.
Parameter
  • val1: first four 8-bit operands.
  • val2: second four 8-bit operands.
Return Value

The function returns:

  • the halved subtraction of the first byte in the second operand from the first byte in the first operand, in the first byte of the return value.
  • the halved subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the halved subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the halved subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.
Operation
res[7:0]   = (val1[7:0]   - val2[7:0])  >> 1
res[15:8]  = (val1[15:8]  - val2[15:8]) >> 1
res[23:16] = (val1[23:16] - val2[23:16] >> 1
res[31:24] = (val1[31:24] - val2[31:24] >> 1

Function __USUB8

Summary
uint32_t __USUB8(uint32_t val1, uint32_t val2);
Description This function It enables you to perform four 8-bit unsigned integer subtractions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first four 8-bit operands.
  • val2: second four 8-bit operands.
Return Value

The function returns:

  • the subtraction of the first byte in the second operand from the first byte in the first operand, in the first byte of the return value.
  • the subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[7:0] ≥ 0 then APSR.GE[0] = 1 else 0
  • if res[15:8] ≥ 0 then APSR.GE[1] = 1 else 0
  • if res[23:16] ≥ 0 then APSR.GE[2] = 1 else 0
  • if res[31:24] ≥ 0 then APSR.GE[3] = 1 else 0
Operation
res[7:0]   = val1[7:0]   - val2[7:0]
res[15:8]  = val1[15:8]  - val2[15:8]
res[23:16] = val1[23:16] - val2[23:16]
res[31:24] = val1[31:24] - val2[31:24]

Function __UQSUB8

Summary
uint32_t __UQSUB8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit integer subtractions, saturating the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 - 1.
Parameter
  • val1: first four 8-bit operands.
  • val2: second four 8-bit operands.
Return Value

The function returns:

  • the subtraction of the first byte in the second operand from the first byte in the first operand, in the first byte of the return value.
  • the subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.

The results are saturated to the 8-bit unsigned integer range 0 ≤ x ≤ 28 - 1.

Operation
res[7:0]   = val1[7:0]   - val2[7:0]
res[15:8]  = val1[15:8]  - val2[15:8]
res[23:16] = val1[23:16] - val2[23:16]
res[31:24] = val1[31:24] - val2[31:24]

Function __UHSUB8

Summary
uint32_t __UHSUB8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit integer subtractions, halving the results.
Parameter
  • val1: first four 8-bit operands.
  • val2: second four 8-bit operands.
Return Value

The function returns:

  • the halved subtraction of the first byte in the second operand from the first byte in the first operand, in the first byte of the return value.
  • the halved subtraction of the second byte in the second operand from the second byte in the first operand, in the second byte of the return value.
  • the halved subtraction of the third byte in the second operand from the third byte in the first operand, in the third byte of the return value.
  • the halved subtraction of the fourth byte in the second operand from the fourth byte in the first operand, in the fourth byte of the return value.
Operation
res[7:0]   = (val1[7:0]   - val2[7:0])   >> 1
res[15:8]  = (val1[15:8]  - val2[15:8])  >> 1
res[23:16] = (val1[23:16] - val2[23:16]) >> 1
res[31:24] = (val1[31:24] - val2[31:24]) >> 1

Function __SADD16

Summary
uint32_t __SADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit signed integer additions.
The GE bits in the APSR are set according to the results of the additions.
Parameter
  • val1: first two 16-bit summands.
  • val2: second two 16-bit summands.
Return Value

The function returns:

  • the addition of the low halfwords in the low halfword of the return value.
  • the addition of the high halfwords in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  + val2[15:0]
res[31:16] = val1[31:16] + val2[31:16]

Function __QADD16

Summary
uint32_t __QADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit integer arithmetic additions in parallel, saturating the results to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.
Parameter
  • val1: first two 16-bit summands.
  • val2: second two 16-bit summands.
Return Value

The function returns:

  • the saturated addition of the low halfwords in the low halfword of the return value.
  • the saturated addition of the high halfwords in the high halfword of the return value.

The returned results are saturated to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1

Operation
res[15:0]  = val1[15:0]  + val2[15:0]
res[16:31] = val1[31:16] + val2[31:16]

Function __SHADD16

Summary
uint32_t __SHADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two signed 16-bit integer additions, halving the results.
Parameter
  • val1: first two 16-bit summands.
  • val2: second two 16-bit summands.
Return Value

The function returns:

  • the halved addition of the low halfwords from each operand, in the low halfword of the return value.
  • the halved addition of the high halfwords from each operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  + val2[15:0])  >> 1
res[31:16] = (val1[31:16] + val2[31:16]) >> 1

Function __UADD16

Summary
uint32_t __UADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit unsigned integer additions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first two 16-bit summands for each addition.
  • val2: second two 16-bit summands for each addition.
Return Value

The function returns:

  • the addition of the low halfwords in each operand, in the low halfword of the return value.
  • the addition of the high halfwords in each operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0x10000 then APSR.GE[0] = 11 else 00
  • if res[31:16] ≥ 0x10000 then APSR.GE[1] = 11 else 00
Operation
res[15:0]  = val1[15:0]  + val2[15:0]
res[31:16] = val1[31:16] + val2[31:16]

Function __UQADD16

Summary
uint32_t __UQADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two unsigned 16-bit integer additions, saturating the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.
Parameter
  • val1: first two 16-bit summands.
  • val2: second two 16-bit summands.
Return Value

The function returns:

  • the addition of the low halfword in the first operand and the low halfword in the second operand, in the low halfword of the return value.
  • the addition of the high halfword in the first operand and the high halfword in the second operand, in the high halfword of the return value.

The results are saturated to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.

Operation
res[15:0]  = val1[15:0]  + val2[15:0]
res[31:16] = val1[31:16] + val2[31:16]

Function __UHADD16

Summary
uint32_t __UHADD16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two unsigned 16-bit integer additions, halving the results.
Parameter
  • val1: first two 16-bit summands.
  • val2: second two 16-bit summands.
Return Value

The function returns:

  • the halved addition of the low halfwords in each operand, in the low halfword of the return value.
  • the halved addition of the high halfwords in each operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  + val2[15:0])  >> 1
res[31:16] = (val1[31:16] + val2[31:16]) >> 1

Function __SSUB16

Summary
uint32_t __SSUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit signed integer subtractions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first two 16-bit operands of each subtraction.
  • val2: second two 16-bit operands of each subtraction.
Return Value

The function returns:

  • the subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  - val2[15:0]
res[31:16] = val1[31:16] - val2[31:16]

Function __QSUB16

Summary
uint32_t __QSUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit integer subtractions, saturating the results to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.
Parameter
  • val1: first two 16-bit operands.
  • val2: second two 16-bit operands.
Return Value

The function returns:

  • the saturated subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the returned result.
  • the saturated subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the returned result.

The returned results are saturated to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.

Operation
res[15:0]  = val1[15:0]  - val2[15:0]
res[31:16] = val1[31:16] - val2[31:16]

Function __SHSUB16

Summary
uint32_t __SHSUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two signed 16-bit integer subtractions, halving the results.
Parameter
  • val1: first two 16-bit operands.
  • val2: second two 16-bit operands.
Return Value

The function returns:

  • the halved subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the halved subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  - val2[15:0])  >> 1
res[31:16] = (val1[31:16] - val2[31:16]) >> 1

Function __USUB16

Summary
uint32_t __USUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit unsigned integer subtractions.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first two 16-bit operands.
  • val2: second two 16-bit operands.
Return Value

The function returns:

  • the subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  - val2[15:0]
res[31:16] = val1[31:16] - val2[31:16]

Function __UQSUB16

Summary
uint32_t __UQSUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two unsigned 16-bit integer subtractions, saturating the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.
Parameter
  • val1: first two 16-bit operands for each subtraction.
  • val2: second two 16-bit operands for each subtraction.
Return Value

The function returns:

  • the subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

The results are saturated to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.

Operation
res[15:0]  = val1[15:0]  - val2[15:0]
res[31:16] = val1[31:16] - val2[31:16]

Function __UHSUB16

Summary
uint32_t __UHSUB16(uint32_t val1, uint32_t val2);
Description This function enables you to perform two unsigned 16-bit integer subtractions, halving the results.
Parameter
  • val1: first two 16-bit operands.
  • val2: second two 16-bit operands.
Return Value

The function returns:

  • the halved subtraction of the low halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the halved subtraction of the high halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  - val2[15:0])  >> 1
res[31:16] = (val1[31:16] - val2[31:16]) >> 1

Function __SASX

Summary
uint32_t __SASX(uint32_t val1, uint32_t val2);
Description This function inserts an SASX instruction into the instruction stream generated by the compiler. It enables you to exchange the halfwords of the second operand, add the high halfwords and subtract the low halfwords.
The GE bits in the APRS are set according to the results.
Parameter
  • val1: first operand for the subtraction in the low halfword, and the first operand for the addition in the high halfword.
  • val2: second operand for the subtraction in the high halfword, and the second operand for the addition in the low halfword.
Return Value

The function returns:

  • the subtraction of the high halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the addition of the high halfword in the first operand and the low halfword in the second operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0] - val2[31:16]
res[31:16] = val1[31:16] + val2[15:0]

Function __QASX

Summary
uint32_t __QASX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the one operand, then add the high halfwords and subtract the low halfwords, saturating the results to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.
Parameter
  • val1: first operand for the subtraction in the low halfword, and the first operand for the addition in the high halfword.
  • val2: second operand for the subtraction in the high halfword, and the second operand for the addition in the low halfword.
Return Value

The function returns:

  • the saturated subtraction of the high halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the saturated addition of the high halfword in the first operand and the low halfword in the second operand, in the high halfword of the return value.

The returned results are saturated to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.

Operation
res[15:0]  = val1[15:0]  - val2[31:16]
res[31:16] = val1[31:16] + val2[15:0]

Function __SHASX

Summary
uint32_t __SHASX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the two halfwords of one operand, perform one signed 16-bit integer addition and one signed 16-bit subtraction, and halve the results.
Parameter
  • val1: first 16-bit operands.
  • val2: second 16-bit operands.
Return Value

The function returns:

  • the halved subtraction of the high halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the halved subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  - val2[31:16]) >> 1
res[31:16] = (val1[31:16] - val2[15:0])  >> 1

Function __UASX

Summary
uint32_t __UASX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the two halfwords of the second operand, add the high halfwords and subtract the low halfwords.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first operand for the subtraction in the low halfword, and the first operand for the addition in the high halfword.
  • val2: second operand for the subtraction in the high halfword and the second operand for the addition in the low halfword.
Return Value

The function returns:

  • the subtraction of the high halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the addition of the high halfword in the first operand and the low halfword in the second operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0x10000 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  - val2[31:16]
res[31:16] = val1[31:16] + val2[15:0]

Function __UQASX

Summary
uint32_t __UQASX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the second operand and perform one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, saturating the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.
Parameter
  • val1: first two 16-bit operands.
  • val2: second two 16-bit operands.
Return Value

The function returns:

  • the subtraction of the high halfword in the second operand from the low halfword in the first operand, in the low halfword of the return value.
  • the subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

The results are saturated to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.

Operation
res[15:0]  = val1[15:0]  - val2[31:16]
res[31:16] = val1[31:16] + val2[15:0]

Function __UHASX

Summary
uint32_t __UHASX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the second operand, add the high halfwords and subtract the low halfwords, halving the results.
Parameter
  • val1: first operand for the subtraction in the low halfword, and the first operand for the addition in the high halfword.
  • val2: second operand for the subtraction in the high halfword, and the second operand for the addition in the low halfword.
Return Value

The function returns:

  • the halved subtraction of the high halfword in the second operand from the low halfword in the first operand.
  • the halved addition of the high halfword in the first operand and the low halfword in the second operand.
Operation
res[15:0]  = (val1[15:0]  - val2[31:16]) >> 1
res[31:16] = (val1[31:16] + val2[15:0])  >> 1

Function __SSAX

Summary
uint32_t __SSAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the two halfwords of one operand and perform one 16-bit integer subtraction and one 16-bit addition.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first operand for the addition in the low halfword, and the first operand for the subtraction in the high halfword.
  • val2: second operand for the addition in the high halfword, and the second operand for the subtraction in the low halfword.
Return Value

The function returns:

  • the addition of the low halfword in the first operand and the high halfword in the second operand, in the low halfword of the return value.
  • the subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  + val2[31:16]
res[31:16] = val1[31:16] - val2[15:0]

Function __QSAX

Summary
uint32_t __QSAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of one operand, then subtract the high halfwords and add the low halfwords, saturating the results to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.
Parameter
  • val1: first operand for the addition in the low halfword, and the first operand for the subtraction in the high halfword.
  • val2: second operand for the addition in the high halfword, and the second operand for the subtraction in the low halfword.
Return Value

The function returns:

  • the saturated addition of the low halfword of the first operand and the high halfword of the second operand, in the low halfword of the return value.
  • the saturated subtraction of the low halfword of the second operand from the high halfword of the first operand, in the high halfword of the return value.

The returned results are saturated to the 16-bit signed integer range -215 ≤ x ≤ 215 - 1.

Operation
res[15:0]  = val1[15:0]  + val2[31:16]
res[31:16] = val1[31:16] - val2[15:0]

Function __SHSAX

Summary
uint32_t __SHSAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the two halfwords of one operand, perform one signed 16-bit integer subtraction and one signed 16-bit addition, and halve the results.
Parameter
  • val1: first 16-bit operands.
  • val2: second 16-bit operands.
Return Value

The function returns:

  • the halved addition of the low halfword in the first operand and the high halfword in the second operand, in the low halfword of the return value.
  • the halved subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  + val2[31:16]) >> 1
res[31:16] = (val1[31:16] - val2[15:0])  >> 1

Function __USAX

Summary
uint32_t __USAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the second operand, subtract the high halfwords and add the low halfwords.
The GE bits in the APSR are set according to the results.
Parameter
  • val1: first operand for the addition in the low halfword, and the first operand for the subtraction in the high halfword.
  • val2: second operand for the addition in the high halfword, and the second operand for the subtraction in the low halfword.
Return Value

The function returns:

  • the addition of the low halfword in the first operand and the high halfword in the second operand, in the low halfword of the return value.
  • the subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

Each bit in APSR.GE is set or cleared for each byte in the return value, depending on the results of the operation.
If res is the return value, then:

  • if res[15:0] ≥ 0x10000 then APSR.GE[1:0] = 11 else 00
  • if res[31:16] ≥ 0 then APSR.GE[3:2] = 11 else 00
Operation
res[15:0]  = val1[15:0]  + val2[31:16]
res[31:16] = val1[31:16] - val2[15:0]

Function __UQSAX

Summary
uint32_t __UQSAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the second operand and perform one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, saturating the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.
Parameter
  • val1: first 16-bit operand for the addition in the low halfword, and the first 16-bit operand for the subtraction in the high halfword.
  • val2: second 16-bit halfword for the addition in the high halfword, and the second 16-bit halfword for the subtraction in the low halfword.
Return Value

The function returns:

  • the addition of the low halfword in the first operand and the high halfword in the second operand, in the low halfword of the return value.
  • the subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.

The results are saturated to the 16-bit unsigned integer range 0 ≤ x ≤ 216 - 1.

Operation
res[15:0]  = val1[15:0]  + val2[31:16]
res[31:16] = val1[31:16] - val2[15:0]

Function __UHSAX

Summary
uint32_t __UHSAX(uint32_t val1, uint32_t val2);
Description This function enables you to exchange the halfwords of the second operand, subtract the high halfwords and add the low halfwords, halving the results.
Parameter
  • val1: first operand for the addition in the low halfword, and the first operand for the subtraction in the high halfword.
  • val2: second operand for the addition in the high halfword, and the second operand for the subtraction in the low halfword.
Return Value

The function returns:

  • the halved addition of the high halfword in the second operand and the low halfword in the first operand, in the low halfword of the return value.
  • the halved subtraction of the low halfword in the second operand from the high halfword in the first operand, in the high halfword of the return value.
Operation
res[15:0]  = (val1[15:0]  + val2[31:16]) >> 1
res[31:16] = (val1[31:16] - val2[15:0])  >> 1

Function __USAD8

Summary
uint32_t __USAD8(uint32_t val1, uint32_t val2);
Description This function enables you to perform four unsigned 8-bit subtractions, and add the absolute values of the differences together, returning the result as a single unsigned integer.
Parameter
  • val1: first four 8-bit operands for the subtractions.
  • val2: second four 8-bit operands for the subtractions.
Return Value

The function returns the sum of the absolute differences of:

  • the subtraction of the first byte in the second operand from the first byte in the first operand.
  • the subtraction of the second byte in the second operand from the second byte in the first operand.
  • the subtraction of the third byte in the second operand from the third byte in the first operand.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand.

The sum is returned as a single unsigned integer.

Operation
absdiff1  = val1[7:0]   - val2[7:0]
absdiff2  = val1[15:8]  - val2[15:8]
absdiff3  = val1[23:16] - val2[23:16]
absdiff4  = val1[31:24] - val2[31:24]
res[31:0] = absdiff1 + absdiff2 + absdiff3 + absdiff4

Function __USADA8

Summary
uint32_t __USADA8(uint32_t val1, uint32_t val2, uint32_t val3);
Description This function enables you to perform four unsigned 8-bit subtractions, and add the absolute values of the differences to a 32-bit accumulate operand.
Parameter
  • val1: first four 8-bit operands for the subtractions.
  • val2: second four 8-bit operands for the subtractions.
  • val3: accumulation value.
Return Value

The function returns the sum of the absolute differences of the following bytes, added to the accumulation value:

  • the subtraction of the first byte in the second operand from the first byte in the first operand.
  • the subtraction of the second byte in the second operand from the second byte in the first operand.
  • the subtraction of the third byte in the second operand from the third byte in the first operand.
  • the subtraction of the fourth byte in the second operand from the fourth byte in the first operand.
Operation
absdiff1  = val1[7:0]   - val2[7:0]
absdiff2  = val1[15:8]  - val2[15:8]
absdiff3  = val1[23:16] - val2[23:16]
absdiff4  = val1[31:24] - val2[31:24]
sum       = absdiff1 + absdiff2 + absdiff3 + absdiff4
res[31:0] = sum[31:0] + val3[31:0]

Function __SSAT16

Summary
uint32_t __SSAT16(uint32_t val1, const uint32_t val2);
Description This function enables you to saturate two signed 16-bit values to a selected signed range.
The Q bit is set if either operation saturates.
Parameter
  • val1: two signed 16-bit values to be saturated.
  • val2: bit position for saturation, an integral constant expression in the range 1 to 16.
Return Value

The function returns:

  • the signed saturation of the low halfword in val1, saturated to the bit position specified in val2 and returned in the low halfword of the return value.
  • the signed saturation of the high halfword in val1, saturated to the bit position specified in val2 and returned in the high halfword of the return value.
Operation
Saturate halfwords in val1 to the signed range specified by the bit position in val2

Function __USAT16

Summary
uint32_t __USAT16(uint32_t val1, const uint32_t val2);
Description This function enables you to saturate two signed 16-bit values to a selected unsigned range.
The Q bit is set if either operation saturates.
Parameter
  • val1: two 16-bit values that are to be saturated.
  • val2: bit position for saturation, and must be an integral constant expression in the range 0 to 15.
Return Value

The function returns the saturation of the two signed 16-bit values, as non-negative values.

  • the saturation of the low halfword in val1, saturated to the bit position specified in val2 and returned in the low halfword of the return value.
  • the saturation of the high halfword in val1, saturated to the bit position specified in val2 and returned in the high halfword of the return value.
Operation
Saturate halfwords in val1 to the unsigned range specified by the bit position in val2

Function __UXTB16

Summary
uint32_t __UXTB16(uint32_t val);
Description This function enables you to extract two 8-bit values from an operand and zero-extend them to 16 bits each.
Parameter
  • val1: two 8-bit values in val[7:0] and val[23:16] to be sign-extended.
Return Value

The function returns the 8-bit values zero-extended to 16-bit values.

  • zero-extended value of val[7:0] in the low halfword of the return value.
  • zero-extended value of val[23:16] in the high halfword of the return value.
Operation
res[15:0]  = ZeroExtended(val[7:0]  )
res[31:16] = ZeroExtended(val[23:16])

Function __UXTAB16

Summary
uint32_t __UXTAB16(uint32_t val1, uint32_t val2);
Description This function enables you to extract two 8-bit values from one operand, zero-extend them to 16 bits each, and add the results to two 16-bit values from another operand.
Parameter
  • val1: value added to the zero-extended to 16-bit values.
  • val2: two 8-bit values to be extracted and zero-extended.
Return Value

The function returns the 8-bit values in val2, zero-extended to 16-bit values and added to val1.

Operation
res[15:0]  = ZeroExt(val2[7:0]   to 16 bits) + val1[15:0]
res[31:16] = ZeroExt(val2[31:16] to 16 bits) + val1[31:16]

Function __SXTB16

Summary
uint32_t __SXTB16(uint32_t val);
Description This function enables you to extract two 8-bit values from an operand and sign-extend them to 16 bits each.
Parameter
  • val1: two 8-bit values in val[7:0] and val[23:16] to be sign-extended.
Return Value

The function returns the 8-bit values sign-extended to 16-bit values.

  • sign-extended value of val[7:0] in the low halfword of the return value.
  • sign-extended value of val[23:16] in the high halfword of the return value.
Operation
res[15:0]  = SignExtended(val[7:0]
res[31:16] = SignExtended(val[23:16]

Function __SXTAB16

Summary
uint32_t __SXTAB16(uint32_t val1, uint32_t val2);
Description This function enables you to extract two 8-bit values from the second operand (at bit positions [7:0] and [23:16]), sign-extend them to 16-bits each, and add the results to the first operand.
Parameter
  • val1: values added to the zero-extended to 16-bit values.
  • val2: two 8-bit values to be extracted and zero-extended.
Return Value

The function returns the addition of val1 and val2, where the 8-bit values in val2[7:0] and val2[23:16] have been extracted and sign-extended prior to the addition.

Operation
res[15:0]  = val1[15:0]  + SignExtended(val2[7:0])
res[31:16] = val1[31:16] + SignExtended(val2[23:16])

Function __SMUAD

Summary
uint32_t __SMUAD(uint32_t val1, uint32_t val2);
Description This function It enables you to perform two 16-bit signed multiplications, adding the products together.
The Q bit is set if the addition overflows.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
Return Value

The function returns the sum of the products of the two 16-bit signed multiplications.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
res[31:0] = p1 + p2

Function __SMUADX

Summary
uint32_t __SMUADX(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit signed multiplications with exchanged halfwords of the second operand, adding the products together.
The Q bit is set if the addition overflows.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
Return Value

The function returns the sum of the products of the two 16-bit signed multiplications with exchanged halfwords of the second operand.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
res[31:0] = p1 + p2

Function __SMLAD

Summary
uint32_t __SMLAD(uint32_t val1, uint32_t val2, uint32_t val3);
Description This function enables you to perform two signed 16-bit multiplications, adding both results to a 32-bit accumulate operand.
The Q bit is set if the addition overflows. Overflow cannot occur during the multiplications.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val2: accumulate value.
Return Value

The function returns the product of each multiplication added to the accumulate value, as a 32-bit integer.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
res[31:0] = p1 + p2 + val3[31:0]

Function __SMLADX

Summary
uint32_t __SMLADX(uint32_t val1, uint32_t val2, uint32_t val3);
Description This function enables you to perform two signed 16-bit multiplications with exchanged halfwords of the second operand, adding both results to a 32-bit accumulate operand.
The Q bit is set if the addition overflows. Overflow cannot occur during the multiplications.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val2: accumulate value.
Return Value

The function returns the product of each multiplication with exchanged halfwords of the second operand added to the accumulate value, as a 32-bit integer.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
res[31:0] = p1 + p2 + val3[31:0]

Function __SMLALD

Summary
uint64_t __SMLALD(uint32_t val1, uint32_t val2, uint64_t val3);
Description This function enables you to perform two signed 16-bit multiplications, adding both results to a 64-bit accumulate operand. Overflow is only possible as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo264.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val2: accumulate value.
Return Value

The function returns the product of each multiplication added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
sum = p1 + p2 + val3[63:32][31:0]
res[63:32] = sum[63:32]
res[31:0]  = sum[31:0]

Function __SMLALDX

Summary
unsigned long long __SMLALDX(uint32_t val1, uint32_t val2, unsigned long long val3);
Description This function enables you to exchange the halfwords of the second operand, and perform two signed 16-bit multiplications, adding both results to a 64-bit accumulate operand. Overflow is only possible as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo264.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val2: accumulate value.
Return Value

The function returns the product of each multiplication added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
sum = p1 + p2 + val3[63:32][31:0]
res[63:32] = sum[63:32]
res[31:0] = sum[31:0]

Function __SMUSD

Summary
uint32_t __SMUSD(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit signed multiplications, taking the difference of the products by subtracting the high halfword product from the low halfword product.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
Return Value

The function returns the difference of the products of the two 16-bit signed multiplications.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
res[31:0] = p1 - p2

Function __SMUSDX

Summary
uint32_t __SMUSDX(uint32_t val1, uint32_t val2);
Description This function enables you to perform two 16-bit signed multiplications, subtracting one of the products from the other. The halfwords of the second operand are exchanged before performing the arithmetic. This produces top * bottom and bottom * top multiplication.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
Return Value

The function returns the difference of the products of the two 16-bit signed multiplications.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
res[31:0] = p1 - p2

Function __SMLSD

Summary
uint32_t __SMLSD(uint32_t val1, uint32_t val2, uint32_t val3);
Description This function enables you to perform two 16-bit signed multiplications, take the difference of the products, subtracting the high halfword product from the low halfword product, and add the difference to a 32-bit accumulate operand.
The Q bit is set if the accumulation overflows. Overflow cannot occur during the multiplications or the subtraction.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val3: accumulate value.
Return Value

The function returns the difference of the product of each multiplication, added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
res[31:0] = p1 - p2 + val3[31:0]

Function __SMLSDX

Summary
uint32_t __SMLSDX(uint32_t val1, uint32_t val2, uint32_t val3);
Description This function enables you to exchange the halfwords in the second operand, then perform two 16-bit signed multiplications. The difference of the products is added to a 32-bit accumulate operand.
The Q bit is set if the addition overflows. Overflow cannot occur during the multiplications or the subtraction.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val3: accumulate value.
Return Value

The function returns the difference of the product of each multiplication, added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
res[31:0] = p1 - p2 + val3[31:0]

Function __SMLSLD

Summary
uint64_t __SMLSLD(uint32_t val1, uint32_t val2, uint64_t val3);
Description This function It enables you to perform two 16-bit signed multiplications, take the difference of the products, subtracting the high halfword product from the low halfword product, and add the difference to a 64-bit accumulate operand. Overflow cannot occur during the multiplications or the subtraction. Overflow can occur as a result of the 64-bit addition, and this overflow is not detected. Instead, the result wraps round to modulo264.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val3: accumulate value.
Return Value

The function returns the difference of the product of each multiplication, added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[15:0]
p2 = val1[31:16] * val2[31:16]
res[63:0] = p1 - p2 + val3[63:0]

Function __SMLSLDX

Summary
unsigned long long __SMLSLDX(uint32_t val1, uint32_t val2, unsigned long long val3);
Description This function enables you to exchange the halfwords of the second operand, perform two 16-bit multiplications, adding the difference of the products to a 64-bit accumulate operand. Overflow cannot occur during the multiplications or the subtraction. Overflow can occur as a result of the 64-bit addition, and this overflow is not detected. Instead, the result wraps round to modulo264.
Parameter
  • val1: first 16-bit operands for each multiplication.
  • val2: second 16-bit operands for each multiplication.
  • val3: accumulate value.
Return Value

The function returns the difference of the product of each multiplication, added to the accumulate value.

Operation
p1 = val1[15:0]  * val2[31:16]
p2 = val1[31:16] * val2[15:0]
res[63:0] = p1 - p2 + val3[63:0]

Function __SEL

Summary
uint32_t __SEL(uint32_t val1, uint32_t val2);
Description This function inserts a SEL instruction into the instruction stream generated by the compiler. It enables you to select bytes from the input parameters, whereby the bytes that are selected depend upon the results of previous SIMD instruction function. The results of previous SIMD instruction function are represented by the Greater than or Equal flags in the Application Program Status Register (APSR). The __SEL function works equally well on both halfword and byte operand function results. This is because halfword operand operations set two (duplicate) GE bits per value.
Parameter
  • val1: four selectable 8-bit values.
  • val2: four selectable 8-bit values.
Return Value

The function selects bytes from the input parameters and returns them in the return value, res, according to the following criteria:

  • if APSR.GE[0] == 1 then res[7:0] = val1[7:0] else res[7:0] = val2[7:0]
  • if APSR.GE[1] == 1 then res[15:8] = val1[15:8] else res[15:8] = val2[15:8]
  • if APSR.GE[2] == 1 then res[23:16] = val1[23:16] else res[23:16] = val2[23:16]
  • if APSR.GE[3] == 1 then res[31;24] = val1[31:24] else res = val2[31:24]

Function __QADD

Summary
uint32_t __QADD(uint32_t val1, uint32_t val2);
Description This function enables you to obtain the saturating add of two integers.
The Q bit is set if the operation saturates.
Parameter
  • val1: first summand of the saturating add operation.
  • val2: second summand of the saturating add operation.
Return Value

The function returns the saturating addition of val1 and val2.

Operation
res[31:0] = SAT(val1 + SAT(val2 * 2))

Function __QSUB

Summary
uint32_t __QSUB(uint32_t val1, uint32_t val2);
Description This function enables you to obtain the saturating subtraction of two integers.
The Q bit is set if the operation saturates.
Parameter
  • val1: minuend of the saturating subtraction operation.
  • val2: subtrahend of the saturating subtraction operation.
Return Value

The function returns the saturating subtraction of val1 and val2.

Operation
res[31:0] = SAT(val1 - SAT(val2 * 2))

 

Examples

Following are some coding examples using the SIMD functions:

Name Description
Addition Add two values using SIMD function
Subtraction Subtract two values using SIMD function
Multiplication Performing a multiplication using SIMD function

Addition

Example
uint32_t add_halfwords(uint32_t val1, uint32_t val2)
{
   uint32_t res;
   res = __SADD16(val1, val2);
   return res;
}

Subtraction

Example
uint32_t sub_halfwords(uint32_t val1, uint32_t val2)
{
  uint32_t res;
  res = __SSUB16(val1, val2);
  return res;
}

Multiplication

Example
uint32_t dual_mul_add_products(uint32_t val1, uint32_t val2)
{
  uint32_t res;
  res = __SMUAD(val1, val2);
  return res;
}