Assembler Variables

Assembler variables, conditional statements, loop statements and macros allow the programmer to write code that is executed by the assembler while the assembler is processing the source. The programmer could for example write a short section of code that will be executed by the assembler and cause the assembler to generate a table of prime numbers. Like any other procedural programming language, such programs need to use variables. These variables belong to the program that must be executed by the assembler and should not be confused with the variables needed by the program that will be executed on the microprocessor in the target system.

Assembler variables can be assigned simple values such as numbers, or more complex values such as strings, or highly complex values such as the names of other variables or code or data labels.


Assembler variables are not macros and cannot be used to perform macro substitution.

Assembler variables are modified via the .set statement

Assembler variables (like labels) are symbols consisting of sequences of alphanumeric characters and the underscore character. Assembler variables must begin with an alpha character. Alpha characters are any of the characters a to z (upper or lower case). Alphanumeric characters are any of the alpha characters and any of the numeric characters 0 to 9. The underscore character is the '_' character.

Assembler variables can be any length and all characters are significant.

Valid assembler variables are:


Invalid assembler variables are:

	2bert			does not start with alpha character, '2' is
				a numeric character which is an illegal start
				of assembler variables character

	_fred			does not start with alpha character, '_' is
				illegal start of assembler variables character

	Brown Fox		contains illegal character ' '

	J.3			contains illegal character '.'
Case in assembler variables is significant e.g. fred and Fred are considered different assembler variables. Care must be taken when using mixed case assembler variables since it is possible to use similar assembler variables that cause confusion and introduce bugs into an assembly program.
Special Considerations
Beware, 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.

Problems related to lexical similarities between labels and assembler variables