* VAR and PLANT macros var macro ds\0 0 \* equ *(a6) \*@ equ * ds\0 \1 endm plant macro org varbase+\*@ dc\0 \1 endm end * FRED VAR.X Y defines fred to be *(A6) and then * allocates space for FRED by using DS.X Y, * thereby advancing *. If you omit the .X it * will assume .W. If you only ever use 1 for Y, * it may be as well to change the DS\0 \1 in the * macro to DS\0 1. The DS\0 0 in the macro simply * word-aligns the location counter if necessary. * This macro also defines FRED@ to be *, which is * intended for use by the PLANT macro. * JIM PLANT.X Y initialises the variable JIM with * value Y, by resetting the location counter to * VARBASE+JIM@, and then using DC.X Y. It is * possible to initialise short arrays (such as * declared by JIM VAR 3) by using JIM PLANT * <1,2,3>. Note use of the angle brackets which * forces the 1,2,3 into parameter 1 (thus DC.X Y * becomes DC 1,2,3), omitting them would define * parameter 1 as 1, p2 as 2, p3, as 3, so DC.X Y * would become DC 1, with the 2 and 3 being * ignored. * The following order must be observed within the * source file: * * ORG 0 must come before first call to VAR. * * All VAR declarations must come before any code * which uses such variables because the assembler * rejects forward references to anything which is * not short absolute or PC relative (and these, * being register-relative, are neither). * * The label VARBASE must be declared (using * VARBASE EQU *) wherever it is intended that the * variables should be. If this is after rather * than before code which sets up the base * register (using LEA VARBASE,A6), it may be * necessary to use RORG ???? instead of ORG ???? * between VAR declarations and code. * * Any calls to the PLANT macro must come after * the VARBASE label. end