.set

The syntax for the .set statement is:

<variable> .set <value>
assigning an assembler variable a number is done simply as:
var1    .set    10
assigning an assembler variable a string is done simply as:
var2	.set	"hello world"

to generate data from these two assembler variables we could do:

        .db     var1, var2
this would be equivalent to
        .db     10, "hello world"
Using assembler variables to store the names of variables is just as stright forward but needs a little more explanation with regard to what actually takes place within the assembler.

assigning a variable name to an assember variable:

var3    .set    Jack
here var3 now holds the name of the variable Jack.
var3    .equ    $
this statement is equivalent to:
Jack    .equ    $
This is because the assembler interprets the use of var3 in this context as meaning "use the nominated variable Jack here"

We can also generate vaiable names and assign them to assember variables by simply applying the LABEL() function to a string expression

e.g.

var1    .set    "fred"
var2    .set    10
var3    .set    LABEL(var1+"_"+var2)

var3    .equ    $
this would be equivalent to:
fred_10 .equ    $
Here is an example that generates a subroutine call address dependant on the address of the caller (this technique is very useful when the source and destintion addresses are not in the same page and caller specific info needs to be passed).