Keil Logo

Defining Standard Macros

Standard macros are defined as follows:

macro-name MACRO <[>parameter-list<]>
<[>LOCAL local-labels<]>


macro-name is the name of the macro.
parameter-list is an optional list of formal parameters that may be passed to the macro.
local-labels is an optional list of local labels within the macro.
macro-body is the text that is expanded to replace the macro name and parameter list. It may contain calls to other macros. If so, these macros are expanded as well. When you define a macro, those macro calls contained in the macro-body are not expanded until the macro is called.

For example:

        MOV   R0, #R0_Val

defines a macro named LOAD_R0 which loads register 0 with the value of the first parameter passed to the macro.


  • Unlike MPL macros, once a standard macro is defined, it may not be redefined.
  • Macros may be defined with or without a formal parameter-list.
  • Standard macro definitions may be nested up to 9 levels deep.
  • Standard macro may be called recursively up to 9 levels deep.

Macro Parameters

Parameters in the body of the macro are represented with the parameter name (src, dst, and cnt in the above example). They may be used any number of times and in any order within the macro body. If a parameter has the same name as the macro and is used in the macro body, the parameter is expanded. The macro is not called.

Standard macros may have up to 16 parameters. Parameters must be separated by commas (',') in the macro definition and invocation. For example:

mymacro MACRO   P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16

You would invoke this macro as follows:

mymacro A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P

You may pass a NULL value for a parameter by omitting that parameter from the macro invocation. The separating comma is still required. For example:

mymacro A,,C,,E,,G,,I,,K,,M,,O,

Null parameters may be tested using the NUL macro operator.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.