The following is a look at the use of this Assembly pseudo-directive (ARM GNU)-----Its own translation of the ambiguous view of the original English language
Instructions:. macro/. Endm
Grammar:
The macro name. MACRO [Formal parameters]
........
Macro definition Statement
........
. Endm
Describe:
With the. macro directive you can define a macro that can be used to repeat a piece of code, or a set of instructions abbreviated to a macro,
When the program calls, you can call this macro directly to make the code more concise and clear, this macro is composed of the following 3 parts:
1. Header: Here you can specify the name of the macro, and define the formal parameters
2. Body: This contains instructions or statements that need to be executed when the macro is called.
3. Tail: Use here. ENDM identifies the end of the macro.
PS: The formal parameter is just an identifier and will be expanded individually when the macro is expanded or the macro is called, and the definition of formal parameters must be defined by the global variable
Rule, parameter cannot be (%).
Example:
Swap_reg. MACRO REG1,REG2; Swap Registers
XCH A, REG1
XCH A, REG2
XCH A, REG1
. Endm
Look at Redboot's startup code, found a lot of places to use. Macro is defined as macros, which feel similar to the inline functions inside C + + (C-language macros are defined as functions that may not be used by newcomers).
Http://blog.sina.com.cn/s/blog_727800bb0100qhnd.html
Assembly. MACRO