1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 @c 2001, 2002, 2003, 2004, 2005, 2006
4 @c Free Software Foundation, Inc.
5 @c UPDATE!! On future updates--
6 @c (1) check for new machine-dep cmdline options in
7 @c md_parse_option definitions in config/tc-*.c
8 @c (2) for platform-specific directives, examine md_pseudo_op
10 @c (3) for object-format specific directives, examine obj_pseudo_op
12 @c (4) portable directives in potable[] in read.c
16 @macro gcctabopt{body}
19 @c defaults, config file may override:
24 @include asconfig.texi
29 @c common OR combinations of conditions
52 @set abnormal-separator
56 @settitle Using @value{AS}
59 @settitle Using @value{AS} (@value{TARGET})
61 @setchapternewpage odd
66 @c WARE! Some of the machine-dependent sections contain tables of machine
67 @c instructions. Except in multi-column format, these tables look silly.
68 @c Unfortunately, Texinfo doesn't have a general-purpose multi-col format, so
69 @c the multi-col format is faked within @example sections.
71 @c Again unfortunately, the natural size that fits on a page, for these tables,
72 @c is different depending on whether or not smallbook is turned on.
73 @c This matters, because of order: text flow switches columns at each page
76 @c The format faked in this source works reasonably well for smallbook,
77 @c not well for the default large-page format. This manual expects that if you
78 @c turn on @smallbook, you will also uncomment the "@set SMALL" to enable the
79 @c tables in question. You can turn on one without the other at your
80 @c discretion, of course.
83 @c the insn tables look just as silly in info files regardless of smallbook,
84 @c might as well show 'em anyways.
90 * As: (as). The GNU assembler.
91 * Gas: (as). The GNU assembler.
100 This file documents the GNU Assembler "@value{AS}".
102 @c man begin COPYRIGHT
103 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
105 Permission is granted to copy, distribute and/or modify this document
106 under the terms of the GNU Free Documentation License, Version 1.1
107 or any later version published by the Free Software Foundation;
108 with no Invariant Sections, with no Front-Cover Texts, and with no
109 Back-Cover Texts. A copy of the license is included in the
110 section entitled ``GNU Free Documentation License''.
115 Permission is granted to process this file through Tex and print the
116 results, provided the printed document carries copying permission
117 notice identical to this one except for the removal of this paragraph
118 (this paragraph not being relevant to the printed manual).
124 @title Using @value{AS}
125 @subtitle The @sc{gnu} Assembler
127 @subtitle for the @value{TARGET} family
130 @subtitle Version @value{VERSION}
133 The Free Software Foundation Inc.@: thanks The Nice Computer
134 Company of Australia for loaning Dean Elsner to write the
135 first (Vax) version of @command{as} for Project @sc{gnu}.
136 The proprietors, management and staff of TNCCA thank FSF for
137 distracting the boss while they got some work
140 @author Dean Elsner, Jay Fenlason & friends
144 \hfill {\it Using {\tt @value{AS}}}\par
145 \hfill Edited by Cygnus Support\par
147 %"boxit" macro for figures:
148 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
149 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
150 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
151 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
152 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
155 @vskip 0pt plus 1filll
156 Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
158 Permission is granted to copy, distribute and/or modify this document
159 under the terms of the GNU Free Documentation License, Version 1.1
160 or any later version published by the Free Software Foundation;
161 with no Invariant Sections, with no Front-Cover Texts, and with no
162 Back-Cover Texts. A copy of the license is included in the
163 section entitled ``GNU Free Documentation License''.
169 @top Using @value{AS}
171 This file is a user guide to the @sc{gnu} assembler @command{@value{AS}} version
174 This version of the file describes @command{@value{AS}} configured to generate
175 code for @value{TARGET} architectures.
178 This document is distributed under the terms of the GNU Free
179 Documentation License. A copy of the license is included in the
180 section entitled ``GNU Free Documentation License''.
183 * Overview:: Overview
184 * Invoking:: Command-Line Options
186 * Sections:: Sections and Relocation
188 * Expressions:: Expressions
189 * Pseudo Ops:: Assembler Directives
190 * Machine Dependencies:: Machine Dependent Features
191 * Reporting Bugs:: Reporting Bugs
192 * Acknowledgements:: Who Did What
193 * GNU Free Documentation License:: GNU Free Documentation License
194 * AS Index:: AS Index
201 This manual is a user guide to the @sc{gnu} assembler @command{@value{AS}}.
203 This version of the manual describes @command{@value{AS}} configured to generate
204 code for @value{TARGET} architectures.
208 @cindex invocation summary
209 @cindex option summary
210 @cindex summary of options
211 Here is a brief summary of how to invoke @command{@value{AS}}. For details,
212 see @ref{Invoking,,Command-Line Options}.
214 @c man title AS the portable GNU assembler.
218 gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
222 @c We don't use deffn and friends for the following because they seem
223 @c to be limited to one line for the header.
225 @c man begin SYNOPSIS
226 @value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
227 [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
228 [@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
229 [@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}]
230 [@b{--listing-lhs-width2}=@var{NUM}] [@b{--listing-rhs-width}=@var{NUM}]
231 [@b{--listing-cont-lines}=@var{NUM}] [@b{--keep-locals}] [@b{-o}
232 @var{objfile}] [@b{-R}] [@b{--reduce-memory-overheads}] [@b{--statistics}]
233 [@b{-v}] [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}]
234 [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] [@b{-Z}] [@b{@@@var{FILE}}]
235 [@b{--target-help}] [@var{target-options}]
236 [@b{--}|@var{files} @dots{}]
238 @c Target dependent options are listed below. Keep the list sorted.
239 @c Add an empty line for separation.
242 @emph{Target Alpha options:}
244 [@b{-mdebug} | @b{-no-mdebug}]
245 [@b{-relax}] [@b{-g}] [@b{-G@var{size}}]
246 [@b{-F}] [@b{-32addr}]
250 @emph{Target ARC options:}
256 @emph{Target ARM options:}
257 @c Don't document the deprecated options
258 [@b{-mcpu}=@var{processor}[+@var{extension}@dots{}]]
259 [@b{-march}=@var{architecture}[+@var{extension}@dots{}]]
260 [@b{-mfpu}=@var{floating-point-format}]
261 [@b{-mfloat-abi}=@var{abi}]
262 [@b{-meabi}=@var{ver}]
265 [@b{-mapcs-32}|@b{-mapcs-26}|@b{-mapcs-float}|
266 @b{-mapcs-reentrant}]
267 [@b{-mthumb-interwork}] [@b{-k}]
271 @emph{Target CRIS options:}
272 [@b{--underscore} | @b{--no-underscore}]
274 [@b{--emulation=criself} | @b{--emulation=crisaout}]
275 [@b{--march=v0_v10} | @b{--march=v10} | @b{--march=v32} | @b{--march=common_v10_v32}]
276 @c Deprecated -- deliberately not documented.
281 @emph{Target D10V options:}
286 @emph{Target D30V options:}
287 [@b{-O}|@b{-n}|@b{-N}]
290 @c Renesas family chips have no machine-dependent assembler options
293 @c HPPA has no machine-dependent assembler options (yet).
297 @emph{Target i386 options:}
298 [@b{--32}|@b{--64}] [@b{-n}]
299 [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}]
303 @emph{Target i960 options:}
304 @c see md_parse_option in tc-i960.c
305 [@b{-ACA}|@b{-ACA_A}|@b{-ACB}|@b{-ACC}|@b{-AKA}|@b{-AKB}|
307 [@b{-b}] [@b{-no-relax}]
311 @emph{Target IA-64 options:}
312 [@b{-mconstant-gp}|@b{-mauto-pic}]
313 [@b{-milp32}|@b{-milp64}|@b{-mlp64}|@b{-mp64}]
315 [@b{-mtune=itanium1}|@b{-mtune=itanium2}]
316 [@b{-munwind-check=warning}|@b{-munwind-check=error}]
317 [@b{-mhint.b=ok}|@b{-mhint.b=warning}|@b{-mhint.b=error}]
318 [@b{-x}|@b{-xexplicit}] [@b{-xauto}] [@b{-xdebug}]
322 @emph{Target IP2K options:}
323 [@b{-mip2022}|@b{-mip2022ext}]
327 @emph{Target M32C options:}
328 [@b{-m32c}|@b{-m16c}]
332 @emph{Target M32R options:}
333 [@b{--m32rx}|@b{--[no-]warn-explicit-parallel-conflicts}|
338 @emph{Target M680X0 options:}
339 [@b{-l}] [@b{-m68000}|@b{-m68010}|@b{-m68020}|@dots{}]
343 @emph{Target M68HC11 options:}
344 [@b{-m68hc11}|@b{-m68hc12}|@b{-m68hcs12}]
345 [@b{-mshort}|@b{-mlong}]
346 [@b{-mshort-double}|@b{-mlong-double}]
347 [@b{--force-long-branches}] [@b{--short-branches}]
348 [@b{--strict-direct-mode}] [@b{--print-insn-syntax}]
349 [@b{--print-opcodes}] [@b{--generate-example}]
353 @emph{Target MCORE options:}
354 [@b{-jsri2bsr}] [@b{-sifilter}] [@b{-relax}]
355 [@b{-mcpu=[210|340]}]
359 @emph{Target MIPS options:}
360 [@b{-nocpp}] [@b{-EL}] [@b{-EB}] [@b{-O}[@var{optimization level}]]
361 [@b{-g}[@var{debug level}]] [@b{-G} @var{num}] [@b{-KPIC}] [@b{-call_shared}]
362 [@b{-non_shared}] [@b{-xgot}]
363 [@b{-mabi}=@var{ABI}] [@b{-32}] [@b{-n32}] [@b{-64}] [@b{-mfp32}] [@b{-mgp32}]
364 [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}] [@b{-mips1}] [@b{-mips2}]
365 [@b{-mips3}] [@b{-mips4}] [@b{-mips5}] [@b{-mips32}] [@b{-mips32r2}]
366 [@b{-mips64}] [@b{-mips64r2}]
367 [@b{-construct-floats}] [@b{-no-construct-floats}]
368 [@b{-trap}] [@b{-no-break}] [@b{-break}] [@b{-no-trap}]
369 [@b{-mfix7000}] [@b{-mno-fix7000}]
370 [@b{-mips16}] [@b{-no-mips16}]
371 [@b{-msmartmips}] [@b{-mno-smartmips}]
372 [@b{-mips3d}] [@b{-no-mips3d}]
373 [@b{-mdmx}] [@b{-no-mdmx}]
374 [@b{-mdsp}] [@b{-mno-dsp}]
375 [@b{-mdspr2}] [@b{-mno-dspr2}]
376 [@b{-mmt}] [@b{-mno-mt}]
377 [@b{-mdebug}] [@b{-no-mdebug}]
378 [@b{-mpdr}] [@b{-mno-pdr}]
382 @emph{Target MMIX options:}
383 [@b{--fixed-special-register-names}] [@b{--globalize-symbols}]
384 [@b{--gnu-syntax}] [@b{--relax}] [@b{--no-predefined-symbols}]
385 [@b{--no-expand}] [@b{--no-merge-gregs}] [@b{-x}]
386 [@b{--linker-allocated-gregs}]
390 @emph{Target PDP11 options:}
391 [@b{-mpic}|@b{-mno-pic}] [@b{-mall}] [@b{-mno-extensions}]
392 [@b{-m}@var{extension}|@b{-mno-}@var{extension}]
393 [@b{-m}@var{cpu}] [@b{-m}@var{machine}]
397 @emph{Target picoJava options:}
402 @emph{Target PowerPC options:}
403 [@b{-mpwrx}|@b{-mpwr2}|@b{-mpwr}|@b{-m601}|@b{-mppc}|@b{-mppc32}|@b{-m603}|@b{-m604}|
404 @b{-m403}|@b{-m405}|@b{-mppc64}|@b{-m620}|@b{-mppc64bridge}|@b{-mbooke}|
405 @b{-mbooke32}|@b{-mbooke64}]
406 [@b{-mcom}|@b{-many}|@b{-maltivec}] [@b{-memb}]
407 [@b{-mregnames}|@b{-mno-regnames}]
408 [@b{-mrelocatable}|@b{-mrelocatable-lib}]
409 [@b{-mlittle}|@b{-mlittle-endian}|@b{-mbig}|@b{-mbig-endian}]
410 [@b{-msolaris}|@b{-mno-solaris}]
414 @emph{Target SPARC options:}
415 @c The order here is important. See c-sparc.texi.
416 [@b{-Av6}|@b{-Av7}|@b{-Av8}|@b{-Asparclet}|@b{-Asparclite}
417 @b{-Av8plus}|@b{-Av8plusa}|@b{-Av9}|@b{-Av9a}]
418 [@b{-xarch=v8plus}|@b{-xarch=v8plusa}] [@b{-bump}]
423 @emph{Target TIC54X options:}
424 [@b{-mcpu=54[123589]}|@b{-mcpu=54[56]lp}] [@b{-mfar-mode}|@b{-mf}]
425 [@b{-merrors-to-file} @var{<filename>}|@b{-me} @var{<filename>}]
430 @emph{Target Z80 options:}
431 [@b{-z80}] [@b{-r800}]
432 [@b{ -ignore-undocumented-instructions}] [@b{-Wnud}]
433 [@b{ -ignore-unportable-instructions}] [@b{-Wnup}]
434 [@b{ -warn-undocumented-instructions}] [@b{-Wud}]
435 [@b{ -warn-unportable-instructions}] [@b{-Wup}]
436 [@b{ -forbid-undocumented-instructions}] [@b{-Fud}]
437 [@b{ -forbid-unportable-instructions}] [@b{-Fup}]
441 @c Z8000 has no machine-dependent assembler options
445 @emph{Target Xtensa options:}
446 [@b{--[no-]text-section-literals}] [@b{--[no-]absolute-literals}]
447 [@b{--[no-]target-align}] [@b{--[no-]longcalls}]
448 [@b{--[no-]transform}]
449 [@b{--rename-section} @var{oldname}=@var{newname}]
457 @include at-file.texi
460 Turn on listings, in any of a variety of ways:
464 omit false conditionals
467 omit debugging directives
470 include high-level source
476 include macro expansions
479 omit forms processing
485 set the name of the listing file
488 You may combine these options; for example, use @samp{-aln} for assembly
489 listing without forms processing. The @samp{=file} option, if used, must be
490 the last one. By itself, @samp{-a} defaults to @samp{-ahls}.
493 Begin in alternate macro mode.
495 @xref{Altmacro,,@code{.altmacro}}.
499 Ignored. This option is accepted for script compatibility with calls to
502 @item --defsym @var{sym}=@var{value}
503 Define the symbol @var{sym} to be @var{value} before assembling the input file.
504 @var{value} must be an integer constant. As in C, a leading @samp{0x}
505 indicates a hexadecimal value, and a leading @samp{0} indicates an octal
506 value. The value of the symbol can be overridden inside a source file via the
507 use of a @code{.set} pseudo-op.
510 ``fast''---skip whitespace and comment preprocessing (assume source is
515 Generate debugging information for each assembler source line using whichever
516 debug format is preferred by the target. This currently means either STABS,
520 Generate stabs debugging information for each assembler line. This
521 may help debugging assembler code, if the debugger can handle it.
524 Generate stabs debugging information for each assembler line, with GNU
525 extensions that probably only gdb can handle, and that could make other
526 debuggers crash or refuse to read your program. This
527 may help debugging assembler code. Currently the only GNU extension is
528 the location of the current working directory at assembling time.
531 Generate DWARF2 debugging information for each assembler line. This
532 may help debugging assembler code, if the debugger can handle it. Note---this
533 option is only supported by some targets, not all of them.
536 Print a summary of the command line options and exit.
539 Print a summary of all target specific options and exit.
542 Add directory @var{dir} to the search list for @code{.include} directives.
545 Don't warn about signed overflow.
548 @ifclear DIFF-TBL-KLUGE
549 This option is accepted but has no effect on the @value{TARGET} family.
551 @ifset DIFF-TBL-KLUGE
552 Issue warnings when difference tables altered for long displacements.
557 Keep (in the symbol table) local symbols. These symbols start with
558 system-specific local label prefixes, typically @samp{.L} for ELF systems
559 or @samp{L} for traditional a.out systems.
564 @item --listing-lhs-width=@var{number}
565 Set the maximum width, in words, of the output data column for an assembler
566 listing to @var{number}.
568 @item --listing-lhs-width2=@var{number}
569 Set the maximum width, in words, of the output data column for continuation
570 lines in an assembler listing to @var{number}.
572 @item --listing-rhs-width=@var{number}
573 Set the maximum width of an input source line, as displayed in a listing, to
576 @item --listing-cont-lines=@var{number}
577 Set the maximum number of lines printed in a listing for a single line of input
580 @item -o @var{objfile}
581 Name the object-file output from @command{@value{AS}} @var{objfile}.
584 Fold the data section into the text section.
586 @kindex --hash-size=@var{number}
587 Set the default size of GAS's hash tables to a prime number close to
588 @var{number}. Increasing this value can reduce the length of time it takes the
589 assembler to perform its tasks, at the expense of increasing the assembler's
590 memory requirements. Similarly reducing this value can reduce the memory
591 requirements at the expense of speed.
593 @item --reduce-memory-overheads
594 This option reduces GAS's memory requirements, at the expense of making the
595 assembly processes slower. Currently this switch is a synonym for
596 @samp{--hash-size=4051}, but in the future it may have other effects as well.
599 Print the maximum space (in bytes) and total time (in seconds) used by
602 @item --strip-local-absolute
603 Remove local absolute symbols from the outgoing symbol table.
607 Print the @command{as} version.
610 Print the @command{as} version and exit.
614 Suppress warning messages.
616 @item --fatal-warnings
617 Treat warnings as errors.
620 Don't suppress warning messages or treat them as errors.
629 Generate an object file even after errors.
631 @item -- | @var{files} @dots{}
632 Standard input, or source files to assemble.
637 The following options are available when @value{AS} is configured for
642 This option selects the core processor variant.
644 Select either big-endian (-EB) or little-endian (-EL) output.
649 The following options are available when @value{AS} is configured for the ARM
653 @item -mcpu=@var{processor}[+@var{extension}@dots{}]
654 Specify which ARM processor variant is the target.
655 @item -march=@var{architecture}[+@var{extension}@dots{}]
656 Specify which ARM architecture variant is used by the target.
657 @item -mfpu=@var{floating-point-format}
658 Select which Floating Point architecture is the target.
659 @item -mfloat-abi=@var{abi}
660 Select which floating point ABI is in use.
662 Enable Thumb only instruction decoding.
663 @item -mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant
664 Select which procedure calling convention is in use.
666 Select either big-endian (-EB) or little-endian (-EL) output.
667 @item -mthumb-interwork
668 Specify that the code has been generated with interworking between Thumb and
671 Specify that PIC code has been generated.
676 See the info pages for documentation of the CRIS-specific options.
680 The following options are available when @value{AS} is configured for
683 @cindex D10V optimization
684 @cindex optimization, D10V
686 Optimize output by parallelizing instructions.
691 The following options are available when @value{AS} is configured for a D30V
694 @cindex D30V optimization
695 @cindex optimization, D30V
697 Optimize output by parallelizing instructions.
701 Warn when nops are generated.
703 @cindex D30V nops after 32-bit multiply
705 Warn when a nop after a 32-bit multiply instruction is generated.
710 The following options are available when @value{AS} is configured for the
711 Intel 80960 processor.
714 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
715 Specify which variant of the 960 architecture is the target.
718 Add code to collect statistics about branches taken.
721 Do not alter compare-and-branch instructions for long displacements;
728 The following options are available when @value{AS} is configured for the
734 Specifies that the extended IP2022 instructions are allowed.
737 Restores the default behaviour, which restricts the permitted instructions to
738 just the basic IP2022 ones.
744 The following options are available when @value{AS} is configured for the
745 Renesas M32C and M16C processors.
750 Assemble M32C instructions.
753 Assemble M16C instructions (the default).
759 The following options are available when @value{AS} is configured for the
760 Renesas M32R (formerly Mitsubishi M32R) series.
765 Specify which processor in the M32R family is the target. The default
766 is normally the M32R, but this option changes it to the M32RX.
768 @item --warn-explicit-parallel-conflicts or --Wp
769 Produce warning messages when questionable parallel constructs are
772 @item --no-warn-explicit-parallel-conflicts or --Wnp
773 Do not produce warning messages when questionable parallel constructs are
780 The following options are available when @value{AS} is configured for the
781 Motorola 68000 series.
786 Shorten references to undefined symbols, to one word instead of two.
788 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030
789 @itemx | -m68040 | -m68060 | -m68302 | -m68331 | -m68332
790 @itemx | -m68333 | -m68340 | -mcpu32 | -m5200
791 Specify what processor in the 68000 family is the target. The default
792 is normally the 68020, but this can be changed at configuration time.
794 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
795 The target machine does (or does not) have a floating-point coprocessor.
796 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
797 the basic 68000 is not compatible with the 68881, a combination of the
798 two can be specified, since it's possible to do emulation of the
799 coprocessor instructions with the main processor.
801 @item -m68851 | -mno-68851
802 The target machine does (or does not) have a memory-management
803 unit coprocessor. The default is to assume an MMU for 68020 and up.
810 For details about the PDP-11 machine dependent features options,
811 see @ref{PDP-11-Options}.
814 @item -mpic | -mno-pic
815 Generate position-independent (or position-dependent) code. The
816 default is @option{-mpic}.
819 @itemx -mall-extensions
820 Enable all instruction set extensions. This is the default.
822 @item -mno-extensions
823 Disable all instruction set extensions.
825 @item -m@var{extension} | -mno-@var{extension}
826 Enable (or disable) a particular instruction set extension.
829 Enable the instruction set extensions supported by a particular CPU, and
830 disable all other extensions.
832 @item -m@var{machine}
833 Enable the instruction set extensions supported by a particular machine
834 model, and disable all other extensions.
840 The following options are available when @value{AS} is configured for
841 a picoJava processor.
845 @cindex PJ endianness
846 @cindex endianness, PJ
847 @cindex big endian output, PJ
849 Generate ``big endian'' format output.
851 @cindex little endian output, PJ
853 Generate ``little endian'' format output.
859 The following options are available when @value{AS} is configured for the
860 Motorola 68HC11 or 68HC12 series.
864 @item -m68hc11 | -m68hc12 | -m68hcs12
865 Specify what processor is the target. The default is
866 defined by the configuration option when building the assembler.
869 Specify to use the 16-bit integer ABI.
872 Specify to use the 32-bit integer ABI.
875 Specify to use the 32-bit double ABI.
878 Specify to use the 64-bit double ABI.
880 @item --force-long-branches
881 Relative branches are turned into absolute ones. This concerns
882 conditional branches, unconditional branches and branches to a
885 @item -S | --short-branches
886 Do not turn relative branches into absolute ones
887 when the offset is out of range.
889 @item --strict-direct-mode
890 Do not turn the direct addressing mode into extended addressing mode
891 when the instruction does not support direct addressing mode.
893 @item --print-insn-syntax
894 Print the syntax of instruction in case of error.
896 @item --print-opcodes
897 print the list of instructions with syntax and then exit.
899 @item --generate-example
900 print an example of instruction for each possible instruction and then exit.
901 This option is only useful for testing @command{@value{AS}}.
907 The following options are available when @command{@value{AS}} is configured
908 for the SPARC architecture:
911 @item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
912 @itemx -Av8plus | -Av8plusa | -Av9 | -Av9a
913 Explicitly select a variant of the SPARC architecture.
915 @samp{-Av8plus} and @samp{-Av8plusa} select a 32 bit environment.
916 @samp{-Av9} and @samp{-Av9a} select a 64 bit environment.
918 @samp{-Av8plusa} and @samp{-Av9a} enable the SPARC V9 instruction set with
919 UltraSPARC extensions.
921 @item -xarch=v8plus | -xarch=v8plusa
922 For compatibility with the Solaris v9 assembler. These options are
923 equivalent to -Av8plus and -Av8plusa, respectively.
926 Warn when the assembler switches to another architecture.
931 The following options are available when @value{AS} is configured for the 'c54x
936 Enable extended addressing mode. All addresses and relocations will assume
937 extended addressing (usually 23 bits).
938 @item -mcpu=@var{CPU_VERSION}
939 Sets the CPU version being compiled for.
940 @item -merrors-to-file @var{FILENAME}
941 Redirect error output to a file, for broken systems which don't support such
942 behaviour in the shell.
947 The following options are available when @value{AS} is configured for
948 a @sc{mips} processor.
952 This option sets the largest size of an object that can be referenced
953 implicitly with the @code{gp} register. It is only accepted for targets that
954 use ECOFF format, such as a DECstation running Ultrix. The default value is 8.
956 @cindex MIPS endianness
957 @cindex endianness, MIPS
958 @cindex big endian output, MIPS
960 Generate ``big endian'' format output.
962 @cindex little endian output, MIPS
964 Generate ``little endian'' format output.
976 Generate code for a particular @sc{mips} Instruction Set Architecture level.
977 @samp{-mips1} is an alias for @samp{-march=r3000}, @samp{-mips2} is an
978 alias for @samp{-march=r6000}, @samp{-mips3} is an alias for
979 @samp{-march=r4000} and @samp{-mips4} is an alias for @samp{-march=r8000}.
980 @samp{-mips5}, @samp{-mips32}, @samp{-mips32r2}, @samp{-mips64}, and
982 correspond to generic
983 @samp{MIPS V}, @samp{MIPS32}, @samp{MIPS32 Release 2}, @samp{MIPS64},
984 and @samp{MIPS64 Release 2}
985 ISA processors, respectively.
987 @item -march=@var{CPU}
988 Generate code for a particular @sc{mips} cpu.
990 @item -mtune=@var{cpu}
991 Schedule and tune for a particular @sc{mips} cpu.
995 Cause nops to be inserted if the read of the destination register
996 of an mfhi or mflo instruction occurs in the following two instructions.
1000 Cause stabs-style debugging output to go into an ECOFF-style .mdebug
1001 section instead of the standard ELF .stabs sections.
1005 Control generation of @code{.pdr} sections.
1009 The register sizes are normally inferred from the ISA and ABI, but these
1010 flags force a certain group of registers to be treated as 32 bits wide at
1011 all times. @samp{-mgp32} controls the size of general-purpose registers
1012 and @samp{-mfp32} controls the size of floating-point registers.
1016 Generate code for the MIPS 16 processor. This is equivalent to putting
1017 @code{.set mips16} at the start of the assembly file. @samp{-no-mips16}
1018 turns off this option.
1021 @itemx -mno-smartmips
1022 Enables the SmartMIPS extension to the MIPS32 instruction set. This is
1023 equivalent to putting @code{.set smartmips} at the start of the assembly file.
1024 @samp{-mno-smartmips} turns off this option.
1028 Generate code for the MIPS-3D Application Specific Extension.
1029 This tells the assembler to accept MIPS-3D instructions.
1030 @samp{-no-mips3d} turns off this option.
1034 Generate code for the MDMX Application Specific Extension.
1035 This tells the assembler to accept MDMX instructions.
1036 @samp{-no-mdmx} turns off this option.
1040 Generate code for the DSP Release 1 Application Specific Extension.
1041 This tells the assembler to accept DSP Release 1 instructions.
1042 @samp{-mno-dsp} turns off this option.
1046 Generate code for the DSP Release 2 Application Specific Extension.
1047 This option implies -mdsp.
1048 This tells the assembler to accept DSP Release 2 instructions.
1049 @samp{-mno-dspr2} turns off this option.
1053 Generate code for the MT Application Specific Extension.
1054 This tells the assembler to accept MT instructions.
1055 @samp{-mno-mt} turns off this option.
1057 @item --construct-floats
1058 @itemx --no-construct-floats
1059 The @samp{--no-construct-floats} option disables the construction of
1060 double width floating point constants by loading the two halves of the
1061 value into the two single width floating point registers that make up
1062 the double width register. By default @samp{--construct-floats} is
1063 selected, allowing construction of these floating point constants.
1066 @item --emulation=@var{name}
1067 This option causes @command{@value{AS}} to emulate @command{@value{AS}} configured
1068 for some other target, in all respects, including output format (choosing
1069 between ELF and ECOFF only), handling of pseudo-opcodes which may generate
1070 debugging information or store symbol table information, and default
1071 endianness. The available configuration names are: @samp{mipsecoff},
1072 @samp{mipself}, @samp{mipslecoff}, @samp{mipsbecoff}, @samp{mipslelf},
1073 @samp{mipsbelf}. The first two do not alter the default endianness from that
1074 of the primary target for which the assembler was configured; the others change
1075 the default to little- or big-endian as indicated by the @samp{b} or @samp{l}
1076 in the name. Using @samp{-EB} or @samp{-EL} will override the endianness
1077 selection in any case.
1079 This option is currently supported only when the primary target
1080 @command{@value{AS}} is configured for is a @sc{mips} ELF or ECOFF target.
1081 Furthermore, the primary target or others specified with
1082 @samp{--enable-targets=@dots{}} at configuration time must include support for
1083 the other format, if both are to be available. For example, the Irix 5
1084 configuration includes support for both.
1086 Eventually, this option will support more configurations, with more
1087 fine-grained control over the assembler's behavior, and will be supported for
1091 @command{@value{AS}} ignores this option. It is accepted for compatibility with
1098 Control how to deal with multiplication overflow and division by zero.
1099 @samp{--trap} or @samp{--no-break} (which are synonyms) take a trap exception
1100 (and only work for Instruction Set Architecture level 2 and higher);
1101 @samp{--break} or @samp{--no-trap} (also synonyms, and the default) take a
1105 When this option is used, @command{@value{AS}} will issue a warning every
1106 time it generates a nop instruction from a macro.
1111 The following options are available when @value{AS} is configured for
1117 Enable or disable the JSRI to BSR transformation. By default this is enabled.
1118 The command line option @samp{-nojsri2bsr} can be used to disable it.
1122 Enable or disable the silicon filter behaviour. By default this is disabled.
1123 The default can be overridden by the @samp{-sifilter} command line option.
1126 Alter jump instructions for long displacements.
1128 @item -mcpu=[210|340]
1129 Select the cpu type on the target hardware. This controls which instructions
1133 Assemble for a big endian target.
1136 Assemble for a little endian target.
1142 See the info pages for documentation of the MMIX-specific options.
1146 The following options are available when @value{AS} is configured for
1147 an Xtensa processor.
1150 @item --text-section-literals | --no-text-section-literals
1151 With @option{--text-@-section-@-literals}, literal pools are interspersed
1152 in the text section. The default is
1153 @option{--no-@-text-@-section-@-literals}, which places literals in a
1154 separate section in the output file. These options only affect literals
1155 referenced via PC-relative @code{L32R} instructions; literals for
1156 absolute mode @code{L32R} instructions are handled separately.
1158 @item --absolute-literals | --no-absolute-literals
1159 Indicate to the assembler whether @code{L32R} instructions use absolute
1160 or PC-relative addressing. The default is to assume absolute addressing
1161 if the Xtensa processor includes the absolute @code{L32R} addressing
1162 option. Otherwise, only the PC-relative @code{L32R} mode can be used.
1164 @item --target-align | --no-target-align
1165 Enable or disable automatic alignment to reduce branch penalties at the
1166 expense of some code density. The default is @option{--target-@-align}.
1168 @item --longcalls | --no-longcalls
1169 Enable or disable transformation of call instructions to allow calls
1170 across a greater range of addresses. The default is
1171 @option{--no-@-longcalls}.
1173 @item --transform | --no-transform
1174 Enable or disable all assembler transformations of Xtensa instructions.
1175 The default is @option{--transform};
1176 @option{--no-transform} should be used only in the rare cases when the
1177 instructions must be exactly as specified in the assembly source.
1182 The following options are available when @value{AS} is configured for
1183 a Z80 family processor.
1186 Assemble for Z80 processor.
1188 Assemble for R800 processor.
1189 @item -ignore-undocumented-instructions
1191 Assemble undocumented Z80 instructions that also work on R800 without warning.
1192 @item -ignore-unportable-instructions
1194 Assemble all undocumented Z80 instructions without warning.
1195 @item -warn-undocumented-instructions
1197 Issue a warning for undocumented Z80 instructions that also work on R800.
1198 @item -warn-unportable-instructions
1200 Issue a warning for undocumented Z80 instructions that do not work on R800.
1201 @item -forbid-undocumented-instructions
1203 Treat all undocumented instructions as errors.
1204 @item -forbid-unportable-instructions
1206 Treat undocumented Z80 instructions that do not work on R800 as errors.
1213 * Manual:: Structure of this Manual
1214 * GNU Assembler:: The GNU Assembler
1215 * Object Formats:: Object File Formats
1216 * Command Line:: Command Line
1217 * Input Files:: Input Files
1218 * Object:: Output (Object) File
1219 * Errors:: Error and Warning Messages
1223 @section Structure of this Manual
1225 @cindex manual, structure and purpose
1226 This manual is intended to describe what you need to know to use
1227 @sc{gnu} @command{@value{AS}}. We cover the syntax expected in source files, including
1228 notation for symbols, constants, and expressions; the directives that
1229 @command{@value{AS}} understands; and of course how to invoke @command{@value{AS}}.
1232 We also cover special features in the @value{TARGET}
1233 configuration of @command{@value{AS}}, including assembler directives.
1236 This manual also describes some of the machine-dependent features of
1237 various flavors of the assembler.
1240 @cindex machine instructions (not covered)
1241 On the other hand, this manual is @emph{not} intended as an introduction
1242 to programming in assembly language---let alone programming in general!
1243 In a similar vein, we make no attempt to introduce the machine
1244 architecture; we do @emph{not} describe the instruction set, standard
1245 mnemonics, registers or addressing modes that are standard to a
1246 particular architecture.
1248 You may want to consult the manufacturer's
1249 machine architecture manual for this information.
1253 For information on the H8/300 machine instruction set, see @cite{H8/300
1254 Series Programming Manual}. For the H8/300H, see @cite{H8/300H Series
1255 Programming Manual} (Renesas).
1258 For information on the Renesas (formerly Hitachi) / SuperH SH machine instruction set,
1259 see @cite{SH-Microcomputer User's Manual} (Renesas) or
1260 @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
1261 @cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
1264 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
1268 @c I think this is premature---doc@cygnus.com, 17jan1991
1270 Throughout this manual, we assume that you are running @dfn{GNU},
1271 the portable operating system from the @dfn{Free Software
1272 Foundation, Inc.}. This restricts our attention to certain kinds of
1273 computer (in particular, the kinds of computers that @sc{gnu} can run on);
1274 once this assumption is granted examples and definitions need less
1277 @command{@value{AS}} is part of a team of programs that turn a high-level
1278 human-readable series of instructions into a low-level
1279 computer-readable series of instructions. Different versions of
1280 @command{@value{AS}} are used for different kinds of computer.
1283 @c There used to be a section "Terminology" here, which defined
1284 @c "contents", "byte", "word", and "long". Defining "word" to any
1285 @c particular size is confusing when the .word directive may generate 16
1286 @c bits on one machine and 32 bits on another; in general, for the user
1287 @c version of this manual, none of these terms seem essential to define.
1288 @c They were used very little even in the former draft of the manual;
1289 @c this draft makes an effort to avoid them (except in names of
1293 @section The GNU Assembler
1295 @c man begin DESCRIPTION
1297 @sc{gnu} @command{as} is really a family of assemblers.
1299 This manual describes @command{@value{AS}}, a member of that family which is
1300 configured for the @value{TARGET} architectures.
1302 If you use (or have used) the @sc{gnu} assembler on one architecture, you
1303 should find a fairly similar environment when you use it on another
1304 architecture. Each version has much in common with the others,
1305 including object file formats, most assembler directives (often called
1306 @dfn{pseudo-ops}) and assembler syntax.@refill
1308 @cindex purpose of @sc{gnu} assembler
1309 @command{@value{AS}} is primarily intended to assemble the output of the
1310 @sc{gnu} C compiler @code{@value{GCC}} for use by the linker
1311 @code{@value{LD}}. Nevertheless, we've tried to make @command{@value{AS}}
1312 assemble correctly everything that other assemblers for the same
1313 machine would assemble.
1315 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
1318 @c This remark should appear in generic version of manual; assumption
1319 @c here is that generic version sets M680x0.
1320 This doesn't mean @command{@value{AS}} always uses the same syntax as another
1321 assembler for the same architecture; for example, we know of several
1322 incompatible versions of 680x0 assembly language syntax.
1327 Unlike older assemblers, @command{@value{AS}} is designed to assemble a source
1328 program in one pass of the source file. This has a subtle impact on the
1329 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
1331 @node Object Formats
1332 @section Object File Formats
1334 @cindex object file format
1335 The @sc{gnu} assembler can be configured to produce several alternative
1336 object file formats. For the most part, this does not affect how you
1337 write assembly language programs; but directives for debugging symbols
1338 are typically different in different file formats. @xref{Symbol
1339 Attributes,,Symbol Attributes}.
1342 For the @value{TARGET} target, @command{@value{AS}} is configured to produce
1343 @value{OBJ-NAME} format object files.
1345 @c The following should exhaust all configs that set MULTI-OBJ, ideally
1347 On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
1348 @code{b.out} or COFF format object files.
1351 On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
1352 SOM or ELF format object files.
1357 @section Command Line
1359 @cindex command line conventions
1361 After the program name @command{@value{AS}}, the command line may contain
1362 options and file names. Options may appear in any order, and may be
1363 before, after, or between file names. The order of file names is
1366 @cindex standard input, as input file
1368 @file{--} (two hyphens) by itself names the standard input file
1369 explicitly, as one of the files for @command{@value{AS}} to assemble.
1371 @cindex options, command line
1372 Except for @samp{--} any command line argument that begins with a
1373 hyphen (@samp{-}) is an option. Each option changes the behavior of
1374 @command{@value{AS}}. No option changes the way another option works. An
1375 option is a @samp{-} followed by one or more letters; the case of
1376 the letter is important. All options are optional.
1378 Some options expect exactly one file name to follow them. The file
1379 name may either immediately follow the option's letter (compatible
1380 with older assemblers) or it may be the next command argument (@sc{gnu}
1381 standard). These two command lines are equivalent:
1384 @value{AS} -o my-object-file.o mumble.s
1385 @value{AS} -omy-object-file.o mumble.s
1389 @section Input Files
1392 @cindex source program
1393 @cindex files, input
1394 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
1395 describe the program input to one run of @command{@value{AS}}. The program may
1396 be in one or more files; how the source is partitioned into files
1397 doesn't change the meaning of the source.
1399 @c I added "con" prefix to "catenation" just to prove I can overcome my
1400 @c APL training... doc@cygnus.com
1401 The source program is a concatenation of the text in all the files, in the
1404 @c man begin DESCRIPTION
1405 Each time you run @command{@value{AS}} it assembles exactly one source
1406 program. The source program is made up of one or more files.
1407 (The standard input is also a file.)
1409 You give @command{@value{AS}} a command line that has zero or more input file
1410 names. The input files are read (from left file name to right). A
1411 command line argument (in any position) that has no special meaning
1412 is taken to be an input file name.
1414 If you give @command{@value{AS}} no file names it attempts to read one input file
1415 from the @command{@value{AS}} standard input, which is normally your terminal. You
1416 may have to type @key{ctl-D} to tell @command{@value{AS}} there is no more program
1419 Use @samp{--} if you need to explicitly name the standard input file
1420 in your command line.
1422 If the source is empty, @command{@value{AS}} produces a small, empty object
1427 @subheading Filenames and Line-numbers
1429 @cindex input file linenumbers
1430 @cindex line numbers, in input files
1431 There are two ways of locating a line in the input file (or files) and
1432 either may be used in reporting error messages. One way refers to a line
1433 number in a physical file; the other refers to a line number in a
1434 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
1436 @dfn{Physical files} are those files named in the command line given
1437 to @command{@value{AS}}.
1439 @dfn{Logical files} are simply names declared explicitly by assembler
1440 directives; they bear no relation to physical files. Logical file names help
1441 error messages reflect the original source file, when @command{@value{AS}} source
1442 is itself synthesized from other files. @command{@value{AS}} understands the
1443 @samp{#} directives emitted by the @code{@value{GCC}} preprocessor. See also
1444 @ref{File,,@code{.file}}.
1447 @section Output (Object) File
1453 Every time you run @command{@value{AS}} it produces an output file, which is
1454 your assembly language program translated into numbers. This file
1455 is the object file. Its default name is
1463 @code{b.out} when @command{@value{AS}} is configured for the Intel 80960.
1465 You can give it another name by using the @option{-o} option. Conventionally,
1466 object file names end with @file{.o}. The default name is used for historical
1467 reasons: older assemblers were capable of assembling self-contained programs
1468 directly into a runnable program. (For some formats, this isn't currently
1469 possible, but it can be done for the @code{a.out} format.)
1473 The object file is meant for input to the linker @code{@value{LD}}. It contains
1474 assembled program code, information to help @code{@value{LD}} integrate
1475 the assembled program into a runnable file, and (optionally) symbolic
1476 information for the debugger.
1478 @c link above to some info file(s) like the description of a.out.
1479 @c don't forget to describe @sc{gnu} info as well as Unix lossage.
1482 @section Error and Warning Messages
1484 @c man begin DESCRIPTION
1486 @cindex error messages
1487 @cindex warning messages
1488 @cindex messages from assembler
1489 @command{@value{AS}} may write warnings and error messages to the standard error
1490 file (usually your terminal). This should not happen when a compiler
1491 runs @command{@value{AS}} automatically. Warnings report an assumption made so
1492 that @command{@value{AS}} could keep assembling a flawed program; errors report a
1493 grave problem that stops the assembly.
1497 @cindex format of warning messages
1498 Warning messages have the format
1501 file_name:@b{NNN}:Warning Message Text
1505 @cindex line numbers, in warnings/errors
1506 (where @b{NNN} is a line number). If a logical file name has been given
1507 (@pxref{File,,@code{.file}}) it is used for the filename, otherwise the name of
1508 the current input file is used. If a logical line number was given
1510 (@pxref{Line,,@code{.line}})
1512 then it is used to calculate the number printed,
1513 otherwise the actual line in the current source file is printed. The
1514 message text is intended to be self explanatory (in the grand Unix
1517 @cindex format of error messages
1518 Error messages have the format
1520 file_name:@b{NNN}:FATAL:Error Message Text
1522 The file name and line number are derived as for warning
1523 messages. The actual message text may be rather less explanatory
1524 because many of them aren't supposed to happen.
1527 @chapter Command-Line Options
1529 @cindex options, all versions of assembler
1530 This chapter describes command-line options available in @emph{all}
1531 versions of the @sc{gnu} assembler; see @ref{Machine Dependencies},
1532 for options specific
1534 to the @value{TARGET} target.
1537 to particular machine architectures.
1540 @c man begin DESCRIPTION
1542 If you are invoking @command{@value{AS}} via the @sc{gnu} C compiler,
1543 you can use the @samp{-Wa} option to pass arguments through to the assembler.
1544 The assembler arguments must be separated from each other (and the @samp{-Wa})
1545 by commas. For example:
1548 gcc -c -g -O -Wa,-alh,-L file.c
1552 This passes two options to the assembler: @samp{-alh} (emit a listing to
1553 standard output with high-level and assembly source) and @samp{-L} (retain
1554 local symbols in the symbol table).
1556 Usually you do not need to use this @samp{-Wa} mechanism, since many compiler
1557 command-line options are automatically passed to the assembler by the compiler.
1558 (You can call the @sc{gnu} compiler driver with the @samp{-v} option to see
1559 precisely what options it passes to each compilation pass, including the
1565 * a:: -a[cdhlns] enable listings
1566 * alternate:: --alternate enable alternate macro syntax
1567 * D:: -D for compatibility
1568 * f:: -f to work faster
1569 * I:: -I for .include search path
1570 @ifclear DIFF-TBL-KLUGE
1571 * K:: -K for compatibility
1573 @ifset DIFF-TBL-KLUGE
1574 * K:: -K for difference tables
1577 * L:: -L to retain local symbols
1578 * listing:: --listing-XXX to configure listing output
1579 * M:: -M or --mri to assemble in MRI compatibility mode
1580 * MD:: --MD for dependency tracking
1581 * o:: -o to name the object file
1582 * R:: -R to join data and text sections
1583 * statistics:: --statistics to see statistics about assembly
1584 * traditional-format:: --traditional-format for compatible output
1585 * v:: -v to announce version
1586 * W:: -W, --no-warn, --warn, --fatal-warnings to control warnings
1587 * Z:: -Z to make object file even after errors
1591 @section Enable Listings: @option{-a[cdhlns]}
1600 @cindex listings, enabling
1601 @cindex assembly listings, enabling
1603 These options enable listing output from the assembler. By itself,
1604 @samp{-a} requests high-level, assembly, and symbols listing.
1605 You can use other letters to select specific options for the list:
1606 @samp{-ah} requests a high-level language listing,
1607 @samp{-al} requests an output-program assembly listing, and
1608 @samp{-as} requests a symbol table listing.
1609 High-level listings require that a compiler debugging option like
1610 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
1613 Use the @samp{-ac} option to omit false conditionals from a listing. Any lines
1614 which are not assembled because of a false @code{.if} (or @code{.ifdef}, or any
1615 other conditional), or a true @code{.if} followed by an @code{.else}, will be
1616 omitted from the listing.
1618 Use the @samp{-ad} option to omit debugging directives from the
1621 Once you have specified one of these options, you can further control
1622 listing output and its appearance using the directives @code{.list},
1623 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
1625 The @samp{-an} option turns off all forms processing.
1626 If you do not request listing output with one of the @samp{-a} options, the
1627 listing-control directives have no effect.
1629 The letters after @samp{-a} may be combined into one option,
1630 @emph{e.g.}, @samp{-aln}.
1632 Note if the assembler source is coming from the standard input (e.g.,
1634 is being created by @code{@value{GCC}} and the @samp{-pipe} command line switch
1635 is being used) then the listing will not contain any comments or preprocessor
1636 directives. This is because the listing code buffers input source lines from
1637 stdin only after they have been preprocessed by the assembler. This reduces
1638 memory usage and makes the code more efficient.
1641 @section @option{--alternate}
1644 Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
1647 @section @option{-D}
1650 This option has no effect whatsoever, but it is accepted to make it more
1651 likely that scripts written for other assemblers also work with
1652 @command{@value{AS}}.
1655 @section Work Faster: @option{-f}
1658 @cindex trusted compiler
1659 @cindex faster processing (@option{-f})
1660 @samp{-f} should only be used when assembling programs written by a
1661 (trusted) compiler. @samp{-f} stops the assembler from doing whitespace
1662 and comment preprocessing on
1663 the input file(s) before assembling them. @xref{Preprocessing,
1667 @emph{Warning:} if you use @samp{-f} when the files actually need to be
1668 preprocessed (if they contain comments, for example), @command{@value{AS}} does
1673 @section @code{.include} Search Path: @option{-I} @var{path}
1675 @kindex -I @var{path}
1676 @cindex paths for @code{.include}
1677 @cindex search path for @code{.include}
1678 @cindex @code{include} directive search path
1679 Use this option to add a @var{path} to the list of directories
1680 @command{@value{AS}} searches for files specified in @code{.include}
1681 directives (@pxref{Include,,@code{.include}}). You may use @option{-I} as
1682 many times as necessary to include a variety of paths. The current
1683 working directory is always searched first; after that, @command{@value{AS}}
1684 searches any @samp{-I} directories in the same order as they were
1685 specified (left to right) on the command line.
1688 @section Difference Tables: @option{-K}
1691 @ifclear DIFF-TBL-KLUGE
1692 On the @value{TARGET} family, this option is allowed, but has no effect. It is
1693 permitted for compatibility with the @sc{gnu} assembler on other platforms,
1694 where it can be used to warn when the assembler alters the machine code
1695 generated for @samp{.word} directives in difference tables. The @value{TARGET}
1696 family does not have the addressing limitations that sometimes lead to this
1697 alteration on other platforms.
1700 @ifset DIFF-TBL-KLUGE
1701 @cindex difference tables, warning
1702 @cindex warning for altered difference tables
1703 @command{@value{AS}} sometimes alters the code emitted for directives of the
1704 form @samp{.word @var{sym1}-@var{sym2}}. @xref{Word,,@code{.word}}.
1705 You can use the @samp{-K} option if you want a warning issued when this
1710 @section Include Local Symbols: @option{-L}
1713 @cindex local symbols, retaining in output
1714 Symbols beginning with system-specific local label prefixes, typically
1715 @samp{.L} for ELF systems or @samp{L} for traditional a.out systems, are
1716 called @dfn{local symbols}. @xref{Symbol Names}. Normally you do not see
1717 such symbols when debugging, because they are intended for the use of
1718 programs (like compilers) that compose assembler programs, not for your
1719 notice. Normally both @command{@value{AS}} and @code{@value{LD}} discard
1720 such symbols, so you do not normally debug with them.
1722 This option tells @command{@value{AS}} to retain those local symbols
1723 in the object file. Usually if you do this you also tell the linker
1724 @code{@value{LD}} to preserve those symbols.
1727 @section Configuring listing output: @option{--listing}
1729 The listing feature of the assembler can be enabled via the command line switch
1730 @samp{-a} (@pxref{a}). This feature combines the input source file(s) with a
1731 hex dump of the corresponding locations in the output object file, and displays
1732 them as a listing file. The format of this listing can be controlled by
1733 directives inside the assembler source (i.e., @code{.list} (@pxref{List}),
1734 @code{.title} (@pxref{Title}), @code{.sbttl} (@pxref{Sbttl}),
1735 @code{.psize} (@pxref{Psize}), and
1736 @code{.eject} (@pxref{Eject}) and also by the following switches:
1739 @item --listing-lhs-width=@samp{number}
1740 @kindex --listing-lhs-width
1741 @cindex Width of first line disassembly output
1742 Sets the maximum width, in words, of the first line of the hex byte dump. This
1743 dump appears on the left hand side of the listing output.
1745 @item --listing-lhs-width2=@samp{number}
1746 @kindex --listing-lhs-width2
1747 @cindex Width of continuation lines of disassembly output
1748 Sets the maximum width, in words, of any further lines of the hex byte dump for
1749 a given input source line. If this value is not specified, it defaults to being
1750 the same as the value specified for @samp{--listing-lhs-width}. If neither
1751 switch is used the default is to one.
1753 @item --listing-rhs-width=@samp{number}
1754 @kindex --listing-rhs-width
1755 @cindex Width of source line output
1756 Sets the maximum width, in characters, of the source line that is displayed
1757 alongside the hex dump. The default value for this parameter is 100. The
1758 source line is displayed on the right hand side of the listing output.
1760 @item --listing-cont-lines=@samp{number}
1761 @kindex --listing-cont-lines
1762 @cindex Maximum number of continuation lines
1763 Sets the maximum number of continuation lines of hex dump that will be
1764 displayed for a given single line of source input. The default value is 4.
1768 @section Assemble in MRI Compatibility Mode: @option{-M}
1771 @cindex MRI compatibility mode
1772 The @option{-M} or @option{--mri} option selects MRI compatibility mode. This
1773 changes the syntax and pseudo-op handling of @command{@value{AS}} to make it
1774 compatible with the @code{ASM68K} or the @code{ASM960} (depending upon the
1775 configured target) assembler from Microtec Research. The exact nature of the
1776 MRI syntax will not be documented here; see the MRI manuals for more
1777 information. Note in particular that the handling of macros and macro
1778 arguments is somewhat different. The purpose of this option is to permit
1779 assembling existing MRI assembler code using @command{@value{AS}}.
1781 The MRI compatibility is not complete. Certain operations of the MRI assembler
1782 depend upon its object file format, and can not be supported using other object
1783 file formats. Supporting these would require enhancing each object file format
1784 individually. These are:
1787 @item global symbols in common section
1789 The m68k MRI assembler supports common sections which are merged by the linker.
1790 Other object file formats do not support this. @command{@value{AS}} handles
1791 common sections by treating them as a single common symbol. It permits local
1792 symbols to be defined within a common section, but it can not support global
1793 symbols, since it has no way to describe them.
1795 @item complex relocations
1797 The MRI assemblers support relocations against a negated section address, and
1798 relocations which combine the start addresses of two or more sections. These
1799 are not support by other object file formats.
1801 @item @code{END} pseudo-op specifying start address
1803 The MRI @code{END} pseudo-op permits the specification of a start address.
1804 This is not supported by other object file formats. The start address may
1805 instead be specified using the @option{-e} option to the linker, or in a linker
1808 @item @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops
1810 The MRI @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops assign a module
1811 name to the output file. This is not supported by other object file formats.
1813 @item @code{ORG} pseudo-op
1815 The m68k MRI @code{ORG} pseudo-op begins an absolute section at a given
1816 address. This differs from the usual @command{@value{AS}} @code{.org} pseudo-op,
1817 which changes the location within the current section. Absolute sections are
1818 not supported by other object file formats. The address of a section may be
1819 assigned within a linker script.
1822 There are some other features of the MRI assembler which are not supported by
1823 @command{@value{AS}}, typically either because they are difficult or because they
1824 seem of little consequence. Some of these may be supported in future releases.
1828 @item EBCDIC strings
1830 EBCDIC strings are not supported.
1832 @item packed binary coded decimal
1834 Packed binary coded decimal is not supported. This means that the @code{DC.P}
1835 and @code{DCB.P} pseudo-ops are not supported.
1837 @item @code{FEQU} pseudo-op
1839 The m68k @code{FEQU} pseudo-op is not supported.
1841 @item @code{NOOBJ} pseudo-op
1843 The m68k @code{NOOBJ} pseudo-op is not supported.
1845 @item @code{OPT} branch control options
1847 The m68k @code{OPT} branch control options---@code{B}, @code{BRS}, @code{BRB},
1848 @code{BRL}, and @code{BRW}---are ignored. @command{@value{AS}} automatically
1849 relaxes all branches, whether forward or backward, to an appropriate size, so
1850 these options serve no purpose.
1852 @item @code{OPT} list control options
1854 The following m68k @code{OPT} list control options are ignored: @code{C},
1855 @code{CEX}, @code{CL}, @code{CRE}, @code{E}, @code{G}, @code{I}, @code{M},
1856 @code{MEX}, @code{MC}, @code{MD}, @code{X}.
1858 @item other @code{OPT} options
1860 The following m68k @code{OPT} options are ignored: @code{NEST}, @code{O},
1861 @code{OLD}, @code{OP}, @code{P}, @code{PCO}, @code{PCR}, @code{PCS}, @code{R}.
1863 @item @code{OPT} @code{D} option is default
1865 The m68k @code{OPT} @code{D} option is the default, unlike the MRI assembler.
1866 @code{OPT NOD} may be used to turn it off.
1868 @item @code{XREF} pseudo-op.
1870 The m68k @code{XREF} pseudo-op is ignored.
1872 @item @code{.debug} pseudo-op
1874 The i960 @code{.debug} pseudo-op is not supported.
1876 @item @code{.extended} pseudo-op
1878 The i960 @code{.extended} pseudo-op is not supported.
1880 @item @code{.list} pseudo-op.
1882 The various options of the i960 @code{.list} pseudo-op are not supported.
1884 @item @code{.optimize} pseudo-op
1886 The i960 @code{.optimize} pseudo-op is not supported.
1888 @item @code{.output} pseudo-op
1890 The i960 @code{.output} pseudo-op is not supported.
1892 @item @code{.setreal} pseudo-op
1894 The i960 @code{.setreal} pseudo-op is not supported.
1899 @section Dependency Tracking: @option{--MD}
1902 @cindex dependency tracking
1905 @command{@value{AS}} can generate a dependency file for the file it creates. This
1906 file consists of a single rule suitable for @code{make} describing the
1907 dependencies of the main source file.
1909 The rule is written to the file named in its argument.
1911 This feature is used in the automatic updating of makefiles.
1914 @section Name the Object File: @option{-o}
1917 @cindex naming object file
1918 @cindex object file name
1919 There is always one object file output when you run @command{@value{AS}}. By
1920 default it has the name
1923 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
1937 You use this option (which takes exactly one filename) to give the
1938 object file a different name.
1940 Whatever the object file is called, @command{@value{AS}} overwrites any
1941 existing file of the same name.
1944 @section Join Data and Text Sections: @option{-R}
1947 @cindex data and text sections, joining
1948 @cindex text and data sections, joining
1949 @cindex joining text and data sections
1950 @cindex merging text and data sections
1951 @option{-R} tells @command{@value{AS}} to write the object file as if all
1952 data-section data lives in the text section. This is only done at
1953 the very last moment: your binary data are the same, but data
1954 section parts are relocated differently. The data section part of
1955 your object file is zero bytes long because all its bytes are
1956 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
1958 When you specify @option{-R} it would be possible to generate shorter
1959 address displacements (because we do not have to cross between text and
1960 data section). We refrain from doing this simply for compatibility with
1961 older versions of @command{@value{AS}}. In future, @option{-R} may work this way.
1964 When @command{@value{AS}} is configured for COFF or ELF output,
1965 this option is only useful if you use sections named @samp{.text} and
1970 @option{-R} is not supported for any of the HPPA targets. Using
1971 @option{-R} generates a warning from @command{@value{AS}}.
1975 @section Display Assembly Statistics: @option{--statistics}
1977 @kindex --statistics
1978 @cindex statistics, about assembly
1979 @cindex time, total for assembly
1980 @cindex space used, maximum for assembly
1981 Use @samp{--statistics} to display two statistics about the resources used by
1982 @command{@value{AS}}: the maximum amount of space allocated during the assembly
1983 (in bytes), and the total execution time taken for the assembly (in @sc{cpu}
1986 @node traditional-format
1987 @section Compatible Output: @option{--traditional-format}
1989 @kindex --traditional-format
1990 For some targets, the output of @command{@value{AS}} is different in some ways
1991 from the output of some existing assembler. This switch requests
1992 @command{@value{AS}} to use the traditional format instead.
1994 For example, it disables the exception frame optimizations which
1995 @command{@value{AS}} normally does by default on @code{@value{GCC}} output.
1998 @section Announce Version: @option{-v}
2002 @cindex assembler version
2003 @cindex version of assembler
2004 You can find out what version of as is running by including the
2005 option @samp{-v} (which you can also spell as @samp{-version}) on the
2009 @section Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings}
2011 @command{@value{AS}} should never give a warning or error message when
2012 assembling compiler output. But programs written by people often
2013 cause @command{@value{AS}} to give a warning that a particular assumption was
2014 made. All such warnings are directed to the standard error file.
2018 @cindex suppressing warnings
2019 @cindex warnings, suppressing
2020 If you use the @option{-W} and @option{--no-warn} options, no warnings are issued.
2021 This only affects the warning messages: it does not change any particular of
2022 how @command{@value{AS}} assembles your file. Errors, which stop the assembly,
2025 @kindex --fatal-warnings
2026 @cindex errors, caused by warnings
2027 @cindex warnings, causing error
2028 If you use the @option{--fatal-warnings} option, @command{@value{AS}} considers
2029 files that generate warnings to be in error.
2032 @cindex warnings, switching on
2033 You can switch these options off again by specifying @option{--warn}, which
2034 causes warnings to be output as usual.
2037 @section Generate Object File in Spite of Errors: @option{-Z}
2038 @cindex object file, after errors
2039 @cindex errors, continuing after
2040 After an error message, @command{@value{AS}} normally produces no output. If for
2041 some reason you are interested in object file output even after
2042 @command{@value{AS}} gives an error message on your program, use the @samp{-Z}
2043 option. If there are any errors, @command{@value{AS}} continues anyways, and
2044 writes an object file after a final warning message of the form @samp{@var{n}
2045 errors, @var{m} warnings, generating bad object file.}
2050 @cindex machine-independent syntax
2051 @cindex syntax, machine-independent
2052 This chapter describes the machine-independent syntax allowed in a
2053 source file. @command{@value{AS}} syntax is similar to what many other
2054 assemblers use; it is inspired by the BSD 4.2
2059 assembler, except that @command{@value{AS}} does not assemble Vax bit-fields.
2063 * Preprocessing:: Preprocessing
2064 * Whitespace:: Whitespace
2065 * Comments:: Comments
2066 * Symbol Intro:: Symbols
2067 * Statements:: Statements
2068 * Constants:: Constants
2072 @section Preprocessing
2074 @cindex preprocessing
2075 The @command{@value{AS}} internal preprocessor:
2077 @cindex whitespace, removed by preprocessor
2079 adjusts and removes extra whitespace. It leaves one space or tab before
2080 the keywords on a line, and turns any other whitespace on the line into
2083 @cindex comments, removed by preprocessor
2085 removes all comments, replacing them with a single space, or an
2086 appropriate number of newlines.
2088 @cindex constants, converted by preprocessor
2090 converts character constants into the appropriate numeric values.
2093 It does not do macro processing, include file handling, or
2094 anything else you may get from your C compiler's preprocessor. You can
2095 do include file processing with the @code{.include} directive
2096 (@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
2097 to get other ``CPP'' style preprocessing by giving the input file a
2098 @samp{.S} suffix. @xref{Overall Options, ,Options Controlling the Kind of
2099 Output, gcc.info, Using GNU CC}.
2101 Excess whitespace, comments, and character constants
2102 cannot be used in the portions of the input text that are not
2105 @cindex turning preprocessing on and off
2106 @cindex preprocessing, turning on and off
2109 If the first line of an input file is @code{#NO_APP} or if you use the
2110 @samp{-f} option, whitespace and comments are not removed from the input file.
2111 Within an input file, you can ask for whitespace and comment removal in
2112 specific portions of the by putting a line that says @code{#APP} before the
2113 text that may contain whitespace or comments, and putting a line that says
2114 @code{#NO_APP} after this text. This feature is mainly intend to support
2115 @code{asm} statements in compilers whose output is otherwise free of comments
2122 @dfn{Whitespace} is one or more blanks or tabs, in any order.
2123 Whitespace is used to separate symbols, and to make programs neater for
2124 people to read. Unless within character constants
2125 (@pxref{Characters,,Character Constants}), any whitespace means the same
2126 as exactly one space.
2132 There are two ways of rendering comments to @command{@value{AS}}. In both
2133 cases the comment is equivalent to one space.
2135 Anything from @samp{/*} through the next @samp{*/} is a comment.
2136 This means you may not nest these comments.
2140 The only way to include a newline ('\n') in a comment
2141 is to use this sort of comment.
2144 /* This sort of comment does not nest. */
2147 @cindex line comment character
2148 Anything from the @dfn{line comment} character to the next newline
2149 is considered a comment and is ignored. The line comment character is
2151 @samp{;} on the ARC;
2154 @samp{@@} on the ARM;
2157 @samp{;} for the H8/300 family;
2160 @samp{;} for the HPPA;
2163 @samp{#} on the i386 and x86-64;
2166 @samp{#} on the i960;
2169 @samp{;} for the PDP-11;
2172 @samp{;} for picoJava;
2175 @samp{#} for Motorola PowerPC;
2178 @samp{!} for the Renesas / SuperH SH;
2181 @samp{!} on the SPARC;
2184 @samp{#} on the ip2k;
2187 @samp{#} on the m32c;
2190 @samp{#} on the m32r;
2193 @samp{|} on the 680x0;
2196 @samp{#} on the 68HC11 and 68HC12;
2199 @samp{#} on the Vax;
2202 @samp{;} for the Z80;
2205 @samp{!} for the Z8000;
2208 @samp{#} on the V850;
2211 @samp{#} for Xtensa systems;
2213 see @ref{Machine Dependencies}. @refill
2214 @c FIXME What about i860?
2217 On some machines there are two different line comment characters. One
2218 character only begins a comment if it is the first non-whitespace character on
2219 a line, while the other always begins a comment.
2223 The V850 assembler also supports a double dash as starting a comment that
2224 extends to the end of the line.
2230 @cindex lines starting with @code{#}
2231 @cindex logical line numbers
2232 To be compatible with past assemblers, lines that begin with @samp{#} have a
2233 special interpretation. Following the @samp{#} should be an absolute
2234 expression (@pxref{Expressions}): the logical line number of the @emph{next}
2235 line. Then a string (@pxref{Strings, ,Strings}) is allowed: if present it is a
2236 new logical file name. The rest of the line, if any, should be whitespace.
2238 If the first non-whitespace characters on the line are not numeric,
2239 the line is ignored. (Just like a comment.)
2242 # This is an ordinary comment.
2243 # 42-6 "new_file_name" # New logical file name
2244 # This is logical line # 36.
2246 This feature is deprecated, and may disappear from future versions
2247 of @command{@value{AS}}.
2252 @cindex characters used in symbols
2253 @ifclear SPECIAL-SYMS
2254 A @dfn{symbol} is one or more characters chosen from the set of all
2255 letters (both upper and lower case), digits and the three characters
2261 A @dfn{symbol} is one or more characters chosen from the set of all
2262 letters (both upper and lower case), digits and the three characters
2263 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
2269 On most machines, you can also use @code{$} in symbol names; exceptions
2270 are noted in @ref{Machine Dependencies}.
2272 No symbol may begin with a digit. Case is significant.
2273 There is no length limit: all characters are significant. Symbols are
2274 delimited by characters not in that set, or by the beginning of a file
2275 (since the source program must end with a newline, the end of a file is
2276 not a possible symbol delimiter). @xref{Symbols}.
2277 @cindex length of symbols
2282 @cindex statements, structure of
2283 @cindex line separator character
2284 @cindex statement separator character
2286 @ifclear abnormal-separator
2287 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
2288 semicolon (@samp{;}). The newline or semicolon is considered part of
2289 the preceding statement. Newlines and semicolons within character
2290 constants are an exception: they do not end statements.
2292 @ifset abnormal-separator
2294 A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
2295 point (@samp{!}). The newline or exclamation point is considered part of the
2296 preceding statement. Newlines and exclamation points within character
2297 constants are an exception: they do not end statements.
2300 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
2301 H8/300) a dollar sign (@samp{$}); or (for the Renesas-SH) a semicolon
2302 (@samp{;}). The newline or separator character is considered part of
2303 the preceding statement. Newlines and separators within character
2304 constants are an exception: they do not end statements.
2309 A @dfn{statement} ends at a newline character (@samp{\n}) or line
2310 separator character. (The line separator is usually @samp{;}, unless this
2311 conflicts with the comment character; see @ref{Machine Dependencies}.) The
2312 newline or separator character is considered part of the preceding
2313 statement. Newlines and separators within character constants are an
2314 exception: they do not end statements.
2317 @cindex newline, required at file end
2318 @cindex EOF, newline must precede
2319 It is an error to end any statement with end-of-file: the last
2320 character of any input file should be a newline.@refill
2322 An empty statement is allowed, and may include whitespace. It is ignored.
2324 @cindex instructions and directives
2325 @cindex directives and instructions
2326 @c "key symbol" is not used elsewhere in the document; seems pedantic to
2327 @c @defn{} it in that case, as was done previously... doc@cygnus.com,
2329 A statement begins with zero or more labels, optionally followed by a
2330 key symbol which determines what kind of statement it is. The key
2331 symbol determines the syntax of the rest of the statement. If the
2332 symbol begins with a dot @samp{.} then the statement is an assembler
2333 directive: typically valid for any computer. If the symbol begins with
2334 a letter the statement is an assembly language @dfn{instruction}: it
2335 assembles into a machine language instruction.
2337 Different versions of @command{@value{AS}} for different computers
2338 recognize different instructions. In fact, the same symbol may
2339 represent a different instruction in a different computer's assembly
2343 @cindex @code{:} (label)
2344 @cindex label (@code{:})
2345 A label is a symbol immediately followed by a colon (@code{:}).
2346 Whitespace before a label or after a colon is permitted, but you may not
2347 have whitespace between a label's symbol and its colon. @xref{Labels}.
2350 For HPPA targets, labels need not be immediately followed by a colon, but
2351 the definition of a label must begin in column zero. This also implies that
2352 only one label may be defined on each line.
2356 label: .directive followed by something
2357 another_label: # This is an empty statement.
2358 instruction operand_1, operand_2, @dots{}
2365 A constant is a number, written so that its value is known by
2366 inspection, without knowing any context. Like this:
2369 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
2370 .ascii "Ring the bell\7" # A string constant.
2371 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
2372 .float 0f-314159265358979323846264338327\
2373 95028841971.693993751E-40 # - pi, a flonum.
2378 * Characters:: Character Constants
2379 * Numbers:: Number Constants
2383 @subsection Character Constants
2385 @cindex character constants
2386 @cindex constants, character
2387 There are two kinds of character constants. A @dfn{character} stands
2388 for one character in one byte and its value may be used in
2389 numeric expressions. String constants (properly called string
2390 @emph{literals}) are potentially many bytes and their values may not be
2391 used in arithmetic expressions.
2395 * Chars:: Characters
2399 @subsubsection Strings
2401 @cindex string constants
2402 @cindex constants, string
2403 A @dfn{string} is written between double-quotes. It may contain
2404 double-quotes or null characters. The way to get special characters
2405 into a string is to @dfn{escape} these characters: precede them with
2406 a backslash @samp{\} character. For example @samp{\\} represents
2407 one backslash: the first @code{\} is an escape which tells
2408 @command{@value{AS}} to interpret the second character literally as a backslash
2409 (which prevents @command{@value{AS}} from recognizing the second @code{\} as an
2410 escape character). The complete list of escapes follows.
2412 @cindex escape codes, character
2413 @cindex character escape codes
2416 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
2418 @cindex @code{\b} (backspace character)
2419 @cindex backspace (@code{\b})
2421 Mnemonic for backspace; for ASCII this is octal code 010.
2424 @c Mnemonic for EOText; for ASCII this is octal code 004.
2426 @cindex @code{\f} (formfeed character)
2427 @cindex formfeed (@code{\f})
2429 Mnemonic for FormFeed; for ASCII this is octal code 014.
2431 @cindex @code{\n} (newline character)
2432 @cindex newline (@code{\n})
2434 Mnemonic for newline; for ASCII this is octal code 012.
2437 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
2439 @cindex @code{\r} (carriage return character)
2440 @cindex carriage return (@code{\r})
2442 Mnemonic for carriage-Return; for ASCII this is octal code 015.
2445 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
2446 @c other assemblers.
2448 @cindex @code{\t} (tab)
2449 @cindex tab (@code{\t})
2451 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
2454 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
2455 @c @item \x @var{digit} @var{digit} @var{digit}
2456 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
2458 @cindex @code{\@var{ddd}} (octal character code)
2459 @cindex octal character code (@code{\@var{ddd}})
2460 @item \ @var{digit} @var{digit} @var{digit}
2461 An octal character code. The numeric code is 3 octal digits.
2462 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
2463 for example, @code{\008} has the value 010, and @code{\009} the value 011.
2465 @cindex @code{\@var{xd...}} (hex character code)
2466 @cindex hex character code (@code{\@var{xd...}})
2467 @item \@code{x} @var{hex-digits...}
2468 A hex character code. All trailing hex digits are combined. Either upper or
2469 lower case @code{x} works.
2471 @cindex @code{\\} (@samp{\} character)
2472 @cindex backslash (@code{\\})
2474 Represents one @samp{\} character.
2477 @c Represents one @samp{'} (accent acute) character.
2478 @c This is needed in single character literals
2479 @c (@xref{Characters,,Character Constants}.) to represent
2482 @cindex @code{\"} (doublequote character)
2483 @cindex doublequote (@code{\"})
2485 Represents one @samp{"} character. Needed in strings to represent
2486 this character, because an unescaped @samp{"} would end the string.
2488 @item \ @var{anything-else}
2489 Any other character when escaped by @kbd{\} gives a warning, but
2490 assembles as if the @samp{\} was not present. The idea is that if
2491 you used an escape sequence you clearly didn't want the literal
2492 interpretation of the following character. However @command{@value{AS}} has no
2493 other interpretation, so @command{@value{AS}} knows it is giving you the wrong
2494 code and warns you of the fact.
2497 Which characters are escapable, and what those escapes represent,
2498 varies widely among assemblers. The current set is what we think
2499 the BSD 4.2 assembler recognizes, and is a subset of what most C
2500 compilers recognize. If you are in doubt, do not use an escape
2504 @subsubsection Characters
2506 @cindex single character constant
2507 @cindex character, single
2508 @cindex constant, single character
2509 A single character may be written as a single quote immediately
2510 followed by that character. The same escapes apply to characters as
2511 to strings. So if you want to write the character backslash, you
2512 must write @kbd{'\\} where the first @code{\} escapes the second
2513 @code{\}. As you can see, the quote is an acute accent, not a
2514 grave accent. A newline
2516 @ifclear abnormal-separator
2517 (or semicolon @samp{;})
2519 @ifset abnormal-separator
2521 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
2526 immediately following an acute accent is taken as a literal character
2527 and does not count as the end of a statement. The value of a character
2528 constant in a numeric expression is the machine's byte-wide code for
2529 that character. @command{@value{AS}} assumes your character code is ASCII:
2530 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
2533 @subsection Number Constants
2535 @cindex constants, number
2536 @cindex number constants
2537 @command{@value{AS}} distinguishes three kinds of numbers according to how they
2538 are stored in the target machine. @emph{Integers} are numbers that
2539 would fit into an @code{int} in the C language. @emph{Bignums} are
2540 integers, but they are stored in more than 32 bits. @emph{Flonums}
2541 are floating point numbers, described below.
2544 * Integers:: Integers
2549 * Bit Fields:: Bit Fields
2555 @subsubsection Integers
2557 @cindex constants, integer
2559 @cindex binary integers
2560 @cindex integers, binary
2561 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
2562 the binary digits @samp{01}.
2564 @cindex octal integers
2565 @cindex integers, octal
2566 An octal integer is @samp{0} followed by zero or more of the octal
2567 digits (@samp{01234567}).
2569 @cindex decimal integers
2570 @cindex integers, decimal
2571 A decimal integer starts with a non-zero digit followed by zero or
2572 more digits (@samp{0123456789}).
2574 @cindex hexadecimal integers
2575 @cindex integers, hexadecimal
2576 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
2577 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
2579 Integers have the usual values. To denote a negative integer, use
2580 the prefix operator @samp{-} discussed under expressions
2581 (@pxref{Prefix Ops,,Prefix Operators}).
2584 @subsubsection Bignums
2587 @cindex constants, bignum
2588 A @dfn{bignum} has the same syntax and semantics as an integer
2589 except that the number (or its negative) takes more than 32 bits to
2590 represent in binary. The distinction is made because in some places
2591 integers are permitted while bignums are not.
2594 @subsubsection Flonums
2596 @cindex floating point numbers
2597 @cindex constants, floating point
2599 @cindex precision, floating point
2600 A @dfn{flonum} represents a floating point number. The translation is
2601 indirect: a decimal floating point number from the text is converted by
2602 @command{@value{AS}} to a generic binary floating point number of more than
2603 sufficient precision. This generic floating point number is converted
2604 to a particular computer's floating point format (or formats) by a
2605 portion of @command{@value{AS}} specialized to that computer.
2607 A flonum is written by writing (in order)
2612 (@samp{0} is optional on the HPPA.)
2616 A letter, to tell @command{@value{AS}} the rest of the number is a flonum.
2618 @kbd{e} is recommended. Case is not important.
2620 @c FIXME: verify if flonum syntax really this vague for most cases
2621 (Any otherwise illegal letter works here, but that might be changed. Vax BSD
2622 4.2 assembler seems to allow any of @samp{defghDEFGH}.)
2625 On the H8/300, Renesas / SuperH SH,
2626 and AMD 29K architectures, the letter must be
2627 one of the letters @samp{DFPRSX} (in upper or lower case).
2629 On the ARC, the letter must be one of the letters @samp{DFRS}
2630 (in upper or lower case).
2632 On the Intel 960 architecture, the letter must be
2633 one of the letters @samp{DFT} (in upper or lower case).
2635 On the HPPA architecture, the letter must be @samp{E} (upper case only).
2639 One of the letters @samp{DFRS} (in upper or lower case).
2642 One of the letters @samp{DFPRSX} (in upper or lower case).
2645 The letter @samp{E} (upper case only).
2648 One of the letters @samp{DFT} (in upper or lower case).
2653 An optional sign: either @samp{+} or @samp{-}.
2656 An optional @dfn{integer part}: zero or more decimal digits.
2659 An optional @dfn{fractional part}: @samp{.} followed by zero
2660 or more decimal digits.
2663 An optional exponent, consisting of:
2667 An @samp{E} or @samp{e}.
2668 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
2669 @c principle this can perfectly well be different on different targets.
2671 Optional sign: either @samp{+} or @samp{-}.
2673 One or more decimal digits.
2678 At least one of the integer part or the fractional part must be
2679 present. The floating point number has the usual base-10 value.
2681 @command{@value{AS}} does all processing using integers. Flonums are computed
2682 independently of any floating point hardware in the computer running
2683 @command{@value{AS}}.
2687 @c Bit fields are written as a general facility but are also controlled
2688 @c by a conditional-compilation flag---which is as of now (21mar91)
2689 @c turned on only by the i960 config of GAS.
2691 @subsubsection Bit Fields
2694 @cindex constants, bit field
2695 You can also define numeric constants as @dfn{bit fields}.
2696 Specify two numbers separated by a colon---
2698 @var{mask}:@var{value}
2701 @command{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
2704 The resulting number is then packed
2706 @c this conditional paren in case bit fields turned on elsewhere than 960
2707 (in host-dependent byte order)
2709 into a field whose width depends on which assembler directive has the
2710 bit-field as its argument. Overflow (a result from the bitwise and
2711 requiring more binary digits to represent) is not an error; instead,
2712 more constants are generated, of the specified width, beginning with the
2713 least significant digits.@refill
2715 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
2716 @code{.short}, and @code{.word} accept bit-field arguments.
2721 @chapter Sections and Relocation
2726 * Secs Background:: Background
2727 * Ld Sections:: Linker Sections
2728 * As Sections:: Assembler Internal Sections
2729 * Sub-Sections:: Sub-Sections
2733 @node Secs Background
2736 Roughly, a section is a range of addresses, with no gaps; all data
2737 ``in'' those addresses is treated the same for some particular purpose.
2738 For example there may be a ``read only'' section.
2740 @cindex linker, and assembler
2741 @cindex assembler, and linker
2742 The linker @code{@value{LD}} reads many object files (partial programs) and
2743 combines their contents to form a runnable program. When @command{@value{AS}}
2744 emits an object file, the partial program is assumed to start at address 0.
2745 @code{@value{LD}} assigns the final addresses for the partial program, so that
2746 different partial programs do not overlap. This is actually an
2747 oversimplification, but it suffices to explain how @command{@value{AS}} uses
2750 @code{@value{LD}} moves blocks of bytes of your program to their run-time
2751 addresses. These blocks slide to their run-time addresses as rigid
2752 units; their length does not change and neither does the order of bytes
2753 within them. Such a rigid unit is called a @emph{section}. Assigning
2754 run-time addresses to sections is called @dfn{relocation}. It includes
2755 the task of adjusting mentions of object-file addresses so they refer to
2756 the proper run-time addresses.
2758 For the H8/300, and for the Renesas / SuperH SH,
2759 @command{@value{AS}} pads sections if needed to
2760 ensure they end on a word (sixteen bit) boundary.
2763 @cindex standard assembler sections
2764 An object file written by @command{@value{AS}} has at least three sections, any
2765 of which may be empty. These are named @dfn{text}, @dfn{data} and
2770 When it generates COFF or ELF output,
2772 @command{@value{AS}} can also generate whatever other named sections you specify
2773 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
2774 If you do not use any directives that place output in the @samp{.text}
2775 or @samp{.data} sections, these sections still exist, but are empty.
2780 When @command{@value{AS}} generates SOM or ELF output for the HPPA,
2782 @command{@value{AS}} can also generate whatever other named sections you
2783 specify using the @samp{.space} and @samp{.subspace} directives. See
2784 @cite{HP9000 Series 800 Assembly Language Reference Manual}
2785 (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
2786 assembler directives.
2789 Additionally, @command{@value{AS}} uses different names for the standard
2790 text, data, and bss sections when generating SOM output. Program text
2791 is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
2792 BSS into @samp{$BSS$}.
2796 Within the object file, the text section starts at address @code{0}, the
2797 data section follows, and the bss section follows the data section.
2800 When generating either SOM or ELF output files on the HPPA, the text
2801 section starts at address @code{0}, the data section at address
2802 @code{0x4000000}, and the bss section follows the data section.
2805 To let @code{@value{LD}} know which data changes when the sections are
2806 relocated, and how to change that data, @command{@value{AS}} also writes to the
2807 object file details of the relocation needed. To perform relocation
2808 @code{@value{LD}} must know, each time an address in the object
2812 Where in the object file is the beginning of this reference to
2815 How long (in bytes) is this reference?
2817 Which section does the address refer to? What is the numeric value of
2819 (@var{address}) @minus{} (@var{start-address of section})?
2822 Is the reference to an address ``Program-Counter relative''?
2825 @cindex addresses, format of
2826 @cindex section-relative addressing
2827 In fact, every address @command{@value{AS}} ever uses is expressed as
2829 (@var{section}) + (@var{offset into section})
2832 Further, most expressions @command{@value{AS}} computes have this section-relative
2835 (For some object formats, such as SOM for the HPPA, some expressions are
2836 symbol-relative instead.)
2839 In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset
2840 @var{N} into section @var{secname}.''
2842 Apart from text, data and bss sections you need to know about the
2843 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
2844 addresses in the absolute section remain unchanged. For example, address
2845 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by
2846 @code{@value{LD}}. Although the linker never arranges two partial programs'
2847 data sections with overlapping addresses after linking, @emph{by definition}
2848 their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one
2849 part of a program is always the same address when the program is running as
2850 address @code{@{absolute@ 239@}} in any other part of the program.
2852 The idea of sections is extended to the @dfn{undefined} section. Any
2853 address whose section is unknown at assembly time is by definition
2854 rendered @{undefined @var{U}@}---where @var{U} is filled in later.
2855 Since numbers are always defined, the only way to generate an undefined
2856 address is to mention an undefined symbol. A reference to a named
2857 common block would be such a symbol: its value is unknown at assembly
2858 time so it has section @emph{undefined}.
2860 By analogy the word @emph{section} is used to describe groups of sections in
2861 the linked program. @code{@value{LD}} puts all partial programs' text
2862 sections in contiguous addresses in the linked program. It is
2863 customary to refer to the @emph{text section} of a program, meaning all
2864 the addresses of all partial programs' text sections. Likewise for
2865 data and bss sections.
2867 Some sections are manipulated by @code{@value{LD}}; others are invented for
2868 use of @command{@value{AS}} and have no meaning except during assembly.
2871 @section Linker Sections
2872 @code{@value{LD}} deals with just four kinds of sections, summarized below.
2877 @cindex named sections
2878 @cindex sections, named
2879 @item named sections
2882 @cindex text section
2883 @cindex data section
2887 These sections hold your program. @command{@value{AS}} and @code{@value{LD}} treat them as
2888 separate but equal sections. Anything you can say of one section is
2891 When the program is running, however, it is
2892 customary for the text section to be unalterable. The
2893 text section is often shared among processes: it contains
2894 instructions, constants and the like. The data section of a running
2895 program is usually alterable: for example, C variables would be stored
2896 in the data section.
2901 This section contains zeroed bytes when your program begins running. It
2902 is used to hold uninitialized variables or common storage. The length of
2903 each partial program's bss section is important, but because it starts
2904 out containing zeroed bytes there is no need to store explicit zero
2905 bytes in the object file. The bss section was invented to eliminate
2906 those explicit zeros from object files.
2908 @cindex absolute section
2909 @item absolute section
2910 Address 0 of this section is always ``relocated'' to runtime address 0.
2911 This is useful if you want to refer to an address that @code{@value{LD}} must
2912 not change when relocating. In this sense we speak of absolute
2913 addresses being ``unrelocatable'': they do not change during relocation.
2915 @cindex undefined section
2916 @item undefined section
2917 This ``section'' is a catch-all for address references to objects not in
2918 the preceding sections.
2919 @c FIXME: ref to some other doc on obj-file formats could go here.
2922 @cindex relocation example
2923 An idealized example of three relocatable sections follows.
2925 The example uses the traditional section names @samp{.text} and @samp{.data}.
2927 Memory addresses are on the horizontal axis.
2931 @c END TEXI2ROFF-KILL
2934 partial program # 1: |ttttt|dddd|00|
2941 partial program # 2: |TTT|DDD|000|
2944 +--+---+-----+--+----+---+-----+~~
2945 linked program: | |TTT|ttttt| |dddd|DDD|00000|
2946 +--+---+-----+--+----+---+-----+~~
2948 addresses: 0 @dots{}
2955 \line{\it Partial program \#1: \hfil}
2956 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2957 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
2959 \line{\it Partial program \#2: \hfil}
2960 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2961 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
2963 \line{\it linked program: \hfil}
2964 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
2965 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
2966 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
2967 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
2969 \line{\it addresses: \hfil}
2973 @c END TEXI2ROFF-KILL
2976 @section Assembler Internal Sections
2978 @cindex internal assembler sections
2979 @cindex sections in messages, internal
2980 These sections are meant only for the internal use of @command{@value{AS}}. They
2981 have no meaning at run-time. You do not really need to know about these
2982 sections for most purposes; but they can be mentioned in @command{@value{AS}}
2983 warning messages, so it might be helpful to have an idea of their
2984 meanings to @command{@value{AS}}. These sections are used to permit the
2985 value of every expression in your assembly language program to be a
2986 section-relative address.
2989 @cindex assembler internal logic error
2990 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
2991 An internal assembler logic error has been found. This means there is a
2992 bug in the assembler.
2994 @cindex expr (internal section)
2996 The assembler stores complex expression internally as combinations of
2997 symbols. When it needs to represent an expression as a symbol, it puts
2998 it in the expr section.
3000 @c FIXME item transfer[t] vector preload
3001 @c FIXME item transfer[t] vector postload
3002 @c FIXME item register
3006 @section Sub-Sections
3008 @cindex numbered subsections
3009 @cindex grouping data
3015 fall into two sections: text and data.
3017 You may have separate groups of
3019 data in named sections
3023 data in named sections
3029 that you want to end up near to each other in the object file, even though they
3030 are not contiguous in the assembler source. @command{@value{AS}} allows you to
3031 use @dfn{subsections} for this purpose. Within each section, there can be
3032 numbered subsections with values from 0 to 8192. Objects assembled into the
3033 same subsection go into the object file together with other objects in the same
3034 subsection. For example, a compiler might want to store constants in the text
3035 section, but might not want to have them interspersed with the program being
3036 assembled. In this case, the compiler could issue a @samp{.text 0} before each
3037 section of code being output, and a @samp{.text 1} before each group of
3038 constants being output.
3040 Subsections are optional. If you do not use subsections, everything
3041 goes in subsection number zero.
3044 Each subsection is zero-padded up to a multiple of four bytes.
3045 (Subsections may be padded a different amount on different flavors
3046 of @command{@value{AS}}.)
3050 On the H8/300 platform, each subsection is zero-padded to a word
3051 boundary (two bytes).
3052 The same is true on the Renesas SH.
3055 @c FIXME section padding (alignment)?
3056 @c Rich Pixley says padding here depends on target obj code format; that
3057 @c doesn't seem particularly useful to say without further elaboration,
3058 @c so for now I say nothing about it. If this is a generic BFD issue,
3059 @c these paragraphs might need to vanish from this manual, and be
3060 @c discussed in BFD chapter of binutils (or some such).
3064 Subsections appear in your object file in numeric order, lowest numbered
3065 to highest. (All this to be compatible with other people's assemblers.)
3066 The object file contains no representation of subsections; @code{@value{LD}} and
3067 other programs that manipulate object files see no trace of them.
3068 They just see all your text subsections as a text section, and all your
3069 data subsections as a data section.
3071 To specify which subsection you want subsequent statements assembled
3072 into, use a numeric argument to specify it, in a @samp{.text
3073 @var{expression}} or a @samp{.data @var{expression}} statement.
3076 When generating COFF output, you
3081 can also use an extra subsection
3082 argument with arbitrary named sections: @samp{.section @var{name},
3087 When generating ELF output, you
3092 can also use the @code{.subsection} directive (@pxref{SubSection})
3093 to specify a subsection: @samp{.subsection @var{expression}}.
3095 @var{Expression} should be an absolute expression
3096 (@pxref{Expressions}). If you just say @samp{.text} then @samp{.text 0}
3097 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
3098 begins in @code{text 0}. For instance:
3100 .text 0 # The default subsection is text 0 anyway.
3101 .ascii "This lives in the first text subsection. *"
3103 .ascii "But this lives in the second text subsection."
3105 .ascii "This lives in the data section,"
3106 .ascii "in the first data subsection."
3108 .ascii "This lives in the first text section,"
3109 .ascii "immediately following the asterisk (*)."
3112 Each section has a @dfn{location counter} incremented by one for every byte
3113 assembled into that section. Because subsections are merely a convenience
3114 restricted to @command{@value{AS}} there is no concept of a subsection location
3115 counter. There is no way to directly manipulate a location counter---but the
3116 @code{.align} directive changes it, and any label definition captures its
3117 current value. The location counter of the section where statements are being
3118 assembled is said to be the @dfn{active} location counter.
3121 @section bss Section
3124 @cindex common variable storage
3125 The bss section is used for local common variable storage.
3126 You may allocate address space in the bss section, but you may
3127 not dictate data to load into it before your program executes. When
3128 your program starts running, all the contents of the bss
3129 section are zeroed bytes.
3131 The @code{.lcomm} pseudo-op defines a symbol in the bss section; see
3132 @ref{Lcomm,,@code{.lcomm}}.
3134 The @code{.comm} pseudo-op may be used to declare a common symbol, which is
3135 another form of uninitialized symbol; see @ref{Comm,,@code{.comm}}.
3138 When assembling for a target which supports multiple sections, such as ELF or
3139 COFF, you may switch into the @code{.bss} section and define symbols as usual;
3140 see @ref{Section,,@code{.section}}. You may only assemble zero values into the
3141 section. Typically the section will only contain symbol definitions and
3142 @code{.skip} directives (@pxref{Skip,,@code{.skip}}).
3149 Symbols are a central concept: the programmer uses symbols to name
3150 things, the linker uses symbols to link, and the debugger uses symbols
3154 @cindex debuggers, and symbol order
3155 @emph{Warning:} @command{@value{AS}} does not place symbols in the object file in
3156 the same order they were declared. This may break some debuggers.
3161 * Setting Symbols:: Giving Symbols Other Values
3162 * Symbol Names:: Symbol Names
3163 * Dot:: The Special Dot Symbol
3164 * Symbol Attributes:: Symbol Attributes
3171 A @dfn{label} is written as a symbol immediately followed by a colon
3172 @samp{:}. The symbol then represents the current value of the
3173 active location counter, and is, for example, a suitable instruction
3174 operand. You are warned if you use the same symbol to represent two
3175 different locations: the first definition overrides any other
3179 On the HPPA, the usual form for a label need not be immediately followed by a
3180 colon, but instead must start in column zero. Only one label may be defined on
3181 a single line. To work around this, the HPPA version of @command{@value{AS}} also
3182 provides a special directive @code{.label} for defining labels more flexibly.
3185 @node Setting Symbols
3186 @section Giving Symbols Other Values
3188 @cindex assigning values to symbols
3189 @cindex symbol values, assigning
3190 A symbol can be given an arbitrary value by writing a symbol, followed
3191 by an equals sign @samp{=}, followed by an expression
3192 (@pxref{Expressions}). This is equivalent to using the @code{.set}
3193 directive. @xref{Set,,@code{.set}}. In the same way, using a double
3194 equals sign @samp{=}@samp{=} here represents an equivalent of the
3195 @code{.eqv} directive. @xref{Eqv,,@code{.eqv}}.
3198 @section Symbol Names
3200 @cindex symbol names
3201 @cindex names, symbol
3202 @ifclear SPECIAL-SYMS
3203 Symbol names begin with a letter or with one of @samp{._}. On most
3204 machines, you can also use @code{$} in symbol names; exceptions are
3205 noted in @ref{Machine Dependencies}. That character may be followed by any
3206 string of digits, letters, dollar signs (unless otherwise noted for a
3207 particular target machine), and underscores.
3211 Symbol names begin with a letter or with one of @samp{._}. On the
3212 Renesas SH you can also use @code{$} in symbol names. That
3213 character may be followed by any string of digits, letters, dollar signs (save
3214 on the H8/300), and underscores.
3218 Case of letters is significant: @code{foo} is a different symbol name
3221 Each symbol has exactly one name. Each name in an assembly language program
3222 refers to exactly one symbol. You may use that symbol name any number of times
3225 @subheading Local Symbol Names
3227 @cindex local symbol names
3228 @cindex symbol names, local
3229 A local symbol is any symbol beginning with certain local label prefixes.
3230 By default, the local label prefix is @samp{.L} for ELF systems or
3231 @samp{L} for traditional a.out systems, but each target may have its own
3232 set of local label prefixes.
3234 On the HPPA local symbols begin with @samp{L$}.
3237 Local symbols are defined and used within the assembler, but they are
3238 normally not saved in object files. Thus, they are not visible when debugging.
3239 You may use the @samp{-L} option (@pxref{L, ,Include Local Symbols:
3240 @option{-L}}) to retain the local symbols in the object files.
3242 @subheading Local Labels
3244 @cindex local labels
3245 @cindex temporary symbol names
3246 @cindex symbol names, temporary
3247 Local labels help compilers and programmers use names temporarily.
3248 They create symbols which are guaranteed to be unique over the entire scope of
3249 the input source code and which can be referred to by a simple notation.
3250 To define a local label, write a label of the form @samp{@b{N}:} (where @b{N}
3251 represents any positive integer). To refer to the most recent previous
3252 definition of that label write @samp{@b{N}b}, using the same number as when
3253 you defined the label. To refer to the next definition of a local label, write
3254 @samp{@b{N}f}---the @samp{b} stands for ``backwards'' and the @samp{f} stands
3257 There is no restriction on how you can use these labels, and you can reuse them
3258 too. So that it is possible to repeatedly define the same local label (using
3259 the same number @samp{@b{N}}), although you can only refer to the most recently
3260 defined local label of that number (for a backwards reference) or the next
3261 definition of a specific local label for a forward reference. It is also worth
3262 noting that the first 10 local labels (@samp{@b{0:}}@dots{}@samp{@b{9:}}) are
3263 implemented in a slightly more efficient manner than the others.
3274 Which is the equivalent of:
3277 label_1: branch label_3
3278 label_2: branch label_1
3279 label_3: branch label_4
3280 label_4: branch label_3
3283 Local label names are only a notational device. They are immediately
3284 transformed into more conventional symbol names before the assembler uses them.
3285 The symbol names are stored in the symbol table, appear in error messages, and
3286 are optionally emitted to the object file. The names are constructed using
3290 @item @emph{local label prefix}
3291 All local symbols begin with the system-specific local label prefix.
3292 Normally both @command{@value{AS}} and @code{@value{LD}} forget symbols
3293 that start with the local label prefix. These labels are
3294 used for symbols you are never intended to see. If you use the
3295 @samp{-L} option then @command{@value{AS}} retains these symbols in the
3296 object file. If you also instruct @code{@value{LD}} to retain these symbols,
3297 you may use them in debugging.
3300 This is the number that was used in the local label definition. So if the
3301 label is written @samp{55:} then the number is @samp{55}.
3304 This unusual character is included so you do not accidentally invent a symbol
3305 of the same name. The character has ASCII value of @samp{\002} (control-B).
3307 @item @emph{ordinal number}
3308 This is a serial number to keep the labels distinct. The first definition of
3309 @samp{0:} gets the number @samp{1}. The 15th definition of @samp{0:} gets the
3310 number @samp{15}, and so on. Likewise the first definition of @samp{1:} gets
3311 the number @samp{1} and its 15th definition gets @samp{15} as well.
3314 So for example, the first @code{1:} may be named @code{.L1@kbd{C-B}1}, and
3315 the 44th @code{3:} may be named @code{.L3@kbd{C-B}44}.
3317 @subheading Dollar Local Labels
3318 @cindex dollar local symbols
3320 @code{@value{AS}} also supports an even more local form of local labels called
3321 dollar labels. These labels go out of scope (i.e., they become undefined) as
3322 soon as a non-local label is defined. Thus they remain valid for only a small
3323 region of the input source code. Normal local labels, by contrast, remain in
3324 scope for the entire file, or until they are redefined by another occurrence of
3325 the same local label.
3327 Dollar labels are defined in exactly the same way as ordinary local labels,
3328 except that instead of being terminated by a colon, they are terminated by a
3329 dollar sign, e.g., @samp{@b{55$}}.
3331 They can also be distinguished from ordinary local labels by their transformed
3332 names which use ASCII character @samp{\001} (control-A) as the magic character
3333 to distinguish them from ordinary labels. For example, the fifth definition of
3334 @samp{6$} may be named @samp{.L6@kbd{C-A}5}.
3337 @section The Special Dot Symbol
3339 @cindex dot (symbol)
3340 @cindex @code{.} (symbol)
3341 @cindex current address
3342 @cindex location counter
3343 The special symbol @samp{.} refers to the current address that
3344 @command{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
3345 .long .} defines @code{melvin} to contain its own address.
3346 Assigning a value to @code{.} is treated the same as a @code{.org}
3347 directive. Thus, the expression @samp{.=.+4} is the same as saying
3348 @ifclear no-space-dir
3352 @node Symbol Attributes
3353 @section Symbol Attributes
3355 @cindex symbol attributes
3356 @cindex attributes, symbol
3357 Every symbol has, as well as its name, the attributes ``Value'' and
3358 ``Type''. Depending on output format, symbols can also have auxiliary
3361 The detailed definitions are in @file{a.out.h}.
3364 If you use a symbol without defining it, @command{@value{AS}} assumes zero for
3365 all these attributes, and probably won't warn you. This makes the
3366 symbol an externally defined symbol, which is generally what you
3370 * Symbol Value:: Value
3371 * Symbol Type:: Type
3374 * a.out Symbols:: Symbol Attributes: @code{a.out}
3378 * a.out Symbols:: Symbol Attributes: @code{a.out}
3381 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
3386 * COFF Symbols:: Symbol Attributes for COFF
3389 * SOM Symbols:: Symbol Attributes for SOM
3396 @cindex value of a symbol
3397 @cindex symbol value
3398 The value of a symbol is (usually) 32 bits. For a symbol which labels a
3399 location in the text, data, bss or absolute sections the value is the
3400 number of addresses from the start of that section to the label.
3401 Naturally for text, data and bss sections the value of a symbol changes
3402 as @code{@value{LD}} changes section base addresses during linking. Absolute
3403 symbols' values do not change during linking: that is why they are
3406 The value of an undefined symbol is treated in a special way. If it is
3407 0 then the symbol is not defined in this assembler source file, and
3408 @code{@value{LD}} tries to determine its value from other files linked into the
3409 same program. You make this kind of symbol simply by mentioning a symbol
3410 name without defining it. A non-zero value represents a @code{.comm}
3411 common declaration. The value is how much common storage to reserve, in
3412 bytes (addresses). The symbol refers to the first address of the
3418 @cindex type of a symbol
3420 The type attribute of a symbol contains relocation (section)
3421 information, any flag settings indicating that a symbol is external, and
3422 (optionally), other information for linkers and debuggers. The exact
3423 format depends on the object-code output format in use.
3428 @c The following avoids a "widow" subsection title. @group would be
3429 @c better if it were available outside examples.
3432 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
3434 @cindex @code{b.out} symbol attributes
3435 @cindex symbol attributes, @code{b.out}
3436 These symbol attributes appear only when @command{@value{AS}} is configured for
3437 one of the Berkeley-descended object output formats---@code{a.out} or
3443 @subsection Symbol Attributes: @code{a.out}
3445 @cindex @code{a.out} symbol attributes
3446 @cindex symbol attributes, @code{a.out}
3452 @subsection Symbol Attributes: @code{a.out}
3454 @cindex @code{a.out} symbol attributes
3455 @cindex symbol attributes, @code{a.out}
3459 * Symbol Desc:: Descriptor
3460 * Symbol Other:: Other
3464 @subsubsection Descriptor
3466 @cindex descriptor, of @code{a.out} symbol
3467 This is an arbitrary 16-bit value. You may establish a symbol's
3468 descriptor value by using a @code{.desc} statement
3469 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
3470 @command{@value{AS}}.
3473 @subsubsection Other
3475 @cindex other attribute, of @code{a.out} symbol
3476 This is an arbitrary 8-bit value. It means nothing to @command{@value{AS}}.
3481 @subsection Symbol Attributes for COFF
3483 @cindex COFF symbol attributes
3484 @cindex symbol attributes, COFF
3486 The COFF format supports a multitude of auxiliary symbol attributes;
3487 like the primary symbol attributes, they are set between @code{.def} and
3488 @code{.endef} directives.
3490 @subsubsection Primary Attributes
3492 @cindex primary attributes, COFF symbols
3493 The symbol name is set with @code{.def}; the value and type,
3494 respectively, with @code{.val} and @code{.type}.
3496 @subsubsection Auxiliary Attributes
3498 @cindex auxiliary attributes, COFF symbols
3499 The @command{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
3500 @code{.size}, @code{.tag}, and @code{.weak} can generate auxiliary symbol
3501 table information for COFF.
3506 @subsection Symbol Attributes for SOM
3508 @cindex SOM symbol attributes
3509 @cindex symbol attributes, SOM
3511 The SOM format for the HPPA supports a multitude of symbol attributes set with
3512 the @code{.EXPORT} and @code{.IMPORT} directives.
3514 The attributes are described in @cite{HP9000 Series 800 Assembly
3515 Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
3516 @code{EXPORT} assembler directive documentation.
3520 @chapter Expressions
3524 @cindex numeric values
3525 An @dfn{expression} specifies an address or numeric value.
3526 Whitespace may precede and/or follow an expression.
3528 The result of an expression must be an absolute number, or else an offset into
3529 a particular section. If an expression is not absolute, and there is not
3530 enough information when @command{@value{AS}} sees the expression to know its
3531 section, a second pass over the source program might be necessary to interpret
3532 the expression---but the second pass is currently not implemented.
3533 @command{@value{AS}} aborts with an error message in this situation.
3536 * Empty Exprs:: Empty Expressions
3537 * Integer Exprs:: Integer Expressions
3541 @section Empty Expressions
3543 @cindex empty expressions
3544 @cindex expressions, empty
3545 An empty expression has no value: it is just whitespace or null.
3546 Wherever an absolute expression is required, you may omit the
3547 expression, and @command{@value{AS}} assumes a value of (absolute) 0. This
3548 is compatible with other assemblers.
3551 @section Integer Expressions
3553 @cindex integer expressions
3554 @cindex expressions, integer
3555 An @dfn{integer expression} is one or more @emph{arguments} delimited
3556 by @emph{operators}.
3559 * Arguments:: Arguments
3560 * Operators:: Operators
3561 * Prefix Ops:: Prefix Operators
3562 * Infix Ops:: Infix Operators
3566 @subsection Arguments
3568 @cindex expression arguments
3569 @cindex arguments in expressions
3570 @cindex operands in expressions
3571 @cindex arithmetic operands
3572 @dfn{Arguments} are symbols, numbers or subexpressions. In other
3573 contexts arguments are sometimes called ``arithmetic operands''. In
3574 this manual, to avoid confusing them with the ``instruction operands'' of
3575 the machine language, we use the term ``argument'' to refer to parts of
3576 expressions only, reserving the word ``operand'' to refer only to machine
3577 instruction operands.
3579 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
3580 @var{section} is one of text, data, bss, absolute,
3581 or undefined. @var{NNN} is a signed, 2's complement 32 bit
3584 Numbers are usually integers.
3586 A number can be a flonum or bignum. In this case, you are warned
3587 that only the low order 32 bits are used, and @command{@value{AS}} pretends
3588 these 32 bits are an integer. You may write integer-manipulating
3589 instructions that act on exotic constants, compatible with other
3592 @cindex subexpressions
3593 Subexpressions are a left parenthesis @samp{(} followed by an integer
3594 expression, followed by a right parenthesis @samp{)}; or a prefix
3595 operator followed by an argument.
3598 @subsection Operators
3600 @cindex operators, in expressions
3601 @cindex arithmetic functions
3602 @cindex functions, in expressions
3603 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
3604 operators are followed by an argument. Infix operators appear
3605 between their arguments. Operators may be preceded and/or followed by
3609 @subsection Prefix Operator
3611 @cindex prefix operators
3612 @command{@value{AS}} has the following @dfn{prefix operators}. They each take
3613 one argument, which must be absolute.
3615 @c the tex/end tex stuff surrounding this small table is meant to make
3616 @c it align, on the printed page, with the similar table in the next
3617 @c section (which is inside an enumerate).
3619 \global\advance\leftskip by \itemindent
3624 @dfn{Negation}. Two's complement negation.
3626 @dfn{Complementation}. Bitwise not.
3630 \global\advance\leftskip by -\itemindent
3634 @subsection Infix Operators
3636 @cindex infix operators
3637 @cindex operators, permitted arguments
3638 @dfn{Infix operators} take two arguments, one on either side. Operators
3639 have precedence, but operations with equal precedence are performed left
3640 to right. Apart from @code{+} or @option{-}, both arguments must be
3641 absolute, and the result is absolute.
3644 @cindex operator precedence
3645 @cindex precedence of operators
3652 @dfn{Multiplication}.
3655 @dfn{Division}. Truncation is the same as the C operator @samp{/}
3661 @dfn{Shift Left}. Same as the C operator @samp{<<}.
3664 @dfn{Shift Right}. Same as the C operator @samp{>>}.
3668 Intermediate precedence
3673 @dfn{Bitwise Inclusive Or}.
3679 @dfn{Bitwise Exclusive Or}.
3682 @dfn{Bitwise Or Not}.
3689 @cindex addition, permitted arguments
3690 @cindex plus, permitted arguments
3691 @cindex arguments for addition
3693 @dfn{Addition}. If either argument is absolute, the result has the section of
3694 the other argument. You may not add together arguments from different
3697 @cindex subtraction, permitted arguments
3698 @cindex minus, permitted arguments
3699 @cindex arguments for subtraction
3701 @dfn{Subtraction}. If the right argument is absolute, the
3702 result has the section of the left argument.
3703 If both arguments are in the same section, the result is absolute.
3704 You may not subtract arguments from different sections.
3705 @c FIXME is there still something useful to say about undefined - undefined ?
3707 @cindex comparison expressions
3708 @cindex expressions, comparison
3713 @dfn{Is Not Equal To}
3717 @dfn{Is Greater Than}
3719 @dfn{Is Greater Than Or Equal To}
3721 @dfn{Is Less Than Or Equal To}
3723 The comparison operators can be used as infix operators. A true results has a
3724 value of -1 whereas a false result has a value of 0. Note, these operators
3725 perform signed comparisons.
3728 @item Lowest Precedence
3737 These two logical operations can be used to combine the results of sub
3738 expressions. Note, unlike the comparison operators a true result returns a
3739 value of 1 but a false results does still return 0. Also note that the logical
3740 or operator has a slightly lower precedence than logical and.
3745 In short, it's only meaningful to add or subtract the @emph{offsets} in an
3746 address; you can only have a defined section in one of the two arguments.
3749 @chapter Assembler Directives
3751 @cindex directives, machine independent
3752 @cindex pseudo-ops, machine independent
3753 @cindex machine independent directives
3754 All assembler directives have names that begin with a period (@samp{.}).
3755 The rest of the name is letters, usually in lower case.
3757 This chapter discusses directives that are available regardless of the
3758 target machine configuration for the @sc{gnu} assembler.
3760 Some machine configurations provide additional directives.
3761 @xref{Machine Dependencies}.
3764 @ifset machine-directives
3765 @xref{Machine Dependencies}, for additional directives.
3770 * Abort:: @code{.abort}
3772 * ABORT (COFF):: @code{.ABORT}
3775 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
3776 * Altmacro:: @code{.altmacro}
3777 * Ascii:: @code{.ascii "@var{string}"}@dots{}
3778 * Asciz:: @code{.asciz "@var{string}"}@dots{}
3779 * Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}}
3780 * Byte:: @code{.byte @var{expressions}}
3781 * Comm:: @code{.comm @var{symbol} , @var{length} }
3783 * CFI directives:: @code{.cfi_startproc}, @code{.cfi_endproc}, etc.
3785 * Data:: @code{.data @var{subsection}}
3787 * Def:: @code{.def @var{name}}
3790 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
3796 * Double:: @code{.double @var{flonums}}
3797 * Eject:: @code{.eject}
3798 * Else:: @code{.else}
3799 * Elseif:: @code{.elseif}
3802 * Endef:: @code{.endef}
3805 * Endfunc:: @code{.endfunc}
3806 * Endif:: @code{.endif}
3807 * Equ:: @code{.equ @var{symbol}, @var{expression}}
3808 * Equiv:: @code{.equiv @var{symbol}, @var{expression}}
3809 * Eqv:: @code{.eqv @var{symbol}, @var{expression}}
3811 * Error:: @code{.error @var{string}}
3812 * Exitm:: @code{.exitm}
3813 * Extern:: @code{.extern}
3814 * Fail:: @code{.fail}
3815 @ifclear no-file-dir
3816 * File:: @code{.file @var{string}}
3819 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
3820 * Float:: @code{.float @var{flonums}}
3821 * Func:: @code{.func}
3822 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
3824 * Hidden:: @code{.hidden @var{names}}
3827 * hword:: @code{.hword @var{expressions}}
3828 * Ident:: @code{.ident}
3829 * If:: @code{.if @var{absolute expression}}
3830 * Incbin:: @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]}
3831 * Include:: @code{.include "@var{file}"}
3832 * Int:: @code{.int @var{expressions}}
3834 * Internal:: @code{.internal @var{names}}
3837 * Irp:: @code{.irp @var{symbol},@var{values}}@dots{}
3838 * Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{}
3839 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
3840 * Lflags:: @code{.lflags}
3841 @ifclear no-line-dir
3842 * Line:: @code{.line @var{line-number}}
3845 * Linkonce:: @code{.linkonce [@var{type}]}
3846 * List:: @code{.list}
3847 * Ln:: @code{.ln @var{line-number}}
3849 * LNS directives:: @code{.file}, @code{.loc}, etc.
3851 * Long:: @code{.long @var{expressions}}
3853 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
3856 * Macro:: @code{.macro @var{name} @var{args}}@dots{}
3857 * MRI:: @code{.mri @var{val}}
3858 * Noaltmacro:: @code{.noaltmacro}
3859 * Nolist:: @code{.nolist}
3860 * Octa:: @code{.octa @var{bignums}}
3861 * Org:: @code{.org @var{new-lc}, @var{fill}}
3862 * P2align:: @code{.p2align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3864 * PopSection:: @code{.popsection}
3865 * Previous:: @code{.previous}
3868 * Print:: @code{.print @var{string}}
3870 * Protected:: @code{.protected @var{names}}
3873 * Psize:: @code{.psize @var{lines}, @var{columns}}
3874 * Purgem:: @code{.purgem @var{name}}
3876 * PushSection:: @code{.pushsection @var{name}}
3879 * Quad:: @code{.quad @var{bignums}}
3880 * Rept:: @code{.rept @var{count}}
3881 * Sbttl:: @code{.sbttl "@var{subheading}"}
3883 * Scl:: @code{.scl @var{class}}
3886 * Section:: @code{.section @var{name}}
3889 * Set:: @code{.set @var{symbol}, @var{expression}}
3890 * Short:: @code{.short @var{expressions}}
3891 * Single:: @code{.single @var{flonums}}
3893 * Size:: @code{.size [@var{name} , @var{expression}]}
3896 * Skip:: @code{.skip @var{size} , @var{fill}}
3897 * Sleb128:: @code{.sleb128 @var{expressions}}
3898 * Space:: @code{.space @var{size} , @var{fill}}
3900 * Stab:: @code{.stabd, .stabn, .stabs}
3903 * String:: @code{.string "@var{str}"}
3904 * Struct:: @code{.struct @var{expression}}
3906 * SubSection:: @code{.subsection}
3907 * Symver:: @code{.symver @var{name},@var{name2@@nodename}}
3911 * Tag:: @code{.tag @var{structname}}
3914 * Text:: @code{.text @var{subsection}}
3915 * Title:: @code{.title "@var{heading}"}
3917 * Type:: @code{.type <@var{int} | @var{name} , @var{type description}>}
3920 * Uleb128:: @code{.uleb128 @var{expressions}}
3922 * Val:: @code{.val @var{addr}}
3926 * Version:: @code{.version "@var{string}"}
3927 * VTableEntry:: @code{.vtable_entry @var{table}, @var{offset}}
3928 * VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}}
3931 * Warning:: @code{.warning @var{string}}
3932 * Weak:: @code{.weak @var{names}}
3933 * Weakref:: @code{.weakref @var{alias}, @var{symbol}}
3934 * Word:: @code{.word @var{expressions}}
3935 * Deprecated:: Deprecated Directives
3939 @section @code{.abort}
3941 @cindex @code{abort} directive
3942 @cindex stopping the assembly
3943 This directive stops the assembly immediately. It is for
3944 compatibility with other assemblers. The original idea was that the
3945 assembly language source would be piped into the assembler. If the sender
3946 of the source quit, it could use this directive tells @command{@value{AS}} to
3947 quit also. One day @code{.abort} will not be supported.
3951 @section @code{.ABORT} (COFF)
3953 @cindex @code{ABORT} directive
3954 When producing COFF output, @command{@value{AS}} accepts this directive as a
3955 synonym for @samp{.abort}.
3958 When producing @code{b.out} output, @command{@value{AS}} accepts this directive,
3964 @section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3966 @cindex padding the location counter
3967 @cindex @code{align} directive
3968 Pad the location counter (in the current subsection) to a particular storage
3969 boundary. The first expression (which must be absolute) is the alignment
3970 required, as described below.
3972 The second expression (also absolute) gives the fill value to be stored in the
3973 padding bytes. It (and the comma) may be omitted. If it is omitted, the
3974 padding bytes are normally zero. However, on some systems, if the section is
3975 marked as containing code and the fill value is omitted, the space is filled
3976 with no-op instructions.
3978 The third expression is also absolute, and is also optional. If it is present,
3979 it is the maximum number of bytes that should be skipped by this alignment
3980 directive. If doing the alignment would require skipping more bytes than the
3981 specified maximum, then the alignment is not done at all. You can omit the
3982 fill value (the second argument) entirely by simply using two commas after the
3983 required alignment; this can be useful if you want the alignment to be filled
3984 with no-op instructions when appropriate.
3986 The way the required alignment is specified varies from system to system.
3987 For the arc, hppa, i386 using ELF, i860, iq2000, m68k, or32,
3988 s390, sparc, tic4x, tic80 and xtensa, the first expression is the
3989 alignment request in bytes. For example @samp{.align 8} advances
3990 the location counter until it is a multiple of 8. If the location counter
3991 is already a multiple of 8, no change is needed. For the tic54x, the
3992 first expression is the alignment request in words.
3994 For other systems, including the i386 using a.out format, and the arm and
3995 strongarm, it is the
3996 number of low-order zero bits the location counter must have after
3997 advancement. For example @samp{.align 3} advances the location
3998 counter until it a multiple of 8. If the location counter is already a
3999 multiple of 8, no change is needed.
4001 This inconsistency is due to the different behaviors of the various
4002 native assemblers for these systems which GAS must emulate.
4003 GAS also provides @code{.balign} and @code{.p2align} directives,
4004 described later, which have a consistent behavior across all
4005 architectures (but are specific to GAS).
4008 @section @code{.ascii "@var{string}"}@dots{}
4010 @cindex @code{ascii} directive
4011 @cindex string literals
4012 @code{.ascii} expects zero or more string literals (@pxref{Strings})
4013 separated by commas. It assembles each string (with no automatic
4014 trailing zero byte) into consecutive addresses.
4017 @section @code{.asciz "@var{string}"}@dots{}
4019 @cindex @code{asciz} directive
4020 @cindex zero-terminated strings
4021 @cindex null-terminated strings
4022 @code{.asciz} is just like @code{.ascii}, but each string is followed by
4023 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
4026 @section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
4028 @cindex padding the location counter given number of bytes
4029 @cindex @code{balign} directive
4030 Pad the location counter (in the current subsection) to a particular
4031 storage boundary. The first expression (which must be absolute) is the
4032 alignment request in bytes. For example @samp{.balign 8} advances
4033 the location counter until it is a multiple of 8. If the location counter
4034 is already a multiple of 8, no change is needed.
4036 The second expression (also absolute) gives the fill value to be stored in the
4037 padding bytes. It (and the comma) may be omitted. If it is omitted, the
4038 padding bytes are normally zero. However, on some systems, if the section is
4039 marked as containing code and the fill value is omitted, the space is filled
4040 with no-op instructions.
4042 The third expression is also absolute, and is also optional. If it is present,
4043 it is the maximum number of bytes that should be skipped by this alignment
4044 directive. If doing the alignment would require skipping more bytes than the
4045 specified maximum, then the alignment is not done at all. You can omit the
4046 fill value (the second argument) entirely by simply using two commas after the
4047 required alignment; this can be useful if you want the alignment to be filled
4048 with no-op instructions when appropriate.
4050 @cindex @code{balignw} directive
4051 @cindex @code{balignl} directive
4052 The @code{.balignw} and @code{.balignl} directives are variants of the
4053 @code{.balign} directive. The @code{.balignw} directive treats the fill
4054 pattern as a two byte word value. The @code{.balignl} directives treats the
4055 fill pattern as a four byte longword value. For example, @code{.balignw
4056 4,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
4057 filled in with the value 0x368d (the exact placement of the bytes depends upon
4058 the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
4062 @section @code{.byte @var{expressions}}
4064 @cindex @code{byte} directive
4065 @cindex integers, one byte
4066 @code{.byte} expects zero or more expressions, separated by commas.
4067 Each expression is assembled into the next byte.
4070 @section @code{.comm @var{symbol} , @var{length} }
4072 @cindex @code{comm} directive
4073 @cindex symbol, common
4074 @code{.comm} declares a common symbol named @var{symbol}. When linking, a
4075 common symbol in one object file may be merged with a defined or common symbol
4076 of the same name in another object file. If @code{@value{LD}} does not see a
4077 definition for the symbol--just one or more common symbols--then it will
4078 allocate @var{length} bytes of uninitialized memory. @var{length} must be an
4079 absolute expression. If @code{@value{LD}} sees multiple common symbols with
4080 the same name, and they do not all have the same size, it will allocate space
4081 using the largest size.
4084 When using ELF, the @code{.comm} directive takes an optional third argument.
4085 This is the desired alignment of the symbol, specified as a byte boundary (for
4086 example, an alignment of 16 means that the least significant 4 bits of the
4087 address should be zero). The alignment must be an absolute expression, and it
4088 must be a power of two. If @code{@value{LD}} allocates uninitialized memory
4089 for the common symbol, it will use the alignment when placing the symbol. If
4090 no alignment is specified, @command{@value{AS}} will set the alignment to the
4091 largest power of two less than or equal to the size of the symbol, up to a
4096 The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
4097 @samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
4100 @node CFI directives
4101 @section @code{.cfi_startproc}
4102 @cindex @code{cfi_startproc} directive
4103 @code{.cfi_startproc} is used at the beginning of each function that
4104 should have an entry in @code{.eh_frame}. It initializes some internal
4105 data structures and emits architecture dependent initial CFI instructions.
4106 Don't forget to close the function by
4107 @code{.cfi_endproc}.
4109 @section @code{.cfi_endproc}
4110 @cindex @code{cfi_endproc} directive
4111 @code{.cfi_endproc} is used at the end of a function where it closes its
4112 unwind entry previously opened by
4113 @code{.cfi_startproc}, and emits it to @code{.eh_frame}.
4115 @section @code{.cfi_personality @var{encoding} [, @var{exp}]}
4116 @code{.cfi_personality} defines personality routine and its encoding.
4117 @var{encoding} must be a constant determining how the personality
4118 should be encoded. If it is 255 (@code{DW_EH_PE_omit}), second
4119 argument is not present, otherwise second argument should be
4120 a constant or a symbol name. When using indirect encodings,
4121 the symbol provided should be the location where personality
4122 can be loaded from, not the personality routine itself.
4123 The default after @code{.cfi_startproc} is @code{.cfi_personality 0xff},
4124 no personality routine.
4126 @section @code{.cfi_lsda @var{encoding} [, @var{exp}]}
4127 @code{.cfi_lsda} defines LSDA and its encoding.
4128 @var{encoding} must be a constant determining how the LSDA
4129 should be encoded. If it is 255 (@code{DW_EH_PE_omit}), second
4130 argument is not present, otherwise second argument should be a constant
4131 or a symbol name. The default after @code{.cfi_startproc} is @code{.cfi_lsda 0xff},
4134 @section @code{.cfi_def_cfa @var{register}, @var{offset}}
4135 @code{.cfi_def_cfa} defines a rule for computing CFA as: @i{take
4136 address from @var{register} and add @var{offset} to it}.
4138 @section @code{.cfi_def_cfa_register @var{register}}
4139 @code{.cfi_def_cfa_register} modifies a rule for computing CFA. From
4140 now on @var{register} will be used instead of the old one. Offset
4143 @section @code{.cfi_def_cfa_offset @var{offset}}
4144 @code{.cfi_def_cfa_offset} modifies a rule for computing CFA. Register
4145 remains the same, but @var{offset} is new. Note that it is the
4146 absolute offset that will be added to a defined register to compute
4149 @section @code{.cfi_adjust_cfa_offset @var{offset}}
4150 Same as @code{.cfi_def_cfa_offset} but @var{offset} is a relative
4151 value that is added/substracted from the previous offset.
4153 @section @code{.cfi_offset @var{register}, @var{offset}}
4154 Previous value of @var{register} is saved at offset @var{offset} from
4157 @section @code{.cfi_rel_offset @var{register}, @var{offset}}
4158 Previous value of @var{register} is saved at offset @var{offset} from
4159 the current CFA register. This is transformed to @code{.cfi_offset}
4160 using the known displacement of the CFA register from the CFA.
4161 This is often easier to use, because the number will match the
4162 code it's annotating.
4164 @section @code{.cfi_signal_frame}
4165 Mark current function as signal trampoline.
4167 @section @code{.cfi_window_save}
4168 SPARC register window has been saved.
4170 @section @code{.cfi_escape} @var{expression}[, @dots{}]
4171 Allows the user to add arbitrary bytes to the unwind info. One
4172 might use this to add OS-specific CFI opcodes, or generic CFI
4173 opcodes that GAS does not yet support.
4175 @node LNS directives
4176 @section @code{.file @var{fileno} @var{filename}}
4177 @cindex @code{file} directive
4178 When emitting dwarf2 line number information @code{.file} assigns filenames
4179 to the @code{.debug_line} file name table. The @var{fileno} operand should
4180 be a unique positive integer to use as the index of the entry in the table.
4181 The @var{filename} operand is a C string literal.
4183 The detail of filename indices is exposed to the user because the filename
4184 table is shared with the @code{.debug_info} section of the dwarf2 debugging
4185 information, and thus the user must know the exact indices that table
4188 @section @code{.loc @var{fileno} @var{lineno} [@var{column}] [@var{options}]}
4189 @cindex @code{loc} directive
4190 The @code{.loc} directive will add row to the @code{.debug_line} line
4191 number matrix corresponding to the immediately following assembly
4192 instruction. The @var{fileno}, @var{lineno}, and optional @var{column}
4193 arguments will be applied to the @code{.debug_line} state machine before
4196 The @var{options} are a sequence of the following tokens in any order:
4200 This option will set the @code{basic_block} register in the
4201 @code{.debug_line} state machine to @code{true}.
4204 This option will set the @code{prologue_end} register in the
4205 @code{.debug_line} state machine to @code{true}.
4207 @item epilogue_begin
4208 This option will set the @code{epilogue_begin} register in the
4209 @code{.debug_line} state machine to @code{true}.
4211 @item is_stmt @var{value}
4212 This option will set the @code{is_stmt} register in the
4213 @code{.debug_line} state machine to @code{value}, which must be
4216 @item isa @var{value}
4217 This directive will set the @code{isa} register in the @code{.debug_line}
4218 state machine to @var{value}, which must be an unsigned integer.
4222 @section @code{.loc_mark_blocks @var{enable}}
4223 @cindex @code{loc_mark_blocks} directive
4224 The @code{.loc_mark_blocks} directive makes the assembler emit an entry
4225 to the @code{.debug_line} line number matrix with the @code{basic_block}
4226 register in the state machine set whenever a code label is seen.
4227 The @var{enable} argument should be either 1 or 0, to enable or disable
4228 this function respectively.
4231 @section @code{.data @var{subsection}}
4233 @cindex @code{data} directive
4234 @code{.data} tells @command{@value{AS}} to assemble the following statements onto the
4235 end of the data subsection numbered @var{subsection} (which is an
4236 absolute expression). If @var{subsection} is omitted, it defaults
4241 @section @code{.def @var{name}}
4243 @cindex @code{def} directive
4244 @cindex COFF symbols, debugging
4245 @cindex debugging COFF symbols
4246 Begin defining debugging information for a symbol @var{name}; the
4247 definition extends until the @code{.endef} directive is encountered.
4250 This directive is only observed when @command{@value{AS}} is configured for COFF
4251 format output; when producing @code{b.out}, @samp{.def} is recognized,
4258 @section @code{.desc @var{symbol}, @var{abs-expression}}
4260 @cindex @code{desc} directive
4261 @cindex COFF symbol descriptor
4262 @cindex symbol descriptor, COFF
4263 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
4264 to the low 16 bits of an absolute expression.
4267 The @samp{.desc} directive is not available when @command{@value{AS}} is
4268 configured for COFF output; it is only for @code{a.out} or @code{b.out}
4269 object format. For the sake of compatibility, @command{@value{AS}} accepts
4270 it, but produces no output, when configured for COFF.
4276 @section @code{.dim}
4278 @cindex @code{dim} directive
4279 @cindex COFF auxiliary symbol information
4280 @cindex auxiliary symbol information, COFF
4281 This directive is generated by compilers to include auxiliary debugging
4282 information in the symbol table. It is only permitted inside
4283 @code{.def}/@code{.endef} pairs.
4286 @samp{.dim} is only meaningful when generating COFF format output; when
4287 @command{@value{AS}} is generating @code{b.out}, it accepts this directive but
4293 @section @code{.double @var{flonums}}
4295 @cindex @code{double} directive
4296 @cindex floating point numbers (double)
4297 @code{.double} expects zero or more flonums, separated by commas. It
4298 assembles floating point numbers.
4300 The exact kind of floating point numbers emitted depends on how
4301 @command{@value{AS}} is configured. @xref{Machine Dependencies}.
4305 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
4306 in @sc{ieee} format.
4311 @section @code{.eject}
4313 @cindex @code{eject} directive
4314 @cindex new page, in listings
4315 @cindex page, in listings
4316 @cindex listing control: new page
4317 Force a page break at this point, when generating assembly listings.
4320 @section @code{.else}
4322 @cindex @code{else} directive
4323 @code{.else} is part of the @command{@value{AS}} support for conditional
4324 assembly; see @ref{If,,@code{.if}}. It marks the beginning of a section
4325 of code to be assembled if the condition for the preceding @code{.if}
4329 @section @code{.elseif}
4331 @cindex @code{elseif} directive
4332 @code{.elseif} is part of the @command{@value{AS}} support for conditional
4333 assembly; see @ref{If,,@code{.if}}. It is shorthand for beginning a new
4334 @code{.if} block that would otherwise fill the entire @code{.else} section.
4337 @section @code{.end}
4339 @cindex @code{end} directive
4340 @code{.end} marks the end of the assembly file. @command{@value{AS}} does not
4341 process anything in the file past the @code{.end} directive.
4345 @section @code{.endef}
4347 @cindex @code{endef} directive
4348 This directive flags the end of a symbol definition begun with
4352 @samp{.endef} is only meaningful when generating COFF format output; if
4353 @command{@value{AS}} is configured to generate @code{b.out}, it accepts this
4354 directive but ignores it.
4359 @section @code{.endfunc}
4360 @cindex @code{endfunc} directive
4361 @code{.endfunc} marks the end of a function specified with @code{.func}.
4364 @section @code{.endif}
4366 @cindex @code{endif} directive
4367 @code{.endif} is part of the @command{@value{AS}} support for conditional assembly;
4368 it marks the end of a block of code that is only assembled
4369 conditionally. @xref{If,,@code{.if}}.
4372 @section @code{.equ @var{symbol}, @var{expression}}
4374 @cindex @code{equ} directive
4375 @cindex assigning values to symbols
4376 @cindex symbols, assigning values to
4377 This directive sets the value of @var{symbol} to @var{expression}.
4378 It is synonymous with @samp{.set}; see @ref{Set,,@code{.set}}.
4381 The syntax for @code{equ} on the HPPA is
4382 @samp{@var{symbol} .equ @var{expression}}.
4386 The syntax for @code{equ} on the Z80 is
4387 @samp{@var{symbol} equ @var{expression}}.
4388 On the Z80 it is an eror if @var{symbol} is already defined,
4389 but the symbol is not protected from later redefinition.
4390 Compare @ref{Equiv}.
4394 @section @code{.equiv @var{symbol}, @var{expression}}
4395 @cindex @code{equiv} directive
4396 The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that
4397 the assembler will signal an error if @var{symbol} is already defined. Note a
4398 symbol which has been referenced but not actually defined is considered to be
4401 Except for the contents of the error message, this is roughly equivalent to
4408 plus it protects the symbol from later redefinition.
4411 @section @code{.eqv @var{symbol}, @var{expression}}
4412 @cindex @code{eqv} directive
4413 The @code{.eqv} directive is like @code{.equiv}, but no attempt is made to
4414 evaluate the expression or any part of it immediately. Instead each time
4415 the resulting symbol is used in an expression, a snapshot of its current
4419 @section @code{.err}
4420 @cindex @code{err} directive
4421 If @command{@value{AS}} assembles a @code{.err} directive, it will print an error
4422 message and, unless the @option{-Z} option was used, it will not generate an
4423 object file. This can be used to signal an error in conditionally compiled code.
4426 @section @code{.error "@var{string}"}
4427 @cindex error directive
4429 Similarly to @code{.err}, this directive emits an error, but you can specify a
4430 string that will be emitted as the error message. If you don't specify the
4431 message, it defaults to @code{".error directive invoked in source file"}.
4432 @xref{Errors, ,Error and Warning Messages}.
4435 .error "This code has not been assembled and tested."
4439 @section @code{.exitm}
4440 Exit early from the current macro definition. @xref{Macro}.
4443 @section @code{.extern}
4445 @cindex @code{extern} directive
4446 @code{.extern} is accepted in the source program---for compatibility
4447 with other assemblers---but it is ignored. @command{@value{AS}} treats
4448 all undefined symbols as external.
4451 @section @code{.fail @var{expression}}
4453 @cindex @code{fail} directive
4454 Generates an error or a warning. If the value of the @var{expression} is 500
4455 or more, @command{@value{AS}} will print a warning message. If the value is less
4456 than 500, @command{@value{AS}} will print an error message. The message will
4457 include the value of @var{expression}. This can occasionally be useful inside
4458 complex nested macros or conditional assembly.
4460 @ifclear no-file-dir
4462 @section @code{.file @var{string}}
4464 @cindex @code{file} directive
4465 @cindex logical file name
4466 @cindex file name, logical
4467 @code{.file} tells @command{@value{AS}} that we are about to start a new logical
4468 file. @var{string} is the new file name. In general, the filename is
4469 recognized whether or not it is surrounded by quotes @samp{"}; but if you wish
4470 to specify an empty file name, you must give the quotes--@code{""}. This
4471 statement may go away in future: it is only recognized to be compatible with
4472 old @command{@value{AS}} programs.
4476 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
4478 @cindex @code{fill} directive
4479 @cindex writing patterns in memory
4480 @cindex patterns, writing in memory
4481 @var{repeat}, @var{size} and @var{value} are absolute expressions.
4482 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
4483 may be zero or more. @var{Size} may be zero or more, but if it is
4484 more than 8, then it is deemed to have the value 8, compatible with
4485 other people's assemblers. The contents of each @var{repeat} bytes
4486 is taken from an 8-byte number. The highest order 4 bytes are
4487 zero. The lowest order 4 bytes are @var{value} rendered in the
4488 byte-order of an integer on the computer @command{@value{AS}} is assembling for.
4489 Each @var{size} bytes in a repetition is taken from the lowest order
4490 @var{size} bytes of this number. Again, this bizarre behavior is
4491 compatible with other people's assemblers.
4493 @var{size} and @var{value} are optional.
4494 If the second comma and @var{value} are absent, @var{value} is
4495 assumed zero. If the first comma and following tokens are absent,
4496 @var{size} is assumed to be 1.
4499 @section @code{.float @var{flonums}}
4501 @cindex floating point numbers (single)
4502 @cindex @code{float} directive
4503 This directive assembles zero or more flonums, separated by commas. It
4504 has the same effect as @code{.single}.
4506 The exact kind of floating point numbers emitted depends on how
4507 @command{@value{AS}} is configured.
4508 @xref{Machine Dependencies}.
4512 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
4513 in @sc{ieee} format.
4518 @section @code{.func @var{name}[,@var{label}]}
4519 @cindex @code{func} directive
4520 @code{.func} emits debugging information to denote function @var{name}, and
4521 is ignored unless the file is assembled with debugging enabled.
4522 Only @samp{--gstabs[+]} is currently supported.
4523 @var{label} is the entry point of the function and if omitted @var{name}
4524 prepended with the @samp{leading char} is used.
4525 @samp{leading char} is usually @code{_} or nothing, depending on the target.
4526 All functions are currently defined to have @code{void} return type.
4527 The function must be terminated with @code{.endfunc}.
4530 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
4532 @cindex @code{global} directive
4533 @cindex symbol, making visible to linker
4534 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
4535 @var{symbol} in your partial program, its value is made available to
4536 other partial programs that are linked with it. Otherwise,
4537 @var{symbol} takes its attributes from a symbol of the same name
4538 from another file linked into the same program.
4540 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
4541 compatibility with other assemblers.
4544 On the HPPA, @code{.global} is not always enough to make it accessible to other
4545 partial programs. You may need the HPPA-only @code{.EXPORT} directive as well.
4546 @xref{HPPA Directives, ,HPPA Assembler Directives}.
4551 @section @code{.hidden @var{names}}
4553 @cindex @code{hidden} directive
4555 This is one of the ELF visibility directives. The other two are
4556 @code{.internal} (@pxref{Internal,,@code{.internal}}) and
4557 @code{.protected} (@pxref{Protected,,@code{.protected}}).
4559 This directive overrides the named symbols default visibility (which is set by
4560 their binding: local, global or weak). The directive sets the visibility to
4561 @code{hidden} which means that the symbols are not visible to other components.
4562 Such symbols are always considered to be @code{protected} as well.
4566 @section @code{.hword @var{expressions}}
4568 @cindex @code{hword} directive
4569 @cindex integers, 16-bit
4570 @cindex numbers, 16-bit
4571 @cindex sixteen bit integers
4572 This expects zero or more @var{expressions}, and emits
4573 a 16 bit number for each.
4576 This directive is a synonym for @samp{.short}; depending on the target
4577 architecture, it may also be a synonym for @samp{.word}.
4581 This directive is a synonym for @samp{.short}.
4584 This directive is a synonym for both @samp{.short} and @samp{.word}.
4589 @section @code{.ident}
4591 @cindex @code{ident} directive
4593 This directive is used by some assemblers to place tags in object files. The
4594 behavior of this directive varies depending on the target. When using the
4595 a.out object file format, @command{@value{AS}} simply accepts the directive for
4596 source-file compatibility with existing assemblers, but does not emit anything
4597 for it. When using COFF, comments are emitted to the @code{.comment} or
4598 @code{.rdata} section, depending on the target. When using ELF, comments are
4599 emitted to the @code{.comment} section.
4602 @section @code{.if @var{absolute expression}}
4604 @cindex conditional assembly
4605 @cindex @code{if} directive
4606 @code{.if} marks the beginning of a section of code which is only
4607 considered part of the source program being assembled if the argument
4608 (which must be an @var{absolute expression}) is non-zero. The end of
4609 the conditional section of code must be marked by @code{.endif}
4610 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
4611 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}).
4612 If you have several conditions to check, @code{.elseif} may be used to avoid
4613 nesting blocks if/else within each subsequent @code{.else} block.
4615 The following variants of @code{.if} are also supported:
4617 @cindex @code{ifdef} directive
4618 @item .ifdef @var{symbol}
4619 Assembles the following section of code if the specified @var{symbol}
4620 has been defined. Note a symbol which has been referenced but not yet defined
4621 is considered to be undefined.
4623 @cindex @code{ifb} directive
4624 @item .ifb @var{text}
4625 Assembles the following section of code if the operand is blank (empty).
4627 @cindex @code{ifc} directive
4628 @item .ifc @var{string1},@var{string2}
4629 Assembles the following section of code if the two strings are the same. The
4630 strings may be optionally quoted with single quotes. If they are not quoted,
4631 the first string stops at the first comma, and the second string stops at the
4632 end of the line. Strings which contain whitespace should be quoted. The
4633 string comparison is case sensitive.
4635 @cindex @code{ifeq} directive
4636 @item .ifeq @var{absolute expression}
4637 Assembles the following section of code if the argument is zero.
4639 @cindex @code{ifeqs} directive
4640 @item .ifeqs @var{string1},@var{string2}
4641 Another form of @code{.ifc}. The strings must be quoted using double quotes.
4643 @cindex @code{ifge} directive
4644 @item .ifge @var{absolute expression}
4645 Assembles the following section of code if the argument is greater than or
4648 @cindex @code{ifgt} directive
4649 @item .ifgt @var{absolute expression}
4650 Assembles the following section of code if the argument is greater than zero.
4652 @cindex @code{ifle} directive
4653 @item .ifle @var{absolute expression}
4654 Assembles the following section of code if the argument is less than or equal
4657 @cindex @code{iflt} directive
4658 @item .iflt @var{absolute expression}
4659 Assembles the following section of code if the argument is less than zero.
4661 @cindex @code{ifnb} directive
4662 @item .ifnb @var{text}
4663 Like @code{.ifb}, but the sense of the test is reversed: this assembles the
4664 following section of code if the operand is non-blank (non-empty).
4666 @cindex @code{ifnc} directive
4667 @item .ifnc @var{string1},@var{string2}.
4668 Like @code{.ifc}, but the sense of the test is reversed: this assembles the
4669 following section of code if the two strings are not the same.
4671 @cindex @code{ifndef} directive
4672 @cindex @code{ifnotdef} directive
4673 @item .ifndef @var{symbol}
4674 @itemx .ifnotdef @var{symbol}
4675 Assembles the following section of code if the specified @var{symbol}
4676 has not been defined. Both spelling variants are equivalent. Note a symbol
4677 which has been referenced but not yet defined is considered to be undefined.
4679 @cindex @code{ifne} directive
4680 @item .ifne @var{absolute expression}
4681 Assembles the following section of code if the argument is not equal to zero
4682 (in other words, this is equivalent to @code{.if}).
4684 @cindex @code{ifnes} directive
4685 @item .ifnes @var{string1},@var{string2}
4686 Like @code{.ifeqs}, but the sense of the test is reversed: this assembles the
4687 following section of code if the two strings are not the same.
4691 @section @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]}
4693 @cindex @code{incbin} directive
4694 @cindex binary files, including
4695 The @code{incbin} directive includes @var{file} verbatim at the current
4696 location. You can control the search paths used with the @samp{-I} command-line
4697 option (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
4700 The @var{skip} argument skips a number of bytes from the start of the
4701 @var{file}. The @var{count} argument indicates the maximum number of bytes to
4702 read. Note that the data is not aligned in any way, so it is the user's
4703 responsibility to make sure that proper alignment is provided both before and
4704 after the @code{incbin} directive.
4707 @section @code{.include "@var{file}"}
4709 @cindex @code{include} directive
4710 @cindex supporting files, including
4711 @cindex files, including
4712 This directive provides a way to include supporting files at specified
4713 points in your source program. The code from @var{file} is assembled as
4714 if it followed the point of the @code{.include}; when the end of the
4715 included file is reached, assembly of the original file continues. You
4716 can control the search paths used with the @samp{-I} command-line option
4717 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
4721 @section @code{.int @var{expressions}}
4723 @cindex @code{int} directive
4724 @cindex integers, 32-bit
4725 Expect zero or more @var{expressions}, of any section, separated by commas.
4726 For each expression, emit a number that, at run time, is the value of that
4727 expression. The byte order and bit size of the number depends on what kind
4728 of target the assembly is for.
4732 On most forms of the H8/300, @code{.int} emits 16-bit
4733 integers. On the H8/300H and the Renesas SH, however, @code{.int} emits
4740 @section @code{.internal @var{names}}
4742 @cindex @code{internal} directive
4744 This is one of the ELF visibility directives. The other two are
4745 @code{.hidden} (@pxref{Hidden,,@code{.hidden}}) and
4746 @code{.protected} (@pxref{Protected,,@code{.protected}}).
4748 This directive overrides the named symbols default visibility (which is set by
4749 their binding: local, global or weak). The directive sets the visibility to
4750 @code{internal} which means that the symbols are considered to be @code{hidden}
4751 (i.e., not visible to other components), and that some extra, processor specific
4752 processing must also be performed upon the symbols as well.
4756 @section @code{.irp @var{symbol},@var{values}}@dots{}
4758 @cindex @code{irp} directive
4759 Evaluate a sequence of statements assigning different values to @var{symbol}.
4760 The sequence of statements starts at the @code{.irp} directive, and is
4761 terminated by an @code{.endr} directive. For each @var{value}, @var{symbol} is
4762 set to @var{value}, and the sequence of statements is assembled. If no
4763 @var{value} is listed, the sequence of statements is assembled once, with
4764 @var{symbol} set to the null string. To refer to @var{symbol} within the
4765 sequence of statements, use @var{\symbol}.
4767 For example, assembling
4775 is equivalent to assembling
4783 For some caveats with the spelling of @var{symbol}, see also @ref{Macro}.
4786 @section @code{.irpc @var{symbol},@var{values}}@dots{}
4788 @cindex @code{irpc} directive
4789 Evaluate a sequence of statements assigning different values to @var{symbol}.
4790 The sequence of statements starts at the @code{.irpc} directive, and is
4791 terminated by an @code{.endr} directive. For each character in @var{value},
4792 @var{symbol} is set to the character, and the sequence of statements is
4793 assembled. If no @var{value} is listed, the sequence of statements is
4794 assembled once, with @var{symbol} set to the null string. To refer to
4795 @var{symbol} within the sequence of statements, use @var{\symbol}.
4797 For example, assembling
4805 is equivalent to assembling
4813 For some caveats with the spelling of @var{symbol}, see also the discussion
4817 @section @code{.lcomm @var{symbol} , @var{length}}
4819 @cindex @code{lcomm} directive
4820 @cindex local common symbols
4821 @cindex symbols, local common
4822 Reserve @var{length} (an absolute expression) bytes for a local common
4823 denoted by @var{symbol}. The section and value of @var{symbol} are
4824 those of the new local common. The addresses are allocated in the bss
4825 section, so that at run-time the bytes start off zeroed. @var{Symbol}
4826 is not declared global (@pxref{Global,,@code{.global}}), so is normally
4827 not visible to @code{@value{LD}}.
4830 Some targets permit a third argument to be used with @code{.lcomm}. This
4831 argument specifies the desired alignment of the symbol in the bss section.
4835 The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
4836 @samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
4840 @section @code{.lflags}
4842 @cindex @code{lflags} directive (ignored)
4843 @command{@value{AS}} accepts this directive, for compatibility with other
4844 assemblers, but ignores it.
4846 @ifclear no-line-dir
4848 @section @code{.line @var{line-number}}
4850 @cindex @code{line} directive
4854 @section @code{.ln @var{line-number}}
4856 @cindex @code{ln} directive
4858 @cindex logical line number
4860 Change the logical line number. @var{line-number} must be an absolute
4861 expression. The next line has that logical line number. Therefore any other
4862 statements on the current line (after a statement separator character) are
4863 reported as on logical line number @var{line-number} @minus{} 1. One day
4864 @command{@value{AS}} will no longer support this directive: it is recognized only
4865 for compatibility with existing assembler programs.
4869 @ifclear no-line-dir
4870 Even though this is a directive associated with the @code{a.out} or
4871 @code{b.out} object-code formats, @command{@value{AS}} still recognizes it
4872 when producing COFF output, and treats @samp{.line} as though it
4873 were the COFF @samp{.ln} @emph{if} it is found outside a
4874 @code{.def}/@code{.endef} pair.
4876 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
4877 used by compilers to generate auxiliary symbol information for
4882 @section @code{.linkonce [@var{type}]}
4884 @cindex @code{linkonce} directive
4885 @cindex common sections
4886 Mark the current section so that the linker only includes a single copy of it.
4887 This may be used to include the same section in several different object files,
4888 but ensure that the linker will only include it once in the final output file.
4889 The @code{.linkonce} pseudo-op must be used for each instance of the section.
4890 Duplicate sections are detected based on the section name, so it should be
4893 This directive is only supported by a few object file formats; as of this
4894 writing, the only object file format which supports it is the Portable
4895 Executable format used on Windows NT.
4897 The @var{type} argument is optional. If specified, it must be one of the
4898 following strings. For example:
4902 Not all types may be supported on all object file formats.
4906 Silently discard duplicate sections. This is the default.
4909 Warn if there are duplicate sections, but still keep only one copy.
4912 Warn if any of the duplicates have different sizes.
4915 Warn if any of the duplicates do not have exactly the same contents.
4919 @section @code{.ln @var{line-number}}
4921 @cindex @code{ln} directive
4922 @ifclear no-line-dir
4923 @samp{.ln} is a synonym for @samp{.line}.
4926 Tell @command{@value{AS}} to change the logical line number. @var{line-number}
4927 must be an absolute expression. The next line has that logical
4928 line number, so any other statements on the current line (after a
4929 statement separator character @code{;}) are reported as on logical
4930 line number @var{line-number} @minus{} 1.
4933 This directive is accepted, but ignored, when @command{@value{AS}} is
4934 configured for @code{b.out}; its effect is only associated with COFF
4940 @section @code{.mri @var{val}}
4942 @cindex @code{mri} directive
4943 @cindex MRI mode, temporarily
4944 If @var{val} is non-zero, this tells @command{@value{AS}} to enter MRI mode. If
4945 @var{val} is zero, this tells @command{@value{AS}} to exit MRI mode. This change
4946 affects code assembled until the next @code{.mri} directive, or until the end
4947 of the file. @xref{M, MRI mode, MRI mode}.
4950 @section @code{.list}
4952 @cindex @code{list} directive
4953 @cindex listing control, turning on
4954 Control (in conjunction with the @code{.nolist} directive) whether or
4955 not assembly listings are generated. These two directives maintain an
4956 internal counter (which is zero initially). @code{.list} increments the
4957 counter, and @code{.nolist} decrements it. Assembly listings are
4958 generated whenever the counter is greater than zero.
4960 By default, listings are disabled. When you enable them (with the
4961 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
4962 the initial value of the listing counter is one.
4965 @section @code{.long @var{expressions}}
4967 @cindex @code{long} directive
4968 @code{.long} is the same as @samp{.int}. @xref{Int,,@code{.int}}.
4971 @c no one seems to know what this is for or whether this description is
4972 @c what it really ought to do
4974 @section @code{.lsym @var{symbol}, @var{expression}}
4976 @cindex @code{lsym} directive
4977 @cindex symbol, not referenced in assembly
4978 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
4979 the hash table, ensuring it cannot be referenced by name during the
4980 rest of the assembly. This sets the attributes of the symbol to be
4981 the same as the expression value:
4983 @var{other} = @var{descriptor} = 0
4984 @var{type} = @r{(section of @var{expression})}
4985 @var{value} = @var{expression}
4988 The new symbol is not flagged as external.
4992 @section @code{.macro}
4995 The commands @code{.macro} and @code{.endm} allow you to define macros that
4996 generate assembly output. For example, this definition specifies a macro
4997 @code{sum} that puts a sequence of numbers into memory:
5000 .macro sum from=0, to=5
5009 With that definition, @samp{SUM 0,5} is equivalent to this assembly input:
5021 @item .macro @var{macname}
5022 @itemx .macro @var{macname} @var{macargs} @dots{}
5023 @cindex @code{macro} directive
5024 Begin the definition of a macro called @var{macname}. If your macro
5025 definition requires arguments, specify their names after the macro name,
5026 separated by commas or spaces. You can qualify the macro argument to
5027 indicate whether all invocations must specify a non-blank value (through
5028 @samp{:@code{req}}), or whether it takes all of the remaining arguments
5029 (through @samp{:@code{vararg}}). You can supply a default value for any
5030 macro argument by following the name with @samp{=@var{deflt}}. You
5031 cannot define two macros with the same @var{macname} unless it has been
5032 subject to the @code{.purgem} directive (@pxref{Purgem}) between the two
5033 definitions. For example, these are all valid @code{.macro} statements:
5037 Begin the definition of a macro called @code{comm}, which takes no
5040 @item .macro plus1 p, p1
5041 @itemx .macro plus1 p p1
5042 Either statement begins the definition of a macro called @code{plus1},
5043 which takes two arguments; within the macro definition, write
5044 @samp{\p} or @samp{\p1} to evaluate the arguments.
5046 @item .macro reserve_str p1=0 p2
5047 Begin the definition of a macro called @code{reserve_str}, with two
5048 arguments. The first argument has a default value, but not the second.
5049 After the definition is complete, you can call the macro either as
5050 @samp{reserve_str @var{a},@var{b}} (with @samp{\p1} evaluating to
5051 @var{a} and @samp{\p2} evaluating to @var{b}), or as @samp{reserve_str
5052 ,@var{b}} (with @samp{\p1} evaluating as the default, in this case
5053 @samp{0}, and @samp{\p2} evaluating to @var{b}).
5055 @item .macro m p1:req, p2=0, p3:vararg
5056 Begin the definition of a macro called @code{m}, with at least three
5057 arguments. The first argument must always have a value specified, but
5058 not the second, which instead has a default value. The third formal
5059 will get assigned all remaining arguments specified at invocation time.
5061 When you call a macro, you can specify the argument values either by
5062 position, or by keyword. For example, @samp{sum 9,17} is equivalent to
5063 @samp{sum to=17, from=9}.
5067 Note that since each of the @var{macargs} can be an identifier exactly
5068 as any other one permitted by the target architecture, there may be
5069 occasional problems if the target hand-crafts special meanings to certain
5070 characters when they occur in a special position. For example, if the colon
5071 (@code{:}) is generally permitted to be part of a symbol name, but the
5072 architecture specific code special-cases it when occurring as the final
5073 character of a symbol (to denote a label), then the macro parameter
5074 replacement code will have no way of knowing that and consider the whole
5075 construct (including the colon) an identifier, and check only this
5076 identifier for being the subject to parameter substitution. So for example
5077 this macro definition:
5085 might not work as expected. Invoking @samp{label foo} might not create a label
5086 called @samp{foo} but instead just insert the text @samp{\l:} into the
5087 assembler source, probably generating an error about an unrecognised
5090 Similarly problems might occur with the period character (@samp{.})
5091 which is often allowed inside opcode names (and hence identifier names). So
5092 for example constructing a macro to build an opcode from a base name and a
5093 length specifier like this:
5096 .macro opcode base length
5101 and invoking it as @samp{opcode store l} will not create a @samp{store.l}
5102 instruction but instead generate some kind of error as the assembler tries to
5103 interpret the text @samp{\base.\length}.
5105 There are several possible ways around this problem:
5108 @item Insert white space
5109 If it is possible to use white space characters then this is the simplest
5118 @item Use @samp{\()}
5119 The string @samp{\()} can be used to separate the end of a macro argument from
5120 the following text. eg:
5123 .macro opcode base length
5128 @item Use the alternate macro syntax mode
5129 In the alternative macro syntax mode the ampersand character (@samp{&}) can be
5130 used as a separator. eg:
5140 Note: this problem of correctly identifying string parameters to pseudo ops
5141 also applies to the identifiers used in @code{.irp} (@pxref{Irp})
5142 and @code{.irpc} (@pxref{Irpc}) as well.
5145 @cindex @code{endm} directive
5146 Mark the end of a macro definition.
5149 @cindex @code{exitm} directive
5150 Exit early from the current macro definition.
5152 @cindex number of macros executed
5153 @cindex macros, count executed
5155 @command{@value{AS}} maintains a counter of how many macros it has
5156 executed in this pseudo-variable; you can copy that number to your
5157 output with @samp{\@@}, but @emph{only within a macro definition}.
5159 @item LOCAL @var{name} [ , @dots{} ]
5160 @emph{Warning: @code{LOCAL} is only available if you select ``alternate
5161 macro syntax'' with @samp{--alternate} or @code{.altmacro}.}
5162 @xref{Altmacro,,@code{.altmacro}}.
5166 @section @code{.altmacro}
5167 Enable alternate macro mode, enabling:
5170 @item LOCAL @var{name} [ , @dots{} ]
5171 One additional directive, @code{LOCAL}, is available. It is used to
5172 generate a string replacement for each of the @var{name} arguments, and
5173 replace any instances of @var{name} in each macro expansion. The
5174 replacement string is unique in the assembly, and different for each
5175 separate macro expansion. @code{LOCAL} allows you to write macros that
5176 define symbols, without fear of conflict between separate macro expansions.
5178 @item String delimiters
5179 You can write strings delimited in these other ways besides
5180 @code{"@var{string}"}:
5183 @item '@var{string}'
5184 You can delimit strings with single-quote characters.
5186 @item <@var{string}>
5187 You can delimit strings with matching angle brackets.
5190 @item single-character string escape
5191 To include any single character literally in a string (even if the
5192 character would otherwise have some special meaning), you can prefix the
5193 character with @samp{!} (an exclamation mark). For example, you can
5194 write @samp{<4.3 !> 5.4!!>} to get the literal text @samp{4.3 > 5.4!}.
5196 @item Expression results as strings
5197 You can write @samp{%@var{expr}} to evaluate the expression @var{expr}
5198 and use the result as a string.
5202 @section @code{.noaltmacro}
5203 Disable alternate macro mode. @xref{Altmacro}.
5206 @section @code{.nolist}
5208 @cindex @code{nolist} directive
5209 @cindex listing control, turning off
5210 Control (in conjunction with the @code{.list} directive) whether or
5211 not assembly listings are generated. These two directives maintain an
5212 internal counter (which is zero initially). @code{.list} increments the
5213 counter, and @code{.nolist} decrements it. Assembly listings are
5214 generated whenever the counter is greater than zero.
5217 @section @code{.octa @var{bignums}}
5219 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
5220 @cindex @code{octa} directive
5221 @cindex integer, 16-byte
5222 @cindex sixteen byte integer
5223 This directive expects zero or more bignums, separated by commas. For each
5224 bignum, it emits a 16-byte integer.
5226 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
5227 hence @emph{octa}-word for 16 bytes.
5230 @section @code{.org @var{new-lc} , @var{fill}}
5232 @cindex @code{org} directive
5233 @cindex location counter, advancing
5234 @cindex advancing location counter
5235 @cindex current address, advancing
5236 Advance the location counter of the current section to
5237 @var{new-lc}. @var{new-lc} is either an absolute expression or an
5238 expression with the same section as the current subsection. That is,
5239 you can't use @code{.org} to cross sections: if @var{new-lc} has the
5240 wrong section, the @code{.org} directive is ignored. To be compatible
5241 with former assemblers, if the section of @var{new-lc} is absolute,
5242 @command{@value{AS}} issues a warning, then pretends the section of @var{new-lc}
5243 is the same as the current subsection.
5245 @code{.org} may only increase the location counter, or leave it
5246 unchanged; you cannot use @code{.org} to move the location counter
5249 @c double negative used below "not undefined" because this is a specific
5250 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
5251 @c section. doc@cygnus.com 18feb91
5252 Because @command{@value{AS}} tries to assemble programs in one pass, @var{new-lc}
5253 may not be undefined. If you really detest this restriction we eagerly await
5254 a chance to share your improved assembler.
5256 Beware that the origin is relative to the start of the section, not
5257 to the start of the subsection. This is compatible with other
5258 people's assemblers.
5260 When the location counter (of the current subsection) is advanced, the
5261 intervening bytes are filled with @var{fill} which should be an
5262 absolute expression. If the comma and @var{fill} are omitted,
5263 @var{fill} defaults to zero.
5266 @section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
5268 @cindex padding the location counter given a power of two
5269 @cindex @code{p2align} directive
5270 Pad the location counter (in the current subsection) to a particular
5271 storage boundary. The first expression (which must be absolute) is the
5272 number of low-order zero bits the location counter must have after
5273 advancement. For example @samp{.p2align 3} advances the location
5274 counter until it a multiple of 8. If the location counter is already a
5275 multiple of 8, no change is needed.
5277 The second expression (also absolute) gives the fill value to be stored in the
5278 padding bytes. It (and the comma) may be omitted. If it is omitted, the
5279 padding bytes are normally zero. However, on some systems, if the section is
5280 marked as containing code and the fill value is omitted, the space is filled
5281 with no-op instructions.
5283 The third expression is also absolute, and is also optional. If it is present,
5284 it is the maximum number of bytes that should be skipped by this alignment
5285 directive. If doing the alignment would require skipping more bytes than the
5286 specified maximum, then the alignment is not done at all. You can omit the
5287 fill value (the second argument) entirely by simply using two commas after the
5288 required alignment; this can be useful if you want the alignment to be filled
5289 with no-op instructions when appropriate.
5291 @cindex @code{p2alignw} directive
5292 @cindex @code{p2alignl} directive
5293 The @code{.p2alignw} and @code{.p2alignl} directives are variants of the
5294 @code{.p2align} directive. The @code{.p2alignw} directive treats the fill
5295 pattern as a two byte word value. The @code{.p2alignl} directives treats the
5296 fill pattern as a four byte longword value. For example, @code{.p2alignw
5297 2,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
5298 filled in with the value 0x368d (the exact placement of the bytes depends upon
5299 the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
5304 @section @code{.previous}
5306 @cindex @code{previous} directive
5307 @cindex Section Stack
5308 This is one of the ELF section stack manipulation directives. The others are
5309 @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5310 @code{.pushsection} (@pxref{PushSection}), and @code{.popsection}
5311 (@pxref{PopSection}).
5313 This directive swaps the current section (and subsection) with most recently
5314 referenced section (and subsection) prior to this one. Multiple
5315 @code{.previous} directives in a row will flip between two sections (and their
5318 In terms of the section stack, this directive swaps the current section with
5319 the top section on the section stack.
5324 @section @code{.popsection}
5326 @cindex @code{popsection} directive
5327 @cindex Section Stack
5328 This is one of the ELF section stack manipulation directives. The others are
5329 @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5330 @code{.pushsection} (@pxref{PushSection}), and @code{.previous}
5333 This directive replaces the current section (and subsection) with the top
5334 section (and subsection) on the section stack. This section is popped off the
5339 @section @code{.print @var{string}}
5341 @cindex @code{print} directive
5342 @command{@value{AS}} will print @var{string} on the standard output during
5343 assembly. You must put @var{string} in double quotes.
5347 @section @code{.protected @var{names}}
5349 @cindex @code{protected} directive
5351 This is one of the ELF visibility directives. The other two are
5352 @code{.hidden} (@pxref{Hidden}) and @code{.internal} (@pxref{Internal}).
5354 This directive overrides the named symbols default visibility (which is set by
5355 their binding: local, global or weak). The directive sets the visibility to
5356 @code{protected} which means that any references to the symbols from within the
5357 components that defines them must be resolved to the definition in that
5358 component, even if a definition in another component would normally preempt
5363 @section @code{.psize @var{lines} , @var{columns}}
5365 @cindex @code{psize} directive
5366 @cindex listing control: paper size
5367 @cindex paper size, for listings
5368 Use this directive to declare the number of lines---and, optionally, the
5369 number of columns---to use for each page, when generating listings.
5371 If you do not use @code{.psize}, listings use a default line-count
5372 of 60. You may omit the comma and @var{columns} specification; the
5373 default width is 200 columns.
5375 @command{@value{AS}} generates formfeeds whenever the specified number of
5376 lines is exceeded (or whenever you explicitly request one, using
5379 If you specify @var{lines} as @code{0}, no formfeeds are generated save
5380 those explicitly specified with @code{.eject}.
5383 @section @code{.purgem @var{name}}
5385 @cindex @code{purgem} directive
5386 Undefine the macro @var{name}, so that later uses of the string will not be
5387 expanded. @xref{Macro}.
5391 @section @code{.pushsection @var{name} , @var{subsection}}
5393 @cindex @code{pushsection} directive
5394 @cindex Section Stack
5395 This is one of the ELF section stack manipulation directives. The others are
5396 @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5397 @code{.popsection} (@pxref{PopSection}), and @code{.previous}
5400 This directive pushes the current section (and subsection) onto the
5401 top of the section stack, and then replaces the current section and
5402 subsection with @code{name} and @code{subsection}.
5406 @section @code{.quad @var{bignums}}
5408 @cindex @code{quad} directive
5409 @code{.quad} expects zero or more bignums, separated by commas. For
5410 each bignum, it emits
5412 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
5413 warning message; and just takes the lowest order 8 bytes of the bignum.
5414 @cindex eight-byte integer
5415 @cindex integer, 8-byte
5417 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
5418 hence @emph{quad}-word for 8 bytes.
5421 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
5422 warning message; and just takes the lowest order 16 bytes of the bignum.
5423 @cindex sixteen-byte integer
5424 @cindex integer, 16-byte
5428 @section @code{.rept @var{count}}
5430 @cindex @code{rept} directive
5431 Repeat the sequence of lines between the @code{.rept} directive and the next
5432 @code{.endr} directive @var{count} times.
5434 For example, assembling
5442 is equivalent to assembling
5451 @section @code{.sbttl "@var{subheading}"}
5453 @cindex @code{sbttl} directive
5454 @cindex subtitles for listings
5455 @cindex listing control: subtitle
5456 Use @var{subheading} as the title (third line, immediately after the
5457 title line) when generating assembly listings.
5459 This directive affects subsequent pages, as well as the current page if
5460 it appears within ten lines of the top of a page.
5464 @section @code{.scl @var{class}}
5466 @cindex @code{scl} directive
5467 @cindex symbol storage class (COFF)
5468 @cindex COFF symbol storage class
5469 Set the storage-class value for a symbol. This directive may only be
5470 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
5471 whether a symbol is static or external, or it may record further
5472 symbolic debugging information.
5475 The @samp{.scl} directive is primarily associated with COFF output; when
5476 configured to generate @code{b.out} output format, @command{@value{AS}}
5477 accepts this directive but ignores it.
5483 @section @code{.section @var{name}}
5485 @cindex named section
5486 Use the @code{.section} directive to assemble the following code into a section
5489 This directive is only supported for targets that actually support arbitrarily
5490 named sections; on @code{a.out} targets, for example, it is not accepted, even
5491 with a standard @code{a.out} section name.
5495 @c only print the extra heading if both COFF and ELF are set
5496 @subheading COFF Version
5499 @cindex @code{section} directive (COFF version)
5500 For COFF targets, the @code{.section} directive is used in one of the following
5504 .section @var{name}[, "@var{flags}"]
5505 .section @var{name}[, @var{subsegment}]
5508 If the optional argument is quoted, it is taken as flags to use for the
5509 section. Each flag is a single character. The following flags are recognized:
5512 bss section (uninitialized data)
5514 section is not loaded
5524 shared section (meaningful for PE targets)
5526 ignored. (For compatibility with the ELF version)
5529 If no flags are specified, the default flags depend upon the section name. If
5530 the section name is not recognized, the default will be for the section to be
5531 loaded and writable. Note the @code{n} and @code{w} flags remove attributes
5532 from the section, rather than adding them, so if they are used on their own it
5533 will be as if no flags had been specified at all.
5535 If the optional argument to the @code{.section} directive is not quoted, it is
5536 taken as a subsegment number (@pxref{Sub-Sections}).
5541 @c only print the extra heading if both COFF and ELF are set
5542 @subheading ELF Version
5545 @cindex Section Stack
5546 This is one of the ELF section stack manipulation directives. The others are
5547 @code{.subsection} (@pxref{SubSection}), @code{.pushsection}
5548 (@pxref{PushSection}), @code{.popsection} (@pxref{PopSection}), and
5549 @code{.previous} (@pxref{Previous}).
5551 @cindex @code{section} directive (ELF version)
5552 For ELF targets, the @code{.section} directive is used like this:
5555 .section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]]
5558 The optional @var{flags} argument is a quoted string which may contain any
5559 combination of the following characters:
5562 section is allocatable
5566 section is executable
5568 section is mergeable
5570 section contains zero terminated strings
5572 section is a member of a section group
5574 section is used for thread-local-storage
5577 The optional @var{type} argument may contain one of the following constants:
5580 section contains data
5582 section does not contain data (i.e., section only occupies space)
5584 section contains data which is used by things other than the program
5586 section contains an array of pointers to init functions
5588 section contains an array of pointers to finish functions
5589 @item @@preinit_array
5590 section contains an array of pointers to pre-init functions
5593 Many targets only support the first three section types.
5595 Note on targets where the @code{@@} character is the start of a comment (eg
5596 ARM) then another character is used instead. For example the ARM port uses the
5599 If @var{flags} contains the @code{M} symbol then the @var{type} argument must
5600 be specified as well as an extra argument---@var{entsize}---like this:
5603 .section @var{name} , "@var{flags}"M, @@@var{type}, @var{entsize}
5606 Sections with the @code{M} flag but not @code{S} flag must contain fixed size
5607 constants, each @var{entsize} octets long. Sections with both @code{M} and
5608 @code{S} must contain zero terminated strings where each character is
5609 @var{entsize} bytes long. The linker may remove duplicates within sections with
5610 the same name, same entity size and same flags. @var{entsize} must be an
5611 absolute expression.
5613 If @var{flags} contains the @code{G} symbol then the @var{type} argument must
5614 be present along with an additional field like this:
5617 .section @var{name} , "@var{flags}"G, @@@var{type}, @var{GroupName}[, @var{linkage}]
5620 The @var{GroupName} field specifies the name of the section group to which this
5621 particular section belongs. The optional linkage field can contain:
5624 indicates that only one copy of this section should be retained
5629 Note: if both the @var{M} and @var{G} flags are present then the fields for
5630 the Merge flag should come first, like this:
5633 .section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}]
5636 If no flags are specified, the default flags depend upon the section name. If
5637 the section name is not recognized, the default will be for the section to have
5638 none of the above flags: it will not be allocated in memory, nor writable, nor
5639 executable. The section will contain data.
5641 For ELF targets, the assembler supports another type of @code{.section}
5642 directive for compatibility with the Solaris assembler:
5645 .section "@var{name}"[, @var{flags}...]
5648 Note that the section name is quoted. There may be a sequence of comma
5652 section is allocatable
5656 section is executable
5658 section is used for thread local storage
5661 This directive replaces the current section and subsection. See the
5662 contents of the gas testsuite directory @code{gas/testsuite/gas/elf} for
5663 some examples of how this directive and the other section stack directives
5669 @section @code{.set @var{symbol}, @var{expression}}
5671 @cindex @code{set} directive
5672 @cindex symbol value, setting
5673 Set the value of @var{symbol} to @var{expression}. This
5674 changes @var{symbol}'s value and type to conform to
5675 @var{expression}. If @var{symbol} was flagged as external, it remains
5676 flagged (@pxref{Symbol Attributes}).
5678 You may @code{.set} a symbol many times in the same assembly.
5680 If you @code{.set} a global symbol, the value stored in the object
5681 file is the last value stored into it.
5684 The syntax for @code{set} on the HPPA is
5685 @samp{@var{symbol} .set @var{expression}}.
5689 On Z80 @code{set} is a real instruction, use
5690 @samp{@var{symbol} defl @var{expression}} instead.
5694 @section @code{.short @var{expressions}}
5696 @cindex @code{short} directive
5698 @code{.short} is normally the same as @samp{.word}.
5699 @xref{Word,,@code{.word}}.
5701 In some configurations, however, @code{.short} and @code{.word} generate
5702 numbers of different lengths. @xref{Machine Dependencies}.
5706 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
5709 This expects zero or more @var{expressions}, and emits
5710 a 16 bit number for each.
5715 @section @code{.single @var{flonums}}
5717 @cindex @code{single} directive
5718 @cindex floating point numbers (single)
5719 This directive assembles zero or more flonums, separated by commas. It
5720 has the same effect as @code{.float}.
5722 The exact kind of floating point numbers emitted depends on how
5723 @command{@value{AS}} is configured. @xref{Machine Dependencies}.
5727 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
5728 numbers in @sc{ieee} format.
5734 @section @code{.size}
5736 This directive is used to set the size associated with a symbol.
5740 @c only print the extra heading if both COFF and ELF are set
5741 @subheading COFF Version
5744 @cindex @code{size} directive (COFF version)
5745 For COFF targets, the @code{.size} directive is only permitted inside
5746 @code{.def}/@code{.endef} pairs. It is used like this:
5749 .size @var{expression}
5753 @samp{.size} is only meaningful when generating COFF format output; when
5754 @command{@value{AS}} is generating @code{b.out}, it accepts this directive but
5761 @c only print the extra heading if both COFF and ELF are set
5762 @subheading ELF Version
5765 @cindex @code{size} directive (ELF version)
5766 For ELF targets, the @code{.size} directive is used like this:
5769 .size @var{name} , @var{expression}
5772 This directive sets the size associated with a symbol @var{name}.
5773 The size in bytes is computed from @var{expression} which can make use of label
5774 arithmetic. This directive is typically used to set the size of function
5780 @section @code{.sleb128 @var{expressions}}
5782 @cindex @code{sleb128} directive
5783 @var{sleb128} stands for ``signed little endian base 128.'' This is a
5784 compact, variable length representation of numbers used by the DWARF
5785 symbolic debugging format. @xref{Uleb128, ,@code{.uleb128}}.
5787 @ifclear no-space-dir
5789 @section @code{.skip @var{size} , @var{fill}}
5791 @cindex @code{skip} directive
5792 @cindex filling memory
5793 This directive emits @var{size} bytes, each of value @var{fill}. Both
5794 @var{size} and @var{fill} are absolute expressions. If the comma and
5795 @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same as
5799 @section @code{.space @var{size} , @var{fill}}
5801 @cindex @code{space} directive
5802 @cindex filling memory
5803 This directive emits @var{size} bytes, each of value @var{fill}. Both
5804 @var{size} and @var{fill} are absolute expressions. If the comma
5805 and @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same
5810 @emph{Warning:} @code{.space} has a completely different meaning for HPPA
5811 targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
5812 Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the
5813 @code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives},
5821 @section @code{.stabd, .stabn, .stabs}
5823 @cindex symbolic debuggers, information for
5824 @cindex @code{stab@var{x}} directives
5825 There are three directives that begin @samp{.stab}.
5826 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
5827 The symbols are not entered in the @command{@value{AS}} hash table: they
5828 cannot be referenced elsewhere in the source file.
5829 Up to five fields are required:
5833 This is the symbol's name. It may contain any character except
5834 @samp{\000}, so is more general than ordinary symbol names. Some
5835 debuggers used to code arbitrarily complex structures into symbol names
5839 An absolute expression. The symbol's type is set to the low 8 bits of
5840 this expression. Any bit pattern is permitted, but @code{@value{LD}}
5841 and debuggers choke on silly bit patterns.
5844 An absolute expression. The symbol's ``other'' attribute is set to the
5845 low 8 bits of this expression.
5848 An absolute expression. The symbol's descriptor is set to the low 16
5849 bits of this expression.
5852 An absolute expression which becomes the symbol's value.
5855 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
5856 or @code{.stabs} statement, the symbol has probably already been created;
5857 you get a half-formed symbol in your object file. This is
5858 compatible with earlier assemblers!
5861 @cindex @code{stabd} directive
5862 @item .stabd @var{type} , @var{other} , @var{desc}
5864 The ``name'' of the symbol generated is not even an empty string.
5865 It is a null pointer, for compatibility. Older assemblers used a
5866 null pointer so they didn't waste space in object files with empty
5869 The symbol's value is set to the location counter,
5870 relocatably. When your program is linked, the value of this symbol
5871 is the address of the location counter when the @code{.stabd} was
5874 @cindex @code{stabn} directive
5875 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
5876 The name of the symbol is set to the empty string @code{""}.
5878 @cindex @code{stabs} directive
5879 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
5880 All five fields are specified.
5886 @section @code{.string} "@var{str}"
5888 @cindex string, copying to object file
5889 @cindex @code{string} directive
5891 Copy the characters in @var{str} to the object file. You may specify more than
5892 one string to copy, separated by commas. Unless otherwise specified for a
5893 particular machine, the assembler marks the end of each string with a 0 byte.
5894 You can use any of the escape sequences described in @ref{Strings,,Strings}.
5897 @section @code{.struct @var{expression}}
5899 @cindex @code{struct} directive
5900 Switch to the absolute section, and set the section offset to @var{expression},
5901 which must be an absolute expression. You might use this as follows:
5910 This would define the symbol @code{field1} to have the value 0, the symbol
5911 @code{field2} to have the value 4, and the symbol @code{field3} to have the
5912 value 8. Assembly would be left in the absolute section, and you would need to
5913 use a @code{.section} directive of some sort to change to some other section
5914 before further assembly.
5918 @section @code{.subsection @var{name}}
5920 @cindex @code{subsection} directive
5921 @cindex Section Stack
5922 This is one of the ELF section stack manipulation directives. The others are
5923 @code{.section} (@pxref{Section}), @code{.pushsection} (@pxref{PushSection}),
5924 @code{.popsection} (@pxref{PopSection}), and @code{.previous}
5927 This directive replaces the current subsection with @code{name}. The current
5928 section is not changed. The replaced subsection is put onto the section stack
5929 in place of the then current top of stack subsection.
5934 @section @code{.symver}
5935 @cindex @code{symver} directive
5936 @cindex symbol versioning
5937 @cindex versions of symbols
5938 Use the @code{.symver} directive to bind symbols to specific version nodes
5939 within a source file. This is only supported on ELF platforms, and is
5940 typically used when assembling files to be linked into a shared library.
5941 There are cases where it may make sense to use this in objects to be bound
5942 into an application itself so as to override a versioned symbol from a
5945 For ELF targets, the @code{.symver} directive can be used like this:
5947 .symver @var{name}, @var{name2@@nodename}
5949 If the symbol @var{name} is defined within the file
5950 being assembled, the @code{.symver} directive effectively creates a symbol
5951 alias with the name @var{name2@@nodename}, and in fact the main reason that we
5952 just don't try and create a regular alias is that the @var{@@} character isn't
5953 permitted in symbol names. The @var{name2} part of the name is the actual name
5954 of the symbol by which it will be externally referenced. The name @var{name}
5955 itself is merely a name of convenience that is used so that it is possible to
5956 have definitions for multiple versions of a function within a single source
5957 file, and so that the compiler can unambiguously know which version of a
5958 function is being mentioned. The @var{nodename} portion of the alias should be
5959 the name of a node specified in the version script supplied to the linker when
5960 building a shared library. If you are attempting to override a versioned
5961 symbol from a shared library, then @var{nodename} should correspond to the
5962 nodename of the symbol you are trying to override.
5964 If the symbol @var{name} is not defined within the file being assembled, all
5965 references to @var{name} will be changed to @var{name2@@nodename}. If no
5966 reference to @var{name} is made, @var{name2@@nodename} will be removed from the
5969 Another usage of the @code{.symver} directive is:
5971 .symver @var{name}, @var{name2@@@@nodename}
5973 In this case, the symbol @var{name} must exist and be defined within
5974 the file being assembled. It is similar to @var{name2@@nodename}. The
5975 difference is @var{name2@@@@nodename} will also be used to resolve
5976 references to @var{name2} by the linker.
5978 The third usage of the @code{.symver} directive is:
5980 .symver @var{name}, @var{name2@@@@@@nodename}
5982 When @var{name} is not defined within the
5983 file being assembled, it is treated as @var{name2@@nodename}. When
5984 @var{name} is defined within the file being assembled, the symbol
5985 name, @var{name}, will be changed to @var{name2@@@@nodename}.
5990 @section @code{.tag @var{structname}}
5992 @cindex COFF structure debugging
5993 @cindex structure debugging, COFF
5994 @cindex @code{tag} directive
5995 This directive is generated by compilers to include auxiliary debugging
5996 information in the symbol table. It is only permitted inside
5997 @code{.def}/@code{.endef} pairs. Tags are used to link structure
5998 definitions in the symbol table with instances of those structures.
6001 @samp{.tag} is only used when generating COFF format output; when
6002 @command{@value{AS}} is generating @code{b.out}, it accepts this directive but
6008 @section @code{.text @var{subsection}}
6010 @cindex @code{text} directive
6011 Tells @command{@value{AS}} to assemble the following statements onto the end of
6012 the text subsection numbered @var{subsection}, which is an absolute
6013 expression. If @var{subsection} is omitted, subsection number zero
6017 @section @code{.title "@var{heading}"}
6019 @cindex @code{title} directive
6020 @cindex listing control: title line
6021 Use @var{heading} as the title (second line, immediately after the
6022 source file name and pagenumber) when generating assembly listings.
6024 This directive affects subsequent pages, as well as the current page if
6025 it appears within ten lines of the top of a page.
6029 @section @code{.type}
6031 This directive is used to set the type of a symbol.
6035 @c only print the extra heading if both COFF and ELF are set
6036 @subheading COFF Version
6039 @cindex COFF symbol type
6040 @cindex symbol type, COFF
6041 @cindex @code{type} directive (COFF version)
6042 For COFF targets, this directive is permitted only within
6043 @code{.def}/@code{.endef} pairs. It is used like this:
6049 This records the integer @var{int} as the type attribute of a symbol table
6053 @samp{.type} is associated only with COFF format output; when
6054 @command{@value{AS}} is configured for @code{b.out} output, it accepts this
6055 directive but ignores it.
6061 @c only print the extra heading if both COFF and ELF are set
6062 @subheading ELF Version
6065 @cindex ELF symbol type
6066 @cindex symbol type, ELF
6067 @cindex @code{type} directive (ELF version)
6068 For ELF targets, the @code{.type} directive is used like this:
6071 .type @var{name} , @var{type description}
6074 This sets the type of symbol @var{name} to be either a
6075 function symbol or an object symbol. There are five different syntaxes
6076 supported for the @var{type description} field, in order to provide
6077 compatibility with various other assemblers.
6079 Because some of the characters used in these syntaxes (such as @samp{@@} and
6080 @samp{#}) are comment characters for some architectures, some of the syntaxes
6081 below do not work on all architectures. The first variant will be accepted by
6082 the GNU assembler on all architectures so that variant should be used for
6083 maximum portability, if you do not need to assemble your code with other
6086 The syntaxes supported are:
6089 .type <name> STT_FUNCTION
6090 .type <name> STT_OBJECT
6092 .type <name>,#function
6093 .type <name>,#object
6095 .type <name>,@@function
6096 .type <name>,@@object
6098 .type <name>,%function
6099 .type <name>,%object
6101 .type <name>,"function"
6102 .type <name>,"object"
6108 @section @code{.uleb128 @var{expressions}}
6110 @cindex @code{uleb128} directive
6111 @var{uleb128} stands for ``unsigned little endian base 128.'' This is a
6112 compact, variable length representation of numbers used by the DWARF
6113 symbolic debugging format. @xref{Sleb128, ,@code{.sleb128}}.
6117 @section @code{.val @var{addr}}
6119 @cindex @code{val} directive
6120 @cindex COFF value attribute
6121 @cindex value attribute, COFF
6122 This directive, permitted only within @code{.def}/@code{.endef} pairs,
6123 records the address @var{addr} as the value attribute of a symbol table
6127 @samp{.val} is used only for COFF output; when @command{@value{AS}} is
6128 configured for @code{b.out}, it accepts this directive but ignores it.
6134 @section @code{.version "@var{string}"}
6136 @cindex @code{version} directive
6137 This directive creates a @code{.note} section and places into it an ELF
6138 formatted note of type NT_VERSION. The note's name is set to @code{string}.
6143 @section @code{.vtable_entry @var{table}, @var{offset}}
6145 @cindex @code{vtable_entry} directive
6146 This directive finds or creates a symbol @code{table} and creates a
6147 @code{VTABLE_ENTRY} relocation for it with an addend of @code{offset}.
6150 @section @code{.vtable_inherit @var{child}, @var{parent}}
6152 @cindex @code{vtable_inherit} directive
6153 This directive finds the symbol @code{child} and finds or creates the symbol
6154 @code{parent} and then creates a @code{VTABLE_INHERIT} relocation for the
6155 parent whose addend is the value of the child symbol. As a special case the
6156 parent name of @code{0} is treated as referring to the @code{*ABS*} section.
6160 @section @code{.warning "@var{string}"}
6161 @cindex warning directive
6162 Similar to the directive @code{.error}
6163 (@pxref{Error,,@code{.error "@var{string}"}}), but just emits a warning.
6166 @section @code{.weak @var{names}}
6168 @cindex @code{weak} directive
6169 This directive sets the weak attribute on the comma separated list of symbol
6170 @code{names}. If the symbols do not already exist, they will be created.
6172 On COFF targets other than PE, weak symbols are a GNU extension. This
6173 directive sets the weak attribute on the comma separated list of symbol
6174 @code{names}. If the symbols do not already exist, they will be created.
6176 On the PE target, weak symbols are supported natively as weak aliases.
6177 When a weak symbol is created that is not an alias, GAS creates an
6178 alternate symbol to hold the default value.
6181 @section @code{.weakref @var{alias}, @var{target}}
6183 @cindex @code{weakref} directive
6184 This directive creates an alias to the target symbol that enables the symbol to
6185 be referenced with weak-symbol semantics, but without actually making it weak.
6186 If direct references or definitions of the symbol are present, then the symbol
6187 will not be weak, but if all references to it are through weak references, the
6188 symbol will be marked as weak in the symbol table.
6190 The effect is equivalent to moving all references to the alias to a separate
6191 assembly source file, renaming the alias to the symbol in it, declaring the
6192 symbol as weak there, and running a reloadable link to merge the object files
6193 resulting from the assembly of the new source file and the old source file that
6194 had the references to the alias removed.
6196 The alias itself never makes to the symbol table, and is entirely handled
6197 within the assembler.
6200 @section @code{.word @var{expressions}}
6202 @cindex @code{word} directive
6203 This directive expects zero or more @var{expressions}, of any section,
6204 separated by commas.
6207 For each expression, @command{@value{AS}} emits a 32-bit number.
6210 For each expression, @command{@value{AS}} emits a 16-bit number.
6215 The size of the number emitted, and its byte order,
6216 depend on what target computer the assembly is for.
6219 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
6220 @c happen---32-bit addressability, period; no long/short jumps.
6221 @ifset DIFF-TBL-KLUGE
6222 @cindex difference tables altered
6223 @cindex altered difference tables
6225 @emph{Warning: Special Treatment to support Compilers}
6229 Machines with a 32-bit address space, but that do less than 32-bit
6230 addressing, require the following special treatment. If the machine of
6231 interest to you does 32-bit addressing (or doesn't require it;
6232 @pxref{Machine Dependencies}), you can ignore this issue.
6235 In order to assemble compiler output into something that works,
6236 @command{@value{AS}} occasionally does strange things to @samp{.word} directives.
6237 Directives of the form @samp{.word sym1-sym2} are often emitted by
6238 compilers as part of jump tables. Therefore, when @command{@value{AS}} assembles a
6239 directive of the form @samp{.word sym1-sym2}, and the difference between
6240 @code{sym1} and @code{sym2} does not fit in 16 bits, @command{@value{AS}}
6241 creates a @dfn{secondary jump table}, immediately before the next label.
6242 This secondary jump table is preceded by a short-jump to the
6243 first byte after the secondary table. This short-jump prevents the flow
6244 of control from accidentally falling into the new table. Inside the
6245 table is a long-jump to @code{sym2}. The original @samp{.word}
6246 contains @code{sym1} minus the address of the long-jump to
6249 If there were several occurrences of @samp{.word sym1-sym2} before the
6250 secondary jump table, all of them are adjusted. If there was a
6251 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
6252 long-jump to @code{sym4} is included in the secondary jump table,
6253 and the @code{.word} directives are adjusted to contain @code{sym3}
6254 minus the address of the long-jump to @code{sym4}; and so on, for as many
6255 entries in the original jump table as necessary.
6258 @emph{This feature may be disabled by compiling @command{@value{AS}} with the
6259 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
6260 assembly language programmers.
6263 @c end DIFF-TBL-KLUGE
6266 @section Deprecated Directives
6268 @cindex deprecated directives
6269 @cindex obsolescent directives
6270 One day these directives won't work.
6271 They are included for compatibility with older assemblers.
6278 @node Machine Dependencies
6279 @chapter Machine Dependent Features
6281 @cindex machine dependencies
6282 The machine instruction sets are (almost by definition) different on
6283 each machine where @command{@value{AS}} runs. Floating point representations
6284 vary as well, and @command{@value{AS}} often supports a few additional
6285 directives or command-line options for compatibility with other
6286 assemblers on a particular platform. Finally, some versions of
6287 @command{@value{AS}} support special pseudo-instructions for branch
6290 This chapter discusses most of these differences, though it does not
6291 include details on any machine's instruction set. For details on that
6292 subject, see the hardware manufacturer's manual.
6296 * Alpha-Dependent:: Alpha Dependent Features
6299 * ARC-Dependent:: ARC Dependent Features
6302 * ARM-Dependent:: ARM Dependent Features
6305 * AVR-Dependent:: AVR Dependent Features
6308 * BFIN-Dependent:: BFIN Dependent Features
6311 * CRIS-Dependent:: CRIS Dependent Features
6314 * D10V-Dependent:: D10V Dependent Features
6317 * D30V-Dependent:: D30V Dependent Features
6320 * H8/300-Dependent:: Renesas H8/300 Dependent Features
6323 * HPPA-Dependent:: HPPA Dependent Features
6326 * ESA/390-Dependent:: IBM ESA/390 Dependent Features
6329 * i386-Dependent:: Intel 80386 and AMD x86-64 Dependent Features
6332 * i860-Dependent:: Intel 80860 Dependent Features
6335 * i960-Dependent:: Intel 80960 Dependent Features
6338 * IA-64-Dependent:: Intel IA-64 Dependent Features
6341 * IP2K-Dependent:: IP2K Dependent Features
6344 * M32C-Dependent:: M32C Dependent Features
6347 * M32R-Dependent:: M32R Dependent Features
6350 * M68K-Dependent:: M680x0 Dependent Features
6353 * M68HC11-Dependent:: M68HC11 and 68HC12 Dependent Features
6356 * MIPS-Dependent:: MIPS Dependent Features
6359 * MMIX-Dependent:: MMIX Dependent Features
6362 * MSP430-Dependent:: MSP430 Dependent Features
6365 * SH-Dependent:: Renesas / SuperH SH Dependent Features
6366 * SH64-Dependent:: SuperH SH64 Dependent Features
6369 * PDP-11-Dependent:: PDP-11 Dependent Features
6372 * PJ-Dependent:: picoJava Dependent Features
6375 * PPC-Dependent:: PowerPC Dependent Features
6378 * Sparc-Dependent:: SPARC Dependent Features
6381 * TIC54X-Dependent:: TI TMS320C54x Dependent Features
6384 * V850-Dependent:: V850 Dependent Features
6387 * Xtensa-Dependent:: Xtensa Dependent Features
6390 * Z80-Dependent:: Z80 Dependent Features
6393 * Z8000-Dependent:: Z8000 Dependent Features
6396 * Vax-Dependent:: VAX Dependent Features
6403 @c The following major nodes are *sections* in the GENERIC version, *chapters*
6404 @c in single-cpu versions. This is mainly achieved by @lowersections. There is a
6405 @c peculiarity: to preserve cross-references, there must be a node called
6406 @c "Machine Dependencies". Hence the conditional nodenames in each
6407 @c major node below. Node defaulting in makeinfo requires adjacency of
6408 @c node and sectioning commands; hence the repetition of @chapter BLAH
6409 @c in both conditional blocks.
6412 @include c-alpha.texi
6428 @include c-bfin.texi
6432 @include c-cris.texi
6437 @node Machine Dependencies
6438 @chapter Machine Dependent Features
6440 The machine instruction sets are different on each Renesas chip family,
6441 and there are also some syntax differences among the families. This
6442 chapter describes the specific @command{@value{AS}} features for each
6446 * H8/300-Dependent:: Renesas H8/300 Dependent Features
6447 * SH-Dependent:: Renesas SH Dependent Features
6454 @include c-d10v.texi
6458 @include c-d30v.texi
6462 @include c-h8300.texi
6466 @include c-hppa.texi
6470 @include c-i370.texi
6474 @include c-i386.texi
6478 @include c-i860.texi
6482 @include c-i960.texi
6486 @include c-ia64.texi
6490 @include c-ip2k.texi
6494 @include c-m32c.texi
6498 @include c-m32r.texi
6502 @include c-m68k.texi
6506 @include c-m68hc11.texi
6510 @include c-mips.texi
6514 @include c-mmix.texi
6518 @include c-msp430.texi
6522 @include c-ns32k.texi
6526 @include c-pdp11.texi
6539 @include c-sh64.texi
6543 @include c-sparc.texi
6547 @include c-tic54x.texi
6563 @include c-v850.texi
6567 @include c-xtensa.texi
6571 @c reverse effect of @down at top of generic Machine-Dep chapter
6575 @node Reporting Bugs
6576 @chapter Reporting Bugs
6577 @cindex bugs in assembler
6578 @cindex reporting bugs in assembler
6580 Your bug reports play an essential role in making @command{@value{AS}} reliable.
6582 Reporting a bug may help you by bringing a solution to your problem, or it may
6583 not. But in any case the principal function of a bug report is to help the
6584 entire community by making the next version of @command{@value{AS}} work better.
6585 Bug reports are your contribution to the maintenance of @command{@value{AS}}.
6587 In order for a bug report to serve its purpose, you must include the
6588 information that enables us to fix the bug.
6591 * Bug Criteria:: Have you found a bug?
6592 * Bug Reporting:: How to report bugs
6596 @section Have You Found a Bug?
6597 @cindex bug criteria
6599 If you are not sure whether you have found a bug, here are some guidelines:
6602 @cindex fatal signal
6603 @cindex assembler crash
6604 @cindex crash of assembler
6606 If the assembler gets a fatal signal, for any input whatever, that is a
6607 @command{@value{AS}} bug. Reliable assemblers never crash.
6609 @cindex error on valid input
6611 If @command{@value{AS}} produces an error message for valid input, that is a bug.
6613 @cindex invalid input
6615 If @command{@value{AS}} does not produce an error message for invalid input, that
6616 is a bug. However, you should note that your idea of ``invalid input'' might
6617 be our idea of ``an extension'' or ``support for traditional practice''.
6620 If you are an experienced user of assemblers, your suggestions for improvement
6621 of @command{@value{AS}} are welcome in any case.
6625 @section How to Report Bugs
6627 @cindex assembler bugs, reporting
6629 A number of companies and individuals offer support for @sc{gnu} products. If
6630 you obtained @command{@value{AS}} from a support organization, we recommend you
6631 contact that organization first.
6633 You can find contact information for many support companies and
6634 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
6637 In any event, we also recommend that you send bug reports for @command{@value{AS}}
6638 to @samp{bug-binutils@@gnu.org}.
6640 The fundamental principle of reporting bugs usefully is this:
6641 @strong{report all the facts}. If you are not sure whether to state a
6642 fact or leave it out, state it!
6644 Often people omit facts because they think they know what causes the problem
6645 and assume that some details do not matter. Thus, you might assume that the
6646 name of a symbol you use in an example does not matter. Well, probably it does
6647 not, but one cannot be sure. Perhaps the bug is a stray memory reference which
6648 happens to fetch from the location where that name is stored in memory;
6649 perhaps, if the name were different, the contents of that location would fool
6650 the assembler into doing the right thing despite the bug. Play it safe and
6651 give a specific, complete example. That is the easiest thing for you to do,
6652 and the most helpful.
6654 Keep in mind that the purpose of a bug report is to enable us to fix the bug if
6655 it is new to us. Therefore, always write your bug reports on the assumption
6656 that the bug has not been reported previously.
6658 Sometimes people give a few sketchy facts and ask, ``Does this ring a
6659 bell?'' This cannot help us fix a bug, so it is basically useless. We
6660 respond by asking for enough details to enable us to investigate.
6661 You might as well expedite matters by sending them to begin with.
6663 To enable us to fix the bug, you should include all these things:
6667 The version of @command{@value{AS}}. @command{@value{AS}} announces it if you start
6668 it with the @samp{--version} argument.
6670 Without this, we will not know whether there is any point in looking for
6671 the bug in the current version of @command{@value{AS}}.
6674 Any patches you may have applied to the @command{@value{AS}} source.
6677 The type of machine you are using, and the operating system name and
6681 What compiler (and its version) was used to compile @command{@value{AS}}---e.g.
6685 The command arguments you gave the assembler to assemble your example and
6686 observe the bug. To guarantee you will not omit something important, list them
6687 all. A copy of the Makefile (or the output from make) is sufficient.
6689 If we were to try to guess the arguments, we would probably guess wrong
6690 and then we might not encounter the bug.
6693 A complete input file that will reproduce the bug. If the bug is observed when
6694 the assembler is invoked via a compiler, send the assembler source, not the
6695 high level language source. Most compilers will produce the assembler source
6696 when run with the @samp{-S} option. If you are using @code{@value{GCC}}, use
6697 the options @samp{-v --save-temps}; this will save the assembler source in a
6698 file with an extension of @file{.s}, and also show you exactly how
6699 @command{@value{AS}} is being run.
6702 A description of what behavior you observe that you believe is
6703 incorrect. For example, ``It gets a fatal signal.''
6705 Of course, if the bug is that @command{@value{AS}} gets a fatal signal, then we
6706 will certainly notice it. But if the bug is incorrect output, we might not
6707 notice unless it is glaringly wrong. You might as well not give us a chance to
6710 Even if the problem you experience is a fatal signal, you should still say so
6711 explicitly. Suppose something strange is going on, such as, your copy of
6712 @command{@value{AS}} is out of sync, or you have encountered a bug in the C
6713 library on your system. (This has happened!) Your copy might crash and ours
6714 would not. If you told us to expect a crash, then when ours fails to crash, we
6715 would know that the bug was not happening for us. If you had not told us to
6716 expect a crash, then we would not be able to draw any conclusion from our
6720 If you wish to suggest changes to the @command{@value{AS}} source, send us context
6721 diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p}
6722 option. Always send diffs from the old file to the new file. If you even
6723 discuss something in the @command{@value{AS}} source, refer to it by context, not
6726 The line numbers in our development sources will not match those in your
6727 sources. Your line numbers would convey no useful information to us.
6730 Here are some things that are not necessary:
6734 A description of the envelope of the bug.
6736 Often people who encounter a bug spend a lot of time investigating
6737 which changes to the input file will make the bug go away and which
6738 changes will not affect it.
6740 This is often time consuming and not very useful, because the way we
6741 will find the bug is by running a single example under the debugger
6742 with breakpoints, not by pure deduction from a series of examples.
6743 We recommend that you save your time for something else.
6745 Of course, if you can find a simpler example to report @emph{instead}
6746 of the original one, that is a convenience for us. Errors in the
6747 output will be easier to spot, running under the debugger will take
6748 less time, and so on.
6750 However, simplification is not vital; if you do not want to do this,
6751 report the bug anyway and send us the entire test case you used.
6754 A patch for the bug.
6756 A patch for the bug does help us if it is a good one. But do not omit
6757 the necessary information, such as the test case, on the assumption that
6758 a patch is all we need. We might see problems with your patch and decide
6759 to fix the problem another way, or we might not understand it at all.
6761 Sometimes with a program as complicated as @command{@value{AS}} it is very hard to
6762 construct an example that will make the program follow a certain path through
6763 the code. If you do not send us the example, we will not be able to construct
6764 one, so we will not be able to verify that the bug is fixed.
6766 And if we cannot understand what bug you are trying to fix, or why your
6767 patch should be an improvement, we will not install it. A test case will
6768 help us to understand.
6771 A guess about what the bug is or what it depends on.
6773 Such guesses are usually wrong. Even we cannot guess right about such
6774 things without first using the debugger to find the facts.
6777 @node Acknowledgements
6778 @chapter Acknowledgements
6780 If you have contributed to GAS and your name isn't listed here,
6781 it is not meant as a slight. We just don't know about it. Send mail to the
6782 maintainer, and we'll correct the situation. Currently
6784 the maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
6786 Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any
6789 Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug
6790 information and the 68k series machines, most of the preprocessing pass, and
6791 extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}.
6793 K. Richard Pixley maintained GAS for a while, adding various enhancements and
6794 many bug fixes, including merging support for several processors, breaking GAS
6795 up to handle multiple object file format back ends (including heavy rewrite,
6796 testing, an integration of the coff and b.out back ends), adding configuration
6797 including heavy testing and verification of cross assemblers and file splits
6798 and renaming, converted GAS to strictly ANSI C including full prototypes, added
6799 support for m680[34]0 and cpu32, did considerable work on i960 including a COFF
6800 port (including considerable amounts of reverse engineering), a SPARC opcode
6801 file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know''
6802 assertions and made them work, much other reorganization, cleanup, and lint.
6804 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
6805 in format-specific I/O modules.
6807 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
6808 has done much work with it since.
6810 The Intel 80386 machine description was written by Eliot Dresselhaus.
6812 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
6814 The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
6815 University and Torbjorn Granlund of the Swedish Institute of Computer Science.
6817 Keith Knowles at the Open Software Foundation wrote the original MIPS back end
6818 (@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support
6819 (which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to
6820 support a.out format.
6822 Support for the Zilog Z8k and Renesas H8/300 processors (tc-z8k,
6823 tc-h8300), and IEEE 695 object file format (obj-ieee), was written by
6824 Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
6825 use BFD for some low-level operations, for use with the H8/300 and AMD 29k
6828 John Gilmore built the AMD 29000 support, added @code{.include} support, and
6829 simplified the configuration of which versions accept which directives. He
6830 updated the 68k machine description so that Motorola's opcodes always produced
6831 fixed-size instructions (e.g., @code{jsr}), while synthetic instructions
6832 remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested
6833 cross-compilation support, and one bug in relaxation that took a week and
6834 required the proverbial one-bit fix.
6836 Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the
6837 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
6838 added support for MIPS ECOFF and ELF targets, wrote the initial RS/6000 and
6839 PowerPC assembler, and made a few other minor patches.
6841 Steve Chamberlain made GAS able to generate listings.
6843 Hewlett-Packard contributed support for the HP9000/300.
6845 Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM)
6846 along with a fairly extensive HPPA testsuite (for both SOM and ELF object
6847 formats). This work was supported by both the Center for Software Science at
6848 the University of Utah and Cygnus Support.
6850 Support for ELF format files has been worked on by Mark Eichin of Cygnus
6851 Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
6852 Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
6853 Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
6854 and some initial 64-bit support).
6856 Linas Vepstas added GAS support for the ESA/390 ``IBM 370'' architecture.
6858 Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD
6859 support for openVMS/Alpha.
6861 Timothy Wall, Michael Hayes, and Greg Smart contributed to the various tic*
6864 David Heine, Sterling Augustine, Bob Wilson and John Ruttenberg from Tensilica,
6865 Inc.@: added support for Xtensa processors.
6867 Several engineers at Cygnus Support have also provided many small bug fixes and
6868 configuration enhancements.
6870 Many others have contributed large or small bugfixes and enhancements. If
6871 you have contributed significant work and are not mentioned on this list, and
6872 want to be, let us know. Some of the history has been lost; we are not
6873 intentionally leaving anyone out.
6878 @unnumbered AS Index