Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
74
Добавлен:
14.04.2015
Размер:
2.03 Mб
Скачать

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

169

 

 

The macro BMOVE is called in line 12 with three actual parameters. Lines 14 to

 

20 shows the macro expansion, which is the return value of the macro call. This

 

text will be assembled.

 

The example will produce assembly errors because no section directives are

 

included in the source file. The purpose here is to show MPL processing, not the

 

assembler semantics.

 

Local Symbols List

The DJNZ instruction in the previous example uses a local label as the target of the branch. If you use a fixed label name (for example xlab, without a leading %), and you use the macro two or more times is the same assembly source file, errors will occur due to multiple definitions of a single name.

Local symbol definitions solve this problem. Local symbols are generated by the MPL processor as local_symbol_nnn, whereby local_symbol is the name of the local symbol and nnn is some number. Each time the macro is called, the number is automatically incremented. The resulting names are unique to each macro invocation.

The MPL processor increments a counter each time your program calls a macro

 

that uses a LOCAL construct. The counter is incremented once for each symbol

 

in the LOCAL list. Symbols in the LOCAL list, when used in the macro-body,

 

receive a one to five digit suffix that is the decimal value of the counter. The

6

first time you call a macro that uses the LOCAL construct, the suffix is 0.

The syntax for the LOCAL construct in the DEFINE functions is shown below:

%*DEFINE (macro-name (parameter-list)) [LOCAL local-list] (macro-body)

The local-list is a list of valid macro identifiers separated by spaces or commas. The LOCAL construct in a macro has no affect on the syntax of a macro call.

Соседние файлы в папке HLP