Assembly. MACRO

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.