Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The GNU Assembler Preprocessor - <b>preprocessor variables</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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 `\&'.  Defining your
     own directives: Macros

`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.


See Also: Macros

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson