类似register uint32_t __regPriMask __ASM("primask");的代码分析

本文仅对 keil armcc 编译器有效,对于其他编译器未验证,不清楚。

代码:

#define __ASM            __asm   /*!< asm keyword for ARM Compiler */
#define __INLINE         __inline  /*!< inline keyword for ARM Compiler */
#define __STATIC_INLINE  static __inline

/** \brief Set Priority Mask
This function assigns the given value to the Priority Mask Register.
\param [in] priMask Priority Mask
*/
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
   register uint32_t __regPriMask         __ASM("primask");
   __regPriMask = (priMask);
}

参见armcc.chm文件9.155 Named register variables一节。

9.155 Named register variables
The compiler enables you to access registers of an ARM architecture-based processor or coprocessor using named register variables.
Syntax register type var-name __asm(reg); Where:

type

  • is the type of the named register variable.
  • Any type of the same size as the register being named can be used in the declaration of a named register variable. The type can be a structure, but bitfield layout is sensitive to endianness.

var-name

  • is the name of the named register variable.

reg

  • is a character string denoting the name of a register on an ARM architecture-based processor, or for coprocessor registers, a string syntax that identifies the coprocessor and corresponds with how you intend to use the variable.
  • Registers available for use with named register variables on ARM architecture-based processors are shown in the following table.

其大致意思是:可以用register type var-name __asm(reg)这样的定义,来声明一个命名寄存器的变量,像使用变量一样操作他们;
type 是声明变量的类型;需要与寄存器大小一致,且注意大小端;
var-name 是声明变量的名称;
r

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值