📄 as.texinfo
字号:
@ifclear GENERICWe also cover special features in the @value{TARGET}configuration of @code{@value{AS}}, including assembler directives.@end ifclear@ifset GENERICThis manual also describes some of the machine-dependent features ofvarious flavors of the assembler.@end ifset@cindex machine instructions (not covered)On the other hand, this manual is @emph{not} intended as an introductionto programming in assembly language---let alone programming in general!In a similar vein, we make no attempt to introduce the machinearchitecture; we do @emph{not} describe the instruction set, standardmnemonics, registers or addressing modes that are standard to aparticular architecture.@ifset GENERICYou may want to consult the manufacturer'smachine architecture manual for this information.@end ifset@ifclear GENERIC@ifset H8/300For information on the H8/300 machine instruction set, see @cite{H8/300Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,see @cite{H8/300H Series Programming Manual} (Hitachi).@end ifset@ifset H8/500For information on the H8/500 machine instruction set, see @cite{H8/500Series Programming Manual} (Hitachi M21T001).@end ifset@ifset SHFor information on the Hitachi SH machine instruction set, see@cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).@end ifset@ifset Z8000For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}@end ifset@end ifclear@c I think this is premature---doc@cygnus.com, 17jan1991@ignoreThroughout this manual, we assume that you are running @dfn{GNU},the portable operating system from the @dfn{Free SoftwareFoundation, Inc.}. This restricts our attention to certain kinds ofcomputer (in particular, the kinds of computers that @sc{gnu} can run on);once this assumption is granted examples and definitions need lessqualification.@code{@value{AS}} is part of a team of programs that turn a high-levelhuman-readable series of instructions into a low-levelcomputer-readable series of instructions. Different versions of@code{@value{AS}} are used for different kinds of computer.@end ignore@c There used to be a section "Terminology" here, which defined@c "contents", "byte", "word", and "long". Defining "word" to any@c particular size is confusing when the .word directive may generate 16@c bits on one machine and 32 bits on another; in general, for the user@c version of this manual, none of these terms seem essential to define.@c They were used very little even in the former draft of the manual;@c this draft makes an effort to avoid them (except in names of@c directives).@node GNU Assembler@section The GNU Assembler@sc{gnu} @code{as} is really a family of assemblers.@ifclear GENERICThis manual describes @code{@value{AS}}, a member of that family which isconfigured for the @value{TARGET} architectures.@end ifclearIf you use (or have used) the @sc{gnu} assembler on one architecture, youshould find a fairly similar environment when you use it on anotherarchitecture. Each version has much in common with the others,including object file formats, most assembler directives (often called@dfn{pseudo-ops}) and assembler syntax.@refill@cindex purpose of @sc{gnu} assembler@code{@value{AS}} is primarily intended to assemble the output of the@sc{gnu} C compiler @code{@value{GCC}} for use by the linker@code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}assemble correctly everything that other assemblers for the samemachine would assemble.@ifset VAXAny exceptions are documented explicitly (@pxref{Machine Dependencies}).@end ifset@ifset M680X0@c This remark should appear in generic version of manual; assumption@c here is that generic version sets M680x0.This doesn't mean @code{@value{AS}} always uses the same syntax as anotherassembler for the same architecture; for example, we know of severalincompatible versions of 680x0 assembly language syntax.@end ifsetUnlike older assemblers, @code{@value{AS}} is designed to assemble a sourceprogram in one pass of the source file. This has a subtle impact on the@kbd{.org} directive (@pxref{Org,,@code{.org}}).@node Object Formats@section Object File Formats@cindex object file formatThe @sc{gnu} assembler can be configured to produce several alternativeobject file formats. For the most part, this does not affect how youwrite assembly language programs; but directives for debugging symbolsare typically different in different file formats. @xref{SymbolAttributes,,Symbol Attributes}.@ifclear GENERIC@ifclear MULTI-OBJOn the @value{TARGET}, @code{@value{AS}} is configured to produce@value{OBJ-NAME} format object files.@end ifclear@c The following should exhaust all configs that set MULTI-OBJ, ideally@ifset A29KOn the @value{TARGET}, @code{@value{AS}} can be configured to produce either@code{a.out} or COFF format object files.@end ifset@ifset I960On the @value{TARGET}, @code{@value{AS}} can be configured to produce either@code{b.out} or COFF format object files.@end ifset@ifset HPPAOn the @value{TARGET}, @code{@value{AS}} can be configured to produce eitherSOM or ELF format object files.@end ifset@end ifclear@node Command Line@section Command Line@cindex command line conventionsAfter the program name @code{@value{AS}}, the command line may containoptions and file names. Options may appear in any order, and may bebefore, after, or between file names. The order of file names issignificant.@cindex standard input, as input file@kindex --@file{--} (two hyphens) by itself names the standard input fileexplicitly, as one of the files for @code{@value{AS}} to assemble.@cindex options, command lineExcept for @samp{--} any command line argument that begins with ahyphen (@samp{-}) is an option. Each option changes the behavior of@code{@value{AS}}. No option changes the way another option works. Anoption is a @samp{-} followed by one or more letters; the case ofthe letter is important. All options are optional.Some options expect exactly one file name to follow them. The filename may either immediately follow the option's letter (compatiblewith older assemblers) or it may be the next command argument (@sc{gnu}standard). These two command lines are equivalent:@smallexample@value{AS} -o my-object-file.o mumble.s@value{AS} -omy-object-file.o mumble.s@end smallexample@node Input Files@section Input Files@cindex input@cindex source program@cindex files, inputWe use the phrase @dfn{source program}, abbreviated @dfn{source}, todescribe the program input to one run of @code{@value{AS}}. The program maybe in one or more files; how the source is partitioned into filesdoesn't change the meaning of the source.@c I added "con" prefix to "catenation" just to prove I can overcome my@c APL training... doc@cygnus.comThe source program is a concatenation of the text in all the files, in theorder specified.Each time you run @code{@value{AS}} it assembles exactly one sourceprogram. The source program is made up of one or more files.(The standard input is also a file.)You give @code{@value{AS}} a command line that has zero or more input filenames. The input files are read (from left file name to right). Acommand line argument (in any position) that has no special meaningis taken to be an input file name.If you give @code{@value{AS}} no file names it attempts to read one input filefrom the @code{@value{AS}} standard input, which is normally your terminal. Youmay have to type @key{ctl-D} to tell @code{@value{AS}} there is no more programto assemble.Use @samp{--} if you need to explicitly name the standard input filein your command line.If the source is empty, @code{@value{AS}} produces a small, empty objectfile.@subheading Filenames and Line-numbers@cindex input file linenumbers@cindex line numbers, in input filesThere are two ways of locating a line in the input file (or files) andeither may be used in reporting error messages. One way refers to a linenumber in a physical file; the other refers to a line number in a``logical'' file. @xref{Errors, ,Error and Warning Messages}.@dfn{Physical files} are those files named in the command line givento @code{@value{AS}}.@dfn{Logical files} are simply names declared explicitly by assemblerdirectives; they bear no relation to physical files. Logical file names helperror messages reflect the original source file, when @code{@value{AS}} sourceis itself synthesized from other files. @code{@value{AS}} understands the@samp{#} directives emitted by the @code{@value{GCC}} preprocessor. See also@ref{File,,@code{.file}}.@node Object@section Output (Object) File@cindex object file@cindex output file@kindex a.out@kindex .oEvery time you run @code{@value{AS}} it produces an output file, which isyour assembly language program translated into numbers. This fileis the object file. Its default name is@ifclear BOUT@code{a.out}.@end ifclear@ifset BOUT@ifset GENERIC@code{a.out}, or @end ifset@code{b.out} when @code{@value{AS}} is configured for the Intel 80960.@end ifsetYou can give it another name by using the @code{-o} option. Conventionally,object file names end with @file{.o}. The default name is used for historicalreasons: older assemblers were capable of assembling self-contained programsdirectly into a runnable program. (For some formats, this isn't currentlypossible, but it can be done for the @code{a.out} format.)@cindex linker@kindex ldThe object file is meant for input to the linker @code{@value{LD}}. It containsassembled program code, information to help @code{@value{LD}} integratethe assembled program into a runnable file, and (optionally) symbolicinformation for the debugger.@c link above to some info file(s) like the description of a.out.@c don't forget to describe @sc{gnu} info as well as Unix lossage.@node Errors@section Error and Warning Messages@cindex error messages@cindex warning messages@cindex messages from assembler@code{@value{AS}} may write warnings and error messages to the standard errorfile (usually your terminal). This should not happen when a compilerruns @code{@value{AS}} automatically. Warnings report an assumption made sothat @code{@value{AS}} could keep assembling a flawed program; errors report agrave problem that stops the assembly.@cindex format of warning messagesWarning messages have the format@smallexamplefile_name:@b{NNN}:Warning Message Text@end smallexample@noindent@cindex line numbers, in warnings/errors(where @b{NNN} is a line number). If a logical file name has been given(@pxref{File,,@code{.file}}) it is used for the filename, otherwise the name ofthe current input file is used. If a logical line number was given@ifset GENERIC(@pxref{Line,,@code{.line}})@end ifset@ifclear GENERIC@ifclear A29K(@pxref{Line,,@code{.line}})@end ifclear@ifset A29K(@pxref{Ln,,@code{.ln}})@end ifset@end ifclearthen it is used to calculate the number printed,otherwise the actual line in the current source file is printed. Themessage text is intended to be self explanatory (in the grand Unixtradition).@cindex format of error messagesError messages have the format@smallexamplefile_name:@b{NNN}:FATAL:Error Message Text@end smallexampleThe file name and line number are derived as for warningmessages. The actual message text may be rather less explanatorybecause many of them aren't supposed to happen.@node Invoking@chapter Command-Line Options@cindex options, all versions of assemblerThis chapter describes command-line options available in @emph{all}versions of the @sc{gnu} assembler; @pxref{Machine Dependencies}, for options specific@ifclear GENERICto the @value{TARGET}.@end ifclear@ifset GENERICto particular machine architectures.@end ifsetIf you are invoking @code{@value{AS}} via the @sc{gnu} C compiler (version 2),you can use the @samp{-Wa} option to pass arguments through to the assembler.The assembler arguments must be separated from each other (and the @samp{-Wa})by commas. For example:@smallexamplegcc -c -g -O -Wa,-alh,-L file.c@end smallexample@noindentThis passes two options to the assembler: @samp{-alh} (emit a listing tostandard output with with high-level and assembly source) and @samp{-L} (retainlocal symbols in the symbol table).Usually you do not need to use this @samp{-Wa} mechanism, since many compilercommand-line options are automatically passed to the assembler by the compiler.(You can call the @sc{gnu} compiler driver with the @samp{-v} option to seeprecisely what options it passes to each compilation pass, including theassembler.)@menu* a:: -a[cdhlns] enable listings* D:: -D for compatibility* f:: -f to work faster* I:: -I for .include search path@ifclear DIFF-TBL-KLUGE* K:: -K for compatibility@end ifclear@ifset DIFF-TBL-KLUGE* K:: -K for difference tables@end ifset* L:: -L to retain local labels* M:: -M or --mri to assemble in MRI compatibility mode* MD:: --MD for dependency tracking* o:: -o to name the object file* R:: -R to join data and text sections* statistics:: --statistics to see statistics about assembly* traditional-format:: --traditional-format for compatible output* v:: -v to announce version* W:: -W, --no-warn, --warn, --fatal-warnings to control warnings* Z:: -Z to make object file even after errors@end menu@node a@section Enable Listings: @code{-a[cdhlns]}@kindex -a@kindex -ac@kindex -ad@kindex -ah@kindex -al@kindex -an@kindex -as@cindex listings, enabling@cindex assembly listings, enablingThese options enable listing output from the assembler. By itself,@samp{-a} requests high-level, assembly, and symbols listing.You can use other letters to select specific options for the list:@samp{-ah} requests a high-level language listing,@samp{-al} requests an output-program assembly listing, and@samp{-as} requests a symbol table listing.High-level listings require that a compiler debugging option like@samp{-g} be used, and that assembly listings (@samp{-al}) be requestedalso.Use the @samp{-ac} option to omit false conditionals from a listing. Any lineswhich are not assembled because of a false @code{.if} (or @code{.ifdef}, or anyother conditional), or a true @code{.if} followed by an @code{.else}, will beomitted from the listing.Use the @samp{-ad} option to omit debugging directives from thelisting.Once you have specified one of these options, you can further controllisting output and its appearance using the directives @code{.list},@code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and@code{.sbttl}.The @samp{-an} option turns off all forms processing.If you do not request listing output with one of the @samp{-a} options, the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -