有时候在程序中会出现
EnableInterrrupt;
ClearReg0
我们看字面意思很容易懂它是什么意思,但是一般初学者一般会被它搞晕,为什么就这样一个单词就能表示开中断呢,其实它在头文件中时有定义的,那就是宏定义,这个单词代表的是一些语句,在包含文件里面有定义的,就是方便编程,增加程序的可读性,下面是CodeWarrior 宏定义的解释:
An HLI assembler macro is defined using the preprocessor directive `define'.
The macro is invoked in the following way in the source code:
The preprocessor expands the macro:
Example:
/* Following macro clears the registers 0 and 1. */
#define ClearReg0And1 {asm CLR Reg0; asm CLR Reg1}
The macro is invoked in the following way in the source code:
The preprocessor expands the macro:
{asm CLR Reg0; asm CLR Reg1; };
You can define an HLI assembler macro on several lines using the line separator `\'.
Example:
/* Following macro clears the registers 0 and 1. */
#define ClearR0andR1 {asm CLR Reg0; \
The macro is invoked in the following way in the source code:
The preprocessor expands the macro:
{asm CLR Reg0; asm CLR Reg1; };
Using Macro Parameters
An HLI assembler macro may have some parameters which are referenced in the macro code.
/* This macro initializes the specified variable to 0.*/
#define Clear(var) {asm CLR var}
The macro is invoked in the following way in the source code:
The preprocessor expands the macro:
文章评论(0条评论)
登录后参与讨论