.varloc location, size
This directive is to used with the directive .var to create a bunch of labels which point to variables in areas of memory without you having to manually calculate the offsets in memory yourself. For example, you might currently use:
.define safe_ram $CED5 me_x .equ safe_ram+0 me_y .equ safe_ram+1 me_dx .equ safe_ram+2 ; 2 bytes me_dy .equ safe_ram+4 ; 2 bytes me_s .equ safe_ram+6
...which is pretty rubbish. A better solution would be to make each one an offset of the previous (eg me_dy .equ me_dx+2) but that is still rubbish, as you can't rearrange them. The easiest way is to use .var, like this:
.define safe_ram $CED5 .varloc safe_ram, 128 ; We have 128 bytes of safe RAM here .var byte, me_x .var byte, me_y .var word, me_dx .var word, me_dy .var byte, me_s
The variables will be slotted into the variable area defined. Note that the variables will be shuffled around and will not end up in consecutive areas of RAM - if you require that variables are in a fixed order,
Each time you use .varloc, you add a new possible area of memory to be used. For example:
.define safe_ram_1 $CED5 .define safe_ram_2 $F000 .varloc safe_ram_1, 128 ; 128 bytes here .varloc safe_ram_2, 256 ; 256 bytes here .var 2, word_test ; Could go in either area .var 204, big_area ; Has to go in safe_ram_2 .var 100, other_big ; Has to go in safe_ram_1, now!