gasp.texi

来自「基于4个mips核的noc设计」· TEXI 代码 · 共 1,447 行 · 第 1/4 页

TEXI
1,447
字号
\input texinfo               @c             -*- Texinfo -*-@setfilename gasp.info@c@c This file documents the assembly preprocessor "GASP"@c@c Copyright 1994, 1995, 2000 Free Software Foundation, Inc.@c@c    Permission is granted to copy, distribute and/or modify this document@c    under the terms of the GNU Free Documentation License, Version 1.1@c    or any later version published by the Free Software Foundation;@c    with no Invariant Sections, with no Front-Cover Texts, and with no@c    Back-Cover Texts.  A copy of the license is included in the@c    section entitled "GNU Free Documentation License".@ifinfo@formatSTART-INFO-DIR-ENTRY* gasp: (gasp).                     The GNU Assembler PreprocessorEND-INFO-DIR-ENTRY@end format@end ifinfo@syncodeindex ky cp@syncodeindex fn cp@finalout@setchapternewpage odd@settitle GASP@titlepage@c FIXME boring title@title GASP, an assembly preprocessor@subtitle for GASP version 1@sp 1@subtitle March 1994@author Roland Pesch@page@tex{\parskip=0pt \hfill Cygnus Support\par}@end tex@vskip 0pt plus 1filllCopyright @copyright{} 1994, 1995, 2000 Free Software Foundation, Inc.      Permission is granted to copy, distribute and/or modify this document      under the terms of the GNU Free Documentation License, Version 1.1      or any later version published by the Free Software Foundation;      with no Invariant Sections, with no Front-Cover Texts, and with no      Back-Cover Texts.  A copy of the license is included in the      section entitled "GNU Free Documentation License".@end titlepage@ifinfoCopyright @copyright{} 1994, 1995, 2000 Free Software Foundation, Inc.@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries a copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignore      Permission is granted to copy, distribute and/or modify this document      under the terms of the GNU Free Documentation License, Version 1.1      or any later version published by the Free Software Foundation;      with no Invariant Sections, with no Front-Cover Texts, and with no      Back-Cover Texts.  A copy of the license is included in the      section entitled "GNU Free Documentation License".@node Top@top GASPGASP is a preprocessor for assembly programs.This file describes version 1 of GASP.Steve Chamberlain wrote GASP; Roland Pesch wrote this manual.@menu* Overview::                    What is GASP?* Invoking GASP::               Command line options.* Commands::                    Preprocessor commands.* GNU Free Documentation License::  GNU Free Documentation License* Index::                       Index.@end menu@end ifinfo@node Overview@chapter What is GASP?The primary purpose of the @sc{gnu} assembler is to assemble the output ofother programs---notably compilers.  When you have to hand-codespecialized routines in assembly, that means the @sc{gnu} assembler isan unfriendly processor: it has no directives for macros, conditionals,or many other conveniences that you might expect.In some cases you can simply use the C preprocessor, or a generalizedpreprocessor like @sc{m4}; but this can be awkward, since none of thesethings are designed with assembly in mind.@sc{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.Here is a small example to give the flavor of @sc{gasp}.  This input to@sc{gasp}@cartouche@example        .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@end example@end cartouche@noindentgenerates this assembly program:@cartouche@example        ! save r12..r14        mov     r12,@@-sp        mov     r13,@@-sp        mov     r14,@@-spbar:    mov     #57005+10,r0foo:    .byte   6,104,101,108,108,111,10@end example@end cartouche@node Invoking GASP@chapter Command Line Options@c FIXME!  Or is there a simpler way, calling from GAS option?The simplest way to use @sc{gasp} is to run it as a filter and assembleits output.  In Unix and its ilk, you can do this, for example:@c FIXME! GASP filename suffix convention?@example$ gasp prog.asm | as -o prog.o@end exampleNaturally, 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 @sc{gasp} command line.@examplegasp  [ -a | --alternate ]      [ -c @var{char} | --commentchar @var{char} ]      [ -d | --debug ]  [ -h | --help ] [ -M | --mri ]      [ -o @var{outfile} | --output @var{outfile} ]      [ -p | --print ]  [ -s | --copysource ]      [ -u | --unreasonable ]  [ -v | --version ]      @var{infile} @dots{}@end example@ftable @code@item @var{infile} @dots{}@c FIXME! Why not stdin as default infile?The input file names.  You must specify at least one input file; if youspecify more, @sc{gasp} preprocesses them all, concatenating the outputin the order you list the @var{infile} arguments.Mark the end of each input file with the preprocessor command@code{.END}.  @xref{Other Commands,, Miscellaneous commands}.@item -a@itemx --alternateUse alternative macro syntax.  @xref{Alternate,, Alternate macrosyntax}, for a discussion of how this syntax differs from the default@sc{gasp} syntax.@cindex comment character, changing@cindex semicolon, as comment@cindex exclamation mark, as comment@cindex shriek, as comment@cindex bang, as comment@cindex @code{!} default comment char@cindex @code{;} as comment char@item -c '@var{char}'@itemx --commentchar '@var{char}'Use @var{char} as the comment character.  The default comment characteris @samp{!}.  For example, to use a semicolon as the comment character,specify @w{@samp{-c ';'}} on the @sc{gasp} command line.  Sinceassembler command characters often have special significance to commandshells, it is a good idea to quote or escape @var{char} when you specifya comment character.For the sake of simplicity, all examples in this manual use the defaultcomment character @samp{!}.@item -d@itemx --debugShow debugging statistics.  In this version of @sc{gasp}, this optionproduces statistics about the string buffers that @sc{gasp} allocatesinternally.  For each defined buffersize @var{s}, @sc{gasp} shows thenumber of strings @var{n} that it allocated, with a line like this:@examplestrings size @var{s} : @var{n}@end example@noindent@sc{gasp} displays these statistics on the standard error stream, whendone preprocessing.@item -h@itemx --helpDisplay a summary of the @sc{gasp} command line options.@item -M@itemx --mriUse MRI compatibility mode.  Using this option causes @sc{gasp} toaccept the syntax and pseudo-ops used by the Microtec Research@code{ASM68K} assembler.@item -o @var{outfile}@itemx --output @var{outfile}Write the output in a file called @var{outfile}.  If you do not use the@samp{-o} option, @sc{gasp} writes its output on the standard outputstream.@item -p@itemx --printPrint line numbers.  @sc{gasp} obeys this option @emph{only} if you alsospecify @samp{-s} to copy source lines to its output.  With @samp{-s-p}, @sc{gasp} displays the line number of each source line copied(immediately after the comment character at the beginning of the line).@item -s@itemx --copysourceCopy the source lines to the output file.  Use this optionto see the effect of each preprocessor line on the @sc{gasp} output.@sc{gasp} places a comment character (@samp{!} by default) atthe beginning of each source line it copies, so that you can use thisoption and still assemble the result.@item -u@itemx --unreasonableBypass ``unreasonable expansion'' limit.  Since you can define @sc{gasp}macros inside other macro definitions, the preprocessor normallyincludes a sanity check.  If your program requires more than 1,000nested expansions, @sc{gasp} normally exits with an error message.  Usethis option to turn off this check, allowing unlimited nestedexpansions.@item -v@itemx --versionDisplay the @sc{gasp} version number.@end ftable@node Commands@chapter Preprocessor Commands@sc{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.  @xref{SyntaxDetails,, Details of the GASP syntax}, for more information.@menu* Conditionals::* Loops::* Variables::* Macros::* Data::* Listings::* Other Commands::* Syntax Details::* Alternate::@end menu@node Conditionals@section Conditional assemblyThe conditional-assembly directives allow you to include or excludeportions of an assembly depending on how a pair of expressions, or apair of strings, compare.The overall structure of conditionals is familiar from many othercontexts.  @code{.AIF} marks the start of a conditional, and precedesassembly for the case when the condition is true.   An optional@code{.AELSE} precedes assembly for the converse case, and an@code{.AENDI} marks the end of the condition.@c FIXME! Why doesn't -u turn off this check?You may nest conditionals up to a depth of 100; @sc{gasp} rejectsnesting beyond that, because it may indicate a bug in your macrostructure.@c FIXME! Why isn't there something like cpp's -D option?  Conditionals@c        would be much more useful if there were.Conditionals are primarily useful inside macro definitions, where youoften need different effects depending on argument values.@xref{Macros,, Defining your own directives}, for details about definingmacros.@ftable @code@item .AIF @var{expra} @var{cmp} @var{exprb}@itemx .AIF "@var{stra}" @var{cmp} "@var{strb}"The governing condition goes on the same line as the @code{.AIF}preprocessor command.  You may compare either two strings, or twoexpressions.When you compare strings, only two conditional @var{cmp} comparisonoperators are available: @samp{EQ} (true if @var{stra} and @var{strb}are identical), and @samp{NE} (the opposite).When you compare two expressions, @emph{both expressions must beabsolute} (@pxref{Expressions,, Arithmetic expressions in GASP}).  Youcan use these @var{cmp} comparison operators with expressions:@ftable @code@item EQAre @var{expra} and @var{exprb} equal?  (For strings, are @var{stra} and@var{strb} identical?)@item NEAre @var{expra} and @var{exprb} different?  (For strings, are @var{stra}and @var{strb} different?@item LTIs @var{expra} less than @var{exprb}?  (Not allowed for strings.)@item LEIs @var{expra} less than or equal to @var{exprb}?  (Not allowed for strings.)@item GTIs @var{expra} greater than @var{exprb}?  (Not allowed for strings.)@item GEIs @var{expra} greater than or equal to @var{exprb}?  (Not allowed forstrings.)@end ftable@item .AELSEMarks the start of assembly code to be included if the condition fails.Optional, and only allowed within a conditional (between @code{.AIF} and@code{.AENDI}).@item .AENDIMarks the end of a conditional assembly.@end ftable

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?