Go to the first, previous, next, last section, table of contents.

Preprocessor variables

You can use variables in GASP to represent strings, registers, or the results of expressions.

You must distinguish two kinds of variables:

  1. Variables defined with .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,r0
    
    Do not use this kind of variable in conditional expressions or while loops; GASP only evaluates these variables when writing assembly output.
  2. Variables for use during preprocessing. You can define these with .ASSIGNC or .ASSIGNA. To evaluate this kind of variable, write `\&' before the variable name; for 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 section 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 first example above could have started `eg:' with the same effect.


Go to the first, previous, next, last section, table of contents.