CMSIS-Core (Cortex-M)  Version 5.7.0
CMSIS-Core support for Cortex-M processor-based devices
 All Data Structures Files Functions Variables Enumerations Enumerator Groups Pages
Intrinsic Functions for CPU Instructions

Functions that generate specific Cortex-M CPU Instructions. More...

Functions

void __NOP (void)
 No Operation. More...
 
void __WFI (void)
 Wait For Interrupt. More...
 
void __WFE (void)
 Wait For Event. More...
 
void __SEV (void)
 Send Event. More...
 
void __BKPT (uint8_t value)
 Set Breakpoint. More...
 
void __ISB (void)
 Instruction Synchronization Barrier. More...
 
void __DSB (void)
 Data Synchronization Barrier. More...
 
void __DMB (void)
 Data Memory Barrier. More...
 
uint32_t __REV (uint32_t value)
 Reverse byte order (32 bit) More...
 
uint32_t __REV16 (uint32_t value)
 Reverse byte order (16 bit) More...
 
int16_t __REVSH (int16_t value)
 Reverse byte order (16 bit) More...
 
uint32_t __RBIT (uint32_t value)
 Reverse bit order of value. More...
 
uint32_t __ROR (uint32_t value, uint32_t shift)
 Rotate a value right by a number of bits. More...
 
uint8_t __LDREXB (volatile uint8_t *addr)
 LDR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
uint16_t __LDREXH (volatile uint16_t *addr)
 LDR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
uint32_t __LDREXW (volatile uint32_t *addr)
 LDR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
uint32_t __STREXB (uint8_t value, volatile uint8_t *addr)
 STR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
uint32_t __STREXH (uint16_t value, volatile uint16_t *addr)
 STR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
uint32_t __STREXW (uint32_t value, volatile uint32_t *addr)
 STR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
void __CLREX (void)
 Remove the exclusive lock [not for Cortex-M0, Cortex-M0+, or SC000]. More...
 
int32_t __SSAT (int32_t value, uint32_t sat)
 Signed Saturate. More...
 
uint32_t __USAT (int32_t value, uint32_t sat)
 Unsigned Saturate. More...
 
uint8_t __CLZ (uint32_t value)
 Count leading zeros. More...
 
uint32_t __RRX (uint32_t value)
 Rotate Right with Extend (32 bit) More...
 
uint8_t __LDRBT (uint8_t ptr)
 LDRT Unprivileged (8 bit) More...
 
uint16_t __LDRHT (uint16_t ptr)
 LDRT Unprivileged (16 bit) More...
 
uint32_t __LDRT (uint32_t ptr)
 LDRT Unprivileged (32 bit) More...
 
void __STRBT (uint8_t value, uint8_t ptr)
 STRT Unprivileged (8 bit) More...
 
void __STRHT (uint16_t value, uint16_t ptr)
 STRT Unprivileged (16 bit) More...
 
void __STRT (uint32_t value, uint32_t ptr)
 STRT Unprivileged (32 bit) More...
 
uint8_t __LDAB (volatile uint8_t *ptr)
 Load-Acquire (8 bit) More...
 
uint16_t __LDAH (volatile uint16_t *ptr)
 Load-Acquire (16 bit) More...
 
uint32_t __LDA (volatile uint32_t *ptr)
 Load-Acquire (32 bit) More...
 
void __STLB (uint8_t value, volatile uint8_t *ptr)
 Store-Release (8 bit) More...
 
void __STLH (uint16_t value, volatile uint16_t *ptr)
 Store-Release (16 bit) More...
 
void __STL (uint32_t value, volatile uint32_t *ptr)
 Store-Release (32 bit) More...
 
uint8_t __LDAEXB (volatile uint32_t *ptr)
 Load-Acquire Exclusive (8 bit) More...
 
uint16_t __LDAEXH (volatile uint32_t *ptr)
 Load-Acquire Exclusive (16 bit) More...
 
uint32_t __LDAEX (volatile uint32_t *ptr)
 Load-Acquire Exclusive (32 bit) More...
 
uint32_t __STLEXB (uint8_t value, volatile uint8_t *ptr)
 Store-Release Exclusive (8 bit) More...
 
uint32_t __STLEXH (uint16_t value, volatile uint16_t *ptr)
 Store-Release Exclusive (16 bit) More...
 
uint32_t __STLEX (uint32_t value, volatile uint32_t *ptr)
 Store-Release Exclusive (32 bit) More...
 

Description

Functions that generate specific Cortex-M CPU Instructions.

The following functions generate specific Cortex-M instructions that cannot be directly accessed by the C/C++ Compiler. Refer to the Cortex-M Generic User Guides for detailed information about these Cortex-M instructions.

Note
When using the Arm Compiler Version 5 Toolchain the following Intrinsic Functions for CPU Instructions are implemented using the Embedded Assembler. As the Embedded Assembler may cause side effects (Refer to Arm Compiler v5.xx User Guide - Using the Inline and Embedded Assemblers of the Arm Compiler for more information) it is possible to disable the following intrinsic functions and therefore the usage of the Embedded Assembler with the define __NO_EMBEDDED_ASM:

Function Documentation

void __BKPT ( uint8_t  value)

Set Breakpoint.

This function causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached.

Parameters
[in]valueis ignored by the processor. If required, a debugger can use it to obtain additional information about the breakpoint.
void __CLREX ( void  )

Remove the exclusive lock [not for Cortex-M0, Cortex-M0+, or SC000].

This function removes the exclusive lock which is created by LDREX [not for Cortex-M0, Cortex-M0+, or SC000].

uint8_t __CLZ ( uint32_t  value)

Count leading zeros.

This function counts the number of leading zeros of a data value.

On Armv6-M (Cortex-M0, Cortex-M0+, and SC000) this function is not available as a core instruction instruction and thus __CLZ is implemented in software.

Parameters
[in]valueValue to count the leading zeros
Returns
number of leading zeros in value
void __DMB ( void  )

Data Memory Barrier.

This function ensures the apparent order of the explicit memory operations before and after the instruction, without ensuring their completion.

void __DSB ( void  )

Data Synchronization Barrier.

This function acts as a special kind of Data Memory Barrier. It completes when all explicit memory accesses before this instruction complete.

void __ISB ( void  )

Instruction Synchronization Barrier.

Instruction Synchronization Barrier flushes the pipeline in the processor, so that all instructions following the ISB are fetched from cache or memory, after the instruction has been completed.

uint32_t __LDA ( volatile uint32_t *  ptr)

Load-Acquire (32 bit)

Executes a LDA instruction for 32 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint32_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint8_t __LDAB ( volatile uint8_t *  ptr)

Load-Acquire (8 bit)

Executes a LDAB instruction for 8 bit value.

Parameters
[in]ptrPointer to data
Returns
value of type uint8_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint32_t __LDAEX ( volatile uint32_t *  ptr)

Load-Acquire Exclusive (32 bit)

Executes a LDA exclusive instruction for 32 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint32_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint8_t __LDAEXB ( volatile uint32_t *  ptr)

Load-Acquire Exclusive (8 bit)

Executes a LDAB exclusive instruction for 8 bit value.

Parameters
[in]ptrPointer to data
Returns
value of type uint8_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint16_t __LDAEXH ( volatile uint32_t *  ptr)

Load-Acquire Exclusive (16 bit)

Executes a LDAH exclusive instruction for 16 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint16_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint16_t __LDAH ( volatile uint16_t *  ptr)

Load-Acquire (16 bit)

Executes a LDAH instruction for 16 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint16_t at (*ptr)
Note
Only available for Armv8-M Architecture.
uint8_t __LDRBT ( uint8_t  ptr)

LDRT Unprivileged (8 bit)

This function executed an Unprivileged LDRT command for 8 bit value.

Parameters
[in]ptrPointer to data
Returns
value of type uint8_t at (*ptr)
uint8_t __LDREXB ( volatile uint8_t *  addr)

LDR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive LDR command for 8 bit value [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]*addrPointer to data
Returns
value of type uint8_t at (*addr)
uint16_t __LDREXH ( volatile uint16_t *  addr)

LDR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive LDR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]*addrPointer to data
Returns
value of type uint16_t at (*addr)
uint32_t __LDREXW ( volatile uint32_t *  addr)

LDR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive LDR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]*addrPointer to data
Returns
value of type uint32_t at (*addr)
uint16_t __LDRHT ( uint16_t  ptr)

LDRT Unprivileged (16 bit)

This function executed an Unprivileged LDRT command for 16 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint16_t at (*ptr)
uint32_t __LDRT ( uint32_t  ptr)

LDRT Unprivileged (32 bit)

This function executed an Unprivileged LDRT command for 32 bit values.

Parameters
[in]ptrPointer to data
Returns
value of type uint32_t at (*ptr)
void __NOP ( void  )

No Operation.

This function does nothing. This instruction can be used for code alignment purposes.

uint32_t __RBIT ( uint32_t  value)

Reverse bit order of value.

Parameters
[in]valueValue to reverse
Returns
Reversed value
uint32_t __REV ( uint32_t  value)

Reverse byte order (32 bit)

Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.

Parameters
[in]valueValue to reverse
Returns
Reversed value
uint32_t __REV16 ( uint32_t  value)

Reverse byte order (16 bit)

Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.

Parameters
[in]valueValue to reverse
Returns
Reversed value
int16_t __REVSH ( int16_t  value)

Reverse byte order (16 bit)

Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.

Parameters
[in]valueValue to reverse
Returns
Reversed value
uint32_t __ROR ( uint32_t  value,
uint32_t  shift 
)

Rotate a value right by a number of bits.

This function rotates a value right by a specified number of bits.

Parameters
[in]valueValue to be shifted right
[in]shiftNumber of bits in the range [1..31]
Returns
Rotated value
uint32_t __RRX ( uint32_t  value)

Rotate Right with Extend (32 bit)

This function moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring.

Parameters
[in]valueValue to rotate
Returns
Rotated value
void __SEV ( void  )

Send Event.

Send Event is a hint instruction. It causes an event to be signaled to the CPU.

int32_t __SSAT ( int32_t  value,
uint32_t  sat 
)

Signed Saturate.

This function saturates a signed value. The Q bit is set if saturation occurs [not for Cortex-M0, Cortex-M0+, or SC000].

On Armv6-M (Cortex-M0, Cortex-M0+, and SC000) this function is not available as a core instruction instruction and thus __SSAT is implemented in software.

Parameters
[in]valueValue to be saturated
[in]satBit position to saturate to [1..32]
Returns
Saturated value
void __STL ( uint32_t  value,
volatile uint32_t *  ptr 
)

Store-Release (32 bit)

Executes a STL instruction for 32 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Note
Only available for Armv8-M Architecture.
void __STLB ( uint8_t  value,
volatile uint8_t *  ptr 
)

Store-Release (8 bit)

Executes a STLB instruction for 8 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Note
Only available for Armv8-M Architecture.
uint32_t __STLEX ( uint32_t  value,
volatile uint32_t *  ptr 
)

Store-Release Exclusive (32 bit)

Executes a STL exclusive instruction for 32 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Returns
0 Function succeeded
1 Function failed
Note
Only available for Armv8-M Architecture.
uint32_t __STLEXB ( uint8_t  value,
volatile uint8_t *  ptr 
)

Store-Release Exclusive (8 bit)

Executes a STLB exclusive instruction for 8 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Returns
0 Function succeeded
1 Function failed
Note
Only available for Armv8-M Architecture.
uint32_t __STLEXH ( uint16_t  value,
volatile uint16_t *  ptr 
)

Store-Release Exclusive (16 bit)

Executes a STLH exclusive instruction for 16 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Returns
0 Function succeeded
1 Function failed
Note
Only available for Armv8-M Architecture.
void __STLH ( uint16_t  value,
volatile uint16_t *  ptr 
)

Store-Release (16 bit)

Executes a STLH instruction for 16 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
Note
Only available for Armv8-M Architecture.
void __STRBT ( uint8_t  value,
uint8_t  ptr 
)

STRT Unprivileged (8 bit)

This function executed an Unprivileged STRT command for 8 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
uint32_t __STREXB ( uint8_t  value,
volatile uint8_t *  addr 
)

STR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive STR command for 8 bit values [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]valueValue to store
[in]*addrPointer to location
Returns
0 Function succeeded
1 Function failed
uint32_t __STREXH ( uint16_t  value,
volatile uint16_t *  addr 
)

STR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive STR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]valueValue to store
[in]*addrPointer to location
Returns
0 Function succeeded
1 Function failed
uint32_t __STREXW ( uint32_t  value,
volatile uint32_t *  addr 
)

STR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000].

This function executed an exclusive STR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].

Parameters
[in]valueValue to store
[in]*addrPointer to location
Returns
0 Function succeeded
1 Function failed
void __STRHT ( uint16_t  value,
uint16_t  ptr 
)

STRT Unprivileged (16 bit)

This function executed an Unprivileged STRT command for 16 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
void __STRT ( uint32_t  value,
uint32_t  ptr 
)

STRT Unprivileged (32 bit)

This function executed an Unprivileged STRT command for 32 bit values.

Parameters
[in]valueValue to store
[in]ptrPointer to location
uint32_t __USAT ( int32_t  value,
uint32_t  sat 
)

Unsigned Saturate.

This function saturates an unsigned value. The Q bit is set if saturation occurs [not for Cortex-M0, Cortex-M0+, or SC000].

On Armv6-M (Cortex-M0, Cortex-M0+, and SC000) this function is not available as a core instruction instruction and thus __USAT is implemented in software.

Parameters
[in]valueValue to be saturated
[in]satBit position to saturate to [0..31]
Returns
Saturated value
void __WFE ( void  )

Wait For Event.

Wait For Event is a hint instruction that permits the processor to enter a low-power state until an events occurs:

  • If the event register is 0, then WFE suspends execution until one of the following events occurs:
    • An exception, unless masked by the exception mask registers or the current priority level.
    • An exception enters the Pending state, if SEVONPEND in the System Control Register is set.
    • A Debug Entry request, if Debug is enabled.
    • An event signaled by a peripheral or another processor in a multiprocessor system using the SEV instruction.
  • If the event register is 1, then WFE clears it to 0 and returns immediately.
void __WFI ( void  )

Wait For Interrupt.

WFI is a hint instruction that suspends execution until one of the following events occurs:

  • A non-masked interrupt occurs and is taken.
  • An interrupt masked by PRIMASK becomes pending.
  • A Debug Entry request.