Correct info about evaluating macro args (distinct from evaluating preprocessor
vars); add version number (1); formatting improvements.
This commit is contained in:
parent
8981cac563
commit
673b162c1a
1 changed files with 28 additions and 18 deletions
|
@ -12,7 +12,7 @@
|
||||||
@ifinfo
|
@ifinfo
|
||||||
@format
|
@format
|
||||||
START-INFO-DIR-ENTRY
|
START-INFO-DIR-ENTRY
|
||||||
* gasp:(gasp). The GNU Assembler Preprocessor
|
* gasp: (gasp). The GNU Assembler Preprocessor
|
||||||
END-INFO-DIR-ENTRY
|
END-INFO-DIR-ENTRY
|
||||||
@end format
|
@end format
|
||||||
@end ifinfo
|
@end ifinfo
|
||||||
|
@ -24,9 +24,10 @@ END-INFO-DIR-ENTRY
|
||||||
@settitle GASP
|
@settitle GASP
|
||||||
@titlepage
|
@titlepage
|
||||||
@c FIXME boring title
|
@c FIXME boring title
|
||||||
|
@title DRAFT EDITION
|
||||||
|
@sp 4
|
||||||
@title GASP, an assembly preprocessor
|
@title GASP, an assembly preprocessor
|
||||||
@c FIXME! Get a version number, global-replace '??'
|
@subtitle for GASP version 1
|
||||||
@subtitle for GASP version ??
|
|
||||||
@sp 1
|
@sp 1
|
||||||
@subtitle January 1994
|
@subtitle January 1994
|
||||||
@author Roland Pesch
|
@author Roland Pesch
|
||||||
|
@ -80,7 +81,7 @@ into another language, under the above conditions for modified versions.
|
||||||
|
|
||||||
GASP is a preprocessor for assembly programs.
|
GASP is a preprocessor for assembly programs.
|
||||||
|
|
||||||
This file describes version ?? of GASP.
|
This file describes version 1 of GASP.
|
||||||
|
|
||||||
Steve Chamberlain wrote GASP; Roland Pesch wrote this manual.
|
Steve Chamberlain wrote GASP; Roland Pesch wrote this manual.
|
||||||
|
|
||||||
|
@ -371,7 +372,6 @@ You can use variables in @sc{gasp} to represent strings, registers, or
|
||||||
the results of expressions.
|
the results of expressions.
|
||||||
|
|
||||||
You must distinguish two kinds of variables:
|
You must distinguish two kinds of variables:
|
||||||
@c FIXME! Is this crud true about conditional comparisons vs variables?
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
Variables defined with @code{.EQU} or @code{.ASSIGN}. To evaluate this
|
Variables defined with @code{.EQU} or @code{.ASSIGN}. To evaluate this
|
||||||
|
@ -391,8 +391,8 @@ while loops; @sc{gasp} only evaluates these variables when writing
|
||||||
assembly output.
|
assembly output.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Variables for use during preprocessing. These are defined as macro
|
Variables for use during preprocessing. You can define these
|
||||||
arguments, or with @code{.ASSIGNC} or @code{.ASSIGNA}. To evaluate this
|
with @code{.ASSIGNC} or @code{.ASSIGNA}. To evaluate this
|
||||||
kind of variable, write @samp{\&} before the variable name; for example,
|
kind of variable, write @samp{\&} before the variable name; for example,
|
||||||
|
|
||||||
@cartouche
|
@cartouche
|
||||||
|
@ -404,6 +404,10 @@ opcit .ASSIGNA 47
|
||||||
.AENDW
|
.AENDW
|
||||||
@end example
|
@end example
|
||||||
@end cartouche
|
@end cartouche
|
||||||
|
|
||||||
|
@sc{gasp} treats macro arguments almost the same way, but to evaluate
|
||||||
|
them you use the prefix @samp{\} rather than @samp{\&}.
|
||||||
|
@xref{Macros,, Defining your own directives}.
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
@ftable @code
|
@ftable @code
|
||||||
|
@ -439,11 +443,13 @@ 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 @samp{eg:}
|
name if you wish; the first example above could have started @samp{eg:}
|
||||||
with the same effect.
|
with the same effect.
|
||||||
|
|
||||||
|
@c pagebreak makes for better aesthetics---ensures macro and expansion together
|
||||||
|
@page
|
||||||
@node Macros
|
@node Macros
|
||||||
@section Defining your own directives
|
@section Defining your own directives
|
||||||
|
|
||||||
The commands @code{.MACRO} and @code{.ENDM} allow you to define macros
|
The commands @code{.MACRO} and @code{.ENDM} allow you to define macros
|
||||||
that generate assembly output, and that you can use with a syntax
|
that generate assembly output. You can use these macros with a syntax
|
||||||
similar to built-in @sc{gasp} or assembler directives. For example,
|
similar to built-in @sc{gasp} or assembler directives. For example,
|
||||||
this definition specifies a macro @code{SUM} that adds together a range of
|
this definition specifies a macro @code{SUM} that adds together a range of
|
||||||
consecutive registers:
|
consecutive registers:
|
||||||
|
@ -494,23 +500,27 @@ arguments.
|
||||||
@item .MACRO PLUS1 P, P1
|
@item .MACRO PLUS1 P, P1
|
||||||
@itemx .MACRO PLUS1 P P1
|
@itemx .MACRO PLUS1 P P1
|
||||||
Either statement begins the definition of a macro called @code{PLUS1},
|
Either statement begins the definition of a macro called @code{PLUS1},
|
||||||
which takes two arguments; within the macro definition, these arguments
|
which takes two arguments; within the macro definition, write
|
||||||
are evaluated as @samp{\&P} and @samp{\&P1}.
|
@samp{\P} or @samp{\P1} to evaluate the arguments.
|
||||||
|
|
||||||
@item .MACRO RESERVE_STR P1=0 P2
|
@item .MACRO RESERVE_STR P1=0 P2
|
||||||
Begin the definition of a macro called @code{RESERVE_STR}, with two
|
Begin the definition of a macro called @code{RESERVE_STR}, with two
|
||||||
arguments. The first argument has a default value, but not the second.
|
arguments. The first argument has a default value, but not the second.
|
||||||
After the definition is complete, you can call the macro either as
|
After the definition is complete, you can call the macro either as
|
||||||
@samp{RESERVE_STR @var{a},@var{b}} (with @samp{\&P1} evaluating to
|
@samp{RESERVE_STR @var{a},@var{b}} (with @samp{\P1} evaluating to
|
||||||
@var{a} and @samp{\&P2} evaluating to @var{b}), or as @samp{RESERVE_STR
|
@var{a} and @samp{\P2} evaluating to @var{b}), or as @samp{RESERVE_STR
|
||||||
,@var{b}} (with @samp{\&P1} evaluating as the default, in this case
|
,@var{b}} (with @samp{\P1} evaluating as the default, in this case
|
||||||
@samp{0}, and @samp{\&P2} evaluating to @var{b}).
|
@samp{0}, and @samp{\P2} evaluating to @var{b}).
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
When you call a macro, the values are assigned by position to each
|
When you call a macro, you can specify the argument values either by
|
||||||
argument name. Macro arguments are preprocessor variables in the same
|
position, or by keyword. For example, @samp{SUM 9,17} is equivalent to
|
||||||
way as variables you define with @samp{.ASSIGNA} or @samp{.ASSIGNC}, and
|
@samp{SUM TO=17, FROM=9}. Macro arguments are preprocessor variables
|
||||||
you can therefore use them in conditionals or for loop control.
|
similar to the variables you define with @samp{.ASSIGNA} or
|
||||||
|
@samp{.ASSIGNC}; in particular, you can use them in conditionals or for
|
||||||
|
loop control. (The only difference is the prefix you write to evaluate
|
||||||
|
the variable: for a macro argument, write @samp{\@var{argname}}, but for
|
||||||
|
a preprocessor variable, write @samp{\&@var{varname}}.)
|
||||||
|
|
||||||
@item @var{name} .MACRO
|
@item @var{name} .MACRO
|
||||||
@itemx @var{name} .MACRO ( @var{macargs} @dots{} )
|
@itemx @var{name} .MACRO ( @var{macargs} @dots{} )
|
||||||
|
|
Loading…
Add table
Reference in a new issue