<一>:extended keyword
(1) : type attributes
You can either place the type attributes directly in your source code, or use the pragma directive #pragma
type_attribute
.
这句话的意思是当你想为段源代码指定type attributes,要么直接指示,要么通过#pragma type_attribute指示
Type attributes can be further divided into memory attributes and general type attributes.
类型属性可进一步分为存储器属性和通用类型属性
Memory attributes(存储器属性)
1: Available function memory attributes:
__banked_func
, __far_func
, and __near_func
有效的函数存储属性:__banked_func,
__far_func
, and __near_func
2: Available data memory attributes (有效的数据存储属性):__bdata,
__bit
, __code
, __data
, __far
, __far_code
, __far_rom
, __generic
,
__huge
, __huge_code
, __huge_rom
, __idata
, __ixdata
, __pdata
, __sfr
, __xdata
, and __xdata_rom
.
以上两种属性的使用说明:Data objects, functions, and destinations of pointers or C++ references always have a memory attribute. If no
attribute is explicitly specified in the declaration or by the pragma directive
#pragma type_attribute
, an
appropriate default attribute is used. You can only specify one memory attribute for each level of pointer
indirection.
General type attributes (通用类型属性)
1: Function type attributes (函数类型属性控制函数怎么样被调用)
__data_overlay
, __ext_stack_reentrant
, __idata_overlay
,
__idata_reentrant
, __interrupt
, __monitor
, __pdata_reentrant
, __task
, and __xdata_reentrant
2: Data type attributes:(数据类型属性)
const
and volatile
使用实例
__data
int i, j; int__data
k, l;
Note that the attribute affects both identifiers.
The following declaration of i
and j
is equivalent with the previous one:
#pragma type_attribute=__data
int i, j;
函数指针定义
To declare a function pointer, use the following syntax:
After this declaration, the function pointerint (__far_func * fp) (double);fp
points to farfunc memory.An easier way of specifying storage is to use type definitions:
typedef __far_func void FUNC_TYPE(int); typedef FUNC_TYPE *FUNC_PTR_TYPE; FUNC_TYPE func(); FUNC_PTR_TYPE funcptr;(2): object attributes
作用:Object attributes affect the internal functionality of functions and data objects, but not how the function is called or howthe data is accessed. This means that an object attribute does not need to be present in the declaration of an object.
类型:
a: Object attributes that can be used for variables: __no_init
b: Object attributes that can be used for functions and variables: location
, @
, and __root
c: Object attributes that can be used for functions: __intrinsic
, __noreturn
, and vector.
<三> intrinsic funcition 内部函数
函数名 描述
__disable_interrupt Disable interrupts
__enable_interrupt Enables interrupts
__get_interrupt_state Returns the interrupt state
__no_operation Inserts a NOP instruction
__parity Indicates the parity of the argument
__set_ interrupt_state Restores the interrupt state
__tbac Atomic read, modify, write instruction