Contents|Index|Previous|Next
Preprocessor
variables
You
can use variables in GASP to represent strings, registers, or the results
of expressions. You must distinguish two kinds of variables.
- Variables defined with .EQU
or .ASSIGN.
To evaluate this kind of variable in your assembly output, simply mention
its name. For example, the following example input of two lines defines
and uses a variable, eg.
eg .EQU FLIP-64
...
mov.l eg,r0
Do not use this kind of variable
in conditional expressions or while loops; GASP only evaluates these variables
when writing assembly output.
- Variables for use during
preprocessing. You can define these with .ASSIGNC
or .ASSIGNA.
To evaluate this kind of variable, write \&
before the variable name. Use the following input as an example.
opcit .ASSIGNA 47
...
.AWHILE \&opcit
GT 0
...
.AENDW
GASP treats macro arguments
almost the same way, but to evaluate them you use the prefix, \,
rather than \&.
See Defining
your own directives.
- pvar .EQU expr
Assign preprocessor
variable, pvar,
the value of the expression, expr.
There are no restrictions on redefinition; use .EQU
with the same pvar
as often as you find it convenient.
- pvar .ASSIGN expr
Almost the
same as .EQU,
save that you may not redefine pvar
using .ASSIGN
once it has a value.
- pvar .ASSIGNA aexpr
Define a variable
with a numeric value, for use during preprocessing. aexpr
must be an absolute expression. You can redefine variables with .ASSIGNA
at any time.
- pvar .ASSIGNC "str"
Define a variable
with a string value, for use during preprocessing. You can redefine variables
with .ASSIGNC
at any time.
- pvar .REG (register)
Use .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 previous example could have started eg:
with the same effect.