[ gas/ChangeLog ]
[deliverable/binutils-gdb.git] / gas / doc / as.texinfo
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
9 @c in config/tc-*.c
10 @c (3) for object-format specific directives, examine obj_pseudo_op
11 @c in config/obj-*.c
12 @c (4) portable directives in potable[] in read.c
13 @c %**start of header
14 @setfilename as.info
15 @c ---config---
16 @macro gcctabopt{body}
17 @code{\body\}
18 @end macro
19 @c defaults, config file may override:
20 @set have-stabs
21 @c ---
22 @c man begin NAME
23 @c ---
24 @include asconfig.texi
25 @include gasver.texi
26 @c ---
27 @c man end
28 @c ---
29 @c common OR combinations of conditions
30 @ifset COFF
31 @set COFF-ELF
32 @end ifset
33 @ifset ELF
34 @set COFF-ELF
35 @end ifset
36 @ifset AOUT
37 @set aout-bout
38 @end ifset
39 @ifset ARM/Thumb
40 @set ARM
41 @end ifset
42 @ifset BOUT
43 @set aout-bout
44 @end ifset
45 @ifset H8/300
46 @set H8
47 @end ifset
48 @ifset SH
49 @set H8
50 @end ifset
51 @ifset HPPA
52 @set abnormal-separator
53 @end ifset
54 @c ------------
55 @ifset GENERIC
56 @settitle Using @value{AS}
57 @end ifset
58 @ifclear GENERIC
59 @settitle Using @value{AS} (@value{TARGET})
60 @end ifclear
61 @setchapternewpage odd
62 @c %**end of header
63
64 @c @smallbook
65 @c @set SMALL
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.
70 @c
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
74 @c break.
75 @c
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.
81 @ifinfo
82 @set SMALL
83 @c the insn tables look just as silly in info files regardless of smallbook,
84 @c might as well show 'em anyways.
85 @end ifinfo
86
87 @ifinfo
88 @format
89 START-INFO-DIR-ENTRY
90 * As: (as). The GNU assembler.
91 * Gas: (as). The GNU assembler.
92 END-INFO-DIR-ENTRY
93 @end format
94 @end ifinfo
95
96 @finalout
97 @syncodeindex ky cp
98
99 @ifinfo
100 This file documents the GNU Assembler "@value{AS}".
101
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.
104
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''.
111
112 @c man end
113
114 @ignore
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).
119
120 @end ignore
121 @end ifinfo
122
123 @titlepage
124 @title Using @value{AS}
125 @subtitle The @sc{gnu} Assembler
126 @ifclear GENERIC
127 @subtitle for the @value{TARGET} family
128 @end ifclear
129 @sp 1
130 @subtitle Version @value{VERSION}
131 @sp 1
132 @sp 13
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
138 done.
139 @sp 3
140 @author Dean Elsner, Jay Fenlason & friends
141 @page
142 @tex
143 {\parskip=0pt
144 \hfill {\it Using {\tt @value{AS}}}\par
145 \hfill Edited by Cygnus Support\par
146 }
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
153 @end tex
154
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.
157
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''.
164
165 @end titlepage
166
167 @ifnottex
168 @node Top
169 @top Using @value{AS}
170
171 This file is a user guide to the @sc{gnu} assembler @command{@value{AS}} version
172 @value{VERSION}.
173 @ifclear GENERIC
174 This version of the file describes @command{@value{AS}} configured to generate
175 code for @value{TARGET} architectures.
176 @end ifclear
177
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''.
181
182 @menu
183 * Overview:: Overview
184 * Invoking:: Command-Line Options
185 * Syntax:: Syntax
186 * Sections:: Sections and Relocation
187 * Symbols:: Symbols
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
195 @end menu
196 @end ifnottex
197
198 @node Overview
199 @chapter Overview
200 @iftex
201 This manual is a user guide to the @sc{gnu} assembler @command{@value{AS}}.
202 @ifclear GENERIC
203 This version of the manual describes @command{@value{AS}} configured to generate
204 code for @value{TARGET} architectures.
205 @end ifclear
206 @end iftex
207
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}.
213
214 @c man title AS the portable GNU assembler.
215
216 @ignore
217 @c man begin SEEALSO
218 gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
219 @c man end
220 @end ignore
221
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.
224 @smallexample
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{}]
237 @c
238 @c Target dependent options are listed below. Keep the list sorted.
239 @c Add an empty line for separation.
240 @ifset ALPHA
241
242 @emph{Target Alpha options:}
243 [@b{-m@var{cpu}}]
244 [@b{-mdebug} | @b{-no-mdebug}]
245 [@b{-relax}] [@b{-g}] [@b{-G@var{size}}]
246 [@b{-F}] [@b{-32addr}]
247 @end ifset
248 @ifset ARC
249
250 @emph{Target ARC options:}
251 [@b{-marc[5|6|7|8]}]
252 [@b{-EB}|@b{-EL}]
253 @end ifset
254 @ifset ARM
255
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}]
263 [@b{-mthumb}]
264 [@b{-EB}|@b{-EL}]
265 [@b{-mapcs-32}|@b{-mapcs-26}|@b{-mapcs-float}|
266 @b{-mapcs-reentrant}]
267 [@b{-mthumb-interwork}] [@b{-k}]
268 @end ifset
269 @ifset CRIS
270
271 @emph{Target CRIS options:}
272 [@b{--underscore} | @b{--no-underscore}]
273 [@b{--pic}] [@b{-N}]
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.
277 @c [@b{-h}] [@b{-H}]
278 @end ifset
279 @ifset D10V
280
281 @emph{Target D10V options:}
282 [@b{-O}]
283 @end ifset
284 @ifset D30V
285
286 @emph{Target D30V options:}
287 [@b{-O}|@b{-n}|@b{-N}]
288 @end ifset
289 @ifset H8
290 @c Renesas family chips have no machine-dependent assembler options
291 @end ifset
292 @ifset HPPA
293 @c HPPA has no machine-dependent assembler options (yet).
294 @end ifset
295 @ifset I80386
296
297 @emph{Target i386 options:}
298 [@b{--32}|@b{--64}] [@b{-n}]
299 [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}]
300 @end ifset
301 @ifset I960
302
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}|
306 @b{-AKC}|@b{-AMC}]
307 [@b{-b}] [@b{-no-relax}]
308 @end ifset
309 @ifset IA64
310
311 @emph{Target IA-64 options:}
312 [@b{-mconstant-gp}|@b{-mauto-pic}]
313 [@b{-milp32}|@b{-milp64}|@b{-mlp64}|@b{-mp64}]
314 [@b{-mle}|@b{mbe}]
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}]
319 @end ifset
320 @ifset IP2K
321
322 @emph{Target IP2K options:}
323 [@b{-mip2022}|@b{-mip2022ext}]
324 @end ifset
325 @ifset M32C
326
327 @emph{Target M32C options:}
328 [@b{-m32c}|@b{-m16c}]
329 @end ifset
330 @ifset M32R
331
332 @emph{Target M32R options:}
333 [@b{--m32rx}|@b{--[no-]warn-explicit-parallel-conflicts}|
334 @b{--W[n]p}]
335 @end ifset
336 @ifset M680X0
337
338 @emph{Target M680X0 options:}
339 [@b{-l}] [@b{-m68000}|@b{-m68010}|@b{-m68020}|@dots{}]
340 @end ifset
341 @ifset M68HC11
342
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}]
350 @end ifset
351 @ifset MCORE
352
353 @emph{Target MCORE options:}
354 [@b{-jsri2bsr}] [@b{-sifilter}] [@b{-relax}]
355 [@b{-mcpu=[210|340]}]
356 @end ifset
357 @ifset MIPS
358
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}]
379 @end ifset
380 @ifset MMIX
381
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}]
387 @end ifset
388 @ifset PDP11
389
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}]
394 @end ifset
395 @ifset PJ
396
397 @emph{Target picoJava options:}
398 [@b{-mb}|@b{-me}]
399 @end ifset
400 @ifset PPC
401
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}]
411 @end ifset
412 @ifset SPARC
413
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}]
419 [@b{-32}|@b{-64}]
420 @end ifset
421 @ifset TIC54X
422
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>}]
426 @end ifset
427
428 @ifset Z80
429
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}]
438 @end ifset
439
440 @ifset Z8000
441 @c Z8000 has no machine-dependent assembler options
442 @end ifset
443 @ifset XTENSA
444
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}]
450 @end ifset
451 @c man end
452 @end smallexample
453
454 @c man begin OPTIONS
455
456 @table @gcctabopt
457 @include at-file.texi
458
459 @item -a[cdhlmns]
460 Turn on listings, in any of a variety of ways:
461
462 @table @gcctabopt
463 @item -ac
464 omit false conditionals
465
466 @item -ad
467 omit debugging directives
468
469 @item -ah
470 include high-level source
471
472 @item -al
473 include assembly
474
475 @item -am
476 include macro expansions
477
478 @item -an
479 omit forms processing
480
481 @item -as
482 include symbols
483
484 @item =file
485 set the name of the listing file
486 @end table
487
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}.
491
492 @item --alternate
493 Begin in alternate macro mode.
494 @ifclear man
495 @xref{Altmacro,,@code{.altmacro}}.
496 @end ifclear
497
498 @item -D
499 Ignored. This option is accepted for script compatibility with calls to
500 other assemblers.
501
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.
508
509 @item -f
510 ``fast''---skip whitespace and comment preprocessing (assume source is
511 compiler output).
512
513 @item -g
514 @itemx --gen-debug
515 Generate debugging information for each assembler source line using whichever
516 debug format is preferred by the target. This currently means either STABS,
517 ECOFF or DWARF2.
518
519 @item --gstabs
520 Generate stabs debugging information for each assembler line. This
521 may help debugging assembler code, if the debugger can handle it.
522
523 @item --gstabs+
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.
529
530 @item --gdwarf-2
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.
534
535 @item --help
536 Print a summary of the command line options and exit.
537
538 @item --target-help
539 Print a summary of all target specific options and exit.
540
541 @item -I @var{dir}
542 Add directory @var{dir} to the search list for @code{.include} directives.
543
544 @item -J
545 Don't warn about signed overflow.
546
547 @item -K
548 @ifclear DIFF-TBL-KLUGE
549 This option is accepted but has no effect on the @value{TARGET} family.
550 @end ifclear
551 @ifset DIFF-TBL-KLUGE
552 Issue warnings when difference tables altered for long displacements.
553 @end ifset
554
555 @item -L
556 @itemx --keep-locals
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.
560 @ifclear man
561 @xref{Symbol Names}.
562 @end ifclear
563
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}.
567
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}.
571
572 @item --listing-rhs-width=@var{number}
573 Set the maximum width of an input source line, as displayed in a listing, to
574 @var{number} bytes.
575
576 @item --listing-cont-lines=@var{number}
577 Set the maximum number of lines printed in a listing for a single line of input
578 to @var{number} + 1.
579
580 @item -o @var{objfile}
581 Name the object-file output from @command{@value{AS}} @var{objfile}.
582
583 @item -R
584 Fold the data section into the text section.
585
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.
592
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.
597
598 @item --statistics
599 Print the maximum space (in bytes) and total time (in seconds) used by
600 assembly.
601
602 @item --strip-local-absolute
603 Remove local absolute symbols from the outgoing symbol table.
604
605 @item -v
606 @itemx -version
607 Print the @command{as} version.
608
609 @item --version
610 Print the @command{as} version and exit.
611
612 @item -W
613 @itemx --no-warn
614 Suppress warning messages.
615
616 @item --fatal-warnings
617 Treat warnings as errors.
618
619 @item --warn
620 Don't suppress warning messages or treat them as errors.
621
622 @item -w
623 Ignored.
624
625 @item -x
626 Ignored.
627
628 @item -Z
629 Generate an object file even after errors.
630
631 @item -- | @var{files} @dots{}
632 Standard input, or source files to assemble.
633
634 @end table
635
636 @ifset ARC
637 The following options are available when @value{AS} is configured for
638 an ARC processor.
639
640 @table @gcctabopt
641 @item -marc[5|6|7|8]
642 This option selects the core processor variant.
643 @item -EB | -EL
644 Select either big-endian (-EB) or little-endian (-EL) output.
645 @end table
646 @end ifset
647
648 @ifset ARM
649 The following options are available when @value{AS} is configured for the ARM
650 processor family.
651
652 @table @gcctabopt
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.
661 @item -mthumb
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.
665 @item -EB | -EL
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
669 ARM code in mind.
670 @item -k
671 Specify that PIC code has been generated.
672 @end table
673 @end ifset
674
675 @ifset CRIS
676 See the info pages for documentation of the CRIS-specific options.
677 @end ifset
678
679 @ifset D10V
680 The following options are available when @value{AS} is configured for
681 a D10V processor.
682 @table @gcctabopt
683 @cindex D10V optimization
684 @cindex optimization, D10V
685 @item -O
686 Optimize output by parallelizing instructions.
687 @end table
688 @end ifset
689
690 @ifset D30V
691 The following options are available when @value{AS} is configured for a D30V
692 processor.
693 @table @gcctabopt
694 @cindex D30V optimization
695 @cindex optimization, D30V
696 @item -O
697 Optimize output by parallelizing instructions.
698
699 @cindex D30V nops
700 @item -n
701 Warn when nops are generated.
702
703 @cindex D30V nops after 32-bit multiply
704 @item -N
705 Warn when a nop after a 32-bit multiply instruction is generated.
706 @end table
707 @end ifset
708
709 @ifset I960
710 The following options are available when @value{AS} is configured for the
711 Intel 80960 processor.
712
713 @table @gcctabopt
714 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
715 Specify which variant of the 960 architecture is the target.
716
717 @item -b
718 Add code to collect statistics about branches taken.
719
720 @item -no-relax
721 Do not alter compare-and-branch instructions for long displacements;
722 error if necessary.
723
724 @end table
725 @end ifset
726
727 @ifset IP2K
728 The following options are available when @value{AS} is configured for the
729 Ubicom IP2K series.
730
731 @table @gcctabopt
732
733 @item -mip2022ext
734 Specifies that the extended IP2022 instructions are allowed.
735
736 @item -mip2022
737 Restores the default behaviour, which restricts the permitted instructions to
738 just the basic IP2022 ones.
739
740 @end table
741 @end ifset
742
743 @ifset M32C
744 The following options are available when @value{AS} is configured for the
745 Renesas M32C and M16C processors.
746
747 @table @gcctabopt
748
749 @item -m32c
750 Assemble M32C instructions.
751
752 @item -m16c
753 Assemble M16C instructions (the default).
754
755 @end table
756 @end ifset
757
758 @ifset M32R
759 The following options are available when @value{AS} is configured for the
760 Renesas M32R (formerly Mitsubishi M32R) series.
761
762 @table @gcctabopt
763
764 @item --m32rx
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.
767
768 @item --warn-explicit-parallel-conflicts or --Wp
769 Produce warning messages when questionable parallel constructs are
770 encountered.
771
772 @item --no-warn-explicit-parallel-conflicts or --Wnp
773 Do not produce warning messages when questionable parallel constructs are
774 encountered.
775
776 @end table
777 @end ifset
778
779 @ifset M680X0
780 The following options are available when @value{AS} is configured for the
781 Motorola 68000 series.
782
783 @table @gcctabopt
784
785 @item -l
786 Shorten references to undefined symbols, to one word instead of two.
787
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.
793
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.
800
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.
804
805 @end table
806 @end ifset
807
808 @ifset PDP11
809
810 For details about the PDP-11 machine dependent features options,
811 see @ref{PDP-11-Options}.
812
813 @table @gcctabopt
814 @item -mpic | -mno-pic
815 Generate position-independent (or position-dependent) code. The
816 default is @option{-mpic}.
817
818 @item -mall
819 @itemx -mall-extensions
820 Enable all instruction set extensions. This is the default.
821
822 @item -mno-extensions
823 Disable all instruction set extensions.
824
825 @item -m@var{extension} | -mno-@var{extension}
826 Enable (or disable) a particular instruction set extension.
827
828 @item -m@var{cpu}
829 Enable the instruction set extensions supported by a particular CPU, and
830 disable all other extensions.
831
832 @item -m@var{machine}
833 Enable the instruction set extensions supported by a particular machine
834 model, and disable all other extensions.
835 @end table
836
837 @end ifset
838
839 @ifset PJ
840 The following options are available when @value{AS} is configured for
841 a picoJava processor.
842
843 @table @gcctabopt
844
845 @cindex PJ endianness
846 @cindex endianness, PJ
847 @cindex big endian output, PJ
848 @item -mb
849 Generate ``big endian'' format output.
850
851 @cindex little endian output, PJ
852 @item -ml
853 Generate ``little endian'' format output.
854
855 @end table
856 @end ifset
857
858 @ifset M68HC11
859 The following options are available when @value{AS} is configured for the
860 Motorola 68HC11 or 68HC12 series.
861
862 @table @gcctabopt
863
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.
867
868 @item -mshort
869 Specify to use the 16-bit integer ABI.
870
871 @item -mlong
872 Specify to use the 32-bit integer ABI.
873
874 @item -mshort-double
875 Specify to use the 32-bit double ABI.
876
877 @item -mlong-double
878 Specify to use the 64-bit double ABI.
879
880 @item --force-long-branches
881 Relative branches are turned into absolute ones. This concerns
882 conditional branches, unconditional branches and branches to a
883 sub routine.
884
885 @item -S | --short-branches
886 Do not turn relative branches into absolute ones
887 when the offset is out of range.
888
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.
892
893 @item --print-insn-syntax
894 Print the syntax of instruction in case of error.
895
896 @item --print-opcodes
897 print the list of instructions with syntax and then exit.
898
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}}.
902
903 @end table
904 @end ifset
905
906 @ifset SPARC
907 The following options are available when @command{@value{AS}} is configured
908 for the SPARC architecture:
909
910 @table @gcctabopt
911 @item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
912 @itemx -Av8plus | -Av8plusa | -Av9 | -Av9a
913 Explicitly select a variant of the SPARC architecture.
914
915 @samp{-Av8plus} and @samp{-Av8plusa} select a 32 bit environment.
916 @samp{-Av9} and @samp{-Av9a} select a 64 bit environment.
917
918 @samp{-Av8plusa} and @samp{-Av9a} enable the SPARC V9 instruction set with
919 UltraSPARC extensions.
920
921 @item -xarch=v8plus | -xarch=v8plusa
922 For compatibility with the Solaris v9 assembler. These options are
923 equivalent to -Av8plus and -Av8plusa, respectively.
924
925 @item -bump
926 Warn when the assembler switches to another architecture.
927 @end table
928 @end ifset
929
930 @ifset TIC54X
931 The following options are available when @value{AS} is configured for the 'c54x
932 architecture.
933
934 @table @gcctabopt
935 @item -mfar-mode
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.
943 @end table
944 @end ifset
945
946 @ifset MIPS
947 The following options are available when @value{AS} is configured for
948 a @sc{mips} processor.
949
950 @table @gcctabopt
951 @item -G @var{num}
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.
955
956 @cindex MIPS endianness
957 @cindex endianness, MIPS
958 @cindex big endian output, MIPS
959 @item -EB
960 Generate ``big endian'' format output.
961
962 @cindex little endian output, MIPS
963 @item -EL
964 Generate ``little endian'' format output.
965
966 @cindex MIPS ISA
967 @item -mips1
968 @itemx -mips2
969 @itemx -mips3
970 @itemx -mips4
971 @itemx -mips5
972 @itemx -mips32
973 @itemx -mips32r2
974 @itemx -mips64
975 @itemx -mips64r2
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
981 @samp{-mips64r2}
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.
986
987 @item -march=@var{CPU}
988 Generate code for a particular @sc{mips} cpu.
989
990 @item -mtune=@var{cpu}
991 Schedule and tune for a particular @sc{mips} cpu.
992
993 @item -mfix7000
994 @itemx -mno-fix7000
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.
997
998 @item -mdebug
999 @itemx -no-mdebug
1000 Cause stabs-style debugging output to go into an ECOFF-style .mdebug
1001 section instead of the standard ELF .stabs sections.
1002
1003 @item -mpdr
1004 @itemx -mno-pdr
1005 Control generation of @code{.pdr} sections.
1006
1007 @item -mgp32
1008 @itemx -mfp32
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.
1013
1014 @item -mips16
1015 @itemx -no-mips16
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.
1019
1020 @item -msmartmips
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.
1025
1026 @item -mips3d
1027 @itemx -no-mips3d
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.
1031
1032 @item -mdmx
1033 @itemx -no-mdmx
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.
1037
1038 @item -mdsp
1039 @itemx -mno-dsp
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.
1043
1044 @item -mdspr2
1045 @itemx -mno-dspr2
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.
1050
1051 @item -mmt
1052 @itemx -mno-mt
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.
1056
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.
1064
1065 @cindex emulation
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.
1078
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.
1085
1086 Eventually, this option will support more configurations, with more
1087 fine-grained control over the assembler's behavior, and will be supported for
1088 more processors.
1089
1090 @item -nocpp
1091 @command{@value{AS}} ignores this option. It is accepted for compatibility with
1092 the native tools.
1093
1094 @item --trap
1095 @itemx --no-trap
1096 @itemx --break
1097 @itemx --no-break
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
1102 break exception.
1103
1104 @item -n
1105 When this option is used, @command{@value{AS}} will issue a warning every
1106 time it generates a nop instruction from a macro.
1107 @end table
1108 @end ifset
1109
1110 @ifset MCORE
1111 The following options are available when @value{AS} is configured for
1112 an MCore processor.
1113
1114 @table @gcctabopt
1115 @item -jsri2bsr
1116 @itemx -nojsri2bsr
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.
1119
1120 @item -sifilter
1121 @itemx -nosifilter
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.
1124
1125 @item -relax
1126 Alter jump instructions for long displacements.
1127
1128 @item -mcpu=[210|340]
1129 Select the cpu type on the target hardware. This controls which instructions
1130 can be assembled.
1131
1132 @item -EB
1133 Assemble for a big endian target.
1134
1135 @item -EL
1136 Assemble for a little endian target.
1137
1138 @end table
1139 @end ifset
1140
1141 @ifset MMIX
1142 See the info pages for documentation of the MMIX-specific options.
1143 @end ifset
1144
1145 @ifset XTENSA
1146 The following options are available when @value{AS} is configured for
1147 an Xtensa processor.
1148
1149 @table @gcctabopt
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.
1157
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.
1163
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}.
1167
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}.
1172
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.
1178 @end table
1179 @end ifset
1180
1181 @ifset Z80
1182 The following options are available when @value{AS} is configured for
1183 a Z80 family processor.
1184 @table @gcctabopt
1185 @item -z80
1186 Assemble for Z80 processor.
1187 @item -r800
1188 Assemble for R800 processor.
1189 @item -ignore-undocumented-instructions
1190 @itemx -Wnud
1191 Assemble undocumented Z80 instructions that also work on R800 without warning.
1192 @item -ignore-unportable-instructions
1193 @itemx -Wnup
1194 Assemble all undocumented Z80 instructions without warning.
1195 @item -warn-undocumented-instructions
1196 @itemx -Wud
1197 Issue a warning for undocumented Z80 instructions that also work on R800.
1198 @item -warn-unportable-instructions
1199 @itemx -Wup
1200 Issue a warning for undocumented Z80 instructions that do not work on R800.
1201 @item -forbid-undocumented-instructions
1202 @itemx -Fud
1203 Treat all undocumented instructions as errors.
1204 @item -forbid-unportable-instructions
1205 @itemx -Fup
1206 Treat undocumented Z80 instructions that do not work on R800 as errors.
1207 @end table
1208 @end ifset
1209
1210 @c man end
1211
1212 @menu
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
1220 @end menu
1221
1222 @node Manual
1223 @section Structure of this Manual
1224
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}}.
1230
1231 @ifclear GENERIC
1232 We also cover special features in the @value{TARGET}
1233 configuration of @command{@value{AS}}, including assembler directives.
1234 @end ifclear
1235 @ifset GENERIC
1236 This manual also describes some of the machine-dependent features of
1237 various flavors of the assembler.
1238 @end ifset
1239
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.
1247 @ifset GENERIC
1248 You may want to consult the manufacturer's
1249 machine architecture manual for this information.
1250 @end ifset
1251 @ifclear GENERIC
1252 @ifset H8/300
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).
1256 @end ifset
1257 @ifset SH
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).
1262 @end ifset
1263 @ifset Z8000
1264 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
1265 @end ifset
1266 @end ifclear
1267
1268 @c I think this is premature---doc@cygnus.com, 17jan1991
1269 @ignore
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
1275 qualification.
1276
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.
1281 @end ignore
1282
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
1290 @c directives).
1291
1292 @node GNU Assembler
1293 @section The GNU Assembler
1294
1295 @c man begin DESCRIPTION
1296
1297 @sc{gnu} @command{as} is really a family of assemblers.
1298 @ifclear GENERIC
1299 This manual describes @command{@value{AS}}, a member of that family which is
1300 configured for the @value{TARGET} architectures.
1301 @end ifclear
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
1307
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.
1314 @ifset VAX
1315 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
1316 @end ifset
1317 @ifset M680X0
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.
1323 @end ifset
1324
1325 @c man end
1326
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}}).
1330
1331 @node Object Formats
1332 @section Object File Formats
1333
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}.
1340 @ifclear GENERIC
1341 @ifclear MULTI-OBJ
1342 For the @value{TARGET} target, @command{@value{AS}} is configured to produce
1343 @value{OBJ-NAME} format object files.
1344 @end ifclear
1345 @c The following should exhaust all configs that set MULTI-OBJ, ideally
1346 @ifset I960
1347 On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
1348 @code{b.out} or COFF format object files.
1349 @end ifset
1350 @ifset HPPA
1351 On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
1352 SOM or ELF format object files.
1353 @end ifset
1354 @end ifclear
1355
1356 @node Command Line
1357 @section Command Line
1358
1359 @cindex command line conventions
1360
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
1364 significant.
1365
1366 @cindex standard input, as input file
1367 @kindex --
1368 @file{--} (two hyphens) by itself names the standard input file
1369 explicitly, as one of the files for @command{@value{AS}} to assemble.
1370
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.
1377
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:
1382
1383 @smallexample
1384 @value{AS} -o my-object-file.o mumble.s
1385 @value{AS} -omy-object-file.o mumble.s
1386 @end smallexample
1387
1388 @node Input Files
1389 @section Input Files
1390
1391 @cindex input
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.
1398
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
1402 order specified.
1403
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.)
1408
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.
1413
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
1417 to assemble.
1418
1419 Use @samp{--} if you need to explicitly name the standard input file
1420 in your command line.
1421
1422 If the source is empty, @command{@value{AS}} produces a small, empty object
1423 file.
1424
1425 @c man end
1426
1427 @subheading Filenames and Line-numbers
1428
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}.
1435
1436 @dfn{Physical files} are those files named in the command line given
1437 to @command{@value{AS}}.
1438
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}}.
1445
1446 @node Object
1447 @section Output (Object) File
1448
1449 @cindex object file
1450 @cindex output file
1451 @kindex a.out
1452 @kindex .o
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
1456 @ifclear BOUT
1457 @code{a.out}.
1458 @end ifclear
1459 @ifset BOUT
1460 @ifset GENERIC
1461 @code{a.out}, or
1462 @end ifset
1463 @code{b.out} when @command{@value{AS}} is configured for the Intel 80960.
1464 @end ifset
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.)
1470
1471 @cindex linker
1472 @kindex ld
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.
1477
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.
1480
1481 @node Errors
1482 @section Error and Warning Messages
1483
1484 @c man begin DESCRIPTION
1485
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.
1494
1495 @c man end
1496
1497 @cindex format of warning messages
1498 Warning messages have the format
1499
1500 @smallexample
1501 file_name:@b{NNN}:Warning Message Text
1502 @end smallexample
1503
1504 @noindent
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
1509 @ifset GENERIC
1510 (@pxref{Line,,@code{.line}})
1511 @end ifset
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
1515 tradition).
1516
1517 @cindex format of error messages
1518 Error messages have the format
1519 @smallexample
1520 file_name:@b{NNN}:FATAL:Error Message Text
1521 @end smallexample
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.
1525
1526 @node Invoking
1527 @chapter Command-Line Options
1528
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
1533 @ifclear GENERIC
1534 to the @value{TARGET} target.
1535 @end ifclear
1536 @ifset GENERIC
1537 to particular machine architectures.
1538 @end ifset
1539
1540 @c man begin DESCRIPTION
1541
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:
1546
1547 @smallexample
1548 gcc -c -g -O -Wa,-alh,-L file.c
1549 @end smallexample
1550
1551 @noindent
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).
1555
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
1560 assembler.)
1561
1562 @c man end
1563
1564 @menu
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
1572 @end ifclear
1573 @ifset DIFF-TBL-KLUGE
1574 * K:: -K for difference tables
1575 @end ifset
1576
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
1588 @end menu
1589
1590 @node a
1591 @section Enable Listings: @option{-a[cdhlns]}
1592
1593 @kindex -a
1594 @kindex -ac
1595 @kindex -ad
1596 @kindex -ah
1597 @kindex -al
1598 @kindex -an
1599 @kindex -as
1600 @cindex listings, enabling
1601 @cindex assembly listings, enabling
1602
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
1611 also.
1612
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.
1617
1618 Use the @samp{-ad} option to omit debugging directives from the
1619 listing.
1620
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
1624 @code{.sbttl}.
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.
1628
1629 The letters after @samp{-a} may be combined into one option,
1630 @emph{e.g.}, @samp{-aln}.
1631
1632 Note if the assembler source is coming from the standard input (e.g.,
1633 because it
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.
1639
1640 @node alternate
1641 @section @option{--alternate}
1642
1643 @kindex --alternate
1644 Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
1645
1646 @node D
1647 @section @option{-D}
1648
1649 @kindex -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}}.
1653
1654 @node f
1655 @section Work Faster: @option{-f}
1656
1657 @kindex -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,
1664 ,Preprocessing}.
1665
1666 @quotation
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
1669 not work correctly.
1670 @end quotation
1671
1672 @node I
1673 @section @code{.include} Search Path: @option{-I} @var{path}
1674
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.
1686
1687 @node K
1688 @section Difference Tables: @option{-K}
1689
1690 @kindex -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.
1698 @end ifclear
1699
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
1706 is done.
1707 @end ifset
1708
1709 @node L
1710 @section Include Local Symbols: @option{-L}
1711
1712 @kindex -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.
1721
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.
1725
1726 @node listing
1727 @section Configuring listing output: @option{--listing}
1728
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:
1737
1738 @table @gcctabopt
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.
1744
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.
1752
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.
1759
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.
1765 @end table
1766
1767 @node M
1768 @section Assemble in MRI Compatibility Mode: @option{-M}
1769
1770 @kindex -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}}.
1780
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:
1785
1786 @itemize @bullet
1787 @item global symbols in common section
1788
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.
1794
1795 @item complex relocations
1796
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.
1800
1801 @item @code{END} pseudo-op specifying start address
1802
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
1806 script.
1807
1808 @item @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops
1809
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.
1812
1813 @item @code{ORG} pseudo-op
1814
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.
1820 @end itemize
1821
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.
1825
1826 @itemize @bullet
1827
1828 @item EBCDIC strings
1829
1830 EBCDIC strings are not supported.
1831
1832 @item packed binary coded decimal
1833
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.
1836
1837 @item @code{FEQU} pseudo-op
1838
1839 The m68k @code{FEQU} pseudo-op is not supported.
1840
1841 @item @code{NOOBJ} pseudo-op
1842
1843 The m68k @code{NOOBJ} pseudo-op is not supported.
1844
1845 @item @code{OPT} branch control options
1846
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.
1851
1852 @item @code{OPT} list control options
1853
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}.
1857
1858 @item other @code{OPT} options
1859
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}.
1862
1863 @item @code{OPT} @code{D} option is default
1864
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.
1867
1868 @item @code{XREF} pseudo-op.
1869
1870 The m68k @code{XREF} pseudo-op is ignored.
1871
1872 @item @code{.debug} pseudo-op
1873
1874 The i960 @code{.debug} pseudo-op is not supported.
1875
1876 @item @code{.extended} pseudo-op
1877
1878 The i960 @code{.extended} pseudo-op is not supported.
1879
1880 @item @code{.list} pseudo-op.
1881
1882 The various options of the i960 @code{.list} pseudo-op are not supported.
1883
1884 @item @code{.optimize} pseudo-op
1885
1886 The i960 @code{.optimize} pseudo-op is not supported.
1887
1888 @item @code{.output} pseudo-op
1889
1890 The i960 @code{.output} pseudo-op is not supported.
1891
1892 @item @code{.setreal} pseudo-op
1893
1894 The i960 @code{.setreal} pseudo-op is not supported.
1895
1896 @end itemize
1897
1898 @node MD
1899 @section Dependency Tracking: @option{--MD}
1900
1901 @kindex --MD
1902 @cindex dependency tracking
1903 @cindex make rules
1904
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.
1908
1909 The rule is written to the file named in its argument.
1910
1911 This feature is used in the automatic updating of makefiles.
1912
1913 @node o
1914 @section Name the Object File: @option{-o}
1915
1916 @kindex -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
1921 @ifset GENERIC
1922 @ifset I960
1923 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
1924 @end ifset
1925 @ifclear I960
1926 @file{a.out}.
1927 @end ifclear
1928 @end ifset
1929 @ifclear GENERIC
1930 @ifset I960
1931 @file{b.out}.
1932 @end ifset
1933 @ifclear I960
1934 @file{a.out}.
1935 @end ifclear
1936 @end ifclear
1937 You use this option (which takes exactly one filename) to give the
1938 object file a different name.
1939
1940 Whatever the object file is called, @command{@value{AS}} overwrites any
1941 existing file of the same name.
1942
1943 @node R
1944 @section Join Data and Text Sections: @option{-R}
1945
1946 @kindex -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}.)
1957
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.
1962
1963 @ifset COFF-ELF
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
1966 @samp{.data}.
1967 @end ifset
1968
1969 @ifset HPPA
1970 @option{-R} is not supported for any of the HPPA targets. Using
1971 @option{-R} generates a warning from @command{@value{AS}}.
1972 @end ifset
1973
1974 @node statistics
1975 @section Display Assembly Statistics: @option{--statistics}
1976
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}
1984 seconds).
1985
1986 @node traditional-format
1987 @section Compatible Output: @option{--traditional-format}
1988
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.
1993
1994 For example, it disables the exception frame optimizations which
1995 @command{@value{AS}} normally does by default on @code{@value{GCC}} output.
1996
1997 @node v
1998 @section Announce Version: @option{-v}
1999
2000 @kindex -v
2001 @kindex -version
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
2006 command line.
2007
2008 @node W
2009 @section Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings}
2010
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.
2015
2016 @kindex -W
2017 @kindex --no-warn
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,
2023 are still reported.
2024
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.
2030
2031 @kindex --warn
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.
2035
2036 @node Z
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.}
2046
2047 @node Syntax
2048 @chapter Syntax
2049
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
2055 @ifclear VAX
2056 assembler.
2057 @end ifclear
2058 @ifset VAX
2059 assembler, except that @command{@value{AS}} does not assemble Vax bit-fields.
2060 @end ifset
2061
2062 @menu
2063 * Preprocessing:: Preprocessing
2064 * Whitespace:: Whitespace
2065 * Comments:: Comments
2066 * Symbol Intro:: Symbols
2067 * Statements:: Statements
2068 * Constants:: Constants
2069 @end menu
2070
2071 @node Preprocessing
2072 @section Preprocessing
2073
2074 @cindex preprocessing
2075 The @command{@value{AS}} internal preprocessor:
2076 @itemize @bullet
2077 @cindex whitespace, removed by preprocessor
2078 @item
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
2081 a single space.
2082
2083 @cindex comments, removed by preprocessor
2084 @item
2085 removes all comments, replacing them with a single space, or an
2086 appropriate number of newlines.
2087
2088 @cindex constants, converted by preprocessor
2089 @item
2090 converts character constants into the appropriate numeric values.
2091 @end itemize
2092
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}.
2100
2101 Excess whitespace, comments, and character constants
2102 cannot be used in the portions of the input text that are not
2103 preprocessed.
2104
2105 @cindex turning preprocessing on and off
2106 @cindex preprocessing, turning on and off
2107 @kindex #NO_APP
2108 @kindex #APP
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
2116 and whitespace.
2117
2118 @node Whitespace
2119 @section Whitespace
2120
2121 @cindex whitespace
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.
2127
2128 @node Comments
2129 @section Comments
2130
2131 @cindex comments
2132 There are two ways of rendering comments to @command{@value{AS}}. In both
2133 cases the comment is equivalent to one space.
2134
2135 Anything from @samp{/*} through the next @samp{*/} is a comment.
2136 This means you may not nest these comments.
2137
2138 @smallexample
2139 /*
2140 The only way to include a newline ('\n') in a comment
2141 is to use this sort of comment.
2142 */
2143
2144 /* This sort of comment does not nest. */
2145 @end smallexample
2146
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
2150 @ifset ARC
2151 @samp{;} on the ARC;
2152 @end ifset
2153 @ifset ARM
2154 @samp{@@} on the ARM;
2155 @end ifset
2156 @ifset H8/300
2157 @samp{;} for the H8/300 family;
2158 @end ifset
2159 @ifset HPPA
2160 @samp{;} for the HPPA;
2161 @end ifset
2162 @ifset I80386
2163 @samp{#} on the i386 and x86-64;
2164 @end ifset
2165 @ifset I960
2166 @samp{#} on the i960;
2167 @end ifset
2168 @ifset PDP11
2169 @samp{;} for the PDP-11;
2170 @end ifset
2171 @ifset PJ
2172 @samp{;} for picoJava;
2173 @end ifset
2174 @ifset PPC
2175 @samp{#} for Motorola PowerPC;
2176 @end ifset
2177 @ifset SH
2178 @samp{!} for the Renesas / SuperH SH;
2179 @end ifset
2180 @ifset SPARC
2181 @samp{!} on the SPARC;
2182 @end ifset
2183 @ifset IP2K
2184 @samp{#} on the ip2k;
2185 @end ifset
2186 @ifset M32C
2187 @samp{#} on the m32c;
2188 @end ifset
2189 @ifset M32R
2190 @samp{#} on the m32r;
2191 @end ifset
2192 @ifset M680X0
2193 @samp{|} on the 680x0;
2194 @end ifset
2195 @ifset M68HC11
2196 @samp{#} on the 68HC11 and 68HC12;
2197 @end ifset
2198 @ifset VAX
2199 @samp{#} on the Vax;
2200 @end ifset
2201 @ifset Z80
2202 @samp{;} for the Z80;
2203 @end ifset
2204 @ifset Z8000
2205 @samp{!} for the Z8000;
2206 @end ifset
2207 @ifset V850
2208 @samp{#} on the V850;
2209 @end ifset
2210 @ifset XTENSA
2211 @samp{#} for Xtensa systems;
2212 @end ifset
2213 see @ref{Machine Dependencies}. @refill
2214 @c FIXME What about i860?
2215
2216 @ifset GENERIC
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.
2220 @end ifset
2221
2222 @ifset V850
2223 The V850 assembler also supports a double dash as starting a comment that
2224 extends to the end of the line.
2225
2226 @samp{--};
2227 @end ifset
2228
2229 @kindex #
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.
2237
2238 If the first non-whitespace characters on the line are not numeric,
2239 the line is ignored. (Just like a comment.)
2240
2241 @smallexample
2242 # This is an ordinary comment.
2243 # 42-6 "new_file_name" # New logical file name
2244 # This is logical line # 36.
2245 @end smallexample
2246 This feature is deprecated, and may disappear from future versions
2247 of @command{@value{AS}}.
2248
2249 @node Symbol Intro
2250 @section Symbols
2251
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
2256 @samp{_.$}.
2257 @end ifclear
2258 @ifset SPECIAL-SYMS
2259 @ifclear GENERIC
2260 @ifset H8
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
2264 symbol names.)
2265 @end ifset
2266 @end ifclear
2267 @end ifset
2268 @ifset GENERIC
2269 On most machines, you can also use @code{$} in symbol names; exceptions
2270 are noted in @ref{Machine Dependencies}.
2271 @end ifset
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
2278
2279 @node Statements
2280 @section Statements
2281
2282 @cindex statements, structure of
2283 @cindex line separator character
2284 @cindex statement separator character
2285 @ifclear GENERIC
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.
2291 @end ifclear
2292 @ifset abnormal-separator
2293 @ifset HPPA
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.
2298 @end ifset
2299 @ifset H8
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.
2305 @end ifset
2306 @end ifset
2307 @end ifclear
2308 @ifset GENERIC
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.
2315 @end ifset
2316
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
2321
2322 An empty statement is allowed, and may include whitespace. It is ignored.
2323
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,
2328 @c 13feb91.
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.
2336 @ifset GENERIC
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
2340 language.@refill
2341 @end ifset
2342
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}.
2348
2349 @ifset HPPA
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.
2353 @end ifset
2354
2355 @smallexample
2356 label: .directive followed by something
2357 another_label: # This is an empty statement.
2358 instruction operand_1, operand_2, @dots{}
2359 @end smallexample
2360
2361 @node Constants
2362 @section Constants
2363
2364 @cindex constants
2365 A constant is a number, written so that its value is known by
2366 inspection, without knowing any context. Like this:
2367 @smallexample
2368 @group
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.
2374 @end group
2375 @end smallexample
2376
2377 @menu
2378 * Characters:: Character Constants
2379 * Numbers:: Number Constants
2380 @end menu
2381
2382 @node Characters
2383 @subsection Character Constants
2384
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.
2392
2393 @menu
2394 * Strings:: Strings
2395 * Chars:: Characters
2396 @end menu
2397
2398 @node Strings
2399 @subsubsection Strings
2400
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.
2411
2412 @cindex escape codes, character
2413 @cindex character escape codes
2414 @table @kbd
2415 @c @item \a
2416 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
2417 @c
2418 @cindex @code{\b} (backspace character)
2419 @cindex backspace (@code{\b})
2420 @item \b
2421 Mnemonic for backspace; for ASCII this is octal code 010.
2422
2423 @c @item \e
2424 @c Mnemonic for EOText; for ASCII this is octal code 004.
2425 @c
2426 @cindex @code{\f} (formfeed character)
2427 @cindex formfeed (@code{\f})
2428 @item \f
2429 Mnemonic for FormFeed; for ASCII this is octal code 014.
2430
2431 @cindex @code{\n} (newline character)
2432 @cindex newline (@code{\n})
2433 @item \n
2434 Mnemonic for newline; for ASCII this is octal code 012.
2435
2436 @c @item \p
2437 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
2438 @c
2439 @cindex @code{\r} (carriage return character)
2440 @cindex carriage return (@code{\r})
2441 @item \r
2442 Mnemonic for carriage-Return; for ASCII this is octal code 015.
2443
2444 @c @item \s
2445 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
2446 @c other assemblers.
2447 @c
2448 @cindex @code{\t} (tab)
2449 @cindex tab (@code{\t})
2450 @item \t
2451 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
2452
2453 @c @item \v
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.
2457 @c
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.
2464
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.
2470
2471 @cindex @code{\\} (@samp{\} character)
2472 @cindex backslash (@code{\\})
2473 @item \\
2474 Represents one @samp{\} character.
2475
2476 @c @item \'
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
2480 @c a @samp{'}.
2481 @c
2482 @cindex @code{\"} (doublequote character)
2483 @cindex doublequote (@code{\"})
2484 @item \"
2485 Represents one @samp{"} character. Needed in strings to represent
2486 this character, because an unescaped @samp{"} would end the string.
2487
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.
2495 @end table
2496
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
2501 sequence.
2502
2503 @node Chars
2504 @subsubsection Characters
2505
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
2515 @ifclear GENERIC
2516 @ifclear abnormal-separator
2517 (or semicolon @samp{;})
2518 @end ifclear
2519 @ifset abnormal-separator
2520 @ifset H8
2521 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
2522 Renesas SH)
2523 @end ifset
2524 @end ifset
2525 @end ifclear
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
2531
2532 @node Numbers
2533 @subsection Number Constants
2534
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.
2542
2543 @menu
2544 * Integers:: Integers
2545 * Bignums:: Bignums
2546 * Flonums:: Flonums
2547 @ifclear GENERIC
2548 @ifset I960
2549 * Bit Fields:: Bit Fields
2550 @end ifset
2551 @end ifclear
2552 @end menu
2553
2554 @node Integers
2555 @subsubsection Integers
2556 @cindex integers
2557 @cindex constants, integer
2558
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}.
2563
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}).
2568
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}).
2573
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}.
2578
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}).
2582
2583 @node Bignums
2584 @subsubsection Bignums
2585
2586 @cindex 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.
2592
2593 @node Flonums
2594 @subsubsection Flonums
2595 @cindex flonums
2596 @cindex floating point numbers
2597 @cindex constants, floating point
2598
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.
2606
2607 A flonum is written by writing (in order)
2608 @itemize @bullet
2609 @item
2610 The digit @samp{0}.
2611 @ifset HPPA
2612 (@samp{0} is optional on the HPPA.)
2613 @end ifset
2614
2615 @item
2616 A letter, to tell @command{@value{AS}} the rest of the number is a flonum.
2617 @ifset GENERIC
2618 @kbd{e} is recommended. Case is not important.
2619 @ignore
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}.)
2623 @end ignore
2624
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).
2628
2629 On the ARC, the letter must be one of the letters @samp{DFRS}
2630 (in upper or lower case).
2631
2632 On the Intel 960 architecture, the letter must be
2633 one of the letters @samp{DFT} (in upper or lower case).
2634
2635 On the HPPA architecture, the letter must be @samp{E} (upper case only).
2636 @end ifset
2637 @ifclear GENERIC
2638 @ifset ARC
2639 One of the letters @samp{DFRS} (in upper or lower case).
2640 @end ifset
2641 @ifset H8
2642 One of the letters @samp{DFPRSX} (in upper or lower case).
2643 @end ifset
2644 @ifset HPPA
2645 The letter @samp{E} (upper case only).
2646 @end ifset
2647 @ifset I960
2648 One of the letters @samp{DFT} (in upper or lower case).
2649 @end ifset
2650 @end ifclear
2651
2652 @item
2653 An optional sign: either @samp{+} or @samp{-}.
2654
2655 @item
2656 An optional @dfn{integer part}: zero or more decimal digits.
2657
2658 @item
2659 An optional @dfn{fractional part}: @samp{.} followed by zero
2660 or more decimal digits.
2661
2662 @item
2663 An optional exponent, consisting of:
2664
2665 @itemize @bullet
2666 @item
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.
2670 @item
2671 Optional sign: either @samp{+} or @samp{-}.
2672 @item
2673 One or more decimal digits.
2674 @end itemize
2675
2676 @end itemize
2677
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.
2680
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}}.
2684
2685 @ifclear GENERIC
2686 @ifset I960
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.
2690 @node Bit Fields
2691 @subsubsection Bit Fields
2692
2693 @cindex 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---
2697 @example
2698 @var{mask}:@var{value}
2699 @end example
2700 @noindent
2701 @command{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
2702 @var{value}.
2703
2704 The resulting number is then packed
2705 @ifset GENERIC
2706 @c this conditional paren in case bit fields turned on elsewhere than 960
2707 (in host-dependent byte order)
2708 @end ifset
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
2714
2715 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
2716 @code{.short}, and @code{.word} accept bit-field arguments.
2717 @end ifset
2718 @end ifclear
2719
2720 @node Sections
2721 @chapter Sections and Relocation
2722 @cindex sections
2723 @cindex relocation
2724
2725 @menu
2726 * Secs Background:: Background
2727 * Ld Sections:: Linker Sections
2728 * As Sections:: Assembler Internal Sections
2729 * Sub-Sections:: Sub-Sections
2730 * bss:: bss Section
2731 @end menu
2732
2733 @node Secs Background
2734 @section Background
2735
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.
2739
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
2748 sections.
2749
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.
2757 @ifset H8
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.
2761 @end ifset
2762
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
2766 @dfn{bss} sections.
2767
2768 @ifset COFF-ELF
2769 @ifset GENERIC
2770 When it generates COFF or ELF output,
2771 @end ifset
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.
2776 @end ifset
2777
2778 @ifset HPPA
2779 @ifset GENERIC
2780 When @command{@value{AS}} generates SOM or ELF output for the HPPA,
2781 @end ifset
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.
2787
2788 @ifset SOM
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$}.
2793 @end ifset
2794 @end ifset
2795
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.
2798
2799 @ifset HPPA
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.
2803 @end ifset
2804
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
2809 file is mentioned:
2810 @itemize @bullet
2811 @item
2812 Where in the object file is the beginning of this reference to
2813 an address?
2814 @item
2815 How long (in bytes) is this reference?
2816 @item
2817 Which section does the address refer to? What is the numeric value of
2818 @display
2819 (@var{address}) @minus{} (@var{start-address of section})?
2820 @end display
2821 @item
2822 Is the reference to an address ``Program-Counter relative''?
2823 @end itemize
2824
2825 @cindex addresses, format of
2826 @cindex section-relative addressing
2827 In fact, every address @command{@value{AS}} ever uses is expressed as
2828 @display
2829 (@var{section}) + (@var{offset into section})
2830 @end display
2831 @noindent
2832 Further, most expressions @command{@value{AS}} computes have this section-relative
2833 nature.
2834 @ifset SOM
2835 (For some object formats, such as SOM for the HPPA, some expressions are
2836 symbol-relative instead.)
2837 @end ifset
2838
2839 In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset
2840 @var{N} into section @var{secname}.''
2841
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.
2851
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}.
2859
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.
2866
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.
2869
2870 @node Ld Sections
2871 @section Linker Sections
2872 @code{@value{LD}} deals with just four kinds of sections, summarized below.
2873
2874 @table @strong
2875
2876 @ifset COFF-ELF
2877 @cindex named sections
2878 @cindex sections, named
2879 @item named sections
2880 @end ifset
2881 @ifset aout-bout
2882 @cindex text section
2883 @cindex data section
2884 @itemx text section
2885 @itemx data section
2886 @end ifset
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
2889 true of another.
2890 @c @ifset aout-bout
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.
2897 @c @end ifset
2898
2899 @cindex bss section
2900 @item bss 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.
2907
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.
2914
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.
2920 @end table
2921
2922 @cindex relocation example
2923 An idealized example of three relocatable sections follows.
2924 @ifset COFF-ELF
2925 The example uses the traditional section names @samp{.text} and @samp{.data}.
2926 @end ifset
2927 Memory addresses are on the horizontal axis.
2928
2929 @c TEXI2ROFF-KILL
2930 @ifnottex
2931 @c END TEXI2ROFF-KILL
2932 @smallexample
2933 +-----+----+--+
2934 partial program # 1: |ttttt|dddd|00|
2935 +-----+----+--+
2936
2937 text data bss
2938 seg. seg. seg.
2939
2940 +---+---+---+
2941 partial program # 2: |TTT|DDD|000|
2942 +---+---+---+
2943
2944 +--+---+-----+--+----+---+-----+~~
2945 linked program: | |TTT|ttttt| |dddd|DDD|00000|
2946 +--+---+-----+--+----+---+-----+~~
2947
2948 addresses: 0 @dots{}
2949 @end smallexample
2950 @c TEXI2ROFF-KILL
2951 @end ifnottex
2952 @need 5000
2953 @tex
2954 \bigskip
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}
2958
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}
2962
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}
2968
2969 \line{\it addresses: \hfil}
2970 \line{0\dots\hfil}
2971
2972 @end tex
2973 @c END TEXI2ROFF-KILL
2974
2975 @node As Sections
2976 @section Assembler Internal Sections
2977
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.
2987
2988 @table @b
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.
2993
2994 @cindex expr (internal section)
2995 @item expr 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.
2999 @c FIXME item debug
3000 @c FIXME item transfer[t] vector preload
3001 @c FIXME item transfer[t] vector postload
3002 @c FIXME item register
3003 @end table
3004
3005 @node Sub-Sections
3006 @section Sub-Sections
3007
3008 @cindex numbered subsections
3009 @cindex grouping data
3010 @ifset aout-bout
3011 Assembled bytes
3012 @ifset COFF-ELF
3013 conventionally
3014 @end ifset
3015 fall into two sections: text and data.
3016 @end ifset
3017 You may have separate groups of
3018 @ifset GENERIC
3019 data in named sections
3020 @end ifset
3021 @ifclear GENERIC
3022 @ifclear aout-bout
3023 data in named sections
3024 @end ifclear
3025 @ifset aout-bout
3026 text or data
3027 @end ifset
3028 @end ifclear
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.
3039
3040 Subsections are optional. If you do not use subsections, everything
3041 goes in subsection number zero.
3042
3043 @ifset GENERIC
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}}.)
3047 @end ifset
3048 @ifclear GENERIC
3049 @ifset H8
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.
3053 @end ifset
3054 @ifset I960
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).
3061 @end ifset
3062 @end ifclear
3063
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.
3070
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.
3074 @ifset COFF
3075 @ifset GENERIC
3076 When generating COFF output, you
3077 @end ifset
3078 @ifclear GENERIC
3079 You
3080 @end ifclear
3081 can also use an extra subsection
3082 argument with arbitrary named sections: @samp{.section @var{name},
3083 @var{expression}}.
3084 @end ifset
3085 @ifset ELF
3086 @ifset GENERIC
3087 When generating ELF output, you
3088 @end ifset
3089 @ifclear GENERIC
3090 You
3091 @end ifclear
3092 can also use the @code{.subsection} directive (@pxref{SubSection})
3093 to specify a subsection: @samp{.subsection @var{expression}}.
3094 @end ifset
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:
3099 @smallexample
3100 .text 0 # The default subsection is text 0 anyway.
3101 .ascii "This lives in the first text subsection. *"
3102 .text 1
3103 .ascii "But this lives in the second text subsection."
3104 .data 0
3105 .ascii "This lives in the data section,"
3106 .ascii "in the first data subsection."
3107 .text 0
3108 .ascii "This lives in the first text section,"
3109 .ascii "immediately following the asterisk (*)."
3110 @end smallexample
3111
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.
3119
3120 @node bss
3121 @section bss Section
3122
3123 @cindex 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.
3130
3131 The @code{.lcomm} pseudo-op defines a symbol in the bss section; see
3132 @ref{Lcomm,,@code{.lcomm}}.
3133
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}}.
3136
3137 @ifset GENERIC
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}}).
3143 @end ifset
3144
3145 @node Symbols
3146 @chapter Symbols
3147
3148 @cindex symbols
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
3151 to debug.
3152
3153 @quotation
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.
3157 @end quotation
3158
3159 @menu
3160 * Labels:: Labels
3161 * Setting Symbols:: Giving Symbols Other Values
3162 * Symbol Names:: Symbol Names
3163 * Dot:: The Special Dot Symbol
3164 * Symbol Attributes:: Symbol Attributes
3165 @end menu
3166
3167 @node Labels
3168 @section Labels
3169
3170 @cindex labels
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
3176 definitions.
3177
3178 @ifset HPPA
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.
3183 @end ifset
3184
3185 @node Setting Symbols
3186 @section Giving Symbols Other Values
3187
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}}.
3196
3197 @node Symbol Names
3198 @section Symbol Names
3199
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.
3208 @end ifclear
3209 @ifset SPECIAL-SYMS
3210 @ifset H8
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.
3215 @end ifset
3216 @end ifset
3217
3218 Case of letters is significant: @code{foo} is a different symbol name
3219 than @code{Foo}.
3220
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
3223 in a program.
3224
3225 @subheading Local Symbol Names
3226
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.
3233 @ifset HPPA
3234 On the HPPA local symbols begin with @samp{L$}.
3235 @end ifset
3236
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.
3241
3242 @subheading Local Labels
3243
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
3255 for ``forwards''.
3256
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.
3264
3265 Here is an example:
3266
3267 @smallexample
3268 1: branch 1f
3269 2: branch 1b
3270 1: branch 2f
3271 2: branch 1b
3272 @end smallexample
3273
3274 Which is the equivalent of:
3275
3276 @smallexample
3277 label_1: branch label_3
3278 label_2: branch label_1
3279 label_3: branch label_4
3280 label_4: branch label_3
3281 @end smallexample
3282
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
3287 these parts:
3288
3289 @table @code
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.
3298
3299 @item @var{number}
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}.
3302
3303 @item @kbd{C-B}
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).
3306
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.
3312 @end table
3313
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}.
3316
3317 @subheading Dollar Local Labels
3318 @cindex dollar local symbols
3319
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.
3326
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$}}.
3330
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}.
3335
3336 @node Dot
3337 @section The Special Dot Symbol
3338
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
3349 @samp{.space 4}.
3350 @end ifclear
3351
3352 @node Symbol Attributes
3353 @section Symbol Attributes
3354
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
3359 attributes.
3360 @ifset INTERNALS
3361 The detailed definitions are in @file{a.out.h}.
3362 @end ifset
3363
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
3367 would want.
3368
3369 @menu
3370 * Symbol Value:: Value
3371 * Symbol Type:: Type
3372 @ifset aout-bout
3373 @ifset GENERIC
3374 * a.out Symbols:: Symbol Attributes: @code{a.out}
3375 @end ifset
3376 @ifclear GENERIC
3377 @ifclear BOUT
3378 * a.out Symbols:: Symbol Attributes: @code{a.out}
3379 @end ifclear
3380 @ifset BOUT
3381 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
3382 @end ifset
3383 @end ifclear
3384 @end ifset
3385 @ifset COFF
3386 * COFF Symbols:: Symbol Attributes for COFF
3387 @end ifset
3388 @ifset SOM
3389 * SOM Symbols:: Symbol Attributes for SOM
3390 @end ifset
3391 @end menu
3392
3393 @node Symbol Value
3394 @subsection Value
3395
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
3404 called absolute.
3405
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
3413 allocated storage.
3414
3415 @node Symbol Type
3416 @subsection Type
3417
3418 @cindex type of a symbol
3419 @cindex symbol type
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.
3424
3425 @ifset aout-bout
3426 @ifclear GENERIC
3427 @ifset BOUT
3428 @c The following avoids a "widow" subsection title. @group would be
3429 @c better if it were available outside examples.
3430 @need 1000
3431 @node a.out Symbols
3432 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
3433
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
3438 @code{b.out}.
3439
3440 @end ifset
3441 @ifclear BOUT
3442 @node a.out Symbols
3443 @subsection Symbol Attributes: @code{a.out}
3444
3445 @cindex @code{a.out} symbol attributes
3446 @cindex symbol attributes, @code{a.out}
3447
3448 @end ifclear
3449 @end ifclear
3450 @ifset GENERIC
3451 @node a.out Symbols
3452 @subsection Symbol Attributes: @code{a.out}
3453
3454 @cindex @code{a.out} symbol attributes
3455 @cindex symbol attributes, @code{a.out}
3456
3457 @end ifset
3458 @menu
3459 * Symbol Desc:: Descriptor
3460 * Symbol Other:: Other
3461 @end menu
3462
3463 @node Symbol Desc
3464 @subsubsection Descriptor
3465
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}}.
3471
3472 @node Symbol Other
3473 @subsubsection Other
3474
3475 @cindex other attribute, of @code{a.out} symbol
3476 This is an arbitrary 8-bit value. It means nothing to @command{@value{AS}}.
3477 @end ifset
3478
3479 @ifset COFF
3480 @node COFF Symbols
3481 @subsection Symbol Attributes for COFF
3482
3483 @cindex COFF symbol attributes
3484 @cindex symbol attributes, COFF
3485
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.
3489
3490 @subsubsection Primary Attributes
3491
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}.
3495
3496 @subsubsection Auxiliary Attributes
3497
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.
3502 @end ifset
3503
3504 @ifset SOM
3505 @node SOM Symbols
3506 @subsection Symbol Attributes for SOM
3507
3508 @cindex SOM symbol attributes
3509 @cindex symbol attributes, SOM
3510
3511 The SOM format for the HPPA supports a multitude of symbol attributes set with
3512 the @code{.EXPORT} and @code{.IMPORT} directives.
3513
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.
3517 @end ifset
3518
3519 @node Expressions
3520 @chapter Expressions
3521
3522 @cindex expressions
3523 @cindex addresses
3524 @cindex numeric values
3525 An @dfn{expression} specifies an address or numeric value.
3526 Whitespace may precede and/or follow an expression.
3527
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.
3534
3535 @menu
3536 * Empty Exprs:: Empty Expressions
3537 * Integer Exprs:: Integer Expressions
3538 @end menu
3539
3540 @node Empty Exprs
3541 @section Empty Expressions
3542
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.
3549
3550 @node Integer Exprs
3551 @section Integer Expressions
3552
3553 @cindex integer expressions
3554 @cindex expressions, integer
3555 An @dfn{integer expression} is one or more @emph{arguments} delimited
3556 by @emph{operators}.
3557
3558 @menu
3559 * Arguments:: Arguments
3560 * Operators:: Operators
3561 * Prefix Ops:: Prefix Operators
3562 * Infix Ops:: Infix Operators
3563 @end menu
3564
3565 @node Arguments
3566 @subsection Arguments
3567
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.
3578
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
3582 integer.
3583
3584 Numbers are usually integers.
3585
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
3590 assemblers.
3591
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.
3596
3597 @node Operators
3598 @subsection Operators
3599
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
3606 whitespace.
3607
3608 @node Prefix Ops
3609 @subsection Prefix Operator
3610
3611 @cindex prefix operators
3612 @command{@value{AS}} has the following @dfn{prefix operators}. They each take
3613 one argument, which must be absolute.
3614
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).
3618 @tex
3619 \global\advance\leftskip by \itemindent
3620 @end tex
3621
3622 @table @code
3623 @item -
3624 @dfn{Negation}. Two's complement negation.
3625 @item ~
3626 @dfn{Complementation}. Bitwise not.
3627 @end table
3628
3629 @tex
3630 \global\advance\leftskip by -\itemindent
3631 @end tex
3632
3633 @node Infix Ops
3634 @subsection Infix Operators
3635
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.
3642
3643 @enumerate
3644 @cindex operator precedence
3645 @cindex precedence of operators
3646
3647 @item
3648 Highest Precedence
3649
3650 @table @code
3651 @item *
3652 @dfn{Multiplication}.
3653
3654 @item /
3655 @dfn{Division}. Truncation is the same as the C operator @samp{/}
3656
3657 @item %
3658 @dfn{Remainder}.
3659
3660 @item <<
3661 @dfn{Shift Left}. Same as the C operator @samp{<<}.
3662
3663 @item >>
3664 @dfn{Shift Right}. Same as the C operator @samp{>>}.
3665 @end table
3666
3667 @item
3668 Intermediate precedence
3669
3670 @table @code
3671 @item |
3672
3673 @dfn{Bitwise Inclusive Or}.
3674
3675 @item &
3676 @dfn{Bitwise And}.
3677
3678 @item ^
3679 @dfn{Bitwise Exclusive Or}.
3680
3681 @item !
3682 @dfn{Bitwise Or Not}.
3683 @end table
3684
3685 @item
3686 Low Precedence
3687
3688 @table @code
3689 @cindex addition, permitted arguments
3690 @cindex plus, permitted arguments
3691 @cindex arguments for addition
3692 @item +
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
3695 sections.
3696
3697 @cindex subtraction, permitted arguments
3698 @cindex minus, permitted arguments
3699 @cindex arguments for subtraction
3700 @item -
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 ?
3706
3707 @cindex comparison expressions
3708 @cindex expressions, comparison
3709 @item ==
3710 @dfn{Is Equal To}
3711 @item <>
3712 @itemx !=
3713 @dfn{Is Not Equal To}
3714 @item <
3715 @dfn{Is Less Than}
3716 @item >
3717 @dfn{Is Greater Than}
3718 @item >=
3719 @dfn{Is Greater Than Or Equal To}
3720 @item <=
3721 @dfn{Is Less Than Or Equal To}
3722
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.
3726 @end table
3727
3728 @item Lowest Precedence
3729
3730 @table @code
3731 @item &&
3732 @dfn{Logical And}.
3733
3734 @item ||
3735 @dfn{Logical Or}.
3736
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.
3741
3742 @end table
3743 @end enumerate
3744
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.
3747
3748 @node Pseudo Ops
3749 @chapter Assembler Directives
3750
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.
3756
3757 This chapter discusses directives that are available regardless of the
3758 target machine configuration for the @sc{gnu} assembler.
3759 @ifset GENERIC
3760 Some machine configurations provide additional directives.
3761 @xref{Machine Dependencies}.
3762 @end ifset
3763 @ifclear GENERIC
3764 @ifset machine-directives
3765 @xref{Machine Dependencies}, for additional directives.
3766 @end ifset
3767 @end ifclear
3768
3769 @menu
3770 * Abort:: @code{.abort}
3771 @ifset COFF
3772 * ABORT (COFF):: @code{.ABORT}
3773 @end ifset
3774
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} }
3782
3783 * CFI directives:: @code{.cfi_startproc}, @code{.cfi_endproc}, etc.
3784
3785 * Data:: @code{.data @var{subsection}}
3786 @ifset COFF
3787 * Def:: @code{.def @var{name}}
3788 @end ifset
3789 @ifset aout-bout
3790 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
3791 @end ifset
3792 @ifset COFF
3793 * Dim:: @code{.dim}
3794 @end ifset
3795
3796 * Double:: @code{.double @var{flonums}}
3797 * Eject:: @code{.eject}
3798 * Else:: @code{.else}
3799 * Elseif:: @code{.elseif}
3800 * End:: @code{.end}
3801 @ifset COFF
3802 * Endef:: @code{.endef}
3803 @end ifset
3804
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}}
3810 * Err:: @code{.err}
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}}
3817 @end ifclear
3818
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}}
3823 @ifset ELF
3824 * Hidden:: @code{.hidden @var{names}}
3825 @end ifset
3826
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}}
3833 @ifset ELF
3834 * Internal:: @code{.internal @var{names}}
3835 @end ifset
3836
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}}
3843 @end ifclear
3844
3845 * Linkonce:: @code{.linkonce [@var{type}]}
3846 * List:: @code{.list}
3847 * Ln:: @code{.ln @var{line-number}}
3848
3849 * LNS directives:: @code{.file}, @code{.loc}, etc.
3850
3851 * Long:: @code{.long @var{expressions}}
3852 @ignore
3853 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
3854 @end ignore
3855
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}}
3863 @ifset ELF
3864 * PopSection:: @code{.popsection}
3865 * Previous:: @code{.previous}
3866 @end ifset
3867
3868 * Print:: @code{.print @var{string}}
3869 @ifset ELF
3870 * Protected:: @code{.protected @var{names}}
3871 @end ifset
3872
3873 * Psize:: @code{.psize @var{lines}, @var{columns}}
3874 * Purgem:: @code{.purgem @var{name}}
3875 @ifset ELF
3876 * PushSection:: @code{.pushsection @var{name}}
3877 @end ifset
3878
3879 * Quad:: @code{.quad @var{bignums}}
3880 * Rept:: @code{.rept @var{count}}
3881 * Sbttl:: @code{.sbttl "@var{subheading}"}
3882 @ifset COFF
3883 * Scl:: @code{.scl @var{class}}
3884 @end ifset
3885 @ifset COFF-ELF
3886 * Section:: @code{.section @var{name}}
3887 @end ifset
3888
3889 * Set:: @code{.set @var{symbol}, @var{expression}}
3890 * Short:: @code{.short @var{expressions}}
3891 * Single:: @code{.single @var{flonums}}
3892 @ifset COFF-ELF
3893 * Size:: @code{.size [@var{name} , @var{expression}]}
3894 @end ifset
3895
3896 * Skip:: @code{.skip @var{size} , @var{fill}}
3897 * Sleb128:: @code{.sleb128 @var{expressions}}
3898 * Space:: @code{.space @var{size} , @var{fill}}
3899 @ifset have-stabs
3900 * Stab:: @code{.stabd, .stabn, .stabs}
3901 @end ifset
3902
3903 * String:: @code{.string "@var{str}"}
3904 * Struct:: @code{.struct @var{expression}}
3905 @ifset ELF
3906 * SubSection:: @code{.subsection}
3907 * Symver:: @code{.symver @var{name},@var{name2@@nodename}}
3908 @end ifset
3909
3910 @ifset COFF
3911 * Tag:: @code{.tag @var{structname}}
3912 @end ifset
3913
3914 * Text:: @code{.text @var{subsection}}
3915 * Title:: @code{.title "@var{heading}"}
3916 @ifset COFF-ELF
3917 * Type:: @code{.type <@var{int} | @var{name} , @var{type description}>}
3918 @end ifset
3919
3920 * Uleb128:: @code{.uleb128 @var{expressions}}
3921 @ifset COFF
3922 * Val:: @code{.val @var{addr}}
3923 @end ifset
3924
3925 @ifset ELF
3926 * Version:: @code{.version "@var{string}"}
3927 * VTableEntry:: @code{.vtable_entry @var{table}, @var{offset}}
3928 * VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}}
3929 @end ifset
3930
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
3936 @end menu
3937
3938 @node Abort
3939 @section @code{.abort}
3940
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.
3948
3949 @ifset COFF
3950 @node ABORT (COFF)
3951 @section @code{.ABORT} (COFF)
3952
3953 @cindex @code{ABORT} directive
3954 When producing COFF output, @command{@value{AS}} accepts this directive as a
3955 synonym for @samp{.abort}.
3956
3957 @ifset BOUT
3958 When producing @code{b.out} output, @command{@value{AS}} accepts this directive,
3959 but ignores it.
3960 @end ifset
3961 @end ifset
3962
3963 @node Align
3964 @section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3965
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.
3971
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.
3977
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.
3985
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.
3993
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.
4000
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).
4006
4007 @node Ascii
4008 @section @code{.ascii "@var{string}"}@dots{}
4009
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.
4015
4016 @node Asciz
4017 @section @code{.asciz "@var{string}"}@dots{}
4018
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''.
4024
4025 @node Balign
4026 @section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
4027
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.
4035
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.
4041
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.
4049
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
4059 undefined.
4060
4061 @node Byte
4062 @section @code{.byte @var{expressions}}
4063
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.
4068
4069 @node Comm
4070 @section @code{.comm @var{symbol} , @var{length} }
4071
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.
4082
4083 @ifset ELF
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
4092 maximum of 16.
4093 @end ifset
4094
4095 @ifset HPPA
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.
4098 @end ifset
4099
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}.
4108
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}.
4114
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.
4125
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},
4132 no LSDA.
4133
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}.
4137
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
4141 remains the same.
4142
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
4147 CFA address.
4148
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.
4152
4153 @section @code{.cfi_offset @var{register}, @var{offset}}
4154 Previous value of @var{register} is saved at offset @var{offset} from
4155 CFA.
4156
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.
4163
4164 @section @code{.cfi_signal_frame}
4165 Mark current function as signal trampoline.
4166
4167 @section @code{.cfi_window_save}
4168 SPARC register window has been saved.
4169
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.
4174
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.
4182
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
4186 entries will have.
4187
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
4194 the row is added.
4195
4196 The @var{options} are a sequence of the following tokens in any order:
4197
4198 @table @code
4199 @item basic_block
4200 This option will set the @code{basic_block} register in the
4201 @code{.debug_line} state machine to @code{true}.
4202
4203 @item prologue_end
4204 This option will set the @code{prologue_end} register in the
4205 @code{.debug_line} state machine to @code{true}.
4206
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}.
4210
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
4214 either 0 or 1.
4215
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.
4219
4220 @end table
4221
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.
4229
4230 @node Data
4231 @section @code{.data @var{subsection}}
4232
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
4237 to zero.
4238
4239 @ifset COFF
4240 @node Def
4241 @section @code{.def @var{name}}
4242
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.
4248 @ifset BOUT
4249
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,
4252 but ignored.
4253 @end ifset
4254 @end ifset
4255
4256 @ifset aout-bout
4257 @node Desc
4258 @section @code{.desc @var{symbol}, @var{abs-expression}}
4259
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.
4265
4266 @ifset COFF
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.
4271 @end ifset
4272 @end ifset
4273
4274 @ifset COFF
4275 @node Dim
4276 @section @code{.dim}
4277
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.
4284 @ifset BOUT
4285
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
4288 ignores it.
4289 @end ifset
4290 @end ifset
4291
4292 @node Double
4293 @section @code{.double @var{flonums}}
4294
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.
4299 @ifset GENERIC
4300 The exact kind of floating point numbers emitted depends on how
4301 @command{@value{AS}} is configured. @xref{Machine Dependencies}.
4302 @end ifset
4303 @ifclear GENERIC
4304 @ifset IEEEFLOAT
4305 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
4306 in @sc{ieee} format.
4307 @end ifset
4308 @end ifclear
4309
4310 @node Eject
4311 @section @code{.eject}
4312
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.
4318
4319 @node Else
4320 @section @code{.else}
4321
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}
4326 was false.
4327
4328 @node Elseif
4329 @section @code{.elseif}
4330
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.
4335
4336 @node End
4337 @section @code{.end}
4338
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.
4342
4343 @ifset COFF
4344 @node Endef
4345 @section @code{.endef}
4346
4347 @cindex @code{endef} directive
4348 This directive flags the end of a symbol definition begun with
4349 @code{.def}.
4350 @ifset BOUT
4351
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.
4355 @end ifset
4356 @end ifset
4357
4358 @node Endfunc
4359 @section @code{.endfunc}
4360 @cindex @code{endfunc} directive
4361 @code{.endfunc} marks the end of a function specified with @code{.func}.
4362
4363 @node Endif
4364 @section @code{.endif}
4365
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}}.
4370
4371 @node Equ
4372 @section @code{.equ @var{symbol}, @var{expression}}
4373
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}}.
4379
4380 @ifset HPPA
4381 The syntax for @code{equ} on the HPPA is
4382 @samp{@var{symbol} .equ @var{expression}}.
4383 @end ifset
4384
4385 @ifset Z80
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}.
4391 @end ifset
4392
4393 @node 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
4399 undefined.
4400
4401 Except for the contents of the error message, this is roughly equivalent to
4402 @smallexample
4403 .ifdef SYM
4404 .err
4405 .endif
4406 .equ SYM,VAL
4407 @end smallexample
4408 plus it protects the symbol from later redefinition.
4409
4410 @node Eqv
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
4416 value is taken.
4417
4418 @node Err
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.
4424
4425 @node Error
4426 @section @code{.error "@var{string}"}
4427 @cindex error directive
4428
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}.
4433
4434 @smallexample
4435 .error "This code has not been assembled and tested."
4436 @end smallexample
4437
4438 @node Exitm
4439 @section @code{.exitm}
4440 Exit early from the current macro definition. @xref{Macro}.
4441
4442 @node Extern
4443 @section @code{.extern}
4444
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.
4449
4450 @node Fail
4451 @section @code{.fail @var{expression}}
4452
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.
4459
4460 @ifclear no-file-dir
4461 @node File
4462 @section @code{.file @var{string}}
4463
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.
4473 @end ifclear
4474
4475 @node Fill
4476 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
4477
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.
4492
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.
4497
4498 @node Float
4499 @section @code{.float @var{flonums}}
4500
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}.
4505 @ifset GENERIC
4506 The exact kind of floating point numbers emitted depends on how
4507 @command{@value{AS}} is configured.
4508 @xref{Machine Dependencies}.
4509 @end ifset
4510 @ifclear GENERIC
4511 @ifset IEEEFLOAT
4512 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
4513 in @sc{ieee} format.
4514 @end ifset
4515 @end ifclear
4516
4517 @node Func
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}.
4528
4529 @node Global
4530 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
4531
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.
4539
4540 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
4541 compatibility with other assemblers.
4542
4543 @ifset HPPA
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}.
4547 @end ifset
4548
4549 @ifset ELF
4550 @node Hidden
4551 @section @code{.hidden @var{names}}
4552
4553 @cindex @code{hidden} directive
4554 @cindex visibility
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}}).
4558
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.
4563 @end ifset
4564
4565 @node hword
4566 @section @code{.hword @var{expressions}}
4567
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.
4574
4575 @ifset GENERIC
4576 This directive is a synonym for @samp{.short}; depending on the target
4577 architecture, it may also be a synonym for @samp{.word}.
4578 @end ifset
4579 @ifclear GENERIC
4580 @ifset W32
4581 This directive is a synonym for @samp{.short}.
4582 @end ifset
4583 @ifset W16
4584 This directive is a synonym for both @samp{.short} and @samp{.word}.
4585 @end ifset
4586 @end ifclear
4587
4588 @node Ident
4589 @section @code{.ident}
4590
4591 @cindex @code{ident} directive
4592
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.
4600
4601 @node If
4602 @section @code{.if @var{absolute expression}}
4603
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.
4614
4615 The following variants of @code{.if} are also supported:
4616 @table @code
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.
4622
4623 @cindex @code{ifb} directive
4624 @item .ifb @var{text}
4625 Assembles the following section of code if the operand is blank (empty).
4626
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.
4634
4635 @cindex @code{ifeq} directive
4636 @item .ifeq @var{absolute expression}
4637 Assembles the following section of code if the argument is zero.
4638
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.
4642
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
4646 equal to zero.
4647
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.
4651
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
4655 to zero.
4656
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.
4660
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).
4665
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.
4670
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.
4678
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}).
4683
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.
4688 @end table
4689
4690 @node Incbin
4691 @section @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]}
4692
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
4698 around @var{file}.
4699
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.
4705
4706 @node Include
4707 @section @code{.include "@var{file}"}
4708
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
4718 around @var{file}.
4719
4720 @node Int
4721 @section @code{.int @var{expressions}}
4722
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.
4729
4730 @ifclear GENERIC
4731 @ifset H8
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
4734 32-bit integers.
4735 @end ifset
4736 @end ifclear
4737
4738 @ifset ELF
4739 @node Internal
4740 @section @code{.internal @var{names}}
4741
4742 @cindex @code{internal} directive
4743 @cindex visibility
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}}).
4747
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.
4753 @end ifset
4754
4755 @node Irp
4756 @section @code{.irp @var{symbol},@var{values}}@dots{}
4757
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}.
4766
4767 For example, assembling
4768
4769 @example
4770 .irp param,1,2,3
4771 move d\param,sp@@-
4772 .endr
4773 @end example
4774
4775 is equivalent to assembling
4776
4777 @example
4778 move d1,sp@@-
4779 move d2,sp@@-
4780 move d3,sp@@-
4781 @end example
4782
4783 For some caveats with the spelling of @var{symbol}, see also @ref{Macro}.
4784
4785 @node Irpc
4786 @section @code{.irpc @var{symbol},@var{values}}@dots{}
4787
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}.
4796
4797 For example, assembling
4798
4799 @example
4800 .irpc param,123
4801 move d\param,sp@@-
4802 .endr
4803 @end example
4804
4805 is equivalent to assembling
4806
4807 @example
4808 move d1,sp@@-
4809 move d2,sp@@-
4810 move d3,sp@@-
4811 @end example
4812
4813 For some caveats with the spelling of @var{symbol}, see also the discussion
4814 at @xref{Macro}.
4815
4816 @node Lcomm
4817 @section @code{.lcomm @var{symbol} , @var{length}}
4818
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}}.
4828
4829 @ifset GENERIC
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.
4832 @end ifset
4833
4834 @ifset HPPA
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.
4837 @end ifset
4838
4839 @node Lflags
4840 @section @code{.lflags}
4841
4842 @cindex @code{lflags} directive (ignored)
4843 @command{@value{AS}} accepts this directive, for compatibility with other
4844 assemblers, but ignores it.
4845
4846 @ifclear no-line-dir
4847 @node Line
4848 @section @code{.line @var{line-number}}
4849
4850 @cindex @code{line} directive
4851 @end ifclear
4852 @ifset no-line-dir
4853 @node Ln
4854 @section @code{.ln @var{line-number}}
4855
4856 @cindex @code{ln} directive
4857 @end ifset
4858 @cindex logical line number
4859 @ifset aout-bout
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.
4866
4867 @end ifset
4868
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.
4875
4876 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
4877 used by compilers to generate auxiliary symbol information for
4878 debugging.
4879 @end ifclear
4880
4881 @node Linkonce
4882 @section @code{.linkonce [@var{type}]}
4883 @cindex COMDAT
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
4891 unique.
4892
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.
4896
4897 The @var{type} argument is optional. If specified, it must be one of the
4898 following strings. For example:
4899 @smallexample
4900 .linkonce same_size
4901 @end smallexample
4902 Not all types may be supported on all object file formats.
4903
4904 @table @code
4905 @item discard
4906 Silently discard duplicate sections. This is the default.
4907
4908 @item one_only
4909 Warn if there are duplicate sections, but still keep only one copy.
4910
4911 @item same_size
4912 Warn if any of the duplicates have different sizes.
4913
4914 @item same_contents
4915 Warn if any of the duplicates do not have exactly the same contents.
4916 @end table
4917
4918 @node Ln
4919 @section @code{.ln @var{line-number}}
4920
4921 @cindex @code{ln} directive
4922 @ifclear no-line-dir
4923 @samp{.ln} is a synonym for @samp{.line}.
4924 @end ifclear
4925 @ifset no-line-dir
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.
4931 @ifset BOUT
4932
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
4935 output format.
4936 @end ifset
4937 @end ifset
4938
4939 @node MRI
4940 @section @code{.mri @var{val}}
4941
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}.
4948
4949 @node List
4950 @section @code{.list}
4951
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.
4959
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.
4963
4964 @node Long
4965 @section @code{.long @var{expressions}}
4966
4967 @cindex @code{long} directive
4968 @code{.long} is the same as @samp{.int}. @xref{Int,,@code{.int}}.
4969
4970 @ignore
4971 @c no one seems to know what this is for or whether this description is
4972 @c what it really ought to do
4973 @node Lsym
4974 @section @code{.lsym @var{symbol}, @var{expression}}
4975
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:
4982 @smallexample
4983 @var{other} = @var{descriptor} = 0
4984 @var{type} = @r{(section of @var{expression})}
4985 @var{value} = @var{expression}
4986 @end smallexample
4987 @noindent
4988 The new symbol is not flagged as external.
4989 @end ignore
4990
4991 @node Macro
4992 @section @code{.macro}
4993
4994 @cindex macros
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:
4998
4999 @example
5000 .macro sum from=0, to=5
5001 .long \from
5002 .if \to-\from
5003 sum "(\from+1)",\to
5004 .endif
5005 .endm
5006 @end example
5007
5008 @noindent
5009 With that definition, @samp{SUM 0,5} is equivalent to this assembly input:
5010
5011 @example
5012 .long 0
5013 .long 1
5014 .long 2
5015 .long 3
5016 .long 4
5017 .long 5
5018 @end example
5019
5020 @ftable @code
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:
5034
5035 @table @code
5036 @item .macro comm
5037 Begin the definition of a macro called @code{comm}, which takes no
5038 arguments.
5039
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.
5045
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}).
5054
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.
5060
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}.
5064
5065 @end table
5066
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:
5078
5079 @example
5080 .macro label l
5081 \l:
5082 .endm
5083 @end example
5084
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
5088 identifier.
5089
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:
5094
5095 @example
5096 .macro opcode base length
5097 \base.\length
5098 .endm
5099 @end example
5100
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}.
5104
5105 There are several possible ways around this problem:
5106
5107 @table @code
5108 @item Insert white space
5109 If it is possible to use white space characters then this is the simplest
5110 solution. eg:
5111
5112 @example
5113 .macro label l
5114 \l :
5115 .endm
5116 @end example
5117
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:
5121
5122 @example
5123 .macro opcode base length
5124 \base\().\length
5125 .endm
5126 @end example
5127
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:
5131
5132 @example
5133 .altmacro
5134 .macro label l
5135 l&:
5136 .endm
5137 @end example
5138 @end table
5139
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.
5143
5144 @item .endm
5145 @cindex @code{endm} directive
5146 Mark the end of a macro definition.
5147
5148 @item .exitm
5149 @cindex @code{exitm} directive
5150 Exit early from the current macro definition.
5151
5152 @cindex number of macros executed
5153 @cindex macros, count executed
5154 @item \@@
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}.
5158
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}}.
5163 @end ftable
5164
5165 @node Altmacro
5166 @section @code{.altmacro}
5167 Enable alternate macro mode, enabling:
5168
5169 @ftable @code
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.
5177
5178 @item String delimiters
5179 You can write strings delimited in these other ways besides
5180 @code{"@var{string}"}:
5181
5182 @table @code
5183 @item '@var{string}'
5184 You can delimit strings with single-quote characters.
5185
5186 @item <@var{string}>
5187 You can delimit strings with matching angle brackets.
5188 @end table
5189
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!}.
5195
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.
5199 @end ftable
5200
5201 @node Noaltmacro
5202 @section @code{.noaltmacro}
5203 Disable alternate macro mode. @xref{Altmacro}.
5204
5205 @node Nolist
5206 @section @code{.nolist}
5207
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.
5215
5216 @node Octa
5217 @section @code{.octa @var{bignums}}
5218
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.
5225
5226 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
5227 hence @emph{octa}-word for 16 bytes.
5228
5229 @node Org
5230 @section @code{.org @var{new-lc} , @var{fill}}
5231
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.
5244
5245 @code{.org} may only increase the location counter, or leave it
5246 unchanged; you cannot use @code{.org} to move the location counter
5247 backwards.
5248
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.
5255
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.
5259
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.
5264
5265 @node P2align
5266 @section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
5267
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.
5276
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.
5282
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.
5290
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
5300 undefined.
5301
5302 @ifset ELF
5303 @node Previous
5304 @section @code{.previous}
5305
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}).
5312
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
5316 subsections).
5317
5318 In terms of the section stack, this directive swaps the current section with
5319 the top section on the section stack.
5320 @end ifset
5321
5322 @ifset ELF
5323 @node PopSection
5324 @section @code{.popsection}
5325
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}
5331 (@pxref{Previous}).
5332
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
5335 stack.
5336 @end ifset
5337
5338 @node Print
5339 @section @code{.print @var{string}}
5340
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.
5344
5345 @ifset ELF
5346 @node Protected
5347 @section @code{.protected @var{names}}
5348
5349 @cindex @code{protected} directive
5350 @cindex visibility
5351 This is one of the ELF visibility directives. The other two are
5352 @code{.hidden} (@pxref{Hidden}) and @code{.internal} (@pxref{Internal}).
5353
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
5359 this.
5360 @end ifset
5361
5362 @node Psize
5363 @section @code{.psize @var{lines} , @var{columns}}
5364
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.
5370
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.
5374
5375 @command{@value{AS}} generates formfeeds whenever the specified number of
5376 lines is exceeded (or whenever you explicitly request one, using
5377 @code{.eject}).
5378
5379 If you specify @var{lines} as @code{0}, no formfeeds are generated save
5380 those explicitly specified with @code{.eject}.
5381
5382 @node Purgem
5383 @section @code{.purgem @var{name}}
5384
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}.
5388
5389 @ifset ELF
5390 @node PushSection
5391 @section @code{.pushsection @var{name} , @var{subsection}}
5392
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}
5398 (@pxref{Previous}).
5399
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}.
5403 @end ifset
5404
5405 @node Quad
5406 @section @code{.quad @var{bignums}}
5407
5408 @cindex @code{quad} directive
5409 @code{.quad} expects zero or more bignums, separated by commas. For
5410 each bignum, it emits
5411 @ifclear bignum-16
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
5416
5417 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
5418 hence @emph{quad}-word for 8 bytes.
5419 @end ifclear
5420 @ifset bignum-16
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
5425 @end ifset
5426
5427 @node Rept
5428 @section @code{.rept @var{count}}
5429
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.
5433
5434 For example, assembling
5435
5436 @example
5437 .rept 3
5438 .long 0
5439 .endr
5440 @end example
5441
5442 is equivalent to assembling
5443
5444 @example
5445 .long 0
5446 .long 0
5447 .long 0
5448 @end example
5449
5450 @node Sbttl
5451 @section @code{.sbttl "@var{subheading}"}
5452
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.
5458
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.
5461
5462 @ifset COFF
5463 @node Scl
5464 @section @code{.scl @var{class}}
5465
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.
5473 @ifset BOUT
5474
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.
5478 @end ifset
5479 @end ifset
5480
5481 @ifset COFF-ELF
5482 @node Section
5483 @section @code{.section @var{name}}
5484
5485 @cindex named section
5486 Use the @code{.section} directive to assemble the following code into a section
5487 named @var{name}.
5488
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.
5492
5493 @ifset COFF
5494 @ifset ELF
5495 @c only print the extra heading if both COFF and ELF are set
5496 @subheading COFF Version
5497 @end ifset
5498
5499 @cindex @code{section} directive (COFF version)
5500 For COFF targets, the @code{.section} directive is used in one of the following
5501 ways:
5502
5503 @smallexample
5504 .section @var{name}[, "@var{flags}"]
5505 .section @var{name}[, @var{subsegment}]
5506 @end smallexample
5507
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:
5510 @table @code
5511 @item b
5512 bss section (uninitialized data)
5513 @item n
5514 section is not loaded
5515 @item w
5516 writable section
5517 @item d
5518 data section
5519 @item r
5520 read-only section
5521 @item x
5522 executable section
5523 @item s
5524 shared section (meaningful for PE targets)
5525 @item a
5526 ignored. (For compatibility with the ELF version)
5527 @end table
5528
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.
5534
5535 If the optional argument to the @code{.section} directive is not quoted, it is
5536 taken as a subsegment number (@pxref{Sub-Sections}).
5537 @end ifset
5538
5539 @ifset ELF
5540 @ifset COFF
5541 @c only print the extra heading if both COFF and ELF are set
5542 @subheading ELF Version
5543 @end ifset
5544
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}).
5550
5551 @cindex @code{section} directive (ELF version)
5552 For ELF targets, the @code{.section} directive is used like this:
5553
5554 @smallexample
5555 .section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]]
5556 @end smallexample
5557
5558 The optional @var{flags} argument is a quoted string which may contain any
5559 combination of the following characters:
5560 @table @code
5561 @item a
5562 section is allocatable
5563 @item w
5564 section is writable
5565 @item x
5566 section is executable
5567 @item M
5568 section is mergeable
5569 @item S
5570 section contains zero terminated strings
5571 @item G
5572 section is a member of a section group
5573 @item T
5574 section is used for thread-local-storage
5575 @end table
5576
5577 The optional @var{type} argument may contain one of the following constants:
5578 @table @code
5579 @item @@progbits
5580 section contains data
5581 @item @@nobits
5582 section does not contain data (i.e., section only occupies space)
5583 @item @@note
5584 section contains data which is used by things other than the program
5585 @item @@init_array
5586 section contains an array of pointers to init functions
5587 @item @@fini_array
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
5591 @end table
5592
5593 Many targets only support the first three section types.
5594
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
5597 @code{%} character.
5598
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:
5601
5602 @smallexample
5603 .section @var{name} , "@var{flags}"M, @@@var{type}, @var{entsize}
5604 @end smallexample
5605
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.
5612
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:
5615
5616 @smallexample
5617 .section @var{name} , "@var{flags}"G, @@@var{type}, @var{GroupName}[, @var{linkage}]
5618 @end smallexample
5619
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:
5622 @table @code
5623 @item comdat
5624 indicates that only one copy of this section should be retained
5625 @item .gnu.linkonce
5626 an alias for comdat
5627 @end table
5628
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:
5631
5632 @smallexample
5633 .section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}]
5634 @end smallexample
5635
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.
5640
5641 For ELF targets, the assembler supports another type of @code{.section}
5642 directive for compatibility with the Solaris assembler:
5643
5644 @smallexample
5645 .section "@var{name}"[, @var{flags}...]
5646 @end smallexample
5647
5648 Note that the section name is quoted. There may be a sequence of comma
5649 separated flags:
5650 @table @code
5651 @item #alloc
5652 section is allocatable
5653 @item #write
5654 section is writable
5655 @item #execinstr
5656 section is executable
5657 @item #tls
5658 section is used for thread local storage
5659 @end table
5660
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
5664 work.
5665 @end ifset
5666 @end ifset
5667
5668 @node Set
5669 @section @code{.set @var{symbol}, @var{expression}}
5670
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}).
5677
5678 You may @code{.set} a symbol many times in the same assembly.
5679
5680 If you @code{.set} a global symbol, the value stored in the object
5681 file is the last value stored into it.
5682
5683 @ifset HPPA
5684 The syntax for @code{set} on the HPPA is
5685 @samp{@var{symbol} .set @var{expression}}.
5686 @end ifset
5687
5688 @ifset Z80
5689 On Z80 @code{set} is a real instruction, use
5690 @samp{@var{symbol} defl @var{expression}} instead.
5691 @end ifset
5692
5693 @node Short
5694 @section @code{.short @var{expressions}}
5695
5696 @cindex @code{short} directive
5697 @ifset GENERIC
5698 @code{.short} is normally the same as @samp{.word}.
5699 @xref{Word,,@code{.word}}.
5700
5701 In some configurations, however, @code{.short} and @code{.word} generate
5702 numbers of different lengths. @xref{Machine Dependencies}.
5703 @end ifset
5704 @ifclear GENERIC
5705 @ifset W16
5706 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
5707 @end ifset
5708 @ifset W32
5709 This expects zero or more @var{expressions}, and emits
5710 a 16 bit number for each.
5711 @end ifset
5712 @end ifclear
5713
5714 @node Single
5715 @section @code{.single @var{flonums}}
5716
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}.
5721 @ifset GENERIC
5722 The exact kind of floating point numbers emitted depends on how
5723 @command{@value{AS}} is configured. @xref{Machine Dependencies}.
5724 @end ifset
5725 @ifclear GENERIC
5726 @ifset IEEEFLOAT
5727 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
5728 numbers in @sc{ieee} format.
5729 @end ifset
5730 @end ifclear
5731
5732 @ifset COFF-ELF
5733 @node Size
5734 @section @code{.size}
5735
5736 This directive is used to set the size associated with a symbol.
5737
5738 @ifset COFF
5739 @ifset ELF
5740 @c only print the extra heading if both COFF and ELF are set
5741 @subheading COFF Version
5742 @end ifset
5743
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:
5747
5748 @smallexample
5749 .size @var{expression}
5750 @end smallexample
5751
5752 @ifset BOUT
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
5755 ignores it.
5756 @end ifset
5757 @end ifset
5758
5759 @ifset ELF
5760 @ifset COFF
5761 @c only print the extra heading if both COFF and ELF are set
5762 @subheading ELF Version
5763 @end ifset
5764
5765 @cindex @code{size} directive (ELF version)
5766 For ELF targets, the @code{.size} directive is used like this:
5767
5768 @smallexample
5769 .size @var{name} , @var{expression}
5770 @end smallexample
5771
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
5775 symbols.
5776 @end ifset
5777 @end ifset
5778
5779 @node Sleb128
5780 @section @code{.sleb128 @var{expressions}}
5781
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}}.
5786
5787 @ifclear no-space-dir
5788 @node Skip
5789 @section @code{.skip @var{size} , @var{fill}}
5790
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
5796 @samp{.space}.
5797
5798 @node Space
5799 @section @code{.space @var{size} , @var{fill}}
5800
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
5806 as @samp{.skip}.
5807
5808 @ifset HPPA
5809 @quotation
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},
5814 for a summary.
5815 @end quotation
5816 @end ifset
5817 @end ifclear
5818
5819 @ifset have-stabs
5820 @node Stab
5821 @section @code{.stabd, .stabn, .stabs}
5822
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:
5830
5831 @table @var
5832 @item string
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
5836 using this field.
5837
5838 @item type
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.
5842
5843 @item other
5844 An absolute expression. The symbol's ``other'' attribute is set to the
5845 low 8 bits of this expression.
5846
5847 @item desc
5848 An absolute expression. The symbol's descriptor is set to the low 16
5849 bits of this expression.
5850
5851 @item value
5852 An absolute expression which becomes the symbol's value.
5853 @end table
5854
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!
5859
5860 @table @code
5861 @cindex @code{stabd} directive
5862 @item .stabd @var{type} , @var{other} , @var{desc}
5863
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
5867 strings.
5868
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
5872 assembled.
5873
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{""}.
5877
5878 @cindex @code{stabs} directive
5879 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
5880 All five fields are specified.
5881 @end table
5882 @end ifset
5883 @c end have-stabs
5884
5885 @node String
5886 @section @code{.string} "@var{str}"
5887
5888 @cindex string, copying to object file
5889 @cindex @code{string} directive
5890
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}.
5895
5896 @node Struct
5897 @section @code{.struct @var{expression}}
5898
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:
5902 @smallexample
5903 .struct 0
5904 field1:
5905 .struct field1 + 4
5906 field2:
5907 .struct field2 + 4
5908 field3:
5909 @end smallexample
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.
5915
5916 @ifset ELF
5917 @node SubSection
5918 @section @code{.subsection @var{name}}
5919
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}
5925 (@pxref{Previous}).
5926
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.
5930 @end ifset
5931
5932 @ifset ELF
5933 @node Symver
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
5943 shared library.
5944
5945 For ELF targets, the @code{.symver} directive can be used like this:
5946 @smallexample
5947 .symver @var{name}, @var{name2@@nodename}
5948 @end smallexample
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.
5963
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
5967 symbol table.
5968
5969 Another usage of the @code{.symver} directive is:
5970 @smallexample
5971 .symver @var{name}, @var{name2@@@@nodename}
5972 @end smallexample
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.
5977
5978 The third usage of the @code{.symver} directive is:
5979 @smallexample
5980 .symver @var{name}, @var{name2@@@@@@nodename}
5981 @end smallexample
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}.
5986 @end ifset
5987
5988 @ifset COFF
5989 @node Tag
5990 @section @code{.tag @var{structname}}
5991
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.
5999 @ifset BOUT
6000
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
6003 ignores it.
6004 @end ifset
6005 @end ifset
6006
6007 @node Text
6008 @section @code{.text @var{subsection}}
6009
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
6014 is used.
6015
6016 @node Title
6017 @section @code{.title "@var{heading}"}
6018
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.
6023
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.
6026
6027 @ifset COFF-ELF
6028 @node Type
6029 @section @code{.type}
6030
6031 This directive is used to set the type of a symbol.
6032
6033 @ifset COFF
6034 @ifset ELF
6035 @c only print the extra heading if both COFF and ELF are set
6036 @subheading COFF Version
6037 @end ifset
6038
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:
6044
6045 @smallexample
6046 .type @var{int}
6047 @end smallexample
6048
6049 This records the integer @var{int} as the type attribute of a symbol table
6050 entry.
6051
6052 @ifset BOUT
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.
6056 @end ifset
6057 @end ifset
6058
6059 @ifset ELF
6060 @ifset COFF
6061 @c only print the extra heading if both COFF and ELF are set
6062 @subheading ELF Version
6063 @end ifset
6064
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:
6069
6070 @smallexample
6071 .type @var{name} , @var{type description}
6072 @end smallexample
6073
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.
6078
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
6084 assemblers.
6085
6086 The syntaxes supported are:
6087
6088 @smallexample
6089 .type <name> STT_FUNCTION
6090 .type <name> STT_OBJECT
6091
6092 .type <name>,#function
6093 .type <name>,#object
6094
6095 .type <name>,@@function
6096 .type <name>,@@object
6097
6098 .type <name>,%function
6099 .type <name>,%object
6100
6101 .type <name>,"function"
6102 .type <name>,"object"
6103 @end smallexample
6104 @end ifset
6105 @end ifset
6106
6107 @node Uleb128
6108 @section @code{.uleb128 @var{expressions}}
6109
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}}.
6114
6115 @ifset COFF
6116 @node Val
6117 @section @code{.val @var{addr}}
6118
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
6124 entry.
6125 @ifset BOUT
6126
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.
6129 @end ifset
6130 @end ifset
6131
6132 @ifset ELF
6133 @node Version
6134 @section @code{.version "@var{string}"}
6135
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}.
6139 @end ifset
6140
6141 @ifset ELF
6142 @node VTableEntry
6143 @section @code{.vtable_entry @var{table}, @var{offset}}
6144
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}.
6148
6149 @node VTableInherit
6150 @section @code{.vtable_inherit @var{child}, @var{parent}}
6151
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.
6157 @end ifset
6158
6159 @node Warning
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.
6164
6165 @node Weak
6166 @section @code{.weak @var{names}}
6167
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.
6171
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.
6175
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.
6179
6180 @node Weakref
6181 @section @code{.weakref @var{alias}, @var{target}}
6182
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.
6189
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.
6195
6196 The alias itself never makes to the symbol table, and is entirely handled
6197 within the assembler.
6198
6199 @node Word
6200 @section @code{.word @var{expressions}}
6201
6202 @cindex @code{word} directive
6203 This directive expects zero or more @var{expressions}, of any section,
6204 separated by commas.
6205 @ifclear GENERIC
6206 @ifset W32
6207 For each expression, @command{@value{AS}} emits a 32-bit number.
6208 @end ifset
6209 @ifset W16
6210 For each expression, @command{@value{AS}} emits a 16-bit number.
6211 @end ifset
6212 @end ifclear
6213 @ifset GENERIC
6214
6215 The size of the number emitted, and its byte order,
6216 depend on what target computer the assembly is for.
6217 @end ifset
6218
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
6224 @quotation
6225 @emph{Warning: Special Treatment to support Compilers}
6226 @end quotation
6227
6228 @ifset GENERIC
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.
6233
6234 @end ifset
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
6247 @code{sym2}.
6248
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.
6256
6257 @ifset INTERNALS
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.
6261 @end ifset
6262 @end ifset
6263 @c end DIFF-TBL-KLUGE
6264
6265 @node Deprecated
6266 @section Deprecated Directives
6267
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.
6272 @table @t
6273 @item .abort
6274 @item .line
6275 @end table
6276
6277 @ifset GENERIC
6278 @node Machine Dependencies
6279 @chapter Machine Dependent Features
6280
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
6288 optimization.
6289
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.
6293
6294 @menu
6295 @ifset ALPHA
6296 * Alpha-Dependent:: Alpha Dependent Features
6297 @end ifset
6298 @ifset ARC
6299 * ARC-Dependent:: ARC Dependent Features
6300 @end ifset
6301 @ifset ARM
6302 * ARM-Dependent:: ARM Dependent Features
6303 @end ifset
6304 @ifset AVR
6305 * AVR-Dependent:: AVR Dependent Features
6306 @end ifset
6307 @ifset BFIN
6308 * BFIN-Dependent:: BFIN Dependent Features
6309 @end ifset
6310 @ifset CRIS
6311 * CRIS-Dependent:: CRIS Dependent Features
6312 @end ifset
6313 @ifset D10V
6314 * D10V-Dependent:: D10V Dependent Features
6315 @end ifset
6316 @ifset D30V
6317 * D30V-Dependent:: D30V Dependent Features
6318 @end ifset
6319 @ifset H8/300
6320 * H8/300-Dependent:: Renesas H8/300 Dependent Features
6321 @end ifset
6322 @ifset HPPA
6323 * HPPA-Dependent:: HPPA Dependent Features
6324 @end ifset
6325 @ifset I370
6326 * ESA/390-Dependent:: IBM ESA/390 Dependent Features
6327 @end ifset
6328 @ifset I80386
6329 * i386-Dependent:: Intel 80386 and AMD x86-64 Dependent Features
6330 @end ifset
6331 @ifset I860
6332 * i860-Dependent:: Intel 80860 Dependent Features
6333 @end ifset
6334 @ifset I960
6335 * i960-Dependent:: Intel 80960 Dependent Features
6336 @end ifset
6337 @ifset IA64
6338 * IA-64-Dependent:: Intel IA-64 Dependent Features
6339 @end ifset
6340 @ifset IP2K
6341 * IP2K-Dependent:: IP2K Dependent Features
6342 @end ifset
6343 @ifset M32C
6344 * M32C-Dependent:: M32C Dependent Features
6345 @end ifset
6346 @ifset M32R
6347 * M32R-Dependent:: M32R Dependent Features
6348 @end ifset
6349 @ifset M680X0
6350 * M68K-Dependent:: M680x0 Dependent Features
6351 @end ifset
6352 @ifset M68HC11
6353 * M68HC11-Dependent:: M68HC11 and 68HC12 Dependent Features
6354 @end ifset
6355 @ifset MIPS
6356 * MIPS-Dependent:: MIPS Dependent Features
6357 @end ifset
6358 @ifset MMIX
6359 * MMIX-Dependent:: MMIX Dependent Features
6360 @end ifset
6361 @ifset MSP430
6362 * MSP430-Dependent:: MSP430 Dependent Features
6363 @end ifset
6364 @ifset SH
6365 * SH-Dependent:: Renesas / SuperH SH Dependent Features
6366 * SH64-Dependent:: SuperH SH64 Dependent Features
6367 @end ifset
6368 @ifset PDP11
6369 * PDP-11-Dependent:: PDP-11 Dependent Features
6370 @end ifset
6371 @ifset PJ
6372 * PJ-Dependent:: picoJava Dependent Features
6373 @end ifset
6374 @ifset PPC
6375 * PPC-Dependent:: PowerPC Dependent Features
6376 @end ifset
6377 @ifset SPARC
6378 * Sparc-Dependent:: SPARC Dependent Features
6379 @end ifset
6380 @ifset TIC54X
6381 * TIC54X-Dependent:: TI TMS320C54x Dependent Features
6382 @end ifset
6383 @ifset V850
6384 * V850-Dependent:: V850 Dependent Features
6385 @end ifset
6386 @ifset XTENSA
6387 * Xtensa-Dependent:: Xtensa Dependent Features
6388 @end ifset
6389 @ifset Z80
6390 * Z80-Dependent:: Z80 Dependent Features
6391 @end ifset
6392 @ifset Z8000
6393 * Z8000-Dependent:: Z8000 Dependent Features
6394 @end ifset
6395 @ifset VAX
6396 * Vax-Dependent:: VAX Dependent Features
6397 @end ifset
6398 @end menu
6399
6400 @lowersections
6401 @end ifset
6402
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.
6410
6411 @ifset ALPHA
6412 @include c-alpha.texi
6413 @end ifset
6414
6415 @ifset ARC
6416 @include c-arc.texi
6417 @end ifset
6418
6419 @ifset ARM
6420 @include c-arm.texi
6421 @end ifset
6422
6423 @ifset AVR
6424 @include c-avr.texi
6425 @end ifset
6426
6427 @ifset BFIN
6428 @include c-bfin.texi
6429 @end ifset
6430
6431 @ifset CRIS
6432 @include c-cris.texi
6433 @end ifset
6434
6435 @ifset Renesas-all
6436 @ifclear GENERIC
6437 @node Machine Dependencies
6438 @chapter Machine Dependent Features
6439
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
6443 family.
6444
6445 @menu
6446 * H8/300-Dependent:: Renesas H8/300 Dependent Features
6447 * SH-Dependent:: Renesas SH Dependent Features
6448 @end menu
6449 @lowersections
6450 @end ifclear
6451 @end ifset
6452
6453 @ifset D10V
6454 @include c-d10v.texi
6455 @end ifset
6456
6457 @ifset D30V
6458 @include c-d30v.texi
6459 @end ifset
6460
6461 @ifset H8/300
6462 @include c-h8300.texi
6463 @end ifset
6464
6465 @ifset HPPA
6466 @include c-hppa.texi
6467 @end ifset
6468
6469 @ifset I370
6470 @include c-i370.texi
6471 @end ifset
6472
6473 @ifset I80386
6474 @include c-i386.texi
6475 @end ifset
6476
6477 @ifset I860
6478 @include c-i860.texi
6479 @end ifset
6480
6481 @ifset I960
6482 @include c-i960.texi
6483 @end ifset
6484
6485 @ifset IA64
6486 @include c-ia64.texi
6487 @end ifset
6488
6489 @ifset IP2K
6490 @include c-ip2k.texi
6491 @end ifset
6492
6493 @ifset M32C
6494 @include c-m32c.texi
6495 @end ifset
6496
6497 @ifset M32R
6498 @include c-m32r.texi
6499 @end ifset
6500
6501 @ifset M680X0
6502 @include c-m68k.texi
6503 @end ifset
6504
6505 @ifset M68HC11
6506 @include c-m68hc11.texi
6507 @end ifset
6508
6509 @ifset MIPS
6510 @include c-mips.texi
6511 @end ifset
6512
6513 @ifset MMIX
6514 @include c-mmix.texi
6515 @end ifset
6516
6517 @ifset MSP430
6518 @include c-msp430.texi
6519 @end ifset
6520
6521 @ifset NS32K
6522 @include c-ns32k.texi
6523 @end ifset
6524
6525 @ifset PDP11
6526 @include c-pdp11.texi
6527 @end ifset
6528
6529 @ifset PJ
6530 @include c-pj.texi
6531 @end ifset
6532
6533 @ifset PPC
6534 @include c-ppc.texi
6535 @end ifset
6536
6537 @ifset SH
6538 @include c-sh.texi
6539 @include c-sh64.texi
6540 @end ifset
6541
6542 @ifset SPARC
6543 @include c-sparc.texi
6544 @end ifset
6545
6546 @ifset TIC54X
6547 @include c-tic54x.texi
6548 @end ifset
6549
6550 @ifset Z80
6551 @include c-z80.texi
6552 @end ifset
6553
6554 @ifset Z8000
6555 @include c-z8k.texi
6556 @end ifset
6557
6558 @ifset VAX
6559 @include c-vax.texi
6560 @end ifset
6561
6562 @ifset V850
6563 @include c-v850.texi
6564 @end ifset
6565
6566 @ifset XTENSA
6567 @include c-xtensa.texi
6568 @end ifset
6569
6570 @ifset GENERIC
6571 @c reverse effect of @down at top of generic Machine-Dep chapter
6572 @raisesections
6573 @end ifset
6574
6575 @node Reporting Bugs
6576 @chapter Reporting Bugs
6577 @cindex bugs in assembler
6578 @cindex reporting bugs in assembler
6579
6580 Your bug reports play an essential role in making @command{@value{AS}} reliable.
6581
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}}.
6586
6587 In order for a bug report to serve its purpose, you must include the
6588 information that enables us to fix the bug.
6589
6590 @menu
6591 * Bug Criteria:: Have you found a bug?
6592 * Bug Reporting:: How to report bugs
6593 @end menu
6594
6595 @node Bug Criteria
6596 @section Have You Found a Bug?
6597 @cindex bug criteria
6598
6599 If you are not sure whether you have found a bug, here are some guidelines:
6600
6601 @itemize @bullet
6602 @cindex fatal signal
6603 @cindex assembler crash
6604 @cindex crash of assembler
6605 @item
6606 If the assembler gets a fatal signal, for any input whatever, that is a
6607 @command{@value{AS}} bug. Reliable assemblers never crash.
6608
6609 @cindex error on valid input
6610 @item
6611 If @command{@value{AS}} produces an error message for valid input, that is a bug.
6612
6613 @cindex invalid input
6614 @item
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''.
6618
6619 @item
6620 If you are an experienced user of assemblers, your suggestions for improvement
6621 of @command{@value{AS}} are welcome in any case.
6622 @end itemize
6623
6624 @node Bug Reporting
6625 @section How to Report Bugs
6626 @cindex bug reports
6627 @cindex assembler bugs, reporting
6628
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.
6632
6633 You can find contact information for many support companies and
6634 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
6635 distribution.
6636
6637 In any event, we also recommend that you send bug reports for @command{@value{AS}}
6638 to @samp{bug-binutils@@gnu.org}.
6639
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!
6643
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.
6653
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.
6657
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.
6662
6663 To enable us to fix the bug, you should include all these things:
6664
6665 @itemize @bullet
6666 @item
6667 The version of @command{@value{AS}}. @command{@value{AS}} announces it if you start
6668 it with the @samp{--version} argument.
6669
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}}.
6672
6673 @item
6674 Any patches you may have applied to the @command{@value{AS}} source.
6675
6676 @item
6677 The type of machine you are using, and the operating system name and
6678 version number.
6679
6680 @item
6681 What compiler (and its version) was used to compile @command{@value{AS}}---e.g.
6682 ``@code{gcc-2.7}''.
6683
6684 @item
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.
6688
6689 If we were to try to guess the arguments, we would probably guess wrong
6690 and then we might not encounter the bug.
6691
6692 @item
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.
6700
6701 @item
6702 A description of what behavior you observe that you believe is
6703 incorrect. For example, ``It gets a fatal signal.''
6704
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
6708 make a mistake.
6709
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
6717 observations.
6718
6719 @item
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
6724 by line number.
6725
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.
6728 @end itemize
6729
6730 Here are some things that are not necessary:
6731
6732 @itemize @bullet
6733 @item
6734 A description of the envelope of the bug.
6735
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.
6739
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.
6744
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.
6749
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.
6752
6753 @item
6754 A patch for the bug.
6755
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.
6760
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.
6765
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.
6769
6770 @item
6771 A guess about what the bug is or what it depends on.
6772
6773 Such guesses are usually wrong. Even we cannot guess right about such
6774 things without first using the debugger to find the facts.
6775 @end itemize
6776
6777 @node Acknowledgements
6778 @chapter Acknowledgements
6779
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
6783 @c (January 1994),
6784 the maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
6785
6786 Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any
6787 more details?}
6788
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}.
6792
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.
6803
6804 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
6805 in format-specific I/O modules.
6806
6807 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
6808 has done much work with it since.
6809
6810 The Intel 80386 machine description was written by Eliot Dresselhaus.
6811
6812 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
6813
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.
6816
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.
6821
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
6826 targets.
6827
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.
6835
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.
6840
6841 Steve Chamberlain made GAS able to generate listings.
6842
6843 Hewlett-Packard contributed support for the HP9000/300.
6844
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.
6849
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).
6855
6856 Linas Vepstas added GAS support for the ESA/390 ``IBM 370'' architecture.
6857
6858 Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD
6859 support for openVMS/Alpha.
6860
6861 Timothy Wall, Michael Hayes, and Greg Smart contributed to the various tic*
6862 flavors.
6863
6864 David Heine, Sterling Augustine, Bob Wilson and John Ruttenberg from Tensilica,
6865 Inc.@: added support for Xtensa processors.
6866
6867 Several engineers at Cygnus Support have also provided many small bug fixes and
6868 configuration enhancements.
6869
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.
6874
6875 @include fdl.texi
6876
6877 @node AS Index
6878 @unnumbered AS Index
6879
6880 @printindex cp
6881
6882 @contents
6883 @bye
6884 @c Local Variables:
6885 @c fill-column: 79
6886 @c End:
This page took 0.321485 seconds and 4 git commands to generate.