简体   繁体   中英

Need explanation of ARM Cortex-M3 assembly instruction in CMSIS to __set_PRIMASK

Below is a code snippet from the ARM CMSIS library that is used to set the value of the PRIMASK register.

/**
 * @brief  Set the Priority Mask value
 *
 * @param  priMask  PriMask
 *
 * Set the priority mask bit in the priority mask register
 */
static __INLINE void __set_PRIMASK(uint32_t priMask)
{
   register uint32_t __regPriMask         __ASM("primask");
   __regPriMask = (priMask);
}

The part that I don't understand is the inline assembly instruction

__ASM("primask");

I haven't read anything about addressing registers by name in this way. How can you have inline assembly without an op-code first? Is this assigning __regPriMask to this register location? Can anyone point to a reference document?

register uint32_t __regPriMask __ASM("primask");

...is the declaration of a local register variable called __regPriMask that is stored in the primask register.

In other words, assigning to that register variable will set the value of the register primask .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM