Ax51 User's Guide

Local Symbols

MPL macros may include local labels that are the targets of branches. Fixed label names cause errors if the macro is called more than once. This happens because the same label name may be used only once in a source file. This problem may be solved by using local symbols. Local macro symbols are appended with a unique, sequential number that increments each time the macro is invoked.

Local symbols must be declared in the macro definition line:

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

where the local-list is a list (separated by commas or spaces) of the macro's local symbols.

Local symbols must be prefixed with the meta character when they are used in the macro macro-body. For example:

%*DEFINE (BMOVE (src, dst, cnt)) LOCAL lab (
        MOV     R2,#%cnt
        MOV     R1,#%src
        MOV     R0,#%dst
%lab:   MOV     A,@R1
        MOV     @R0,A
        INC     R0
        INC     R1
        DJNZ    R2,lab
)