?? as.html
字號:
<HTML><HEAD><!-- This HTML file has been created by texi2html 1.52 from as.texinfo on 22 March 1999 --><TITLE>Using as</TITLE></HEAD><BODY><H1>Using as</H1><H2>The GNU Assembler</H2><H2>January 1994</H2><ADDRESS>Dean Elsner, Jay Fenlason & friends</ADDRESS><P><P><HR><P><P></P><P>The Free Software Foundation Inc. thanks The Nice ComputerCompany of Australia for loaning Dean Elsner to write thefirst (Vax) version of <CODE>as</CODE> for Project GNU.The proprietors, management and staff of TNCCA thank FSF fordistracting the boss while they got some workdone.<P></P><P>Copyright (C) 1991, 92, 93, 94, 95, 1996 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 this manualunder the conditions for verbatim copying, provided that the entire resultingderived work is distributed under the terms of a permission notice identical tothis 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="as_toc.html#TOC1">Overview</A></H1><P>This manual is a user guide to the GNU assembler <CODE>as</CODE>.</P><P><A NAME="IDX1"></A><A NAME="IDX2"></A><A NAME="IDX3"></A>Here is a brief summary of how to invoke <CODE>as</CODE>. For details,see section <A HREF="as.html#SEC9">Command-Line Options</A>.</P><PRE>as [ -a[dhlns][=file] ] [ -D ] [ --defsym <VAR>sym</VAR>=<VAR>val</VAR> ] [ -f ] [ --help ] [ -I <VAR>dir</VAR> ] [ -J ] [ -K ] [ -L ] [ -o <VAR>objfile</VAR> ] [ -R ] [ --statistics ] [ -v ] [ -version ] [ --version ] [ -W ] [ -w ] [ -x ] [ -Z ] [ -Av6 | -Av7 | -Av8 | -Asparclite | -Av9 | -Av9a ] [ -xarch=v8plus | -xarch=v8plusa ] [ -bump ] [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ] [ -b ] [ -no-relax ] [ -nocpp ] [ -EL ] [ -EB ] [ -G <VAR>num</VAR> ] [ -mcpu=<VAR>CPU</VAR> ] [ -mips1 ] [ -mips2 ] [ -mips3 ] [ -m4650 ] [ -no-m4650 ] [ --trap ] [ --break ] [ --emulation=<VAR>name</VAR> ] [ -mpwrx ] [ -mpwr2 ] [ -mpwr ] [ -m601 ] [ -mppc | -mppc32 | -m403 | -m603 | -m604 ] [ -mppc64 | -m620 ] [ -mcom ] [ -many ] [ -mregnames ] [ -mno-regnames ] [ -mrelocatable ] [ -mrelocatable-lib ] [ -memb ] [ -mlittle | -mlittle-endian ] [ -mbig | -mbig-endian ] [ -- | <VAR>files</VAR> ... ]</PRE><DL COMPACT><DT><CODE>-a[dhlns]</CODE><DD>Turn on listings, in any of a variety of ways:<DL COMPACT><DT><CODE>-ad</CODE><DD>omit debugging directives<DT><CODE>-ah</CODE><DD>include high-level source<DT><CODE>-al</CODE><DD>include assembly<DT><CODE>-an</CODE><DD>omit forms processing<DT><CODE>-as</CODE><DD>include symbols<DT><CODE>=file</CODE><DD>set the name of the listing file</DL>You may combine these options; for example, use <SAMP>`-aln'</SAMP> for assemblylisting without forms processing. The <SAMP>`=file'</SAMP> option, if used, must bethe last one. By itself, <SAMP>`-a'</SAMP> defaults to <SAMP>`-ahls'</SAMP>---that is, alllistings turned on.<DT><CODE>-D</CODE><DD>Ignored. This option is accepted for script compatibility with calls toother assemblers.<DT><CODE>--defsym <VAR>sym</VAR>=<VAR>value</VAR></CODE><DD>Define the symbol <VAR>sym</VAR> to be <VAR>value</VAR> before assembling the input file.<VAR>value</VAR> must be an integer constant. As in C, a leading <SAMP>`0x'</SAMP>indicates a hexadecimal value, and a leading <SAMP>`0'</SAMP> indicates an octal value.<DT><CODE>-f</CODE><DD>"fast"---skip whitespace and comment preprocessing (assume source iscompiler output).<DT><CODE>--help</CODE><DD>Print a summary of the command line options and exit.<DT><CODE>-I <VAR>dir</VAR></CODE><DD>Add directory <VAR>dir</VAR> to the search list for <CODE>.include</CODE> directives.<DT><CODE>-J</CODE><DD>Don't warn about signed overflow.<DT><CODE>-K</CODE><DD>Issue warnings when difference tables altered for long displacements.<DT><CODE>-L</CODE><DD>Keep (in the symbol table) local symbols, starting with <SAMP>`L'</SAMP>.<DT><CODE>-o <VAR>objfile</VAR></CODE><DD>Name the object-file output from <CODE>as</CODE> <VAR>objfile</VAR>.<DT><CODE>-R</CODE><DD>Fold the data section into the text section.<DT><CODE>--statistics</CODE><DD>Print the maximum space (in bytes) and total time (in seconds) used byassembly.<DT><CODE>-v</CODE><DD><DT><CODE>-version</CODE><DD>Print the <CODE>as</CODE> version.<DT><CODE>--version</CODE><DD>Print the <CODE>as</CODE> version and exit.<DT><CODE>-W</CODE><DD>Suppress warning messages.<DT><CODE>-w</CODE><DD>Ignored.<DT><CODE>-x</CODE><DD>Ignored.<DT><CODE>-Z</CODE><DD>Generate an object file even after errors.<DT><CODE>-- | <VAR>files</VAR> ...</CODE><DD>Standard input, or source files to assemble.</DL><P>The following options are available when as is configured for theIntel 80960 processor.</P><DL COMPACT><DT><CODE>-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC</CODE><DD>Specify which variant of the 960 architecture is the target.<DT><CODE>-b</CODE><DD>Add code to collect statistics about branches taken.<DT><CODE>-no-relax</CODE><DD>Do not alter compare-and-branch instructions for long displacements;error if necessary.</DL><P>The following options are available when <CODE>as</CODE> is configuredfor the SPARC architecture:</P><DL COMPACT><DT><CODE>-Av6 | -Av7 | -Av8 | -Asparclite | -Av9 | -Av9a</CODE><DD>Explicitly select a variant of the SPARC architecture.<DT><CODE>-xarch=v8plus | -xarch=v8plusa</CODE><DD>For compatibility with the Solaris v9 assembler. These options areequivalent to -Av9 and -Av9a, respectively.<DT><CODE>-bump</CODE><DD>Warn when the assembler switches to another architecture.</DL><P>The following options are available when as is configured fora MIPS processor.</P><DL COMPACT><DT><CODE>-G <VAR>num</VAR></CODE><DD>This option sets the largest size of an object that can be referencedimplicitly with the <CODE>gp</CODE> register. It is only accepted for targets thatuse ECOFF format, such as a DECstation running Ultrix. The default value is 8.<A NAME="IDX4"></A><A NAME="IDX5"></A><A NAME="IDX6"></A><DT><CODE>-EB</CODE><DD>Generate "big endian" format output.<A NAME="IDX7"></A><DT><CODE>-EL</CODE><DD>Generate "little endian" format output.<A NAME="IDX8"></A><DT><CODE>-mips1</CODE><DD><DT><CODE>-mips2</CODE><DD><DT><CODE>-mips3</CODE><DD>Generate code for a particular MIPS Instruction Set Architecture level.<SAMP>`-mips1'</SAMP> corresponds to the R2000 and R3000 processors,<SAMP>`-mips2'</SAMP> to the R6000 processor, and <SAMP>`-mips3'</SAMP> to the R4000processor.<DT><CODE>-m4650</CODE><DD><DT><CODE>-no-m4650</CODE><DD>Generate code for the MIPS R4650 chip. This tells the assembler to acceptthe <SAMP>`mad'</SAMP> and <SAMP>`madu'</SAMP> instruction, and to not schedule <SAMP>`nop'</SAMP>instructions around accesses to the <SAMP>`HI'</SAMP> and <SAMP>`LO'</SAMP> registers.<SAMP>`-no-m4650'</SAMP> turns off this option.<DT><CODE>-mcpu=<VAR>CPU</VAR></CODE><DD>Generate code for a particular MIPS cpu. This has little effect on theassembler, but it is passed by <CODE>gcc</CODE>.<A NAME="IDX9"></A><DT><CODE>--emulation=<VAR>name</VAR></CODE><DD>This option causes <CODE>as</CODE> to emulated <CODE>as</CODE> configuredfor some other target, in all respects, including output format (choosingbetween ELF and ECOFF only), handling of pseudo-opcodes which may generatedebugging information or store symbol table information, and defaultendianness. The available configuration names are: <SAMP>`mipsecoff'</SAMP>,<SAMP>`mipself'</SAMP>, <SAMP>`mipslecoff'</SAMP>, <SAMP>`mipsbecoff'</SAMP>, <SAMP>`mipslelf'</SAMP>,<SAMP>`mipsbelf'</SAMP>. The first two do not alter the default endianness from thatof the primary target for which the assembler was configured; the others changethe default to little- or big-endian as indicated by the <SAMP>`b'</SAMP> or <SAMP>`l'</SAMP>in the name. Using <SAMP>`-EB'</SAMP> or <SAMP>`-EL'</SAMP> will override the endiannessselection in any case.This option is currently supported only when the primary target<CODE>as</CODE> is configured for is a MIPS ELF or ECOFF target.Furthermore, the primary target or others specified with<SAMP>`--enable-targets=...'</SAMP> at configuration time must include support forthe other format, if both are to be available. For example, the Irix 5configuration includes support for both.Eventually, this option will support more configurations, with morefine-grained control over the assembler's behavior, and will be supported formore processors.<DT><CODE>-nocpp</CODE><DD><CODE>as</CODE> ignores this option. It is accepted for compatibility withthe native tools.</DL><DL COMPACT><DT><CODE>--trap</CODE><DD><DT><CODE>--no-trap</CODE><DD><DT><CODE>--break</CODE><DD><DT><CODE>--no-break</CODE><DD>Control how to deal with multiplication overflow and division by zero.<SAMP>`--trap'</SAMP> or <SAMP>`--no-break'</SAMP> (which are synonyms) take a trap exception(and only work for Instruction Set Architecture level 2 and higher);<SAMP>`--break'</SAMP> or <SAMP>`--no-trap'</SAMP> (also synonyms, and the default) take abreak exception.</DL><H2><A NAME="SEC2" HREF="as_toc.html#TOC2">Structure of this Manual</A></H2><P><A NAME="IDX10"></A>This manual is intended to describe what you need to know to useGNU <CODE>as</CODE>. We cover the syntax expected in source files, includingnotation for symbols, constants, and expressions; the directives that<CODE>as</CODE> understands; and of course how to invoke <CODE>as</CODE>.</P><P>This manual also describes some of the machine-dependent features ofvarious flavors of the assembler.</P><P><A NAME="IDX11"></A>On the other hand, this manual is <EM>not</EM> 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 <EM>not</EM> describe the instruction set, standardmnemonics, registers or addressing modes that are standard to aparticular architecture.You may want to consult the manufacturer'smachine architecture manual for this information.</P><H2><A NAME="SEC3" HREF="as_toc.html#TOC3">as, the GNU Assembler</A></H2><P>GNU <CODE>as</CODE> is really a family of assemblers.If you use (or have used) the 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<EM>pseudo-ops</EM>) and assembler syntax.</P><P><A NAME="IDX12"></A><CODE>as</CODE> is primarily intended to assemble the output of theGNU C compiler <CODE>gcc</CODE> for use by the linker<CODE>ld</CODE>. Nevertheless, we've tried to make <CODE>as</CODE>assemble correctly everything that other assemblers for the samemachine would assemble.</P><P>Unlike older assemblers, <CODE>as</CODE> is designed to assemble a sourceprogram in one pass of the source file. This has a subtle impact on the<KBD>.org</KBD> directive (see section <A HREF="as.html#SEC106"><CODE>.org <VAR>new-lc</CODE> , <VAR>fill</VAR></VAR></A>).</P><H2><A NAME="SEC4" HREF="as_toc.html#TOC4">Object File Formats</A></H2><P><A NAME="IDX13"></A>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -