You can use variables in GASP to represent strings, registers, or the results of expressions.
You must distinguish two kinds of variables:
.EQU
or .ASSIGN
. To evaluate this
kind of variable in your assembly output, simply mention its name. For
example, these two lines define and use a variable `eg':
eg .EQU FLIP-64 ... mov.l eg,r0Do not use this kind of variable in conditional expressions or while loops; GASP only evaluates these variables when writing assembly output.
.ASSIGNC
or .ASSIGNA
. To evaluate this
kind of variable, write `\&' before the variable name; for example,
opcit .ASSIGNA 47 ... .AWHILE \&opcit GT 0 ... .AENDWGASP treats macro arguments almost the same way, but to evaluate them you use the prefix `\' rather than `\&'. See section Defining your own directives.
pvar .EQU expr
pvar .ASSIGN expr
.EQU
, save that you may not redefine
pvar using .ASSIGN
once it has a value.
pvar .ASSIGNA aexpr
.ASSIGNA
at any time.
pvar .ASSIGNC "str"
.ASSIGNC
at any time.
pvar .REG (register)
.REG
to define a variable that represents a register. In
particular, register is not evaluated as an expression.
You may use .REG
at will to redefine register variables.
All these directives accept the variable name in the "label" position, that is at the left margin. You may specify a colon after the variable name if you wish; the first example above could have started `eg:' with the same effect.