When some labels are defined in HLI Assembler Macros, if you invoke the same macro twice in the same function, the ANSI C preprocessor generates the same label twice (once in each macro expansion). Use the special string concatenation operator of the ANSI-C preprocessor (` ##') in order to generate unique labels. See the following listing.
/* The following macro copies the string pointed to by 'src' into the string pointed to by 'dest'. 'src' and 'dest' must be valid arrays of characters. 'inst' is the instance number of the macro call. This parameter must be different for each invocation of the macro to allow the generation of unique labels. */ #pragma NO_STRING_CONSTR #define copyMacro2(src, dest, inst) { \ __asm LOAD @src,Reg0; /* load src addr */ \ __asm LOAD @dest,Reg1; /* load dst addr */ \ __asm CLR Reg2; /* clear index reg */ \ __asm lp##inst: LOADB (Reg2, Reg0); /* load byte reg indir */ \ __asm STOREB (Reg2, Reg1); /* store byte reg indir */ \ __asm ADD #1,Reg2; /* increment index register */ \ __asm TST Reg2; /* test if not zero */ \ __asm BNE lp##inst; }
copyMacro2(source2, destination2, 1); copyMacro2(source2, destination3, 2);
During expansion of the first macro, the preprocessor generates an lp1 label. During expansion of the second macro, an lp2 label is created.