📄 gasp.html
字号:
<HTML><HEAD><!-- This HTML file has been created by texi2html 1.52 from gasp.texi on 17 March 1999 --><TITLE>GASP</TITLE></HEAD><BODY><H1>GASP, an assembly preprocessor</H1><H2>for GASP version 1</H2><H2>March 1994</H2><ADDRESS>Roland Pesch</ADDRESS><P><P><HR><P><P><P>Copyright (C) 1994, 1995 Free Software Foundation, Inc.</P><P>Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.</P><P>Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.</P><P>Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.</P><H1><A NAME="SEC1" HREF="gasp_toc.html#TOC1">What is GASP?</A></H1><P>The primary purpose of the GNU assembler is to assemble the output ofother programs--notably compilers. When you have to hand-codespecialized routines in assembly, that means the GNU assembler isan unfriendly processor: it has no directives for macros, conditionals,or many other conveniences that you might expect.</P><P>In some cases you can simply use the C preprocessor, or a generalizedpreprocessor like M4; but this can be awkward, since none of thesethings are designed with assembly in mind.</P><P>GASP fills this need. It is expressly designed to provide thefacilities you need with hand-coded assembly code. Implementing it as apreprocessor, rather than part of the assembler, allows the maximumflexibility: you can use it with hand-coded assembly, without paying apenalty of added complexity in the assembler you use for compileroutput.</P><P>Here is a small example to give the flavor of GASP. This input toGASP</P><PRE> .MACRO saveregs from=8 to=14count .ASSIGNA \from ! save r\from..r\to .AWHILE \&count LE \to mov r\&count,@-spcount .ASSIGNA \&count + 1 .AENDW .ENDM saveregs from=12bar: mov #H'dead+10,r0foo .SDATAC "hello"<10> .END</PRE><P>generates this assembly program:</P><PRE> ! save r12..r14 mov r12,@-sp mov r13,@-sp mov r14,@-spbar: mov #57005+10,r0foo: .byte 6,104,101,108,108,111,10</PRE><H1><A NAME="SEC2" HREF="gasp_toc.html#TOC2">Command Line Options</A></H1><P>The simplest way to use GASP is to run it as a filter and assembleits output. In Unix and its ilk, you can do this, for example:</P><PRE>$ gasp prog.asm | as -o prog.o</PRE><P>Naturally, there are also a few command-line options to allow you torequest variations on this basic theme. Here is the full set ofpossibilities for the GASP command line.</P><PRE>gasp [ -a | --alternate ] [ -c <VAR>char</VAR> | --commentchar <VAR>char</VAR> ] [ -d | --debug ] [ -h | --help ] [ -M | --mri ] [ -o <VAR>outfile</VAR> | --output <VAR>outfile</VAR> ] [ -p | --print ] [ -s | --copysource ] [ -u | --unreasonable ] [ -v | --version ] <VAR>infile</VAR> ...</PRE><DL COMPACT><DT><CODE><VAR>infile</VAR> ...</CODE><DD><A NAME="IDX1"></A>The input file names. You must specify at least one input file; if youspecify more, GASP preprocesses them all, concatenating the outputin the order you list the <VAR>infile</VAR> arguments.Mark the end of each input file with the preprocessor command<CODE>.END</CODE>. See section <A HREF="gasp.html#SEC12">Miscellaneous commands</A>.<DT><CODE>-a</CODE><DD><A NAME="IDX2"></A><DT><CODE>--alternate</CODE><DD><A NAME="IDX3"></A>Use alternative macro syntax. See section <A HREF="gasp.html#SEC19">Alternate macro syntax</A>, for a discussion of how this syntax differs from the defaultGASP syntax.<A NAME="IDX4"></A><A NAME="IDX5"></A><A NAME="IDX6"></A><A NAME="IDX7"></A><A NAME="IDX8"></A><A NAME="IDX9"></A><A NAME="IDX10"></A><DT><CODE>-c '<VAR>char</VAR>'</CODE><DD><A NAME="IDX11"></A><DT><CODE>--commentchar '<VAR>char</VAR>'</CODE><DD><A NAME="IDX12"></A>Use <VAR>char</VAR> as the comment character. The default comment characteris <SAMP>`!'</SAMP>. For example, to use a semicolon as the comment character,specify <SAMP>`-c ';''</SAMP> on the GASP command line. Sinceassembler command characters often have special significance to commandshells, it is a good idea to quote or escape <VAR>char</VAR> when you specifya comment character.For the sake of simplicity, all examples in this manual use the defaultcomment character <SAMP>`!'</SAMP>.<DT><CODE>-d</CODE><DD><A NAME="IDX13"></A><DT><CODE>--debug</CODE><DD><A NAME="IDX14"></A>Show debugging statistics. In this version of GASP, this optionproduces statistics about the string buffers that GASP allocatesinternally. For each defined buffersize <VAR>s</VAR>, GASP shows thenumber of strings <VAR>n</VAR> that it allocated, with a line like this:<PRE>strings size <VAR>s</VAR> : <VAR>n</VAR></PRE>GASP displays these statistics on the standard error stream, whendone preprocessing.<DT><CODE>-h</CODE><DD><A NAME="IDX15"></A><DT><CODE>--help</CODE><DD><A NAME="IDX16"></A>Display a summary of the GASP command line options.<DT><CODE>-M</CODE><DD><A NAME="IDX17"></A><DT><CODE>--mri</CODE><DD><A NAME="IDX18"></A>Use MRI compatibility mode. Using this option causes GASP toaccept the syntax and pseudo-ops used by the Microtec Research<CODE>ASM68K</CODE> assembler.<DT><CODE>-o <VAR>outfile</VAR></CODE><DD><A NAME="IDX19"></A><DT><CODE>--output <VAR>outfile</VAR></CODE><DD><A NAME="IDX20"></A>Write the output in a file called <VAR>outfile</VAR>. If you do not use the<SAMP>`-o'</SAMP> option, GASP writes its output on the standard outputstream.<DT><CODE>-p</CODE><DD><A NAME="IDX21"></A><DT><CODE>--print</CODE><DD><A NAME="IDX22"></A>Print line numbers. GASP obeys this option <EM>only</EM> if you alsospecify <SAMP>`-s'</SAMP> to copy source lines to its output. With <SAMP>`-s-p'</SAMP>, GASP displays the line number of each source line copied(immediately after the comment character at the beginning of the line).<DT><CODE>-s</CODE><DD><A NAME="IDX23"></A><DT><CODE>--copysource</CODE><DD><A NAME="IDX24"></A>Copy the source lines to the output file. Use this optionto see the effect of each preprocessor line on the GASP output.GASP places a comment character (<SAMP>`!'</SAMP> by default) atthe beginning of each source line it copies, so that you can use thisoption and still assemble the result.<DT><CODE>-u</CODE><DD><A NAME="IDX25"></A><DT><CODE>--unreasonable</CODE><DD><A NAME="IDX26"></A>Bypass "unreasonable expansion" limit. Since you can define GASPmacros inside other macro definitions, the preprocessor normallyincludes a sanity check. If your program requires more than 1,000nested expansions, GASP normally exits with an error message. Usethis option to turn off this check, allowing unlimited nestedexpansions.<DT><CODE>-v</CODE><DD><A NAME="IDX27"></A><DT><CODE>--version</CODE><DD><A NAME="IDX28"></A>Display the GASP version number.</DL><H1><A NAME="SEC3" HREF="gasp_toc.html#TOC3">Preprocessor Commands</A></H1><P>GASP commands have a straightforward syntax that fits in well withassembly conventions. In general, a command extends for a line, and mayhave up to three fields: an optional label, the command itself, andoptional arguments to the command. You can write commands in upper orlower case, though this manual shows them in upper case. See section <A HREF="gasp.html#SEC13">Details of the GASP syntax</A>, for more information.</P><H2><A NAME="SEC4" HREF="gasp_toc.html#TOC4">Conditional assembly</A></H2><P>The conditional-assembly directives allow you to include or excludeportions of an assembly depending on how a pair of expressions, or apair of strings, compare.</P><P>The overall structure of conditionals is familiar from many othercontexts. <CODE>.AIF</CODE> marks the start of a conditional, and precedesassembly for the case when the condition is true. An optional<CODE>.AELSE</CODE> precedes assembly for the converse case, and an<CODE>.AENDI</CODE> marks the end of the condition.</P><P>You may nest conditionals up to a depth of 100; GASP rejectsnesting beyond that, because it may indicate a bug in your macrostructure.</P><P>Conditionals are primarily useful inside macro definitions, where youoften need different effects depending on argument values.See section <A HREF="gasp.html#SEC7">Defining your own directives</A>, for details about definingmacros.</P><DL COMPACT><DT><CODE>.AIF <VAR>expra</VAR> <VAR>cmp</VAR> <VAR>exprb</VAR></CODE><DD><A NAME="IDX29"></A><DT><CODE>.AIF "<VAR>stra</VAR>" <VAR>cmp</VAR> "<VAR>strb</VAR>"</CODE><DD><A NAME="IDX30"></A>The governing condition goes on the same line as the <CODE>.AIF</CODE>preprocessor command. You may compare either two strings, or twoexpressions.When you compare strings, only two conditional <VAR>cmp</VAR> comparisonoperators are available: <SAMP>`EQ'</SAMP> (true if <VAR>stra</VAR> and <VAR>strb</VAR>are identical), and <SAMP>`NE'</SAMP> (the opposite).When you compare two expressions, <EM>both expressions must beabsolute</EM> (see section <A HREF="gasp.html#SEC17">Arithmetic expressions in GASP</A>). Youcan use these <VAR>cmp</VAR> comparison operators with expressions:<DL COMPACT><DT><CODE>EQ</CODE><DD><A NAME="IDX31"></A>Are <VAR>expra</VAR> and <VAR>exprb</VAR> equal? (For strings, are <VAR>stra</VAR> and<VAR>strb</VAR> identical?)<DT><CODE>NE</CODE><DD><A NAME="IDX32"></A>Are <VAR>expra</VAR> and <VAR>exprb</VAR> different? (For strings, are <VAR>stra</VAR>and <VAR>strb</VAR> different?<DT><CODE>LT</CODE><DD><A NAME="IDX33"></A>Is <VAR>expra</VAR> less than <VAR>exprb</VAR>? (Not allowed for strings.)<DT><CODE>LE</CODE><DD><A NAME="IDX34"></A>Is <VAR>expra</VAR> less than or equal to <VAR>exprb</VAR>? (Not allowed for strings.)<DT><CODE>GT</CODE><DD><A NAME="IDX35"></A>Is <VAR>expra</VAR> greater than <VAR>exprb</VAR>? (Not allowed for strings.)<DT><CODE>GE</CODE><DD><A NAME="IDX36"></A>Is <VAR>expra</VAR> greater than or equal to <VAR>exprb</VAR>? (Not allowed forstrings.)</DL><DT><CODE>.AELSE</CODE><DD><A NAME="IDX37"></A>Marks the start of assembly code to be included if the condition fails.Optional, and only allowed within a conditional (between <CODE>.AIF</CODE> and<CODE>.AENDI</CODE>).<DT><CODE>.AENDI</CODE><DD><A NAME="IDX38"></A>Marks the end of a conditional assembly.</DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -