Keil™, An ARM® Company

Ax51 User's Guide

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 ExpansionAfter 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 ExpansionAfter 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 ExpansionAfter 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.