Using the Immediate-Addressing Mode in HLI Assembler Macros

There may be one ambiguity if you are using the immediate addressing mode inside of a macro.

For the ANSI-C preprocessor, the symbol # inside of a macro has a specific meaning (string constructor).

Using #pragma NO_STRING_CONSTR: No String Concatenation during preprocessing, instructs the Compiler that in all the macros defined afterward, the instructions remain unchanged wherever the symbol # is specified. This macro is valid for the rest of the file in which it is specified.

Listing: Definition of the Clear2 macro


/* This macro initializes the specified variable to 0.*/
#pragma NO_STRING_CONSTR

#define Clear2(var){__asm LOAD #0,Reg0;__asm STORE Reg0,var;}
Listing: Invoking the Clear2 macro in the source code


Clear2(var1);
Listing: The preprocessor expands the Clear2 macro


{ __asm LOAD #0,Reg0;__asm STORE Reg0,var1; };