Problems related to lexical similarities between labels and assembler variables

The lexical definition of a label is identical to that of an assembler variable. The context of the first occurance of a label or assmebler variable determins the assemblers subsequent interpretation of that symbol. Problems occure where the symbol is first seen in the context of a label and subsequently used as an assembler variable.

Consider the following:

mac1		.macro

mac1_var	.set	mac1_var+1	; here mac1_var is first seen as
					; an assembler variable

		.db	mac1_var	; here mac1_var is interpreted as
					; an assembler variable
		.endm
if instead the macro had been written as
mac1		.macro

		.db	mac1_var	; here mac1_var is first seen as
					; a label

mac1_var	.set	mac1_var+1	; here mac1_var is interpreted as
					; a label which causes an error
					; since an assembler variable is
					; expected

		.endm
The way around this problem is to insert an explicit assembler variable context statement before the definition of the macro.
mac1_var	.set	0		; here mac1_var is first seen as
					; an assembler variable

mac1		.macro

		.db	mac1_var	; here mac1_var is interpreted as
					; an assembler variable

mac1_var	.set	mac1_var+1	; here mac1_var is interpreted as
					; an assembler variable and so
					; no error occures

		.endm

See also example of obscure problems related to lexical similarities between labels and macros