Keil Logo

Literal Delimiters

The delimiters used in user-defined macros (parentheses and commas) are literal delimiters. A literal delimiter can be any character except the metacharacter. When you define a macro using a literal delimiter, you must use exactly that delimiter when you call the macro, to prevent a macro error.

When defining a macro, the delimiter string must be literalized if the delimiter meets any of the following conditions:

  • Has more than one character.
  • Has a macro-identifier character (A-Z, 0-9, _, or ?).
  • Has an at sign ('@'), space, tab, carriage return, or linefeed.

Use the escape function (%n) or the bracket function (%()) to literalize the delimiter string.

This is the simple form shown previously:

Before Macro Expansion After Macro Expansion
%*DEFINE(MAC(A,B))(%A %B) null string
%MAC(4,5) 4 5

However, in the following example, brackets are used instead of parentheses. The @ symbol separates parameters:

Before Macro Expansion After Macro Expansion
%*DEFINE (MOV[A%(@)B]) (MOV %A,%B) null string
%MOV[P0@P1] MOV P0,P1

In the next box, delimiters that could be id delimiters are defined as literal delimiters:

Before Macro Expansion After Macro Expansion
%*DEFINE(ADD (R10 AND B)) (ADD R10,%B) null string
%ADD (R10 AND #27H) ADD R10,#27H

Spaces around AND are considered part of the argument string.

  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.