Variables are like labels for addresses in code. When you do something like
VAR,test var (and yes they can have spaces, just NO COMMAS OR HASHTAGS)
it automatically assigns "test var" to be Var ram pos + number of vars when the assembler reaches it
This means any instances of "test var" will be replaced with it's corresponding number. Say, 14216 is the beginning of Var Ram so put that into binary and it replaces something like
STA,test var
with something like
STA,
this means you can use a variable anywhere and it will just replace the name with the var number but this has one drawback:
if you would have used a $ without a var, you DO NOT HAVE TO USE A $. This is because something like
LDA,test var
would put the value test var into A. You can do "double addressing" with a $ and a variable where it would load the value from ram at an address defined by the value in the variable.
LDA,00000011
STA,var
LDA,$var
would load the value at RAM[3] into A. NOT THE VARIABLE.
You can have over 2000 variables because that's just how big var ram is. You arent running out anytime soon,