z80:Directives:VARLOC

From Learn @ Cemetech
Jump to navigationJump to search

This directive is to used with the directive var/tvar/tempvar 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.

Syntax

   .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

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!


Allowed inputs

Uses

See Also

var/tvar/tempvar