06.02.2013 Views

C166/ST10 Cross-Assembler, Linker/Locator, Utilities ... - Tasking

C166/ST10 Cross-Assembler, Linker/Locator, Utilities ... - Tasking

C166/ST10 Cross-Assembler, Linker/Locator, Utilities ... - Tasking

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2−36<br />

MACRO PREPROCESSOR<br />

2.5.3 LOCAL SYMBOLS IN MACROS<br />

Chapter 2<br />

As mentioned in the note to Example 3, a macro using a fixed label can<br />

only be called once, since a second call to the macro causes a conflict in<br />

the label definitions at assembly time. The label can be made a parameter<br />

and a different symbol name can be specified each time the macro is<br />

called.<br />

A preferable way to ensure a unique label for each macro call is to put the<br />

label in a local−list. The local−list construct allows you to use macro<br />

identifiers to specify assembly−time symbols. Each use of a LOCAL symbol<br />

in a macro guarantees that the symbol will be replaced by a unique<br />

assembly−time symbol each time the symbol is called.<br />

The macro preprocessor increments a counter once for each symbol used<br />

in the list every time your program calls a macro that uses the LOCAL<br />

construct. Symbols in the local−list, when used in the macro−body, receive<br />

a three digit suffix that is the decimal value of the counter preceded by ’_’.<br />

The first time you call a macro that uses the LOCAL construct the suffix is<br />

’_001’.<br />

The syntax for the LOCAL construct in the DEFINE function is shown<br />

below. (This is the complete syntax for the built−in function DEFINE):<br />

Syntax:<br />

@[*]DEFINE macro−name [(parameter−list)] [@LOCAL(local−list)]<br />

macro−body<br />

@ENDD<br />

The local−list is a list of valid macro identifiers separated by commas.<br />

Since these macro identifiers are not parameters, the LOCAL construct in a<br />

macro has no effect on a macro call.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!