CMSIS-Core (Cortex-M)  
CMSIS-Core support for Cortex-M processor-based devices
 
Loading...
Searching...
No Matches
Intrinsic Functions for CPU Instructions

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

Functions

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

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

◆ __BKPT()

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.

◆ __CLREX()

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].

◆ __CLZ()

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

◆ __DMB()

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.

◆ __DSB()

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.

◆ __ISB()

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.

◆ __LDA()

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.

◆ __LDAB()

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.

◆ __LDAEX()

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.

◆ __LDAEXB()

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.

◆ __LDAEXH()

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.

◆ __LDAH()

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.

◆ __LDRBT()

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)

◆ __LDREXB()

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)

◆ __LDREXH()

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)

◆ __LDREXW()

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)

◆ __LDRHT()

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)

◆ __LDRT()

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)

◆ __NOP()

void __NOP ( void  )

No Operation.

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

◆ __RBIT()

uint32_t __RBIT ( uint32_t  value)

Reverse bit order of value.

Parameters
[in]valueValue to reverse
Returns
Reversed value

◆ __REV()

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

◆ __REV16()

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

◆ __REVSH()

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

◆ __ROR()

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

◆ __RRX()

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

◆ __SEV()

void __SEV ( void  )

Send Event.

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

◆ __SSAT()

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

◆ __STL()

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.

◆ __STLB()

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.

◆ __STLEX()

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.

◆ __STLEXB()

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.

◆ __STLEXH()

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.

◆ __STLH()

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.

◆ __STRBT()

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

◆ __STREXB()

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

◆ __STREXH()

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

◆ __STREXW()

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

◆ __STRHT()

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

◆ __STRT()

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

◆ __USAT()

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

◆ __WFE()

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.

◆ __WFI()

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.