gas/
[deliverable/binutils-gdb.git] / gas / doc / as.texinfo
CommitLineData
252b5132 1\input texinfo @c -*-Texinfo-*-
f7e42eb4 2@c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
78849248 3@c 2001, 2002, 2003, 2004
252b5132
RH
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---
a4fb0134
SC
16@macro gcctabopt{body}
17@code{\body\}
18@end macro
252b5132
RH
19@c defaults, config file may override:
20@set have-stabs
21@c ---
4a4c4a1d
MR
22@c man begin NAME
23@c ---
252b5132
RH
24@include asconfig.texi
25@include gasver.texi
26@c ---
0285c67d 27@c man end
4a4c4a1d 28@c ---
252b5132 29@c common OR combinations of conditions
c1253627
NC
30@ifset COFF
31@set COFF-ELF
32@end ifset
33@ifset ELF
34@set COFF-ELF
35@end ifset
252b5132
RH
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 H8/500
49@set H8
50@end ifset
51@ifset SH
52@set H8
53@end ifset
54@ifset HPPA
55@set abnormal-separator
56@end ifset
57@c ------------
58@ifset GENERIC
59@settitle Using @value{AS}
60@end ifset
61@ifclear GENERIC
62@settitle Using @value{AS} (@value{TARGET})
63@end ifclear
64@setchapternewpage odd
65@c %**end of header
66
67@c @smallbook
68@c @set SMALL
69@c WARE! Some of the machine-dependent sections contain tables of machine
70@c instructions. Except in multi-column format, these tables look silly.
71@c Unfortunately, Texinfo doesn't have a general-purpose multi-col format, so
72@c the multi-col format is faked within @example sections.
73@c
74@c Again unfortunately, the natural size that fits on a page, for these tables,
75@c is different depending on whether or not smallbook is turned on.
76@c This matters, because of order: text flow switches columns at each page
77@c break.
78@c
79@c The format faked in this source works reasonably well for smallbook,
80@c not well for the default large-page format. This manual expects that if you
81@c turn on @smallbook, you will also uncomment the "@set SMALL" to enable the
82@c tables in question. You can turn on one without the other at your
83@c discretion, of course.
84@ifinfo
85@set SMALL
86@c the insn tables look just as silly in info files regardless of smallbook,
87@c might as well show 'em anyways.
88@end ifinfo
89
90@ifinfo
91@format
92START-INFO-DIR-ENTRY
93* As: (as). The GNU assembler.
59455fb1 94* Gas: (as). The GNU assembler.
252b5132
RH
95END-INFO-DIR-ENTRY
96@end format
97@end ifinfo
98
99@finalout
100@syncodeindex ky cp
101
102@ifinfo
103This file documents the GNU Assembler "@value{AS}".
104
0285c67d 105@c man begin COPYRIGHT
973eb340 106Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 Free Software Foundation, Inc.
252b5132 107
0285c67d
NC
108Permission is granted to copy, distribute and/or modify this document
109under the terms of the GNU Free Documentation License, Version 1.1
110or any later version published by the Free Software Foundation;
111with no Invariant Sections, with no Front-Cover Texts, and with no
112Back-Cover Texts. A copy of the license is included in the
c1253627 113section entitled ``GNU Free Documentation License''.
0285c67d
NC
114
115@c man end
252b5132
RH
116
117@ignore
118Permission is granted to process this file through Tex and print the
119results, provided the printed document carries copying permission
120notice identical to this one except for the removal of this paragraph
121(this paragraph not being relevant to the printed manual).
122
123@end ignore
252b5132
RH
124@end ifinfo
125
126@titlepage
127@title Using @value{AS}
128@subtitle The @sc{gnu} Assembler
129@ifclear GENERIC
130@subtitle for the @value{TARGET} family
131@end ifclear
132@sp 1
133@subtitle Version @value{VERSION}
134@sp 1
135@sp 13
136The Free Software Foundation Inc. thanks The Nice Computer
137Company of Australia for loaning Dean Elsner to write the
a4fb0134 138first (Vax) version of @command{as} for Project @sc{gnu}.
252b5132
RH
139The proprietors, management and staff of TNCCA thank FSF for
140distracting the boss while they got some work
141done.
142@sp 3
143@author Dean Elsner, Jay Fenlason & friends
144@page
145@tex
146{\parskip=0pt
147\hfill {\it Using {\tt @value{AS}}}\par
148\hfill Edited by Cygnus Support\par
149}
150%"boxit" macro for figures:
151%Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
152\gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
153 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
154#2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
155\gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
156@end tex
157
158@vskip 0pt plus 1filll
973eb340 159Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 Free Software Foundation, Inc.
252b5132 160
cf055d54
NC
161 Permission is granted to copy, distribute and/or modify this document
162 under the terms of the GNU Free Documentation License, Version 1.1
163 or any later version published by the Free Software Foundation;
164 with no Invariant Sections, with no Front-Cover Texts, and with no
165 Back-Cover Texts. A copy of the license is included in the
c1253627 166 section entitled ``GNU Free Documentation License''.
252b5132 167
252b5132
RH
168@end titlepage
169
2e64b665 170@ifnottex
252b5132
RH
171@node Top
172@top Using @value{AS}
173
a4fb0134 174This file is a user guide to the @sc{gnu} assembler @command{@value{AS}} version
252b5132
RH
175@value{VERSION}.
176@ifclear GENERIC
a4fb0134 177This version of the file describes @command{@value{AS}} configured to generate
252b5132
RH
178code for @value{TARGET} architectures.
179@end ifclear
cf055d54
NC
180
181This document is distributed under the terms of the GNU Free
182Documentation License. A copy of the license is included in the
c1253627 183section entitled ``GNU Free Documentation License''.
cf055d54 184
252b5132
RH
185@menu
186* Overview:: Overview
187* Invoking:: Command-Line Options
188* Syntax:: Syntax
189* Sections:: Sections and Relocation
190* Symbols:: Symbols
191* Expressions:: Expressions
192* Pseudo Ops:: Assembler Directives
193* Machine Dependencies:: Machine Dependent Features
194* Reporting Bugs:: Reporting Bugs
195* Acknowledgements:: Who Did What
cf055d54 196* GNU Free Documentation License:: GNU Free Documentation License
252b5132
RH
197* Index:: Index
198@end menu
2e64b665 199@end ifnottex
252b5132
RH
200
201@node Overview
202@chapter Overview
203@iftex
a4fb0134 204This manual is a user guide to the @sc{gnu} assembler @command{@value{AS}}.
252b5132 205@ifclear GENERIC
a4fb0134 206This version of the manual describes @command{@value{AS}} configured to generate
252b5132
RH
207code for @value{TARGET} architectures.
208@end ifclear
209@end iftex
210
211@cindex invocation summary
212@cindex option summary
213@cindex summary of options
a4fb0134 214Here is a brief summary of how to invoke @command{@value{AS}}. For details,
8dfa0188 215@pxref{Invoking,,Command-Line Options}.
252b5132 216
0285c67d
NC
217@c man title AS the portable GNU assembler.
218
a4fb0134 219@ignore
0285c67d
NC
220@c man begin SEEALSO
221gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
222@c man end
a4fb0134 223@end ignore
0285c67d 224
252b5132
RH
225@c We don't use deffn and friends for the following because they seem
226@c to be limited to one line for the header.
227@smallexample
0285c67d 228@c man begin SYNOPSIS
caa32fe5 229@value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
329e276d
NC
230 [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}] [@b{--gstabs+}]
231 [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}] [@b{-K}] [@b{-L}]
a4fb0134
SC
232 [@b{--listing-lhs-width}=@var{NUM}] [@b{--listing-lhs-width2}=@var{NUM}]
233 [@b{--listing-rhs-width}=@var{NUM}] [@b{--listing-cont-lines}=@var{NUM}]
234 [@b{--keep-locals}] [@b{-o} @var{objfile}] [@b{-R}] [@b{--statistics}] [@b{-v}]
235 [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}] [@b{--fatal-warnings}]
236 [@b{-w}] [@b{-x}] [@b{-Z}] [@b{--target-help}] [@var{target-options}]
237 [@b{--}|@var{files} @dots{}]
238@c
239@c Target dependent options are listed below. Keep the list sorted.
240@c Add an empty line for separation.
252b5132
RH
241@ifset A29K
242@c am29k has no machine-dependent assembler options
243@end ifset
625e1353
RH
244@ifset ALPHA
245
246@emph{Target Alpha options:}
247 [@b{-m@var{cpu}}]
248 [@b{-mdebug} | @b{-no-mdebug}]
249 [@b{-relax}] [@b{-g}] [@b{-G@var{size}}]
250 [@b{-F}] [@b{-32addr}]
251@end ifset
252b5132 252@ifset ARC
a4fb0134
SC
253
254@emph{Target ARC options:}
255 [@b{-marc[5|6|7|8]}]
256 [@b{-EB}|@b{-EL}]
252b5132
RH
257@end ifset
258@ifset ARM
a4fb0134
SC
259
260@emph{Target ARM options:}
03b1477f 261@c Don't document the deprecated options
92081f48
HPN
262 [@b{-mcpu}=@var{processor}[+@var{extension}@dots{}]]
263 [@b{-march}=@var{architecture}[+@var{extension}@dots{}]]
33a392fb
PB
264 [@b{-mfpu}=@var{floating-point-format}]
265 [@b{-mfloat-abi}=@var{abi}]
d507cf36 266 [@b{-meabi}=@var{ver}]
03b1477f 267 [@b{-mthumb}]
a4fb0134
SC
268 [@b{-EB}|@b{-EL}]
269 [@b{-mapcs-32}|@b{-mapcs-26}|@b{-mapcs-float}|
270 @b{-mapcs-reentrant}]
7f266840 271 [@b{-mthumb-interwork}] [@b{-k}]
252b5132 272@end ifset
328eb32e
HPN
273@ifset CRIS
274
275@emph{Target CRIS options:}
276 [@b{--underscore} | @b{--no-underscore}]
277 [@b{--pic}] [@b{-N}]
278 [@b{--emulation=criself} | @b{--emulation=crisaout}]
ae57792d 279 [@b{--march=v0_v10} | @b{--march=v10} | @b{--march=v32} | @b{--march=common_v10_v32}]
328eb32e
HPN
280@c Deprecated -- deliberately not documented.
281@c [@b{-h}] [@b{-H}]
282@end ifset
252b5132 283@ifset D10V
a4fb0134
SC
284
285@emph{Target D10V options:}
286 [@b{-O}]
252b5132
RH
287@end ifset
288@ifset D30V
a4fb0134
SC
289
290@emph{Target D30V options:}
291 [@b{-O}|@b{-n}|@b{-N}]
252b5132
RH
292@end ifset
293@ifset H8
c2dcd04e 294@c Renesas family chips have no machine-dependent assembler options
252b5132
RH
295@end ifset
296@ifset HPPA
297@c HPPA has no machine-dependent assembler options (yet).
298@end ifset
a4fb0134
SC
299@ifset I80386
300
301@emph{Target i386 options:}
12b55ccc 302 [@b{--32}|@b{--64}] [@b{-n}]
252b5132
RH
303@end ifset
304@ifset I960
a4fb0134
SC
305
306@emph{Target i960 options:}
252b5132 307@c see md_parse_option in tc-i960.c
a4fb0134
SC
308 [@b{-ACA}|@b{-ACA_A}|@b{-ACB}|@b{-ACC}|@b{-AKA}|@b{-AKB}|
309 @b{-AKC}|@b{-AMC}]
310 [@b{-b}] [@b{-no-relax}]
252b5132 311@end ifset
587fe2b3 312@ifset IA64
a4fb0134 313
9e32ca89
NC
314@emph{Target IA-64 options:}
315 [@b{-mconstant-gp}|@b{-mauto-pic}]
316 [@b{-milp32}|@b{-milp64}|@b{-mlp64}|@b{-mp64}]
317 [@b{-mle}|@b{mbe}]
970d6792 318 [@b{-munwind-check=warning}|@b{-munwind-check=error}]
9e32ca89
NC
319 [@b{-x}|@b{-xexplicit}] [@b{-xauto}] [@b{-xdebug}]
320@end ifset
a40cbfa3
NC
321@ifset IP2K
322
323@emph{Target IP2K options:}
324 [@b{-mip2022}|@b{-mip2022ext}]
325@end ifset
587fe2b3 326@ifset M32R
9e32ca89 327
a4fb0134
SC
328@emph{Target M32R options:}
329 [@b{--m32rx}|@b{--[no-]warn-explicit-parallel-conflicts}|
587fe2b3 330 @b{--W[n]p}]
ec694b89 331@end ifset
252b5132 332@ifset M680X0
a4fb0134
SC
333
334@emph{Target M680X0 options:}
335 [@b{-l}] [@b{-m68000}|@b{-m68010}|@b{-m68020}|@dots{}]
252b5132 336@end ifset
60bcf0fa 337@ifset M68HC11
a4fb0134
SC
338
339@emph{Target M68HC11 options:}
d01030e6 340 [@b{-m68hc11}|@b{-m68hc12}|@b{-m68hcs12}]
2f904664
SC
341 [@b{-mshort}|@b{-mlong}]
342 [@b{-mshort-double}|@b{-mlong-double}]
a4fb0134
SC
343 [@b{--force-long-branchs}] [@b{--short-branchs}]
344 [@b{--strict-direct-mode}] [@b{--print-insn-syntax}]
345 [@b{--print-opcodes}] [@b{--generate-example}]
346@end ifset
347@ifset MCORE
348
349@emph{Target MCORE options:}
350 [@b{-jsri2bsr}] [@b{-sifilter}] [@b{-relax}]
351 [@b{-mcpu=[210|340]}]
60bcf0fa 352@end ifset
252b5132 353@ifset MIPS
a4fb0134
SC
354
355@emph{Target MIPS options:}
78849248 356 [@b{-nocpp}] [@b{-EL}] [@b{-EB}] [@b{-O}[@var{optimization level}]]
437ee9d5 357 [@b{-g}[@var{debug level}]] [@b{-G} @var{num}] [@b{-KPIC}] [@b{-call_shared}]
1ffcab4b 358 [@b{-non_shared}] [@b{-xgot}]
437ee9d5
TS
359 [@b{-mabi}=@var{ABI}] [@b{-32}] [@b{-n32}] [@b{-64}] [@b{-mfp32}] [@b{-mgp32}]
360 [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}] [@b{-mips1}] [@b{-mips2}]
af7ee8bf 361 [@b{-mips3}] [@b{-mips4}] [@b{-mips5}] [@b{-mips32}] [@b{-mips32r2}]
5f74bc13 362 [@b{-mips64}] [@b{-mips64r2}]
437ee9d5
TS
363 [@b{-construct-floats}] [@b{-no-construct-floats}]
364 [@b{-trap}] [@b{-no-break}] [@b{-break}] [@b{-no-trap}]
365 [@b{-mfix7000}] [@b{-mno-fix7000}]
366 [@b{-mips16}] [@b{-no-mips16}]
1f25f5d3 367 [@b{-mips3d}] [@b{-no-mips3d}]
deec1734 368 [@b{-mdmx}] [@b{-no-mdmx}]
ecb4347a 369 [@b{-mdebug}] [@b{-no-mdebug}]
dcd410fe 370 [@b{-mpdr}] [@b{-mno-pdr}]
3c3bdf30
NC
371@end ifset
372@ifset MMIX
a4fb0134
SC
373
374@emph{Target MMIX options:}
375 [@b{--fixed-special-register-names}] [@b{--globalize-symbols}]
376 [@b{--gnu-syntax}] [@b{--relax}] [@b{--no-predefined-symbols}]
377 [@b{--no-expand}] [@b{--no-merge-gregs}] [@b{-x}]
973eb340 378 [@b{--linker-allocated-gregs}]
a4fb0134
SC
379@end ifset
380@ifset PDP11
381
382@emph{Target PDP11 options:}
383 [@b{-mpic}|@b{-mno-pic}] [@b{-mall}] [@b{-mno-extensions}]
384 [@b{-m}@var{extension}|@b{-mno-}@var{extension}]
385 [@b{-m}@var{cpu}] [@b{-m}@var{machine}]
386@end ifset
387@ifset PJ
388
389@emph{Target picoJava options:}
390 [@b{-mb}|@b{-me}]
391@end ifset
392@ifset PPC
393
394@emph{Target PowerPC options:}
395 [@b{-mpwrx}|@b{-mpwr2}|@b{-mpwr}|@b{-m601}|@b{-mppc}|@b{-mppc32}|@b{-m603}|@b{-m604}|
396 @b{-m403}|@b{-m405}|@b{-mppc64}|@b{-m620}|@b{-mppc64bridge}|@b{-mbooke}|
397 @b{-mbooke32}|@b{-mbooke64}]
398 [@b{-mcom}|@b{-many}|@b{-maltivec}] [@b{-memb}]
399 [@b{-mregnames}|@b{-mno-regnames}]
400 [@b{-mrelocatable}|@b{-mrelocatable-lib}]
401 [@b{-mlittle}|@b{-mlittle-endian}|@b{-mbig}|@b{-mbig-endian}]
402 [@b{-msolaris}|@b{-mno-solaris}]
403@end ifset
404@ifset SPARC
405
406@emph{Target SPARC options:}
407@c The order here is important. See c-sparc.texi.
408 [@b{-Av6}|@b{-Av7}|@b{-Av8}|@b{-Asparclet}|@b{-Asparclite}
409 @b{-Av8plus}|@b{-Av8plusa}|@b{-Av9}|@b{-Av9a}]
410 [@b{-xarch=v8plus}|@b{-xarch=v8plusa}] [@b{-bump}]
411 [@b{-32}|@b{-64}]
412@end ifset
413@ifset TIC54X
414
415@emph{Target TIC54X options:}
416 [@b{-mcpu=54[123589]}|@b{-mcpu=54[56]lp}] [@b{-mfar-mode}|@b{-mf}]
417 [@b{-merrors-to-file} @var{<filename>}|@b{-me} @var{<filename>}]
418@end ifset
419@ifset Z8000
420@c Z8000 has no machine-dependent assembler options
252b5132 421@end ifset
e0001a05
NC
422@ifset XTENSA
423
424@emph{Target Xtensa options:}
43cd72b9 425 [@b{--[no-]text-section-literals}] [@b{--[no-]absolute-literals}]
e0001a05 426 [@b{--[no-]target-align}] [@b{--[no-]longcalls}]
43cd72b9 427 [@b{--[no-]transform}]
9456465c 428 [@b{--rename-section} @var{oldname}=@var{newname}]
e0001a05 429@end ifset
0285c67d 430@c man end
252b5132
RH
431@end smallexample
432
0285c67d
NC
433@c man begin OPTIONS
434
a4fb0134 435@table @gcctabopt
252b5132
RH
436@item -a[cdhlmns]
437Turn on listings, in any of a variety of ways:
438
a4fb0134 439@table @gcctabopt
252b5132
RH
440@item -ac
441omit false conditionals
442
443@item -ad
444omit debugging directives
445
446@item -ah
447include high-level source
448
449@item -al
450include assembly
451
452@item -am
453include macro expansions
454
455@item -an
456omit forms processing
457
458@item -as
459include symbols
460
461@item =file
462set the name of the listing file
463@end table
464
465You may combine these options; for example, use @samp{-aln} for assembly
466listing without forms processing. The @samp{=file} option, if used, must be
467the last one. By itself, @samp{-a} defaults to @samp{-ahls}.
468
caa32fe5
NC
469@item --alternate
470Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
471
252b5132
RH
472@item -D
473Ignored. This option is accepted for script compatibility with calls to
474other assemblers.
475
476@item --defsym @var{sym}=@var{value}
477Define the symbol @var{sym} to be @var{value} before assembling the input file.
478@var{value} must be an integer constant. As in C, a leading @samp{0x}
479indicates a hexadecimal value, and a leading @samp{0} indicates an octal value.
480
481@item -f
482``fast''---skip whitespace and comment preprocessing (assume source is
483compiler output).
484
329e276d
NC
485@item -g
486@itemx --gen-debug
487Generate debugging information for each assembler source line using whichever
488debug format is preferred by the target. This currently means either STABS,
489ECOFF or DWARF2.
490
252b5132
RH
491@item --gstabs
492Generate stabs debugging information for each assembler line. This
493may help debugging assembler code, if the debugger can handle it.
494
05da4302
NC
495@item --gstabs+
496Generate stabs debugging information for each assembler line, with GNU
497extensions that probably only gdb can handle, and that could make other
498debuggers crash or refuse to read your program. This
499may help debugging assembler code. Currently the only GNU extension is
500the location of the current working directory at assembling time.
501
329e276d 502@item --gdwarf-2
cdf82bcf 503Generate DWARF2 debugging information for each assembler line. This
c1253627 504may help debugging assembler code, if the debugger can handle it. Note---this
85a39694 505option is only supported by some targets, not all of them.
cdf82bcf 506
252b5132
RH
507@item --help
508Print a summary of the command line options and exit.
509
ea20a7da
CC
510@item --target-help
511Print a summary of all target specific options and exit.
512
252b5132
RH
513@item -I @var{dir}
514Add directory @var{dir} to the search list for @code{.include} directives.
515
516@item -J
517Don't warn about signed overflow.
518
519@item -K
520@ifclear DIFF-TBL-KLUGE
521This option is accepted but has no effect on the @value{TARGET} family.
522@end ifclear
523@ifset DIFF-TBL-KLUGE
524Issue warnings when difference tables altered for long displacements.
525@end ifset
526
527@item -L
528@itemx --keep-locals
529Keep (in the symbol table) local symbols. On traditional a.out systems
530these start with @samp{L}, but different systems have different local
531label prefixes.
532
c3a27914
NC
533@item --listing-lhs-width=@var{number}
534Set the maximum width, in words, of the output data column for an assembler
535listing to @var{number}.
536
537@item --listing-lhs-width2=@var{number}
538Set the maximum width, in words, of the output data column for continuation
539lines in an assembler listing to @var{number}.
540
541@item --listing-rhs-width=@var{number}
542Set the maximum width of an input source line, as displayed in a listing, to
543@var{number} bytes.
544
545@item --listing-cont-lines=@var{number}
546Set the maximum number of lines printed in a listing for a single line of input
547to @var{number} + 1.
548
252b5132 549@item -o @var{objfile}
a4fb0134 550Name the object-file output from @command{@value{AS}} @var{objfile}.
252b5132
RH
551
552@item -R
553Fold the data section into the text section.
554
555@item --statistics
556Print the maximum space (in bytes) and total time (in seconds) used by
557assembly.
558
559@item --strip-local-absolute
560Remove local absolute symbols from the outgoing symbol table.
561
562@item -v
563@itemx -version
a4fb0134 564Print the @command{as} version.
252b5132
RH
565
566@item --version
a4fb0134 567Print the @command{as} version and exit.
252b5132
RH
568
569@item -W
2bdd6cf5 570@itemx --no-warn
252b5132
RH
571Suppress warning messages.
572
2bdd6cf5
GK
573@item --fatal-warnings
574Treat warnings as errors.
575
576@item --warn
577Don't suppress warning messages or treat them as errors.
578
252b5132
RH
579@item -w
580Ignored.
581
582@item -x
583Ignored.
584
585@item -Z
586Generate an object file even after errors.
587
588@item -- | @var{files} @dots{}
589Standard input, or source files to assemble.
590
591@end table
592
593@ifset ARC
594The following options are available when @value{AS} is configured for
595an ARC processor.
596
a4fb0134 597@table @gcctabopt
0d2bcfaf
NC
598@item -marc[5|6|7|8]
599This option selects the core processor variant.
600@item -EB | -EL
601Select either big-endian (-EB) or little-endian (-EL) output.
252b5132
RH
602@end table
603@end ifset
604
605@ifset ARM
606The following options are available when @value{AS} is configured for the ARM
607processor family.
608
a4fb0134 609@table @gcctabopt
92081f48 610@item -mcpu=@var{processor}[+@var{extension}@dots{}]
cdf82bcf 611Specify which ARM processor variant is the target.
92081f48 612@item -march=@var{architecture}[+@var{extension}@dots{}]
cdf82bcf 613Specify which ARM architecture variant is used by the target.
03b1477f 614@item -mfpu=@var{floating-point-format}
a349d9dd 615Select which Floating Point architecture is the target.
33a392fb
PB
616@item -mfloat-abi=@var{abi}
617Select which floating point ABI is in use.
03b1477f
RE
618@item -mthumb
619Enable Thumb only instruction decoding.
7f266840 620@item -mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant
252b5132
RH
621Select which procedure calling convention is in use.
622@item -EB | -EL
623Select either big-endian (-EB) or little-endian (-EL) output.
cdf82bcf
NC
624@item -mthumb-interwork
625Specify that the code has been generated with interworking between Thumb and
626ARM code in mind.
627@item -k
628Specify that PIC code has been generated.
252b5132
RH
629@end table
630@end ifset
631
328eb32e
HPN
632@ifset CRIS
633See the info pages for documentation of the CRIS-specific options.
634@end ifset
635
252b5132
RH
636@ifset D10V
637The following options are available when @value{AS} is configured for
638a D10V processor.
a4fb0134 639@table @gcctabopt
252b5132
RH
640@cindex D10V optimization
641@cindex optimization, D10V
642@item -O
643Optimize output by parallelizing instructions.
644@end table
645@end ifset
646
647@ifset D30V
648The following options are available when @value{AS} is configured for a D30V
649processor.
a4fb0134 650@table @gcctabopt
252b5132
RH
651@cindex D30V optimization
652@cindex optimization, D30V
653@item -O
654Optimize output by parallelizing instructions.
655
656@cindex D30V nops
657@item -n
658Warn when nops are generated.
659
660@cindex D30V nops after 32-bit multiply
661@item -N
662Warn when a nop after a 32-bit multiply instruction is generated.
663@end table
664@end ifset
665
666@ifset I960
667The following options are available when @value{AS} is configured for the
668Intel 80960 processor.
669
a4fb0134 670@table @gcctabopt
252b5132
RH
671@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
672Specify which variant of the 960 architecture is the target.
673
674@item -b
675Add code to collect statistics about branches taken.
676
677@item -no-relax
678Do not alter compare-and-branch instructions for long displacements;
679error if necessary.
680
681@end table
682@end ifset
683
a40cbfa3
NC
684@ifset IP2K
685The following options are available when @value{AS} is configured for the
ec88d317 686Ubicom IP2K series.
a40cbfa3
NC
687
688@table @gcctabopt
689
690@item -mip2022ext
691Specifies that the extended IP2022 instructions are allowed.
692
693@item -mip2022
8dfa0188 694Restores the default behaviour, which restricts the permitted instructions to
a40cbfa3
NC
695just the basic IP2022 ones.
696
697@end table
698@end ifset
699
ec694b89
NC
700@ifset M32R
701The following options are available when @value{AS} is configured for the
26597c86 702Renesas M32R (formerly Mitsubishi M32R) series.
ec694b89 703
a4fb0134 704@table @gcctabopt
ec694b89
NC
705
706@item --m32rx
707Specify which processor in the M32R family is the target. The default
708is normally the M32R, but this option changes it to the M32RX.
709
710@item --warn-explicit-parallel-conflicts or --Wp
711Produce warning messages when questionable parallel constructs are
712encountered.
713
714@item --no-warn-explicit-parallel-conflicts or --Wnp
715Do not produce warning messages when questionable parallel constructs are
716encountered.
717
718@end table
719@end ifset
252b5132
RH
720
721@ifset M680X0
722The following options are available when @value{AS} is configured for the
723Motorola 68000 series.
724
a4fb0134 725@table @gcctabopt
252b5132
RH
726
727@item -l
728Shorten references to undefined symbols, to one word instead of two.
729
0285c67d
NC
730@item -m68000 | -m68008 | -m68010 | -m68020 | -m68030
731@itemx | -m68040 | -m68060 | -m68302 | -m68331 | -m68332
732@itemx | -m68333 | -m68340 | -mcpu32 | -m5200
252b5132
RH
733Specify what processor in the 68000 family is the target. The default
734is normally the 68020, but this can be changed at configuration time.
735
736@item -m68881 | -m68882 | -mno-68881 | -mno-68882
737The target machine does (or does not) have a floating-point coprocessor.
738The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
739the basic 68000 is not compatible with the 68881, a combination of the
740two can be specified, since it's possible to do emulation of the
741coprocessor instructions with the main processor.
742
743@item -m68851 | -mno-68851
744The target machine does (or does not) have a memory-management
745unit coprocessor. The default is to assume an MMU for 68020 and up.
746
747@end table
748@end ifset
749
e135f41b
NC
750@ifset PDP11
751
752For details about the PDP-11 machine dependent features options,
753see @ref{PDP-11-Options}.
754
a4fb0134 755@table @gcctabopt
e135f41b
NC
756@item -mpic | -mno-pic
757Generate position-independent (or position-dependent) code. The
a4fb0134 758default is @option{-mpic}.
e135f41b
NC
759
760@item -mall
761@itemx -mall-extensions
762Enable all instruction set extensions. This is the default.
763
764@item -mno-extensions
765Disable all instruction set extensions.
766
767@item -m@var{extension} | -mno-@var{extension}
768Enable (or disable) a particular instruction set extension.
769
770@item -m@var{cpu}
771Enable the instruction set extensions supported by a particular CPU, and
772disable all other extensions.
773
774@item -m@var{machine}
775Enable the instruction set extensions supported by a particular machine
776model, and disable all other extensions.
777@end table
778
779@end ifset
780
041dd5a9
ILT
781@ifset PJ
782The following options are available when @value{AS} is configured for
783a picoJava processor.
784
a4fb0134 785@table @gcctabopt
041dd5a9
ILT
786
787@cindex PJ endianness
788@cindex endianness, PJ
789@cindex big endian output, PJ
790@item -mb
791Generate ``big endian'' format output.
792
793@cindex little endian output, PJ
794@item -ml
795Generate ``little endian'' format output.
796
797@end table
798@end ifset
799
60bcf0fa
NC
800@ifset M68HC11
801The following options are available when @value{AS} is configured for the
802Motorola 68HC11 or 68HC12 series.
803
a4fb0134 804@table @gcctabopt
60bcf0fa 805
d01030e6 806@item -m68hc11 | -m68hc12 | -m68hcs12
60bcf0fa
NC
807Specify what processor is the target. The default is
808defined by the configuration option when building the assembler.
809
2f904664
SC
810@item -mshort
811Specify to use the 16-bit integer ABI.
812
813@item -mlong
814Specify to use the 32-bit integer ABI.
815
816@item -mshort-double
817Specify to use the 32-bit double ABI.
818
819@item -mlong-double
820Specify to use the 64-bit double ABI.
821
60bcf0fa
NC
822@item --force-long-branchs
823Relative branches are turned into absolute ones. This concerns
824conditional branches, unconditional branches and branches to a
825sub routine.
826
827@item -S | --short-branchs
828Do not turn relative branchs into absolute ones
829when the offset is out of range.
830
831@item --strict-direct-mode
832Do not turn the direct addressing mode into extended addressing mode
833when the instruction does not support direct addressing mode.
834
835@item --print-insn-syntax
836Print the syntax of instruction in case of error.
837
838@item --print-opcodes
839print the list of instructions with syntax and then exit.
840
841@item --generate-example
842print an example of instruction for each possible instruction and then exit.
a4fb0134 843This option is only useful for testing @command{@value{AS}}.
60bcf0fa
NC
844
845@end table
846@end ifset
847
252b5132 848@ifset SPARC
a4fb0134 849The following options are available when @command{@value{AS}} is configured
252b5132
RH
850for the SPARC architecture:
851
a4fb0134 852@table @gcctabopt
252b5132
RH
853@item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
854@itemx -Av8plus | -Av8plusa | -Av9 | -Av9a
855Explicitly select a variant of the SPARC architecture.
856
857@samp{-Av8plus} and @samp{-Av8plusa} select a 32 bit environment.
858@samp{-Av9} and @samp{-Av9a} select a 64 bit environment.
859
860@samp{-Av8plusa} and @samp{-Av9a} enable the SPARC V9 instruction set with
861UltraSPARC extensions.
862
863@item -xarch=v8plus | -xarch=v8plusa
864For compatibility with the Solaris v9 assembler. These options are
865equivalent to -Av8plus and -Av8plusa, respectively.
866
867@item -bump
868Warn when the assembler switches to another architecture.
869@end table
870@end ifset
871
39bec121
TW
872@ifset TIC54X
873The following options are available when @value{AS} is configured for the 'c54x
874architecture.
875
a4fb0134 876@table @gcctabopt
39bec121
TW
877@item -mfar-mode
878Enable extended addressing mode. All addresses and relocations will assume
879extended addressing (usually 23 bits).
880@item -mcpu=@var{CPU_VERSION}
881Sets the CPU version being compiled for.
882@item -merrors-to-file @var{FILENAME}
883Redirect error output to a file, for broken systems which don't support such
884behaviour in the shell.
885@end table
886@end ifset
887
252b5132
RH
888@ifset MIPS
889The following options are available when @value{AS} is configured for
437ee9d5 890a @sc{mips} processor.
252b5132 891
a4fb0134 892@table @gcctabopt
252b5132
RH
893@item -G @var{num}
894This option sets the largest size of an object that can be referenced
895implicitly with the @code{gp} register. It is only accepted for targets that
896use ECOFF format, such as a DECstation running Ultrix. The default value is 8.
897
898@cindex MIPS endianness
899@cindex endianness, MIPS
900@cindex big endian output, MIPS
901@item -EB
902Generate ``big endian'' format output.
903
904@cindex little endian output, MIPS
905@item -EL
906Generate ``little endian'' format output.
907
908@cindex MIPS ISA
909@item -mips1
910@itemx -mips2
911@itemx -mips3
e7af610e 912@itemx -mips4
437ee9d5 913@itemx -mips5
e7af610e 914@itemx -mips32
af7ee8bf 915@itemx -mips32r2
4058e45f 916@itemx -mips64
5f74bc13 917@itemx -mips64r2
437ee9d5
TS
918Generate code for a particular @sc{mips} Instruction Set Architecture level.
919@samp{-mips1} is an alias for @samp{-march=r3000}, @samp{-mips2} is an
920alias for @samp{-march=r6000}, @samp{-mips3} is an alias for
921@samp{-march=r4000} and @samp{-mips4} is an alias for @samp{-march=r8000}.
5f74bc13
CD
922@samp{-mips5}, @samp{-mips32}, @samp{-mips32r2}, @samp{-mips64}, and
923@samp{-mips64r2}
af7ee8bf 924correspond to generic
5f74bc13
CD
925@samp{MIPS V}, @samp{MIPS32}, @samp{MIPS32 Release 2}, @samp{MIPS64},
926and @samp{MIPS64 Release 2}
927ISA processors, respectively.
437ee9d5
TS
928
929@item -march=@var{CPU}
930Generate code for a particular @sc{mips} cpu.
931
932@item -mtune=@var{cpu}
933Schedule and tune for a particular @sc{mips} cpu.
934
935@item -mfix7000
936@itemx -mno-fix7000
937Cause nops to be inserted if the read of the destination register
938of an mfhi or mflo instruction occurs in the following two instructions.
939
ecb4347a
DJ
940@item -mdebug
941@itemx -no-mdebug
942Cause stabs-style debugging output to go into an ECOFF-style .mdebug
943section instead of the standard ELF .stabs sections.
944
dcd410fe
RO
945@item -mpdr
946@itemx -mno-pdr
947Control generation of @code{.pdr} sections.
948
437ee9d5
TS
949@item -mgp32
950@itemx -mfp32
951The register sizes are normally inferred from the ISA and ABI, but these
952flags force a certain group of registers to be treated as 32 bits wide at
953all times. @samp{-mgp32} controls the size of general-purpose registers
954and @samp{-mfp32} controls the size of floating-point registers.
955
956@item -mips16
957@itemx -no-mips16
958Generate code for the MIPS 16 processor. This is equivalent to putting
959@code{.set mips16} at the start of the assembly file. @samp{-no-mips16}
960turns off this option.
252b5132 961
1f25f5d3
CD
962@item -mips3d
963@itemx -no-mips3d
964Generate code for the MIPS-3D Application Specific Extension.
965This tells the assembler to accept MIPS-3D instructions.
966@samp{-no-mips3d} turns off this option.
967
deec1734
CD
968@item -mdmx
969@itemx -no-mdmx
970Generate code for the MDMX Application Specific Extension.
971This tells the assembler to accept MDMX instructions.
972@samp{-no-mdmx} turns off this option.
973
437ee9d5
TS
974@item --construct-floats
975@itemx --no-construct-floats
976The @samp{--no-construct-floats} option disables the construction of
977double width floating point constants by loading the two halves of the
978value into the two single width floating point registers that make up
979the double width register. By default @samp{--construct-floats} is
980selected, allowing construction of these floating point constants.
252b5132
RH
981
982@cindex emulation
983@item --emulation=@var{name}
a4fb0134 984This option causes @command{@value{AS}} to emulate @command{@value{AS}} configured
252b5132
RH
985for some other target, in all respects, including output format (choosing
986between ELF and ECOFF only), handling of pseudo-opcodes which may generate
987debugging information or store symbol table information, and default
988endianness. The available configuration names are: @samp{mipsecoff},
989@samp{mipself}, @samp{mipslecoff}, @samp{mipsbecoff}, @samp{mipslelf},
990@samp{mipsbelf}. The first two do not alter the default endianness from that
991of the primary target for which the assembler was configured; the others change
992the default to little- or big-endian as indicated by the @samp{b} or @samp{l}
993in the name. Using @samp{-EB} or @samp{-EL} will override the endianness
994selection in any case.
995
996This option is currently supported only when the primary target
437ee9d5 997@command{@value{AS}} is configured for is a @sc{mips} ELF or ECOFF target.
252b5132
RH
998Furthermore, the primary target or others specified with
999@samp{--enable-targets=@dots{}} at configuration time must include support for
1000the other format, if both are to be available. For example, the Irix 5
1001configuration includes support for both.
1002
1003Eventually, this option will support more configurations, with more
1004fine-grained control over the assembler's behavior, and will be supported for
1005more processors.
1006
1007@item -nocpp
a4fb0134 1008@command{@value{AS}} ignores this option. It is accepted for compatibility with
252b5132
RH
1009the native tools.
1010
252b5132
RH
1011@item --trap
1012@itemx --no-trap
1013@itemx --break
1014@itemx --no-break
1015Control how to deal with multiplication overflow and division by zero.
1016@samp{--trap} or @samp{--no-break} (which are synonyms) take a trap exception
1017(and only work for Instruction Set Architecture level 2 and higher);
1018@samp{--break} or @samp{--no-trap} (also synonyms, and the default) take a
1019break exception.
63486801
L
1020
1021@item -n
a4fb0134 1022When this option is used, @command{@value{AS}} will issue a warning every
63486801 1023time it generates a nop instruction from a macro.
252b5132
RH
1024@end table
1025@end ifset
1026
1027@ifset MCORE
1028The following options are available when @value{AS} is configured for
1029an MCore processor.
1030
a4fb0134 1031@table @gcctabopt
252b5132
RH
1032@item -jsri2bsr
1033@itemx -nojsri2bsr
1034Enable or disable the JSRI to BSR transformation. By default this is enabled.
1035The command line option @samp{-nojsri2bsr} can be used to disable it.
1036
1037@item -sifilter
1038@itemx -nosifilter
1039Enable or disable the silicon filter behaviour. By default this is disabled.
a349d9dd 1040The default can be overridden by the @samp{-sifilter} command line option.
252b5132
RH
1041
1042@item -relax
1043Alter jump instructions for long displacements.
1044
ec694b89
NC
1045@item -mcpu=[210|340]
1046Select the cpu type on the target hardware. This controls which instructions
1047can be assembled.
1048
1049@item -EB
1050Assemble for a big endian target.
1051
1052@item -EL
1053Assemble for a little endian target.
252b5132
RH
1054
1055@end table
1056@end ifset
1057
3c3bdf30
NC
1058@ifset MMIX
1059See the info pages for documentation of the MMIX-specific options.
1060@end ifset
1061
e0001a05
NC
1062@ifset XTENSA
1063The following options are available when @value{AS} is configured for
1064an Xtensa processor.
1065
1066@table @gcctabopt
e0001a05
NC
1067@item --text-section-literals | --no-text-section-literals
1068With @option{--text-@-section-@-literals}, literal pools are interspersed
1069in the text section. The default is
1070@option{--no-@-text-@-section-@-literals}, which places literals in a
43cd72b9
BW
1071separate section in the output file. These options only affect literals
1072referenced via PC-relative @code{L32R} instructions; literals for
1073absolute mode @code{L32R} instructions are handled separately.
1074
1075@item --absolute-literals | --no-absolute-literals
1076Indicate to the assembler whether @code{L32R} instructions use absolute
1077or PC-relative addressing. The default is to assume absolute addressing
1078if the Xtensa processor includes the absolute @code{L32R} addressing
1079option. Otherwise, only the PC-relative @code{L32R} mode can be used.
e0001a05
NC
1080
1081@item --target-align | --no-target-align
1082Enable or disable automatic alignment to reduce branch penalties at the
1083expense of some code density. The default is @option{--target-@-align}.
1084
1085@item --longcalls | --no-longcalls
1086Enable or disable transformation of call instructions to allow calls
1087across a greater range of addresses. The default is
1088@option{--no-@-longcalls}.
43cd72b9
BW
1089
1090@item --transform | --no-transform
1091Enable or disable all assembler transformations of Xtensa instructions.
1092The default is @option{--transform};
1093@option{--no-transform} should be used only in the rare cases when the
1094instructions must be exactly as specified in the assembly source.
e0001a05
NC
1095@end table
1096@end ifset
1097
0285c67d
NC
1098@c man end
1099
252b5132
RH
1100@menu
1101* Manual:: Structure of this Manual
1102* GNU Assembler:: The GNU Assembler
1103* Object Formats:: Object File Formats
1104* Command Line:: Command Line
1105* Input Files:: Input Files
1106* Object:: Output (Object) File
1107* Errors:: Error and Warning Messages
1108@end menu
1109
1110@node Manual
1111@section Structure of this Manual
1112
1113@cindex manual, structure and purpose
1114This manual is intended to describe what you need to know to use
a4fb0134 1115@sc{gnu} @command{@value{AS}}. We cover the syntax expected in source files, including
252b5132 1116notation for symbols, constants, and expressions; the directives that
a4fb0134 1117@command{@value{AS}} understands; and of course how to invoke @command{@value{AS}}.
252b5132
RH
1118
1119@ifclear GENERIC
1120We also cover special features in the @value{TARGET}
a4fb0134 1121configuration of @command{@value{AS}}, including assembler directives.
252b5132
RH
1122@end ifclear
1123@ifset GENERIC
1124This manual also describes some of the machine-dependent features of
1125various flavors of the assembler.
1126@end ifset
1127
1128@cindex machine instructions (not covered)
1129On the other hand, this manual is @emph{not} intended as an introduction
1130to programming in assembly language---let alone programming in general!
1131In a similar vein, we make no attempt to introduce the machine
1132architecture; we do @emph{not} describe the instruction set, standard
1133mnemonics, registers or addressing modes that are standard to a
1134particular architecture.
1135@ifset GENERIC
1136You may want to consult the manufacturer's
1137machine architecture manual for this information.
1138@end ifset
1139@ifclear GENERIC
1140@ifset H8/300
1141For information on the H8/300 machine instruction set, see @cite{H8/300
c2dcd04e
NC
1142Series Programming Manual}. For the H8/300H, see @cite{H8/300H Series
1143Programming Manual} (Renesas).
252b5132
RH
1144@end ifset
1145@ifset H8/500
1146For information on the H8/500 machine instruction set, see @cite{H8/500
c2dcd04e 1147Series Programming Manual} (Renesas M21T001).
252b5132
RH
1148@end ifset
1149@ifset SH
ef230218
JR
1150For information on the Renesas (formerly Hitachi) / SuperH SH machine instruction set,
1151see @cite{SH-Microcomputer User's Manual} (Renesas) or
1152@cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
1153@cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
252b5132
RH
1154@end ifset
1155@ifset Z8000
1156For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
1157@end ifset
1158@end ifclear
1159
1160@c I think this is premature---doc@cygnus.com, 17jan1991
1161@ignore
1162Throughout this manual, we assume that you are running @dfn{GNU},
1163the portable operating system from the @dfn{Free Software
1164Foundation, Inc.}. This restricts our attention to certain kinds of
1165computer (in particular, the kinds of computers that @sc{gnu} can run on);
1166once this assumption is granted examples and definitions need less
1167qualification.
1168
a4fb0134 1169@command{@value{AS}} is part of a team of programs that turn a high-level
252b5132
RH
1170human-readable series of instructions into a low-level
1171computer-readable series of instructions. Different versions of
a4fb0134 1172@command{@value{AS}} are used for different kinds of computer.
252b5132
RH
1173@end ignore
1174
1175@c There used to be a section "Terminology" here, which defined
1176@c "contents", "byte", "word", and "long". Defining "word" to any
1177@c particular size is confusing when the .word directive may generate 16
1178@c bits on one machine and 32 bits on another; in general, for the user
1179@c version of this manual, none of these terms seem essential to define.
1180@c They were used very little even in the former draft of the manual;
1181@c this draft makes an effort to avoid them (except in names of
1182@c directives).
1183
1184@node GNU Assembler
1185@section The GNU Assembler
1186
0285c67d
NC
1187@c man begin DESCRIPTION
1188
a4fb0134 1189@sc{gnu} @command{as} is really a family of assemblers.
252b5132 1190@ifclear GENERIC
a4fb0134 1191This manual describes @command{@value{AS}}, a member of that family which is
252b5132
RH
1192configured for the @value{TARGET} architectures.
1193@end ifclear
1194If you use (or have used) the @sc{gnu} assembler on one architecture, you
1195should find a fairly similar environment when you use it on another
1196architecture. Each version has much in common with the others,
1197including object file formats, most assembler directives (often called
1198@dfn{pseudo-ops}) and assembler syntax.@refill
1199
1200@cindex purpose of @sc{gnu} assembler
a4fb0134 1201@command{@value{AS}} is primarily intended to assemble the output of the
252b5132 1202@sc{gnu} C compiler @code{@value{GCC}} for use by the linker
a4fb0134 1203@code{@value{LD}}. Nevertheless, we've tried to make @command{@value{AS}}
252b5132
RH
1204assemble correctly everything that other assemblers for the same
1205machine would assemble.
1206@ifset VAX
1207Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
1208@end ifset
1209@ifset M680X0
1210@c This remark should appear in generic version of manual; assumption
1211@c here is that generic version sets M680x0.
a4fb0134 1212This doesn't mean @command{@value{AS}} always uses the same syntax as another
252b5132
RH
1213assembler for the same architecture; for example, we know of several
1214incompatible versions of 680x0 assembly language syntax.
1215@end ifset
1216
0285c67d
NC
1217@c man end
1218
a4fb0134 1219Unlike older assemblers, @command{@value{AS}} is designed to assemble a source
252b5132
RH
1220program in one pass of the source file. This has a subtle impact on the
1221@kbd{.org} directive (@pxref{Org,,@code{.org}}).
1222
1223@node Object Formats
1224@section Object File Formats
1225
1226@cindex object file format
1227The @sc{gnu} assembler can be configured to produce several alternative
1228object file formats. For the most part, this does not affect how you
1229write assembly language programs; but directives for debugging symbols
1230are typically different in different file formats. @xref{Symbol
1231Attributes,,Symbol Attributes}.
1232@ifclear GENERIC
1233@ifclear MULTI-OBJ
c1253627 1234For the @value{TARGET} target, @command{@value{AS}} is configured to produce
252b5132
RH
1235@value{OBJ-NAME} format object files.
1236@end ifclear
1237@c The following should exhaust all configs that set MULTI-OBJ, ideally
1238@ifset A29K
a4fb0134 1239On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
252b5132
RH
1240@code{a.out} or COFF format object files.
1241@end ifset
1242@ifset I960
a4fb0134 1243On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
252b5132
RH
1244@code{b.out} or COFF format object files.
1245@end ifset
1246@ifset HPPA
a4fb0134 1247On the @value{TARGET}, @command{@value{AS}} can be configured to produce either
252b5132
RH
1248SOM or ELF format object files.
1249@end ifset
1250@end ifclear
1251
1252@node Command Line
1253@section Command Line
1254
1255@cindex command line conventions
0285c67d 1256
a4fb0134 1257After the program name @command{@value{AS}}, the command line may contain
252b5132
RH
1258options and file names. Options may appear in any order, and may be
1259before, after, or between file names. The order of file names is
1260significant.
1261
1262@cindex standard input, as input file
1263@kindex --
1264@file{--} (two hyphens) by itself names the standard input file
a4fb0134 1265explicitly, as one of the files for @command{@value{AS}} to assemble.
252b5132
RH
1266
1267@cindex options, command line
1268Except for @samp{--} any command line argument that begins with a
1269hyphen (@samp{-}) is an option. Each option changes the behavior of
a4fb0134 1270@command{@value{AS}}. No option changes the way another option works. An
252b5132
RH
1271option is a @samp{-} followed by one or more letters; the case of
1272the letter is important. All options are optional.
1273
1274Some options expect exactly one file name to follow them. The file
1275name may either immediately follow the option's letter (compatible
1276with older assemblers) or it may be the next command argument (@sc{gnu}
1277standard). These two command lines are equivalent:
1278
1279@smallexample
1280@value{AS} -o my-object-file.o mumble.s
1281@value{AS} -omy-object-file.o mumble.s
1282@end smallexample
1283
1284@node Input Files
1285@section Input Files
1286
1287@cindex input
1288@cindex source program
1289@cindex files, input
1290We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
a4fb0134 1291describe the program input to one run of @command{@value{AS}}. The program may
252b5132
RH
1292be in one or more files; how the source is partitioned into files
1293doesn't change the meaning of the source.
1294
1295@c I added "con" prefix to "catenation" just to prove I can overcome my
1296@c APL training... doc@cygnus.com
1297The source program is a concatenation of the text in all the files, in the
1298order specified.
1299
0285c67d 1300@c man begin DESCRIPTION
a4fb0134 1301Each time you run @command{@value{AS}} it assembles exactly one source
252b5132
RH
1302program. The source program is made up of one or more files.
1303(The standard input is also a file.)
1304
a4fb0134 1305You give @command{@value{AS}} a command line that has zero or more input file
252b5132
RH
1306names. The input files are read (from left file name to right). A
1307command line argument (in any position) that has no special meaning
1308is taken to be an input file name.
1309
a4fb0134
SC
1310If you give @command{@value{AS}} no file names it attempts to read one input file
1311from the @command{@value{AS}} standard input, which is normally your terminal. You
1312may have to type @key{ctl-D} to tell @command{@value{AS}} there is no more program
252b5132
RH
1313to assemble.
1314
1315Use @samp{--} if you need to explicitly name the standard input file
1316in your command line.
1317
a4fb0134 1318If the source is empty, @command{@value{AS}} produces a small, empty object
252b5132
RH
1319file.
1320
0285c67d
NC
1321@c man end
1322
252b5132
RH
1323@subheading Filenames and Line-numbers
1324
1325@cindex input file linenumbers
1326@cindex line numbers, in input files
1327There are two ways of locating a line in the input file (or files) and
1328either may be used in reporting error messages. One way refers to a line
1329number in a physical file; the other refers to a line number in a
1330``logical'' file. @xref{Errors, ,Error and Warning Messages}.
1331
1332@dfn{Physical files} are those files named in the command line given
a4fb0134 1333to @command{@value{AS}}.
252b5132
RH
1334
1335@dfn{Logical files} are simply names declared explicitly by assembler
1336directives; they bear no relation to physical files. Logical file names help
a4fb0134
SC
1337error messages reflect the original source file, when @command{@value{AS}} source
1338is itself synthesized from other files. @command{@value{AS}} understands the
252b5132
RH
1339@samp{#} directives emitted by the @code{@value{GCC}} preprocessor. See also
1340@ref{File,,@code{.file}}.
1341
1342@node Object
1343@section Output (Object) File
1344
1345@cindex object file
1346@cindex output file
1347@kindex a.out
1348@kindex .o
a4fb0134 1349Every time you run @command{@value{AS}} it produces an output file, which is
252b5132
RH
1350your assembly language program translated into numbers. This file
1351is the object file. Its default name is
1352@ifclear BOUT
1353@code{a.out}.
1354@end ifclear
1355@ifset BOUT
1356@ifset GENERIC
1357@code{a.out}, or
1358@end ifset
a4fb0134 1359@code{b.out} when @command{@value{AS}} is configured for the Intel 80960.
252b5132 1360@end ifset
a4fb0134 1361You can give it another name by using the @option{-o} option. Conventionally,
252b5132
RH
1362object file names end with @file{.o}. The default name is used for historical
1363reasons: older assemblers were capable of assembling self-contained programs
1364directly into a runnable program. (For some formats, this isn't currently
1365possible, but it can be done for the @code{a.out} format.)
1366
1367@cindex linker
1368@kindex ld
1369The object file is meant for input to the linker @code{@value{LD}}. It contains
1370assembled program code, information to help @code{@value{LD}} integrate
1371the assembled program into a runnable file, and (optionally) symbolic
1372information for the debugger.
1373
1374@c link above to some info file(s) like the description of a.out.
1375@c don't forget to describe @sc{gnu} info as well as Unix lossage.
1376
1377@node Errors
1378@section Error and Warning Messages
1379
0285c67d
NC
1380@c man begin DESCRIPTION
1381
a349d9dd 1382@cindex error messages
252b5132
RH
1383@cindex warning messages
1384@cindex messages from assembler
a4fb0134 1385@command{@value{AS}} may write warnings and error messages to the standard error
252b5132 1386file (usually your terminal). This should not happen when a compiler
a4fb0134
SC
1387runs @command{@value{AS}} automatically. Warnings report an assumption made so
1388that @command{@value{AS}} could keep assembling a flawed program; errors report a
252b5132
RH
1389grave problem that stops the assembly.
1390
0285c67d
NC
1391@c man end
1392
252b5132
RH
1393@cindex format of warning messages
1394Warning messages have the format
1395
1396@smallexample
1397file_name:@b{NNN}:Warning Message Text
1398@end smallexample
1399
1400@noindent
1401@cindex line numbers, in warnings/errors
1402(where @b{NNN} is a line number). If a logical file name has been given
1403(@pxref{File,,@code{.file}}) it is used for the filename, otherwise the name of
1404the current input file is used. If a logical line number was given
1405@ifset GENERIC
1406(@pxref{Line,,@code{.line}})
1407@end ifset
1408@ifclear GENERIC
1409@ifclear A29K
1410(@pxref{Line,,@code{.line}})
1411@end ifclear
1412@ifset A29K
1413(@pxref{Ln,,@code{.ln}})
1414@end ifset
1415@end ifclear
1416then it is used to calculate the number printed,
1417otherwise the actual line in the current source file is printed. The
1418message text is intended to be self explanatory (in the grand Unix
1419tradition).
1420
1421@cindex format of error messages
1422Error messages have the format
1423@smallexample
1424file_name:@b{NNN}:FATAL:Error Message Text
1425@end smallexample
1426The file name and line number are derived as for warning
1427messages. The actual message text may be rather less explanatory
1428because many of them aren't supposed to happen.
1429
1430@node Invoking
1431@chapter Command-Line Options
1432
1433@cindex options, all versions of assembler
1434This chapter describes command-line options available in @emph{all}
1435versions of the @sc{gnu} assembler; @pxref{Machine Dependencies}, for options specific
1436@ifclear GENERIC
c1253627 1437to the @value{TARGET} target.
252b5132
RH
1438@end ifclear
1439@ifset GENERIC
1440to particular machine architectures.
1441@end ifset
1442
0285c67d
NC
1443@c man begin DESCRIPTION
1444
c1253627 1445If you are invoking @command{@value{AS}} via the @sc{gnu} C compiler,
252b5132
RH
1446you can use the @samp{-Wa} option to pass arguments through to the assembler.
1447The assembler arguments must be separated from each other (and the @samp{-Wa})
1448by commas. For example:
1449
1450@smallexample
1451gcc -c -g -O -Wa,-alh,-L file.c
1452@end smallexample
1453
1454@noindent
1455This passes two options to the assembler: @samp{-alh} (emit a listing to
5f5e16be 1456standard output with high-level and assembly source) and @samp{-L} (retain
252b5132
RH
1457local symbols in the symbol table).
1458
1459Usually you do not need to use this @samp{-Wa} mechanism, since many compiler
1460command-line options are automatically passed to the assembler by the compiler.
1461(You can call the @sc{gnu} compiler driver with the @samp{-v} option to see
1462precisely what options it passes to each compilation pass, including the
1463assembler.)
1464
0285c67d
NC
1465@c man end
1466
252b5132
RH
1467@menu
1468* a:: -a[cdhlns] enable listings
caa32fe5 1469* alternate:: --alternate enable alternate macro syntax
252b5132
RH
1470* D:: -D for compatibility
1471* f:: -f to work faster
1472* I:: -I for .include search path
1473@ifclear DIFF-TBL-KLUGE
1474* K:: -K for compatibility
1475@end ifclear
1476@ifset DIFF-TBL-KLUGE
1477* K:: -K for difference tables
1478@end ifset
1479
1480* L:: -L to retain local labels
c3a27914 1481* listing:: --listing-XXX to configure listing output
252b5132
RH
1482* M:: -M or --mri to assemble in MRI compatibility mode
1483* MD:: --MD for dependency tracking
1484* o:: -o to name the object file
1485* R:: -R to join data and text sections
1486* statistics:: --statistics to see statistics about assembly
1487* traditional-format:: --traditional-format for compatible output
1488* v:: -v to announce version
2bdd6cf5 1489* W:: -W, --no-warn, --warn, --fatal-warnings to control warnings
252b5132
RH
1490* Z:: -Z to make object file even after errors
1491@end menu
1492
1493@node a
a4fb0134 1494@section Enable Listings: @option{-a[cdhlns]}
252b5132
RH
1495
1496@kindex -a
1497@kindex -ac
1498@kindex -ad
1499@kindex -ah
1500@kindex -al
1501@kindex -an
1502@kindex -as
1503@cindex listings, enabling
1504@cindex assembly listings, enabling
1505
1506These options enable listing output from the assembler. By itself,
1507@samp{-a} requests high-level, assembly, and symbols listing.
1508You can use other letters to select specific options for the list:
1509@samp{-ah} requests a high-level language listing,
1510@samp{-al} requests an output-program assembly listing, and
1511@samp{-as} requests a symbol table listing.
1512High-level listings require that a compiler debugging option like
1513@samp{-g} be used, and that assembly listings (@samp{-al}) be requested
1514also.
1515
1516Use the @samp{-ac} option to omit false conditionals from a listing. Any lines
1517which are not assembled because of a false @code{.if} (or @code{.ifdef}, or any
1518other conditional), or a true @code{.if} followed by an @code{.else}, will be
1519omitted from the listing.
1520
1521Use the @samp{-ad} option to omit debugging directives from the
1522listing.
1523
1524Once you have specified one of these options, you can further control
1525listing output and its appearance using the directives @code{.list},
1526@code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
1527@code{.sbttl}.
1528The @samp{-an} option turns off all forms processing.
1529If you do not request listing output with one of the @samp{-a} options, the
1530listing-control directives have no effect.
1531
1532The letters after @samp{-a} may be combined into one option,
1533@emph{e.g.}, @samp{-aln}.
1534
c3a27914
NC
1535Note if the assembler source is coming from the standard input (eg because it
1536is being created by @code{@value{GCC}} and the @samp{-pipe} command line switch
1537is being used) then the listing will not contain any comments or preprocessor
1538directives. This is because the listing code buffers input source lines from
1539stdin only after they have been preprocessed by the assembler. This reduces
1540memory usage and makes the code more efficient.
1541
caa32fe5
NC
1542@node alternate
1543@section @option{--alternate}
1544
1545@kindex --alternate
1546Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
1547
252b5132 1548@node D
a4fb0134 1549@section @option{-D}
252b5132
RH
1550
1551@kindex -D
1552This option has no effect whatsoever, but it is accepted to make it more
1553likely that scripts written for other assemblers also work with
a4fb0134 1554@command{@value{AS}}.
252b5132
RH
1555
1556@node f
a4fb0134 1557@section Work Faster: @option{-f}
252b5132
RH
1558
1559@kindex -f
1560@cindex trusted compiler
a4fb0134 1561@cindex faster processing (@option{-f})
252b5132
RH
1562@samp{-f} should only be used when assembling programs written by a
1563(trusted) compiler. @samp{-f} stops the assembler from doing whitespace
1564and comment preprocessing on
1565the input file(s) before assembling them. @xref{Preprocessing,
1566,Preprocessing}.
1567
1568@quotation
1569@emph{Warning:} if you use @samp{-f} when the files actually need to be
a4fb0134 1570preprocessed (if they contain comments, for example), @command{@value{AS}} does
252b5132
RH
1571not work correctly.
1572@end quotation
1573
1574@node I
c1253627 1575@section @code{.include} Search Path: @option{-I} @var{path}
252b5132
RH
1576
1577@kindex -I @var{path}
1578@cindex paths for @code{.include}
1579@cindex search path for @code{.include}
1580@cindex @code{include} directive search path
1581Use this option to add a @var{path} to the list of directories
a4fb0134
SC
1582@command{@value{AS}} searches for files specified in @code{.include}
1583directives (@pxref{Include,,@code{.include}}). You may use @option{-I} as
252b5132 1584many times as necessary to include a variety of paths. The current
a4fb0134 1585working directory is always searched first; after that, @command{@value{AS}}
252b5132
RH
1586searches any @samp{-I} directories in the same order as they were
1587specified (left to right) on the command line.
1588
1589@node K
a4fb0134 1590@section Difference Tables: @option{-K}
252b5132
RH
1591
1592@kindex -K
1593@ifclear DIFF-TBL-KLUGE
1594On the @value{TARGET} family, this option is allowed, but has no effect. It is
1595permitted for compatibility with the @sc{gnu} assembler on other platforms,
1596where it can be used to warn when the assembler alters the machine code
1597generated for @samp{.word} directives in difference tables. The @value{TARGET}
1598family does not have the addressing limitations that sometimes lead to this
1599alteration on other platforms.
1600@end ifclear
1601
1602@ifset DIFF-TBL-KLUGE
1603@cindex difference tables, warning
1604@cindex warning for altered difference tables
a4fb0134 1605@command{@value{AS}} sometimes alters the code emitted for directives of the form
252b5132
RH
1606@samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
1607You can use the @samp{-K} option if you want a warning issued when this
1608is done.
1609@end ifset
1610
1611@node L
a4fb0134 1612@section Include Local Labels: @option{-L}
252b5132
RH
1613
1614@kindex -L
1615@cindex local labels, retaining in output
1616Labels beginning with @samp{L} (upper case only) are called @dfn{local
1617labels}. @xref{Symbol Names}. Normally you do not see such labels when
1618debugging, because they are intended for the use of programs (like
1619compilers) that compose assembler programs, not for your notice.
a4fb0134 1620Normally both @command{@value{AS}} and @code{@value{LD}} discard such labels, so you do not
252b5132
RH
1621normally debug with them.
1622
a4fb0134 1623This option tells @command{@value{AS}} to retain those @samp{L@dots{}} symbols
252b5132
RH
1624in the object file. Usually if you do this you also tell the linker
1625@code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
1626
1627By default, a local label is any label beginning with @samp{L}, but each
1628target is allowed to redefine the local label prefix.
1629@ifset HPPA
1630On the HPPA local labels begin with @samp{L$}.
1631@end ifset
252b5132 1632
c3a27914 1633@node listing
a4fb0134 1634@section Configuring listing output: @option{--listing}
c3a27914
NC
1635
1636The listing feature of the assembler can be enabled via the command line switch
1637@samp{-a} (@pxref{a}). This feature combines the input source file(s) with a
1638hex dump of the corresponding locations in the output object file, and displays
1639them as a listing file. The format of this listing can be controlled by pseudo
1640ops inside the assembler source (@pxref{List} @pxref{Title} @pxref{Sbttl}
1641@pxref{Psize} @pxref{Eject}) and also by the following switches:
1642
a4fb0134 1643@table @gcctabopt
c3a27914
NC
1644@item --listing-lhs-width=@samp{number}
1645@kindex --listing-lhs-width
1646@cindex Width of first line disassembly output
1647Sets the maximum width, in words, of the first line of the hex byte dump. This
1648dump appears on the left hand side of the listing output.
1649
1650@item --listing-lhs-width2=@samp{number}
1651@kindex --listing-lhs-width2
1652@cindex Width of continuation lines of disassembly output
1653Sets the maximum width, in words, of any further lines of the hex byte dump for
8dfa0188 1654a given input source line. If this value is not specified, it defaults to being
c3a27914
NC
1655the same as the value specified for @samp{--listing-lhs-width}. If neither
1656switch is used the default is to one.
1657
1658@item --listing-rhs-width=@samp{number}
1659@kindex --listing-rhs-width
1660@cindex Width of source line output
1661Sets the maximum width, in characters, of the source line that is displayed
1662alongside the hex dump. The default value for this parameter is 100. The
1663source line is displayed on the right hand side of the listing output.
1664
1665@item --listing-cont-lines=@samp{number}
1666@kindex --listing-cont-lines
1667@cindex Maximum number of continuation lines
1668Sets the maximum number of continuation lines of hex dump that will be
1669displayed for a given single line of source input. The default value is 4.
1670@end table
1671
252b5132 1672@node M
a4fb0134 1673@section Assemble in MRI Compatibility Mode: @option{-M}
252b5132
RH
1674
1675@kindex -M
1676@cindex MRI compatibility mode
a4fb0134
SC
1677The @option{-M} or @option{--mri} option selects MRI compatibility mode. This
1678changes the syntax and pseudo-op handling of @command{@value{AS}} to make it
252b5132
RH
1679compatible with the @code{ASM68K} or the @code{ASM960} (depending upon the
1680configured target) assembler from Microtec Research. The exact nature of the
1681MRI syntax will not be documented here; see the MRI manuals for more
1682information. Note in particular that the handling of macros and macro
1683arguments is somewhat different. The purpose of this option is to permit
a4fb0134 1684assembling existing MRI assembler code using @command{@value{AS}}.
252b5132
RH
1685
1686The MRI compatibility is not complete. Certain operations of the MRI assembler
1687depend upon its object file format, and can not be supported using other object
1688file formats. Supporting these would require enhancing each object file format
1689individually. These are:
1690
1691@itemize @bullet
1692@item global symbols in common section
1693
1694The m68k MRI assembler supports common sections which are merged by the linker.
a4fb0134 1695Other object file formats do not support this. @command{@value{AS}} handles
252b5132
RH
1696common sections by treating them as a single common symbol. It permits local
1697symbols to be defined within a common section, but it can not support global
1698symbols, since it has no way to describe them.
1699
1700@item complex relocations
1701
1702The MRI assemblers support relocations against a negated section address, and
1703relocations which combine the start addresses of two or more sections. These
1704are not support by other object file formats.
1705
1706@item @code{END} pseudo-op specifying start address
1707
1708The MRI @code{END} pseudo-op permits the specification of a start address.
1709This is not supported by other object file formats. The start address may
a4fb0134 1710instead be specified using the @option{-e} option to the linker, or in a linker
252b5132
RH
1711script.
1712
1713@item @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops
1714
1715The MRI @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops assign a module
1716name to the output file. This is not supported by other object file formats.
1717
1718@item @code{ORG} pseudo-op
1719
1720The m68k MRI @code{ORG} pseudo-op begins an absolute section at a given
a4fb0134 1721address. This differs from the usual @command{@value{AS}} @code{.org} pseudo-op,
252b5132
RH
1722which changes the location within the current section. Absolute sections are
1723not supported by other object file formats. The address of a section may be
1724assigned within a linker script.
1725@end itemize
1726
1727There are some other features of the MRI assembler which are not supported by
a4fb0134 1728@command{@value{AS}}, typically either because they are difficult or because they
252b5132
RH
1729seem of little consequence. Some of these may be supported in future releases.
1730
1731@itemize @bullet
1732
1733@item EBCDIC strings
1734
1735EBCDIC strings are not supported.
1736
1737@item packed binary coded decimal
1738
1739Packed binary coded decimal is not supported. This means that the @code{DC.P}
1740and @code{DCB.P} pseudo-ops are not supported.
1741
1742@item @code{FEQU} pseudo-op
1743
1744The m68k @code{FEQU} pseudo-op is not supported.
1745
1746@item @code{NOOBJ} pseudo-op
1747
1748The m68k @code{NOOBJ} pseudo-op is not supported.
1749
1750@item @code{OPT} branch control options
1751
1752The m68k @code{OPT} branch control options---@code{B}, @code{BRS}, @code{BRB},
a4fb0134 1753@code{BRL}, and @code{BRW}---are ignored. @command{@value{AS}} automatically
252b5132
RH
1754relaxes all branches, whether forward or backward, to an appropriate size, so
1755these options serve no purpose.
1756
1757@item @code{OPT} list control options
1758
1759The following m68k @code{OPT} list control options are ignored: @code{C},
1760@code{CEX}, @code{CL}, @code{CRE}, @code{E}, @code{G}, @code{I}, @code{M},
1761@code{MEX}, @code{MC}, @code{MD}, @code{X}.
1762
1763@item other @code{OPT} options
1764
1765The following m68k @code{OPT} options are ignored: @code{NEST}, @code{O},
1766@code{OLD}, @code{OP}, @code{P}, @code{PCO}, @code{PCR}, @code{PCS}, @code{R}.
1767
1768@item @code{OPT} @code{D} option is default
1769
1770The m68k @code{OPT} @code{D} option is the default, unlike the MRI assembler.
1771@code{OPT NOD} may be used to turn it off.
1772
1773@item @code{XREF} pseudo-op.
1774
1775The m68k @code{XREF} pseudo-op is ignored.
1776
1777@item @code{.debug} pseudo-op
1778
1779The i960 @code{.debug} pseudo-op is not supported.
1780
1781@item @code{.extended} pseudo-op
1782
1783The i960 @code{.extended} pseudo-op is not supported.
1784
1785@item @code{.list} pseudo-op.
1786
1787The various options of the i960 @code{.list} pseudo-op are not supported.
1788
1789@item @code{.optimize} pseudo-op
1790
1791The i960 @code{.optimize} pseudo-op is not supported.
1792
1793@item @code{.output} pseudo-op
1794
1795The i960 @code{.output} pseudo-op is not supported.
1796
1797@item @code{.setreal} pseudo-op
1798
1799The i960 @code{.setreal} pseudo-op is not supported.
1800
1801@end itemize
1802
1803@node MD
c1253627 1804@section Dependency Tracking: @option{--MD}
252b5132
RH
1805
1806@kindex --MD
1807@cindex dependency tracking
1808@cindex make rules
1809
a4fb0134 1810@command{@value{AS}} can generate a dependency file for the file it creates. This
252b5132
RH
1811file consists of a single rule suitable for @code{make} describing the
1812dependencies of the main source file.
1813
1814The rule is written to the file named in its argument.
1815
1816This feature is used in the automatic updating of makefiles.
1817
1818@node o
a4fb0134 1819@section Name the Object File: @option{-o}
252b5132
RH
1820
1821@kindex -o
1822@cindex naming object file
1823@cindex object file name
a4fb0134 1824There is always one object file output when you run @command{@value{AS}}. By
252b5132
RH
1825default it has the name
1826@ifset GENERIC
1827@ifset I960
1828@file{a.out} (or @file{b.out}, for Intel 960 targets only).
1829@end ifset
1830@ifclear I960
1831@file{a.out}.
1832@end ifclear
1833@end ifset
1834@ifclear GENERIC
1835@ifset I960
1836@file{b.out}.
1837@end ifset
1838@ifclear I960
1839@file{a.out}.
1840@end ifclear
1841@end ifclear
1842You use this option (which takes exactly one filename) to give the
1843object file a different name.
1844
a4fb0134 1845Whatever the object file is called, @command{@value{AS}} overwrites any
252b5132
RH
1846existing file of the same name.
1847
1848@node R
a4fb0134 1849@section Join Data and Text Sections: @option{-R}
252b5132
RH
1850
1851@kindex -R
1852@cindex data and text sections, joining
1853@cindex text and data sections, joining
1854@cindex joining text and data sections
1855@cindex merging text and data sections
a4fb0134 1856@option{-R} tells @command{@value{AS}} to write the object file as if all
252b5132
RH
1857data-section data lives in the text section. This is only done at
1858the very last moment: your binary data are the same, but data
1859section parts are relocated differently. The data section part of
1860your object file is zero bytes long because all its bytes are
1861appended to the text section. (@xref{Sections,,Sections and Relocation}.)
1862
a4fb0134 1863When you specify @option{-R} it would be possible to generate shorter
252b5132
RH
1864address displacements (because we do not have to cross between text and
1865data section). We refrain from doing this simply for compatibility with
a4fb0134 1866older versions of @command{@value{AS}}. In future, @option{-R} may work this way.
252b5132 1867
c1253627
NC
1868@ifset COFF-ELF
1869When @command{@value{AS}} is configured for COFF or ELF output,
252b5132
RH
1870this option is only useful if you use sections named @samp{.text} and
1871@samp{.data}.
1872@end ifset
1873
1874@ifset HPPA
a4fb0134
SC
1875@option{-R} is not supported for any of the HPPA targets. Using
1876@option{-R} generates a warning from @command{@value{AS}}.
252b5132
RH
1877@end ifset
1878
1879@node statistics
a4fb0134 1880@section Display Assembly Statistics: @option{--statistics}
252b5132
RH
1881
1882@kindex --statistics
1883@cindex statistics, about assembly
1884@cindex time, total for assembly
1885@cindex space used, maximum for assembly
1886Use @samp{--statistics} to display two statistics about the resources used by
a4fb0134 1887@command{@value{AS}}: the maximum amount of space allocated during the assembly
252b5132
RH
1888(in bytes), and the total execution time taken for the assembly (in @sc{cpu}
1889seconds).
1890
1891@node traditional-format
c1253627 1892@section Compatible Output: @option{--traditional-format}
252b5132
RH
1893
1894@kindex --traditional-format
a4fb0134 1895For some targets, the output of @command{@value{AS}} is different in some ways
252b5132 1896from the output of some existing assembler. This switch requests
a4fb0134 1897@command{@value{AS}} to use the traditional format instead.
252b5132
RH
1898
1899For example, it disables the exception frame optimizations which
a4fb0134 1900@command{@value{AS}} normally does by default on @code{@value{GCC}} output.
252b5132
RH
1901
1902@node v
a4fb0134 1903@section Announce Version: @option{-v}
252b5132
RH
1904
1905@kindex -v
1906@kindex -version
1907@cindex assembler version
1908@cindex version of assembler
1909You can find out what version of as is running by including the
1910option @samp{-v} (which you can also spell as @samp{-version}) on the
1911command line.
1912
1913@node W
a4fb0134 1914@section Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings}
252b5132 1915
a4fb0134 1916@command{@value{AS}} should never give a warning or error message when
252b5132 1917assembling compiler output. But programs written by people often
a4fb0134 1918cause @command{@value{AS}} to give a warning that a particular assumption was
252b5132 1919made. All such warnings are directed to the standard error file.
2bdd6cf5 1920
c1253627
NC
1921@kindex -W
1922@kindex --no-warn
2bdd6cf5
GK
1923@cindex suppressing warnings
1924@cindex warnings, suppressing
a4fb0134 1925If you use the @option{-W} and @option{--no-warn} options, no warnings are issued.
2bdd6cf5 1926This only affects the warning messages: it does not change any particular of
a4fb0134 1927how @command{@value{AS}} assembles your file. Errors, which stop the assembly,
2bdd6cf5
GK
1928are still reported.
1929
c1253627 1930@kindex --fatal-warnings
2bdd6cf5
GK
1931@cindex errors, caused by warnings
1932@cindex warnings, causing error
a4fb0134 1933If you use the @option{--fatal-warnings} option, @command{@value{AS}} considers
2bdd6cf5
GK
1934files that generate warnings to be in error.
1935
c1253627 1936@kindex --warn
2bdd6cf5 1937@cindex warnings, switching on
a4fb0134 1938You can switch these options off again by specifying @option{--warn}, which
2bdd6cf5 1939causes warnings to be output as usual.
252b5132
RH
1940
1941@node Z
a4fb0134 1942@section Generate Object File in Spite of Errors: @option{-Z}
252b5132
RH
1943@cindex object file, after errors
1944@cindex errors, continuing after
a4fb0134 1945After an error message, @command{@value{AS}} normally produces no output. If for
252b5132 1946some reason you are interested in object file output even after
a4fb0134
SC
1947@command{@value{AS}} gives an error message on your program, use the @samp{-Z}
1948option. If there are any errors, @command{@value{AS}} continues anyways, and
252b5132
RH
1949writes an object file after a final warning message of the form @samp{@var{n}
1950errors, @var{m} warnings, generating bad object file.}
1951
1952@node Syntax
1953@chapter Syntax
1954
1955@cindex machine-independent syntax
1956@cindex syntax, machine-independent
1957This chapter describes the machine-independent syntax allowed in a
a4fb0134 1958source file. @command{@value{AS}} syntax is similar to what many other
252b5132
RH
1959assemblers use; it is inspired by the BSD 4.2
1960@ifclear VAX
1961assembler.
1962@end ifclear
1963@ifset VAX
a4fb0134 1964assembler, except that @command{@value{AS}} does not assemble Vax bit-fields.
252b5132
RH
1965@end ifset
1966
1967@menu
1968* Preprocessing:: Preprocessing
1969* Whitespace:: Whitespace
1970* Comments:: Comments
1971* Symbol Intro:: Symbols
1972* Statements:: Statements
1973* Constants:: Constants
1974@end menu
1975
1976@node Preprocessing
1977@section Preprocessing
1978
1979@cindex preprocessing
a4fb0134 1980The @command{@value{AS}} internal preprocessor:
252b5132
RH
1981@itemize @bullet
1982@cindex whitespace, removed by preprocessor
1983@item
1984adjusts and removes extra whitespace. It leaves one space or tab before
1985the keywords on a line, and turns any other whitespace on the line into
1986a single space.
1987
1988@cindex comments, removed by preprocessor
1989@item
1990removes all comments, replacing them with a single space, or an
1991appropriate number of newlines.
1992
1993@cindex constants, converted by preprocessor
1994@item
1995converts character constants into the appropriate numeric values.
1996@end itemize
1997
1998It does not do macro processing, include file handling, or
1999anything else you may get from your C compiler's preprocessor. You can
2000do include file processing with the @code{.include} directive
2001(@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
c1253627 2002to get other ``CPP'' style preprocessing by giving the input file a
252b5132
RH
2003@samp{.S} suffix. @xref{Overall Options,, Options Controlling the Kind of
2004Output, gcc.info, Using GNU CC}.
2005
2006Excess whitespace, comments, and character constants
2007cannot be used in the portions of the input text that are not
2008preprocessed.
2009
2010@cindex turning preprocessing on and off
2011@cindex preprocessing, turning on and off
2012@kindex #NO_APP
2013@kindex #APP
2014If the first line of an input file is @code{#NO_APP} or if you use the
2015@samp{-f} option, whitespace and comments are not removed from the input file.
2016Within an input file, you can ask for whitespace and comment removal in
2017specific portions of the by putting a line that says @code{#APP} before the
2018text that may contain whitespace or comments, and putting a line that says
2019@code{#NO_APP} after this text. This feature is mainly intend to support
2020@code{asm} statements in compilers whose output is otherwise free of comments
2021and whitespace.
2022
2023@node Whitespace
2024@section Whitespace
2025
2026@cindex whitespace
2027@dfn{Whitespace} is one or more blanks or tabs, in any order.
2028Whitespace is used to separate symbols, and to make programs neater for
2029people to read. Unless within character constants
2030(@pxref{Characters,,Character Constants}), any whitespace means the same
2031as exactly one space.
2032
2033@node Comments
2034@section Comments
2035
2036@cindex comments
a4fb0134 2037There are two ways of rendering comments to @command{@value{AS}}. In both
252b5132
RH
2038cases the comment is equivalent to one space.
2039
2040Anything from @samp{/*} through the next @samp{*/} is a comment.
2041This means you may not nest these comments.
2042
2043@smallexample
2044/*
2045 The only way to include a newline ('\n') in a comment
2046 is to use this sort of comment.
2047*/
2048
2049/* This sort of comment does not nest. */
2050@end smallexample
2051
2052@cindex line comment character
2053Anything from the @dfn{line comment} character to the next newline
2054is considered a comment and is ignored. The line comment character is
2055@ifset A29K
2056@samp{;} for the AMD 29K family;
2057@end ifset
2058@ifset ARC
2059@samp{;} on the ARC;
2060@end ifset
550262c4
NC
2061@ifset ARM
2062@samp{@@} on the ARM;
2063@end ifset
252b5132
RH
2064@ifset H8/300
2065@samp{;} for the H8/300 family;
2066@end ifset
2067@ifset H8/500
2068@samp{!} for the H8/500 family;
2069@end ifset
2070@ifset HPPA
2071@samp{;} for the HPPA;
2072@end ifset
55b62671
AJ
2073@ifset I80386
2074@samp{#} on the i386 and x86-64;
2075@end ifset
252b5132
RH
2076@ifset I960
2077@samp{#} on the i960;
2078@end ifset
e135f41b
NC
2079@ifset PDP11
2080@samp{;} for the PDP-11;
2081@end ifset
041dd5a9
ILT
2082@ifset PJ
2083@samp{;} for picoJava;
2084@end ifset
418c1742 2085@ifset PPC
3fb9d77f 2086@samp{#} for Motorola PowerPC;
418c1742 2087@end ifset
252b5132 2088@ifset SH
ef230218 2089@samp{!} for the Renesas / SuperH SH;
252b5132
RH
2090@end ifset
2091@ifset SPARC
2092@samp{!} on the SPARC;
2093@end ifset
a40cbfa3
NC
2094@ifset IP2K
2095@samp{#} on the ip2k;
2096@end ifset
252b5132
RH
2097@ifset M32R
2098@samp{#} on the m32r;
2099@end ifset
2100@ifset M680X0
2101@samp{|} on the 680x0;
2102@end ifset
60bcf0fa
NC
2103@ifset M68HC11
2104@samp{#} on the 68HC11 and 68HC12;
2105@end ifset
81b0b3f1
BE
2106@ifset M880X0
2107@samp{;} on the M880x0;
2108@end ifset
252b5132
RH
2109@ifset VAX
2110@samp{#} on the Vax;
2111@end ifset
2112@ifset Z8000
2113@samp{!} for the Z8000;
2114@end ifset
2115@ifset V850
2116@samp{#} on the V850;
2117@end ifset
e0001a05
NC
2118@ifset XTENSA
2119@samp{#} for Xtensa systems;
2120@end ifset
252b5132 2121see @ref{Machine Dependencies}. @refill
81b0b3f1 2122@c FIXME What about i860?
252b5132
RH
2123
2124@ifset GENERIC
2125On some machines there are two different line comment characters. One
2126character only begins a comment if it is the first non-whitespace character on
2127a line, while the other always begins a comment.
2128@end ifset
2129
2130@ifset V850
2131The V850 assembler also supports a double dash as starting a comment that
2132extends to the end of the line.
2133
2134@samp{--};
2135@end ifset
2136
2137@kindex #
2138@cindex lines starting with @code{#}
2139@cindex logical line numbers
2140To be compatible with past assemblers, lines that begin with @samp{#} have a
2141special interpretation. Following the @samp{#} should be an absolute
2142expression (@pxref{Expressions}): the logical line number of the @emph{next}
2143line. Then a string (@pxref{Strings,, Strings}) is allowed: if present it is a
2144new logical file name. The rest of the line, if any, should be whitespace.
2145
2146If the first non-whitespace characters on the line are not numeric,
2147the line is ignored. (Just like a comment.)
2148
2149@smallexample
2150 # This is an ordinary comment.
2151# 42-6 "new_file_name" # New logical file name
2152 # This is logical line # 36.
2153@end smallexample
2154This feature is deprecated, and may disappear from future versions
a4fb0134 2155of @command{@value{AS}}.
252b5132
RH
2156
2157@node Symbol Intro
2158@section Symbols
2159
2160@cindex characters used in symbols
2161@ifclear SPECIAL-SYMS
2162A @dfn{symbol} is one or more characters chosen from the set of all
2163letters (both upper and lower case), digits and the three characters
2164@samp{_.$}.
2165@end ifclear
2166@ifset SPECIAL-SYMS
2167@ifclear GENERIC
2168@ifset H8
2169A @dfn{symbol} is one or more characters chosen from the set of all
2170letters (both upper and lower case), digits and the three characters
2171@samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
2172symbol names.)
2173@end ifset
2174@end ifclear
2175@end ifset
2176@ifset GENERIC
2177On most machines, you can also use @code{$} in symbol names; exceptions
2178are noted in @ref{Machine Dependencies}.
2179@end ifset
2180No symbol may begin with a digit. Case is significant.
2181There is no length limit: all characters are significant. Symbols are
2182delimited by characters not in that set, or by the beginning of a file
2183(since the source program must end with a newline, the end of a file is
2184not a possible symbol delimiter). @xref{Symbols}.
2185@cindex length of symbols
2186
2187@node Statements
2188@section Statements
2189
2190@cindex statements, structure of
2191@cindex line separator character
2192@cindex statement separator character
2193@ifclear GENERIC
2194@ifclear abnormal-separator
2195A @dfn{statement} ends at a newline character (@samp{\n}) or at a
2196semicolon (@samp{;}). The newline or semicolon is considered part of
2197the preceding statement. Newlines and semicolons within character
2198constants are an exception: they do not end statements.
2199@end ifclear
2200@ifset abnormal-separator
2201@ifset A29K
2202A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
2203sign (@samp{@@}). The newline or at sign is considered part of the
2204preceding statement. Newlines and at signs within character constants
2205are an exception: they do not end statements.
2206@end ifset
2207@ifset HPPA
2208A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
2209point (@samp{!}). The newline or exclamation point is considered part of the
2210preceding statement. Newlines and exclamation points within character
2211constants are an exception: they do not end statements.
2212@end ifset
2213@ifset H8
2214A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
2215H8/300) a dollar sign (@samp{$}); or (for the
c2dcd04e 2216Renesas-SH or the
252b5132
RH
2217H8/500) a semicolon
2218(@samp{;}). The newline or separator character is considered part of
2219the preceding statement. Newlines and separators within character
2220constants are an exception: they do not end statements.
2221@end ifset
2222@end ifset
2223@end ifclear
2224@ifset GENERIC
2225A @dfn{statement} ends at a newline character (@samp{\n}) or line
2226separator character. (The line separator is usually @samp{;}, unless
2227this conflicts with the comment character; @pxref{Machine Dependencies}.) The
2228newline or separator character is considered part of the preceding
2229statement. Newlines and separators within character constants are an
2230exception: they do not end statements.
2231@end ifset
2232
2233@cindex newline, required at file end
2234@cindex EOF, newline must precede
2235It is an error to end any statement with end-of-file: the last
2236character of any input file should be a newline.@refill
2237
2238An empty statement is allowed, and may include whitespace. It is ignored.
2239
2240@cindex instructions and directives
2241@cindex directives and instructions
2242@c "key symbol" is not used elsewhere in the document; seems pedantic to
2243@c @defn{} it in that case, as was done previously... doc@cygnus.com,
2244@c 13feb91.
2245A statement begins with zero or more labels, optionally followed by a
2246key symbol which determines what kind of statement it is. The key
2247symbol determines the syntax of the rest of the statement. If the
2248symbol begins with a dot @samp{.} then the statement is an assembler
2249directive: typically valid for any computer. If the symbol begins with
2250a letter the statement is an assembly language @dfn{instruction}: it
2251assembles into a machine language instruction.
2252@ifset GENERIC
a4fb0134 2253Different versions of @command{@value{AS}} for different computers
252b5132
RH
2254recognize different instructions. In fact, the same symbol may
2255represent a different instruction in a different computer's assembly
2256language.@refill
2257@end ifset
2258
2259@cindex @code{:} (label)
2260@cindex label (@code{:})
2261A label is a symbol immediately followed by a colon (@code{:}).
2262Whitespace before a label or after a colon is permitted, but you may not
2263have whitespace between a label's symbol and its colon. @xref{Labels}.
2264
2265@ifset HPPA
2266For HPPA targets, labels need not be immediately followed by a colon, but
2267the definition of a label must begin in column zero. This also implies that
2268only one label may be defined on each line.
2269@end ifset
2270
2271@smallexample
2272label: .directive followed by something
2273another_label: # This is an empty statement.
2274 instruction operand_1, operand_2, @dots{}
2275@end smallexample
2276
2277@node Constants
2278@section Constants
2279
2280@cindex constants
2281A constant is a number, written so that its value is known by
2282inspection, without knowing any context. Like this:
2283@smallexample
2284@group
2285.byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
2286.ascii "Ring the bell\7" # A string constant.
2287.octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
2288.float 0f-314159265358979323846264338327\
228995028841971.693993751E-40 # - pi, a flonum.
2290@end group
2291@end smallexample
2292
2293@menu
2294* Characters:: Character Constants
2295* Numbers:: Number Constants
2296@end menu
2297
2298@node Characters
2299@subsection Character Constants
2300
2301@cindex character constants
2302@cindex constants, character
2303There are two kinds of character constants. A @dfn{character} stands
2304for one character in one byte and its value may be used in
2305numeric expressions. String constants (properly called string
2306@emph{literals}) are potentially many bytes and their values may not be
2307used in arithmetic expressions.
2308
2309@menu
2310* Strings:: Strings
2311* Chars:: Characters
2312@end menu
2313
2314@node Strings
2315@subsubsection Strings
2316
2317@cindex string constants
2318@cindex constants, string
2319A @dfn{string} is written between double-quotes. It may contain
2320double-quotes or null characters. The way to get special characters
2321into a string is to @dfn{escape} these characters: precede them with
2322a backslash @samp{\} character. For example @samp{\\} represents
2323one backslash: the first @code{\} is an escape which tells
a4fb0134
SC
2324@command{@value{AS}} to interpret the second character literally as a backslash
2325(which prevents @command{@value{AS}} from recognizing the second @code{\} as an
252b5132
RH
2326escape character). The complete list of escapes follows.
2327
2328@cindex escape codes, character
2329@cindex character escape codes
2330@table @kbd
2331@c @item \a
2332@c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
2333@c
2334@cindex @code{\b} (backspace character)
2335@cindex backspace (@code{\b})
2336@item \b
2337Mnemonic for backspace; for ASCII this is octal code 010.
2338
2339@c @item \e
2340@c Mnemonic for EOText; for ASCII this is octal code 004.
2341@c
2342@cindex @code{\f} (formfeed character)
2343@cindex formfeed (@code{\f})
2344@item \f
2345Mnemonic for FormFeed; for ASCII this is octal code 014.
2346
2347@cindex @code{\n} (newline character)
2348@cindex newline (@code{\n})
2349@item \n
2350Mnemonic for newline; for ASCII this is octal code 012.
2351
2352@c @item \p
2353@c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
2354@c
2355@cindex @code{\r} (carriage return character)
2356@cindex carriage return (@code{\r})
2357@item \r
2358Mnemonic for carriage-Return; for ASCII this is octal code 015.
2359
2360@c @item \s
2361@c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
2362@c other assemblers.
2363@c
2364@cindex @code{\t} (tab)
2365@cindex tab (@code{\t})
2366@item \t
2367Mnemonic for horizontal Tab; for ASCII this is octal code 011.
2368
2369@c @item \v
2370@c Mnemonic for Vertical tab; for ASCII this is octal code 013.
2371@c @item \x @var{digit} @var{digit} @var{digit}
2372@c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
2373@c
2374@cindex @code{\@var{ddd}} (octal character code)
2375@cindex octal character code (@code{\@var{ddd}})
2376@item \ @var{digit} @var{digit} @var{digit}
2377An octal character code. The numeric code is 3 octal digits.
2378For compatibility with other Unix systems, 8 and 9 are accepted as digits:
2379for example, @code{\008} has the value 010, and @code{\009} the value 011.
2380
2381@cindex @code{\@var{xd...}} (hex character code)
2382@cindex hex character code (@code{\@var{xd...}})
2383@item \@code{x} @var{hex-digits...}
2384A hex character code. All trailing hex digits are combined. Either upper or
2385lower case @code{x} works.
2386
2387@cindex @code{\\} (@samp{\} character)
2388@cindex backslash (@code{\\})
2389@item \\
2390Represents one @samp{\} character.
2391
2392@c @item \'
2393@c Represents one @samp{'} (accent acute) character.
2394@c This is needed in single character literals
2395@c (@xref{Characters,,Character Constants}.) to represent
2396@c a @samp{'}.
2397@c
2398@cindex @code{\"} (doublequote character)
2399@cindex doublequote (@code{\"})
2400@item \"
2401Represents one @samp{"} character. Needed in strings to represent
2402this character, because an unescaped @samp{"} would end the string.
2403
2404@item \ @var{anything-else}
2405Any other character when escaped by @kbd{\} gives a warning, but
2406assembles as if the @samp{\} was not present. The idea is that if
2407you used an escape sequence you clearly didn't want the literal
a4fb0134
SC
2408interpretation of the following character. However @command{@value{AS}} has no
2409other interpretation, so @command{@value{AS}} knows it is giving you the wrong
252b5132
RH
2410code and warns you of the fact.
2411@end table
2412
2413Which characters are escapable, and what those escapes represent,
2414varies widely among assemblers. The current set is what we think
2415the BSD 4.2 assembler recognizes, and is a subset of what most C
2416compilers recognize. If you are in doubt, do not use an escape
2417sequence.
2418
2419@node Chars
2420@subsubsection Characters
2421
2422@cindex single character constant
2423@cindex character, single
2424@cindex constant, single character
2425A single character may be written as a single quote immediately
2426followed by that character. The same escapes apply to characters as
2427to strings. So if you want to write the character backslash, you
2428must write @kbd{'\\} where the first @code{\} escapes the second
2429@code{\}. As you can see, the quote is an acute accent, not a
2430grave accent. A newline
2431@ifclear GENERIC
2432@ifclear abnormal-separator
2433(or semicolon @samp{;})
2434@end ifclear
2435@ifset abnormal-separator
2436@ifset A29K
2437(or at sign @samp{@@})
2438@end ifset
2439@ifset H8
2440(or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
c2dcd04e 2441Renesas SH or H8/500)
252b5132
RH
2442@end ifset
2443@end ifset
2444@end ifclear
2445immediately following an acute accent is taken as a literal character
2446and does not count as the end of a statement. The value of a character
2447constant in a numeric expression is the machine's byte-wide code for
a4fb0134 2448that character. @command{@value{AS}} assumes your character code is ASCII:
252b5132
RH
2449@kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
2450
2451@node Numbers
2452@subsection Number Constants
2453
2454@cindex constants, number
2455@cindex number constants
a4fb0134 2456@command{@value{AS}} distinguishes three kinds of numbers according to how they
252b5132
RH
2457are stored in the target machine. @emph{Integers} are numbers that
2458would fit into an @code{int} in the C language. @emph{Bignums} are
2459integers, but they are stored in more than 32 bits. @emph{Flonums}
2460are floating point numbers, described below.
2461
2462@menu
2463* Integers:: Integers
2464* Bignums:: Bignums
2465* Flonums:: Flonums
2466@ifclear GENERIC
2467@ifset I960
2468* Bit Fields:: Bit Fields
2469@end ifset
2470@end ifclear
2471@end menu
2472
2473@node Integers
2474@subsubsection Integers
2475@cindex integers
2476@cindex constants, integer
2477
2478@cindex binary integers
2479@cindex integers, binary
2480A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
2481the binary digits @samp{01}.
2482
2483@cindex octal integers
2484@cindex integers, octal
2485An octal integer is @samp{0} followed by zero or more of the octal
2486digits (@samp{01234567}).
2487
2488@cindex decimal integers
2489@cindex integers, decimal
2490A decimal integer starts with a non-zero digit followed by zero or
2491more digits (@samp{0123456789}).
2492
2493@cindex hexadecimal integers
2494@cindex integers, hexadecimal
2495A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
2496more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
2497
2498Integers have the usual values. To denote a negative integer, use
2499the prefix operator @samp{-} discussed under expressions
2500(@pxref{Prefix Ops,,Prefix Operators}).
2501
2502@node Bignums
2503@subsubsection Bignums
2504
2505@cindex bignums
2506@cindex constants, bignum
2507A @dfn{bignum} has the same syntax and semantics as an integer
2508except that the number (or its negative) takes more than 32 bits to
2509represent in binary. The distinction is made because in some places
2510integers are permitted while bignums are not.
2511
2512@node Flonums
2513@subsubsection Flonums
2514@cindex flonums
2515@cindex floating point numbers
2516@cindex constants, floating point
2517
2518@cindex precision, floating point
2519A @dfn{flonum} represents a floating point number. The translation is
2520indirect: a decimal floating point number from the text is converted by
a4fb0134 2521@command{@value{AS}} to a generic binary floating point number of more than
252b5132
RH
2522sufficient precision. This generic floating point number is converted
2523to a particular computer's floating point format (or formats) by a
a4fb0134 2524portion of @command{@value{AS}} specialized to that computer.
252b5132
RH
2525
2526A flonum is written by writing (in order)
2527@itemize @bullet
2528@item
2529The digit @samp{0}.
2530@ifset HPPA
2531(@samp{0} is optional on the HPPA.)
2532@end ifset
2533
2534@item
a4fb0134 2535A letter, to tell @command{@value{AS}} the rest of the number is a flonum.
252b5132
RH
2536@ifset GENERIC
2537@kbd{e} is recommended. Case is not important.
2538@ignore
2539@c FIXME: verify if flonum syntax really this vague for most cases
2540(Any otherwise illegal letter works here, but that might be changed. Vax BSD
25414.2 assembler seems to allow any of @samp{defghDEFGH}.)
2542@end ignore
2543
2544On the H8/300, H8/500,
ef230218 2545Renesas / SuperH SH,
252b5132
RH
2546and AMD 29K architectures, the letter must be
2547one of the letters @samp{DFPRSX} (in upper or lower case).
2548
2549On the ARC, the letter must be one of the letters @samp{DFRS}
2550(in upper or lower case).
2551
2552On the Intel 960 architecture, the letter must be
2553one of the letters @samp{DFT} (in upper or lower case).
2554
2555On the HPPA architecture, the letter must be @samp{E} (upper case only).
2556@end ifset
2557@ifclear GENERIC
2558@ifset A29K
2559One of the letters @samp{DFPRSX} (in upper or lower case).
2560@end ifset
2561@ifset ARC
2562One of the letters @samp{DFRS} (in upper or lower case).
2563@end ifset
2564@ifset H8
2565One of the letters @samp{DFPRSX} (in upper or lower case).
2566@end ifset
2567@ifset HPPA
2568The letter @samp{E} (upper case only).
2569@end ifset
2570@ifset I960
2571One of the letters @samp{DFT} (in upper or lower case).
2572@end ifset
2573@end ifclear
2574
2575@item
2576An optional sign: either @samp{+} or @samp{-}.
2577
2578@item
2579An optional @dfn{integer part}: zero or more decimal digits.
2580
2581@item
2582An optional @dfn{fractional part}: @samp{.} followed by zero
2583or more decimal digits.
2584
2585@item
2586An optional exponent, consisting of:
2587
2588@itemize @bullet
2589@item
2590An @samp{E} or @samp{e}.
2591@c I can't find a config where "EXP_CHARS" is other than 'eE', but in
2592@c principle this can perfectly well be different on different targets.
2593@item
2594Optional sign: either @samp{+} or @samp{-}.
2595@item
2596One or more decimal digits.
2597@end itemize
2598
2599@end itemize
2600
2601At least one of the integer part or the fractional part must be
2602present. The floating point number has the usual base-10 value.
2603
a4fb0134 2604@command{@value{AS}} does all processing using integers. Flonums are computed
252b5132 2605independently of any floating point hardware in the computer running
a4fb0134 2606@command{@value{AS}}.
252b5132
RH
2607
2608@ifclear GENERIC
2609@ifset I960
2610@c Bit fields are written as a general facility but are also controlled
2611@c by a conditional-compilation flag---which is as of now (21mar91)
2612@c turned on only by the i960 config of GAS.
2613@node Bit Fields
2614@subsubsection Bit Fields
2615
2616@cindex bit fields
2617@cindex constants, bit field
2618You can also define numeric constants as @dfn{bit fields}.
2619specify two numbers separated by a colon---
2620@example
2621@var{mask}:@var{value}
2622@end example
2623@noindent
a4fb0134 2624@command{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
252b5132
RH
2625@var{value}.
2626
2627The resulting number is then packed
2628@ifset GENERIC
2629@c this conditional paren in case bit fields turned on elsewhere than 960
2630(in host-dependent byte order)
2631@end ifset
2632into a field whose width depends on which assembler directive has the
2633bit-field as its argument. Overflow (a result from the bitwise and
2634requiring more binary digits to represent) is not an error; instead,
2635more constants are generated, of the specified width, beginning with the
2636least significant digits.@refill
2637
2638The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
2639@code{.short}, and @code{.word} accept bit-field arguments.
2640@end ifset
2641@end ifclear
2642
2643@node Sections
2644@chapter Sections and Relocation
2645@cindex sections
2646@cindex relocation
2647
2648@menu
2649* Secs Background:: Background
2650* Ld Sections:: Linker Sections
2651* As Sections:: Assembler Internal Sections
2652* Sub-Sections:: Sub-Sections
2653* bss:: bss Section
2654@end menu
2655
2656@node Secs Background
2657@section Background
2658
2659Roughly, a section is a range of addresses, with no gaps; all data
2660``in'' those addresses is treated the same for some particular purpose.
2661For example there may be a ``read only'' section.
2662
2663@cindex linker, and assembler
2664@cindex assembler, and linker
2665The linker @code{@value{LD}} reads many object files (partial programs) and
a4fb0134 2666combines their contents to form a runnable program. When @command{@value{AS}}
252b5132
RH
2667emits an object file, the partial program is assumed to start at address 0.
2668@code{@value{LD}} assigns the final addresses for the partial program, so that
2669different partial programs do not overlap. This is actually an
a4fb0134 2670oversimplification, but it suffices to explain how @command{@value{AS}} uses
252b5132
RH
2671sections.
2672
2673@code{@value{LD}} moves blocks of bytes of your program to their run-time
2674addresses. These blocks slide to their run-time addresses as rigid
2675units; their length does not change and neither does the order of bytes
2676within them. Such a rigid unit is called a @emph{section}. Assigning
2677run-time addresses to sections is called @dfn{relocation}. It includes
2678the task of adjusting mentions of object-file addresses so they refer to
2679the proper run-time addresses.
2680@ifset H8
2681For the H8/300 and H8/500,
ef230218 2682and for the Renesas / SuperH SH,
a4fb0134 2683@command{@value{AS}} pads sections if needed to
252b5132
RH
2684ensure they end on a word (sixteen bit) boundary.
2685@end ifset
2686
2687@cindex standard assembler sections
a4fb0134 2688An object file written by @command{@value{AS}} has at least three sections, any
252b5132
RH
2689of which may be empty. These are named @dfn{text}, @dfn{data} and
2690@dfn{bss} sections.
2691
c1253627 2692@ifset COFF-ELF
252b5132 2693@ifset GENERIC
c1253627 2694When it generates COFF or ELF output,
252b5132 2695@end ifset
a4fb0134 2696@command{@value{AS}} can also generate whatever other named sections you specify
252b5132
RH
2697using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
2698If you do not use any directives that place output in the @samp{.text}
2699or @samp{.data} sections, these sections still exist, but are empty.
2700@end ifset
2701
2702@ifset HPPA
2703@ifset GENERIC
a4fb0134 2704When @command{@value{AS}} generates SOM or ELF output for the HPPA,
252b5132 2705@end ifset
a4fb0134 2706@command{@value{AS}} can also generate whatever other named sections you
252b5132
RH
2707specify using the @samp{.space} and @samp{.subspace} directives. See
2708@cite{HP9000 Series 800 Assembly Language Reference Manual}
2709(HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
2710assembler directives.
2711
2712@ifset SOM
a4fb0134 2713Additionally, @command{@value{AS}} uses different names for the standard
252b5132
RH
2714text, data, and bss sections when generating SOM output. Program text
2715is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
2716BSS into @samp{$BSS$}.
2717@end ifset
2718@end ifset
2719
2720Within the object file, the text section starts at address @code{0}, the
2721data section follows, and the bss section follows the data section.
2722
2723@ifset HPPA
2724When generating either SOM or ELF output files on the HPPA, the text
2725section starts at address @code{0}, the data section at address
2726@code{0x4000000}, and the bss section follows the data section.
2727@end ifset
2728
2729To let @code{@value{LD}} know which data changes when the sections are
a4fb0134 2730relocated, and how to change that data, @command{@value{AS}} also writes to the
252b5132
RH
2731object file details of the relocation needed. To perform relocation
2732@code{@value{LD}} must know, each time an address in the object
2733file is mentioned:
2734@itemize @bullet
2735@item
2736Where in the object file is the beginning of this reference to
2737an address?
2738@item
2739How long (in bytes) is this reference?
2740@item
2741Which section does the address refer to? What is the numeric value of
2742@display
2743(@var{address}) @minus{} (@var{start-address of section})?
2744@end display
2745@item
2746Is the reference to an address ``Program-Counter relative''?
2747@end itemize
2748
2749@cindex addresses, format of
2750@cindex section-relative addressing
a4fb0134 2751In fact, every address @command{@value{AS}} ever uses is expressed as
252b5132
RH
2752@display
2753(@var{section}) + (@var{offset into section})
2754@end display
2755@noindent
a4fb0134 2756Further, most expressions @command{@value{AS}} computes have this section-relative
252b5132
RH
2757nature.
2758@ifset SOM
2759(For some object formats, such as SOM for the HPPA, some expressions are
2760symbol-relative instead.)
2761@end ifset
2762
2763In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset
2764@var{N} into section @var{secname}.''
2765
2766Apart from text, data and bss sections you need to know about the
2767@dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
2768addresses in the absolute section remain unchanged. For example, address
2769@code{@{absolute 0@}} is ``relocated'' to run-time address 0 by
2770@code{@value{LD}}. Although the linker never arranges two partial programs'
2771data sections with overlapping addresses after linking, @emph{by definition}
2772their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one
2773part of a program is always the same address when the program is running as
2774address @code{@{absolute@ 239@}} in any other part of the program.
2775
2776The idea of sections is extended to the @dfn{undefined} section. Any
2777address whose section is unknown at assembly time is by definition
2778rendered @{undefined @var{U}@}---where @var{U} is filled in later.
2779Since numbers are always defined, the only way to generate an undefined
2780address is to mention an undefined symbol. A reference to a named
2781common block would be such a symbol: its value is unknown at assembly
2782time so it has section @emph{undefined}.
2783
2784By analogy the word @emph{section} is used to describe groups of sections in
2785the linked program. @code{@value{LD}} puts all partial programs' text
2786sections in contiguous addresses in the linked program. It is
2787customary to refer to the @emph{text section} of a program, meaning all
2788the addresses of all partial programs' text sections. Likewise for
2789data and bss sections.
2790
2791Some sections are manipulated by @code{@value{LD}}; others are invented for
a4fb0134 2792use of @command{@value{AS}} and have no meaning except during assembly.
252b5132
RH
2793
2794@node Ld Sections
2795@section Linker Sections
2796@code{@value{LD}} deals with just four kinds of sections, summarized below.
2797
2798@table @strong
2799
c1253627 2800@ifset COFF-ELF
252b5132
RH
2801@cindex named sections
2802@cindex sections, named
2803@item named sections
2804@end ifset
2805@ifset aout-bout
2806@cindex text section
2807@cindex data section
2808@itemx text section
2809@itemx data section
2810@end ifset
a4fb0134 2811These sections hold your program. @command{@value{AS}} and @code{@value{LD}} treat them as
252b5132 2812separate but equal sections. Anything you can say of one section is
c1253627
NC
2813true of another.
2814@c @ifset aout-bout
252b5132
RH
2815When the program is running, however, it is
2816customary for the text section to be unalterable. The
2817text section is often shared among processes: it contains
2818instructions, constants and the like. The data section of a running
2819program is usually alterable: for example, C variables would be stored
2820in the data section.
c1253627 2821@c @end ifset
252b5132
RH
2822
2823@cindex bss section
2824@item bss section
2825This section contains zeroed bytes when your program begins running. It
a349d9dd 2826is used to hold uninitialized variables or common storage. The length of
252b5132
RH
2827each partial program's bss section is important, but because it starts
2828out containing zeroed bytes there is no need to store explicit zero
2829bytes in the object file. The bss section was invented to eliminate
2830those explicit zeros from object files.
2831
2832@cindex absolute section
2833@item absolute section
2834Address 0 of this section is always ``relocated'' to runtime address 0.
2835This is useful if you want to refer to an address that @code{@value{LD}} must
2836not change when relocating. In this sense we speak of absolute
2837addresses being ``unrelocatable'': they do not change during relocation.
2838
2839@cindex undefined section
2840@item undefined section
2841This ``section'' is a catch-all for address references to objects not in
2842the preceding sections.
2843@c FIXME: ref to some other doc on obj-file formats could go here.
2844@end table
2845
2846@cindex relocation example
2847An idealized example of three relocatable sections follows.
c1253627 2848@ifset COFF-ELF
252b5132
RH
2849The example uses the traditional section names @samp{.text} and @samp{.data}.
2850@end ifset
2851Memory addresses are on the horizontal axis.
2852
2853@c TEXI2ROFF-KILL
c1253627 2854@ifnottex
252b5132
RH
2855@c END TEXI2ROFF-KILL
2856@smallexample
2857 +-----+----+--+
2858partial program # 1: |ttttt|dddd|00|
2859 +-----+----+--+
2860
2861 text data bss
2862 seg. seg. seg.
2863
2864 +---+---+---+
2865partial program # 2: |TTT|DDD|000|
2866 +---+---+---+
2867
2868 +--+---+-----+--+----+---+-----+~~
2869linked program: | |TTT|ttttt| |dddd|DDD|00000|
2870 +--+---+-----+--+----+---+-----+~~
2871
2872 addresses: 0 @dots{}
2873@end smallexample
2874@c TEXI2ROFF-KILL
c1253627 2875@end ifnottex
252b5132
RH
2876@need 5000
2877@tex
c1253627 2878\bigskip
252b5132
RH
2879\line{\it Partial program \#1: \hfil}
2880\line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2881\line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
2882
2883\line{\it Partial program \#2: \hfil}
2884\line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2885\line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
2886
2887\line{\it linked program: \hfil}
2888\line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
2889\line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
2890ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
2891DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
2892
2893\line{\it addresses: \hfil}
2894\line{0\dots\hfil}
2895
2896@end tex
2897@c END TEXI2ROFF-KILL
2898
2899@node As Sections
2900@section Assembler Internal Sections
2901
2902@cindex internal assembler sections
2903@cindex sections in messages, internal
a4fb0134 2904These sections are meant only for the internal use of @command{@value{AS}}. They
252b5132 2905have no meaning at run-time. You do not really need to know about these
a4fb0134 2906sections for most purposes; but they can be mentioned in @command{@value{AS}}
252b5132 2907warning messages, so it might be helpful to have an idea of their
a4fb0134 2908meanings to @command{@value{AS}}. These sections are used to permit the
252b5132
RH
2909value of every expression in your assembly language program to be a
2910section-relative address.
2911
2912@table @b
2913@cindex assembler internal logic error
2914@item ASSEMBLER-INTERNAL-LOGIC-ERROR!
2915An internal assembler logic error has been found. This means there is a
2916bug in the assembler.
2917
2918@cindex expr (internal section)
2919@item expr section
2920The assembler stores complex expression internally as combinations of
2921symbols. When it needs to represent an expression as a symbol, it puts
2922it in the expr section.
2923@c FIXME item debug
2924@c FIXME item transfer[t] vector preload
2925@c FIXME item transfer[t] vector postload
2926@c FIXME item register
2927@end table
2928
2929@node Sub-Sections
2930@section Sub-Sections
2931
2932@cindex numbered subsections
2933@cindex grouping data
2934@ifset aout-bout
2935Assembled bytes
c1253627 2936@ifset COFF-ELF
252b5132
RH
2937conventionally
2938@end ifset
2939fall into two sections: text and data.
2940@end ifset
2941You may have separate groups of
2942@ifset GENERIC
2943data in named sections
2944@end ifset
2945@ifclear GENERIC
2946@ifclear aout-bout
2947data in named sections
2948@end ifclear
2949@ifset aout-bout
2950text or data
2951@end ifset
2952@end ifclear
2953that you want to end up near to each other in the object file, even though they
a4fb0134 2954are not contiguous in the assembler source. @command{@value{AS}} allows you to
252b5132
RH
2955use @dfn{subsections} for this purpose. Within each section, there can be
2956numbered subsections with values from 0 to 8192. Objects assembled into the
2957same subsection go into the object file together with other objects in the same
2958subsection. For example, a compiler might want to store constants in the text
2959section, but might not want to have them interspersed with the program being
2960assembled. In this case, the compiler could issue a @samp{.text 0} before each
2961section of code being output, and a @samp{.text 1} before each group of
2962constants being output.
2963
2964Subsections are optional. If you do not use subsections, everything
2965goes in subsection number zero.
2966
2967@ifset GENERIC
2968Each subsection is zero-padded up to a multiple of four bytes.
2969(Subsections may be padded a different amount on different flavors
a4fb0134 2970of @command{@value{AS}}.)
252b5132
RH
2971@end ifset
2972@ifclear GENERIC
2973@ifset H8
2974On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
2975boundary (two bytes).
c2dcd04e 2976The same is true on the Renesas SH.
252b5132
RH
2977@end ifset
2978@ifset I960
2979@c FIXME section padding (alignment)?
2980@c Rich Pixley says padding here depends on target obj code format; that
2981@c doesn't seem particularly useful to say without further elaboration,
2982@c so for now I say nothing about it. If this is a generic BFD issue,
2983@c these paragraphs might need to vanish from this manual, and be
2984@c discussed in BFD chapter of binutils (or some such).
2985@end ifset
2986@ifset A29K
2987On the AMD 29K family, no particular padding is added to section or
2988subsection sizes; @value{AS} forces no alignment on this platform.
2989@end ifset
2990@end ifclear
2991
2992Subsections appear in your object file in numeric order, lowest numbered
2993to highest. (All this to be compatible with other people's assemblers.)
2994The object file contains no representation of subsections; @code{@value{LD}} and
2995other programs that manipulate object files see no trace of them.
2996They just see all your text subsections as a text section, and all your
2997data subsections as a data section.
2998
2999To specify which subsection you want subsequent statements assembled
3000into, use a numeric argument to specify it, in a @samp{.text
3001@var{expression}} or a @samp{.data @var{expression}} statement.
ed9589d4 3002@ifset COFF
252b5132 3003@ifset GENERIC
ed9589d4 3004When generating COFF output, you
252b5132
RH
3005@end ifset
3006@ifclear GENERIC
3007You
3008@end ifclear
3009can also use an extra subsection
3010argument with arbitrary named sections: @samp{.section @var{name},
3011@var{expression}}.
3012@end ifset
ed9589d4
BW
3013@ifset ELF
3014@ifset GENERIC
3015When generating ELF output, you
3016@end ifset
3017@ifclear GENERIC
3018You
3019@end ifclear
3020can also use the @code{.subsection} directive (@pxref{SubSection})
3021to specify a subsection: @samp{.subsection @var{expression}}.
3022@end ifset
252b5132
RH
3023@var{Expression} should be an absolute expression.
3024(@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
3025is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
3026begins in @code{text 0}. For instance:
3027@smallexample
3028.text 0 # The default subsection is text 0 anyway.
3029.ascii "This lives in the first text subsection. *"
3030.text 1
3031.ascii "But this lives in the second text subsection."
3032.data 0
3033.ascii "This lives in the data section,"
3034.ascii "in the first data subsection."
3035.text 0
3036.ascii "This lives in the first text section,"
3037.ascii "immediately following the asterisk (*)."
3038@end smallexample
3039
3040Each section has a @dfn{location counter} incremented by one for every byte
3041assembled into that section. Because subsections are merely a convenience
a4fb0134 3042restricted to @command{@value{AS}} there is no concept of a subsection location
252b5132
RH
3043counter. There is no way to directly manipulate a location counter---but the
3044@code{.align} directive changes it, and any label definition captures its
3045current value. The location counter of the section where statements are being
3046assembled is said to be the @dfn{active} location counter.
3047
3048@node bss
3049@section bss Section
3050
3051@cindex bss section
3052@cindex common variable storage
3053The bss section is used for local common variable storage.
3054You may allocate address space in the bss section, but you may
3055not dictate data to load into it before your program executes. When
3056your program starts running, all the contents of the bss
3057section are zeroed bytes.
3058
3059The @code{.lcomm} pseudo-op defines a symbol in the bss section; see
3060@ref{Lcomm,,@code{.lcomm}}.
3061
3062The @code{.comm} pseudo-op may be used to declare a common symbol, which is
3063another form of uninitialized symbol; see @xref{Comm,,@code{.comm}}.
3064
3065@ifset GENERIC
3066When assembling for a target which supports multiple sections, such as ELF or
3067COFF, you may switch into the @code{.bss} section and define symbols as usual;
3068see @ref{Section,,@code{.section}}. You may only assemble zero values into the
3069section. Typically the section will only contain symbol definitions and
3070@code{.skip} directives (@pxref{Skip,,@code{.skip}}).
3071@end ifset
3072
3073@node Symbols
3074@chapter Symbols
3075
3076@cindex symbols
3077Symbols are a central concept: the programmer uses symbols to name
3078things, the linker uses symbols to link, and the debugger uses symbols
3079to debug.
3080
3081@quotation
3082@cindex debuggers, and symbol order
a4fb0134 3083@emph{Warning:} @command{@value{AS}} does not place symbols in the object file in
252b5132
RH
3084the same order they were declared. This may break some debuggers.
3085@end quotation
3086
3087@menu
3088* Labels:: Labels
3089* Setting Symbols:: Giving Symbols Other Values
3090* Symbol Names:: Symbol Names
3091* Dot:: The Special Dot Symbol
3092* Symbol Attributes:: Symbol Attributes
3093@end menu
3094
3095@node Labels
3096@section Labels
3097
3098@cindex labels
3099A @dfn{label} is written as a symbol immediately followed by a colon
3100@samp{:}. The symbol then represents the current value of the
3101active location counter, and is, for example, a suitable instruction
3102operand. You are warned if you use the same symbol to represent two
3103different locations: the first definition overrides any other
3104definitions.
3105
3106@ifset HPPA
3107On the HPPA, the usual form for a label need not be immediately followed by a
3108colon, but instead must start in column zero. Only one label may be defined on
a4fb0134 3109a single line. To work around this, the HPPA version of @command{@value{AS}} also
252b5132
RH
3110provides a special directive @code{.label} for defining labels more flexibly.
3111@end ifset
3112
3113@node Setting Symbols
3114@section Giving Symbols Other Values
3115
3116@cindex assigning values to symbols
3117@cindex symbol values, assigning
3118A symbol can be given an arbitrary value by writing a symbol, followed
3119by an equals sign @samp{=}, followed by an expression
3120(@pxref{Expressions}). This is equivalent to using the @code{.set}
3121directive. @xref{Set,,@code{.set}}.
3122
3123@node Symbol Names
3124@section Symbol Names
3125
3126@cindex symbol names
3127@cindex names, symbol
3128@ifclear SPECIAL-SYMS
3129Symbol names begin with a letter or with one of @samp{._}. On most
3130machines, you can also use @code{$} in symbol names; exceptions are
3131noted in @ref{Machine Dependencies}. That character may be followed by any
3132string of digits, letters, dollar signs (unless otherwise noted in
3133@ref{Machine Dependencies}), and underscores.
3134@end ifclear
3135@ifset A29K
3136For the AMD 29K family, @samp{?} is also allowed in the
3137body of a symbol name, though not at its beginning.
3138@end ifset
3139
3140@ifset SPECIAL-SYMS
3141@ifset H8
3142Symbol names begin with a letter or with one of @samp{._}. On the
c2dcd04e
NC
3143Renesas SH or the H8/500, you can also use @code{$} in symbol names. That
3144character may be followed by any string of digits, letters, dollar signs (save
3145on the H8/300), and underscores.
252b5132
RH
3146@end ifset
3147@end ifset
3148
3149Case of letters is significant: @code{foo} is a different symbol name
3150than @code{Foo}.
3151
3152Each symbol has exactly one name. Each name in an assembly language program
3153refers to exactly one symbol. You may use that symbol name any number of times
3154in a program.
3155
3156@subheading Local Symbol Names
3157
3158@cindex local symbol names
3159@cindex symbol names, local
3160@cindex temporary symbol names
3161@cindex symbol names, temporary
3162Local symbols help compilers and programmers use names temporarily.
2d5aaba0
NC
3163They create symbols which are guaranteed to be unique over the entire scope of
3164the input source code and which can be referred to by a simple notation.
3165To define a local symbol, write a label of the form @samp{@b{N}:} (where @b{N}
3166represents any positive integer). To refer to the most recent previous
3167definition of that symbol write @samp{@b{N}b}, using the same number as when
3168you defined the label. To refer to the next definition of a local label, write
3169@samp{@b{N}f}--- The @samp{b} stands for``backwards'' and the @samp{f} stands
3170for ``forwards''.
3171
3172There is no restriction on how you can use these labels, and you can reuse them
3173too. So that it is possible to repeatedly define the same local label (using
3174the same number @samp{@b{N}}), although you can only refer to the most recently
3175defined local label of that number (for a backwards reference) or the next
3176definition of a specific local label for a forward reference. It is also worth
3177noting that the first 10 local labels (@samp{@b{0:}}@dots{}@samp{@b{9:}}) are
3178implemented in a slightly more efficient manner than the others.
3179
3180Here is an example:
3181
3182@smallexample
31831: branch 1f
31842: branch 1b
31851: branch 2f
31862: branch 1b
3187@end smallexample
3188
3189Which is the equivalent of:
3190
3191@smallexample
3192label_1: branch label_3
3193label_2: branch label_1
3194label_3: branch label_4
3195label_4: branch label_3
3196@end smallexample
3197
3198Local symbol names are only a notational device. They are immediately
3199transformed into more conventional symbol names before the assembler uses them.
3200The symbol names stored in the symbol table, appearing in error messages and
3201optionally emitted to the object file. The names are constructed using these
252b5132
RH
3202parts:
3203
3204@table @code
3205@item L
a4fb0134 3206All local labels begin with @samp{L}. Normally both @command{@value{AS}} and
252b5132
RH
3207@code{@value{LD}} forget symbols that start with @samp{L}. These labels are
3208used for symbols you are never intended to see. If you use the
a4fb0134 3209@samp{-L} option then @command{@value{AS}} retains these symbols in the
252b5132
RH
3210object file. If you also instruct @code{@value{LD}} to retain these symbols,
3211you may use them in debugging.
3212
2d5aaba0
NC
3213@item @var{number}
3214This is the number that was used in the local label definition. So if the
3215label is written @samp{55:} then the number is @samp{55}.
252b5132 3216
2d5aaba0
NC
3217@item @kbd{C-B}
3218This unusual character is included so you do not accidentally invent a symbol
3219of the same name. The character has ASCII value of @samp{\002} (control-B).
252b5132
RH
3220
3221@item @emph{ordinal number}
2d5aaba0
NC
3222This is a serial number to keep the labels distinct. The first definition of
3223@samp{0:} gets the number @samp{1}. The 15th definition of @samp{0:} gets the
3224number @samp{15}, and so on. Likewise the first definition of @samp{1:} gets
3225the number @samp{1} and its 15th defintion gets @samp{15} as well.
252b5132
RH
3226@end table
3227
2d5aaba0
NC
3228So for example, the first @code{1:} is named @code{L1@kbd{C-B}1}, the 44th
3229@code{3:} is named @code{L3@kbd{C-B}44}.
3230
3231@subheading Dollar Local Labels
3232@cindex dollar local symbols
3233
3234@code{@value{AS}} also supports an even more local form of local labels called
3235dollar labels. These labels go out of scope (ie they become undefined) as soon
3236as a non-local label is defined. Thus they remain valid for only a small
3237region of the input source code. Normal local labels, by contrast, remain in
3238scope for the entire file, or until they are redefined by another occurrence of
3239the same local label.
3240
3241Dollar labels are defined in exactly the same way as ordinary local labels,
3242except that instead of being terminated by a colon, they are terminated by a
3243dollar sign. eg @samp{@b{55$}}.
3244
3245They can also be distinguished from ordinary local labels by their transformed
3246name which uses ASCII character @samp{\001} (control-A) as the magic character
3247to distinguish them from ordinary labels. Thus the 5th defintion of @samp{6$}
3248is named @samp{L6@kbd{C-A}5}.
252b5132
RH
3249
3250@node Dot
3251@section The Special Dot Symbol
3252
3253@cindex dot (symbol)
3254@cindex @code{.} (symbol)
3255@cindex current address
3256@cindex location counter
3257The special symbol @samp{.} refers to the current address that
a4fb0134 3258@command{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
252b5132
RH
3259.long .} defines @code{melvin} to contain its own address.
3260Assigning a value to @code{.} is treated the same as a @code{.org}
3261directive. Thus, the expression @samp{.=.+4} is the same as saying
3262@ifclear no-space-dir
3263@samp{.space 4}.
3264@end ifclear
3265@ifset no-space-dir
3266@ifset A29K
3267@samp{.block 4}.
3268@end ifset
3269@end ifset
3270
3271@node Symbol Attributes
3272@section Symbol Attributes
3273
3274@cindex symbol attributes
3275@cindex attributes, symbol
3276Every symbol has, as well as its name, the attributes ``Value'' and
3277``Type''. Depending on output format, symbols can also have auxiliary
3278attributes.
3279@ifset INTERNALS
3280The detailed definitions are in @file{a.out.h}.
3281@end ifset
3282
a4fb0134 3283If you use a symbol without defining it, @command{@value{AS}} assumes zero for
252b5132
RH
3284all these attributes, and probably won't warn you. This makes the
3285symbol an externally defined symbol, which is generally what you
3286would want.
3287
3288@menu
3289* Symbol Value:: Value
3290* Symbol Type:: Type
3291@ifset aout-bout
3292@ifset GENERIC
3293* a.out Symbols:: Symbol Attributes: @code{a.out}
3294@end ifset
3295@ifclear GENERIC
3296@ifclear BOUT
3297* a.out Symbols:: Symbol Attributes: @code{a.out}
3298@end ifclear
3299@ifset BOUT
3300* a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
3301@end ifset
3302@end ifclear
3303@end ifset
3304@ifset COFF
3305* COFF Symbols:: Symbol Attributes for COFF
3306@end ifset
3307@ifset SOM
3308* SOM Symbols:: Symbol Attributes for SOM
3309@end ifset
3310@end menu
3311
3312@node Symbol Value
3313@subsection Value
3314
3315@cindex value of a symbol
3316@cindex symbol value
3317The value of a symbol is (usually) 32 bits. For a symbol which labels a
3318location in the text, data, bss or absolute sections the value is the
3319number of addresses from the start of that section to the label.
3320Naturally for text, data and bss sections the value of a symbol changes
3321as @code{@value{LD}} changes section base addresses during linking. Absolute
3322symbols' values do not change during linking: that is why they are
3323called absolute.
3324
3325The value of an undefined symbol is treated in a special way. If it is
33260 then the symbol is not defined in this assembler source file, and
3327@code{@value{LD}} tries to determine its value from other files linked into the
3328same program. You make this kind of symbol simply by mentioning a symbol
3329name without defining it. A non-zero value represents a @code{.comm}
3330common declaration. The value is how much common storage to reserve, in
3331bytes (addresses). The symbol refers to the first address of the
3332allocated storage.
3333
3334@node Symbol Type
3335@subsection Type
3336
3337@cindex type of a symbol
3338@cindex symbol type
3339The type attribute of a symbol contains relocation (section)
3340information, any flag settings indicating that a symbol is external, and
3341(optionally), other information for linkers and debuggers. The exact
3342format depends on the object-code output format in use.
3343
3344@ifset aout-bout
3345@ifclear GENERIC
3346@ifset BOUT
3347@c The following avoids a "widow" subsection title. @group would be
3348@c better if it were available outside examples.
3349@need 1000
3350@node a.out Symbols
3351@subsection Symbol Attributes: @code{a.out}, @code{b.out}
3352
3353@cindex @code{b.out} symbol attributes
3354@cindex symbol attributes, @code{b.out}
a4fb0134 3355These symbol attributes appear only when @command{@value{AS}} is configured for
252b5132
RH
3356one of the Berkeley-descended object output formats---@code{a.out} or
3357@code{b.out}.
3358
3359@end ifset
3360@ifclear BOUT
3361@node a.out Symbols
3362@subsection Symbol Attributes: @code{a.out}
3363
3364@cindex @code{a.out} symbol attributes
3365@cindex symbol attributes, @code{a.out}
3366
3367@end ifclear
3368@end ifclear
3369@ifset GENERIC
3370@node a.out Symbols
3371@subsection Symbol Attributes: @code{a.out}
3372
3373@cindex @code{a.out} symbol attributes
3374@cindex symbol attributes, @code{a.out}
3375
3376@end ifset
3377@menu
3378* Symbol Desc:: Descriptor
3379* Symbol Other:: Other
3380@end menu
3381
3382@node Symbol Desc
3383@subsubsection Descriptor
3384
3385@cindex descriptor, of @code{a.out} symbol
3386This is an arbitrary 16-bit value. You may establish a symbol's
3387descriptor value by using a @code{.desc} statement
3388(@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
a4fb0134 3389@command{@value{AS}}.
252b5132
RH
3390
3391@node Symbol Other
3392@subsubsection Other
3393
3394@cindex other attribute, of @code{a.out} symbol
a4fb0134 3395This is an arbitrary 8-bit value. It means nothing to @command{@value{AS}}.
252b5132
RH
3396@end ifset
3397
3398@ifset COFF
3399@node COFF Symbols
3400@subsection Symbol Attributes for COFF
3401
3402@cindex COFF symbol attributes
3403@cindex symbol attributes, COFF
3404
3405The COFF format supports a multitude of auxiliary symbol attributes;
3406like the primary symbol attributes, they are set between @code{.def} and
3407@code{.endef} directives.
3408
3409@subsubsection Primary Attributes
3410
3411@cindex primary attributes, COFF symbols
3412The symbol name is set with @code{.def}; the value and type,
3413respectively, with @code{.val} and @code{.type}.
3414
3415@subsubsection Auxiliary Attributes
3416
3417@cindex auxiliary attributes, COFF symbols
a4fb0134 3418The @command{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
c87db184
CF
3419@code{.size}, @code{.tag}, and @code{.weak} can generate auxiliary symbol
3420table information for COFF.
252b5132
RH
3421@end ifset
3422
3423@ifset SOM
3424@node SOM Symbols
3425@subsection Symbol Attributes for SOM
3426
3427@cindex SOM symbol attributes
3428@cindex symbol attributes, SOM
3429
3430The SOM format for the HPPA supports a multitude of symbol attributes set with
3431the @code{.EXPORT} and @code{.IMPORT} directives.
3432
3433The attributes are described in @cite{HP9000 Series 800 Assembly
3434Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
3435@code{EXPORT} assembler directive documentation.
3436@end ifset
3437
3438@node Expressions
3439@chapter Expressions
3440
3441@cindex expressions
3442@cindex addresses
3443@cindex numeric values
3444An @dfn{expression} specifies an address or numeric value.
3445Whitespace may precede and/or follow an expression.
3446
3447The result of an expression must be an absolute number, or else an offset into
3448a particular section. If an expression is not absolute, and there is not
a4fb0134 3449enough information when @command{@value{AS}} sees the expression to know its
252b5132
RH
3450section, a second pass over the source program might be necessary to interpret
3451the expression---but the second pass is currently not implemented.
a4fb0134 3452@command{@value{AS}} aborts with an error message in this situation.
252b5132
RH
3453
3454@menu
3455* Empty Exprs:: Empty Expressions
3456* Integer Exprs:: Integer Expressions
3457@end menu
3458
3459@node Empty Exprs
3460@section Empty Expressions
3461
3462@cindex empty expressions
3463@cindex expressions, empty
3464An empty expression has no value: it is just whitespace or null.
3465Wherever an absolute expression is required, you may omit the
a4fb0134 3466expression, and @command{@value{AS}} assumes a value of (absolute) 0. This
252b5132
RH
3467is compatible with other assemblers.
3468
3469@node Integer Exprs
3470@section Integer Expressions
3471
3472@cindex integer expressions
3473@cindex expressions, integer
3474An @dfn{integer expression} is one or more @emph{arguments} delimited
3475by @emph{operators}.
3476
3477@menu
3478* Arguments:: Arguments
3479* Operators:: Operators
3480* Prefix Ops:: Prefix Operators
3481* Infix Ops:: Infix Operators
3482@end menu
3483
3484@node Arguments
3485@subsection Arguments
3486
3487@cindex expression arguments
3488@cindex arguments in expressions
3489@cindex operands in expressions
3490@cindex arithmetic operands
3491@dfn{Arguments} are symbols, numbers or subexpressions. In other
3492contexts arguments are sometimes called ``arithmetic operands''. In
3493this manual, to avoid confusing them with the ``instruction operands'' of
3494the machine language, we use the term ``argument'' to refer to parts of
3495expressions only, reserving the word ``operand'' to refer only to machine
3496instruction operands.
3497
3498Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
3499@var{section} is one of text, data, bss, absolute,
3500or undefined. @var{NNN} is a signed, 2's complement 32 bit
3501integer.
3502
3503Numbers are usually integers.
3504
3505A number can be a flonum or bignum. In this case, you are warned
a4fb0134 3506that only the low order 32 bits are used, and @command{@value{AS}} pretends
252b5132
RH
3507these 32 bits are an integer. You may write integer-manipulating
3508instructions that act on exotic constants, compatible with other
3509assemblers.
3510
3511@cindex subexpressions
3512Subexpressions are a left parenthesis @samp{(} followed by an integer
3513expression, followed by a right parenthesis @samp{)}; or a prefix
3514operator followed by an argument.
3515
3516@node Operators
3517@subsection Operators
3518
3519@cindex operators, in expressions
3520@cindex arithmetic functions
3521@cindex functions, in expressions
3522@dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
3523operators are followed by an argument. Infix operators appear
3524between their arguments. Operators may be preceded and/or followed by
3525whitespace.
3526
3527@node Prefix Ops
3528@subsection Prefix Operator
3529
3530@cindex prefix operators
a4fb0134 3531@command{@value{AS}} has the following @dfn{prefix operators}. They each take
252b5132
RH
3532one argument, which must be absolute.
3533
3534@c the tex/end tex stuff surrounding this small table is meant to make
3535@c it align, on the printed page, with the similar table in the next
3536@c section (which is inside an enumerate).
3537@tex
3538\global\advance\leftskip by \itemindent
3539@end tex
3540
3541@table @code
3542@item -
3543@dfn{Negation}. Two's complement negation.
3544@item ~
3545@dfn{Complementation}. Bitwise not.
3546@end table
3547
3548@tex
3549\global\advance\leftskip by -\itemindent
3550@end tex
3551
3552@node Infix Ops
3553@subsection Infix Operators
3554
3555@cindex infix operators
3556@cindex operators, permitted arguments
3557@dfn{Infix operators} take two arguments, one on either side. Operators
3558have precedence, but operations with equal precedence are performed left
a4fb0134 3559to right. Apart from @code{+} or @option{-}, both arguments must be
252b5132
RH
3560absolute, and the result is absolute.
3561
3562@enumerate
3563@cindex operator precedence
3564@cindex precedence of operators
3565
3566@item
3567Highest Precedence
3568
3569@table @code
3570@item *
3571@dfn{Multiplication}.
3572
3573@item /
3574@dfn{Division}. Truncation is the same as the C operator @samp{/}
3575
3576@item %
3577@dfn{Remainder}.
3578
3579@item <
3580@itemx <<
3581@dfn{Shift Left}. Same as the C operator @samp{<<}.
3582
3583@item >
3584@itemx >>
3585@dfn{Shift Right}. Same as the C operator @samp{>>}.
3586@end table
3587
3588@item
3589Intermediate precedence
3590
3591@table @code
3592@item |
3593
3594@dfn{Bitwise Inclusive Or}.
3595
3596@item &
3597@dfn{Bitwise And}.
3598
3599@item ^
3600@dfn{Bitwise Exclusive Or}.
3601
3602@item !
3603@dfn{Bitwise Or Not}.
3604@end table
3605
3606@item
b131d4dc 3607Low Precedence
252b5132
RH
3608
3609@table @code
3610@cindex addition, permitted arguments
3611@cindex plus, permitted arguments
3612@cindex arguments for addition
3613@item +
3614@dfn{Addition}. If either argument is absolute, the result has the section of
3615the other argument. You may not add together arguments from different
3616sections.
3617
3618@cindex subtraction, permitted arguments
3619@cindex minus, permitted arguments
3620@cindex arguments for subtraction
3621@item -
3622@dfn{Subtraction}. If the right argument is absolute, the
3623result has the section of the left argument.
3624If both arguments are in the same section, the result is absolute.
3625You may not subtract arguments from different sections.
3626@c FIXME is there still something useful to say about undefined - undefined ?
b131d4dc
NC
3627
3628@cindex comparison expressions
3629@cindex expressions, comparison
3630@item ==
3631@dfn{Is Equal To}
3632@item <>
3633@dfn{Is Not Equal To}
3634@item <
3635@dfn{Is Less Than}
3636@itemx >
3637@dfn{Is Greater Than}
3638@itemx >=
3639@dfn{Is Greater Than Or Equal To}
3640@itemx <=
3641@dfn{Is Less Than Or Equal To}
3642
3643The comparison operators can be used as infix operators. A true results has a
3644value of -1 whereas a false result has a value of 0. Note, these operators
3645perform signed comparisons.
3646@end table
3647
3648@item Lowest Precedence
3649
3650@table @code
3651@item &&
3652@dfn{Logical And}.
3653
3654@item ||
3655@dfn{Logical Or}.
3656
3657These two logical operations can be used to combine the results of sub
3658expressions. Note, unlike the comparison operators a true result returns a
3659value of 1 but a false results does still return 0. Also note that the logical
3660or operator has a slightly lower precedence than logical and.
3661
252b5132
RH
3662@end table
3663@end enumerate
3664
3665In short, it's only meaningful to add or subtract the @emph{offsets} in an
3666address; you can only have a defined section in one of the two arguments.
3667
3668@node Pseudo Ops
3669@chapter Assembler Directives
3670
3671@cindex directives, machine independent
3672@cindex pseudo-ops, machine independent
3673@cindex machine independent directives
3674All assembler directives have names that begin with a period (@samp{.}).
3675The rest of the name is letters, usually in lower case.
3676
3677This chapter discusses directives that are available regardless of the
3678target machine configuration for the @sc{gnu} assembler.
3679@ifset GENERIC
3680Some machine configurations provide additional directives.
3681@xref{Machine Dependencies}.
3682@end ifset
3683@ifclear GENERIC
3684@ifset machine-directives
3685@xref{Machine Dependencies} for additional directives.
3686@end ifset
3687@end ifclear
3688
3689@menu
3690* Abort:: @code{.abort}
3691@ifset COFF
3692* ABORT:: @code{.ABORT}
3693@end ifset
f0dc282c 3694
252b5132 3695* Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
caa32fe5 3696* Altmacro:: @code{.altmacro}
252b5132
RH
3697* Ascii:: @code{.ascii "@var{string}"}@dots{}
3698* Asciz:: @code{.asciz "@var{string}"}@dots{}
3699* Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}}
3700* Byte:: @code{.byte @var{expressions}}
3701* Comm:: @code{.comm @var{symbol} , @var{length} }
54cfded0 3702
cdfbf930 3703* CFI directives:: @code{.cfi_startproc}, @code{.cfi_endproc}, etc.
54cfded0 3704
252b5132
RH
3705* Data:: @code{.data @var{subsection}}
3706@ifset COFF
3707* Def:: @code{.def @var{name}}
3708@end ifset
3709@ifset aout-bout
3710* Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
3711@end ifset
3712@ifset COFF
3713* Dim:: @code{.dim}
3714@end ifset
f0dc282c 3715
252b5132
RH
3716* Double:: @code{.double @var{flonums}}
3717* Eject:: @code{.eject}
3718* Else:: @code{.else}
3fd9f047 3719* Elseif:: @code{.elseif}
252b5132
RH
3720* End:: @code{.end}
3721@ifset COFF
3722* Endef:: @code{.endef}
3723@end ifset
f0dc282c 3724
252b5132
RH
3725* Endfunc:: @code{.endfunc}
3726* Endif:: @code{.endif}
3727* Equ:: @code{.equ @var{symbol}, @var{expression}}
3728* Equiv:: @code{.equiv @var{symbol}, @var{expression}}
3729* Err:: @code{.err}
d190d046 3730* Error:: @code{.error @var{string}}
252b5132
RH
3731* Exitm:: @code{.exitm}
3732* Extern:: @code{.extern}
3733* Fail:: @code{.fail}
3734@ifclear no-file-dir
3735* File:: @code{.file @var{string}}
3736@end ifclear
f0dc282c 3737
252b5132
RH
3738* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
3739* Float:: @code{.float @var{flonums}}
3740* Func:: @code{.func}
3741* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
c91d2e08
NC
3742@ifset ELF
3743* Hidden:: @code{.hidden @var{names}}
3744@end ifset
f0dc282c 3745
252b5132
RH
3746* hword:: @code{.hword @var{expressions}}
3747* Ident:: @code{.ident}
3748* If:: @code{.if @var{absolute expression}}
7e005732 3749* Incbin:: @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]}
252b5132
RH
3750* Include:: @code{.include "@var{file}"}
3751* Int:: @code{.int @var{expressions}}
c91d2e08
NC
3752@ifset ELF
3753* Internal:: @code{.internal @var{names}}
3754@end ifset
f0dc282c 3755
252b5132
RH
3756* Irp:: @code{.irp @var{symbol},@var{values}}@dots{}
3757* Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{}
3758* Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
3759* Lflags:: @code{.lflags}
3760@ifclear no-line-dir
3761* Line:: @code{.line @var{line-number}}
3762@end ifclear
f0dc282c 3763
252b5132
RH
3764* Ln:: @code{.ln @var{line-number}}
3765* Linkonce:: @code{.linkonce [@var{type}]}
3766* List:: @code{.list}
3767* Long:: @code{.long @var{expressions}}
3768@ignore
3769* Lsym:: @code{.lsym @var{symbol}, @var{expression}}
3770@end ignore
f0dc282c 3771
252b5132
RH
3772* Macro:: @code{.macro @var{name} @var{args}}@dots{}
3773* MRI:: @code{.mri @var{val}}
caa32fe5 3774* Noaltmacro:: @code{.noaltmacro}
252b5132
RH
3775* Nolist:: @code{.nolist}
3776* Octa:: @code{.octa @var{bignums}}
3777* Org:: @code{.org @var{new-lc} , @var{fill}}
3778* P2align:: @code{.p2align @var{abs-expr} , @var{abs-expr}}
c91d2e08
NC
3779@ifset ELF
3780* PopSection:: @code{.popsection}
3781* Previous:: @code{.previous}
3782@end ifset
f0dc282c 3783
252b5132 3784* Print:: @code{.print @var{string}}
c91d2e08
NC
3785@ifset ELF
3786* Protected:: @code{.protected @var{names}}
3787@end ifset
f0dc282c 3788
252b5132
RH
3789* Psize:: @code{.psize @var{lines}, @var{columns}}
3790* Purgem:: @code{.purgem @var{name}}
c91d2e08
NC
3791@ifset ELF
3792* PushSection:: @code{.pushsection @var{name}}
3793@end ifset
f0dc282c 3794
252b5132
RH
3795* Quad:: @code{.quad @var{bignums}}
3796* Rept:: @code{.rept @var{count}}
3797* Sbttl:: @code{.sbttl "@var{subheading}"}
3798@ifset COFF
3799* Scl:: @code{.scl @var{class}}
c1253627
NC
3800@end ifset
3801@ifset COFF-ELF
3802* Section:: @code{.section @var{name}}
252b5132 3803@end ifset
f0dc282c 3804
252b5132
RH
3805* Set:: @code{.set @var{symbol}, @var{expression}}
3806* Short:: @code{.short @var{expressions}}
3807* Single:: @code{.single @var{flonums}}
c1253627 3808@ifset COFF-ELF
c91d2e08 3809* Size:: @code{.size [@var{name} , @var{expression}]}
c1253627
NC
3810@end ifset
3811
252b5132
RH
3812* Skip:: @code{.skip @var{size} , @var{fill}}
3813* Sleb128:: @code{.sleb128 @var{expressions}}
3814* Space:: @code{.space @var{size} , @var{fill}}
3815@ifset have-stabs
3816* Stab:: @code{.stabd, .stabn, .stabs}
3817@end ifset
f0dc282c 3818
252b5132
RH
3819* String:: @code{.string "@var{str}"}
3820* Struct:: @code{.struct @var{expression}}
3821@ifset ELF
c91d2e08 3822* SubSection:: @code{.subsection}
252b5132
RH
3823* Symver:: @code{.symver @var{name},@var{name2@@nodename}}
3824@end ifset
f0dc282c 3825
252b5132
RH
3826@ifset COFF
3827* Tag:: @code{.tag @var{structname}}
3828@end ifset
f0dc282c 3829
252b5132
RH
3830* Text:: @code{.text @var{subsection}}
3831* Title:: @code{.title "@var{heading}"}
c1253627 3832@ifset COFF-ELF
c91d2e08 3833* Type:: @code{.type <@var{int} | @var{name} , @var{type description}>}
c1253627
NC
3834@end ifset
3835
c91d2e08 3836* Uleb128:: @code{.uleb128 @var{expressions}}
252b5132 3837@ifset COFF
252b5132
RH
3838* Val:: @code{.val @var{addr}}
3839@end ifset
f0dc282c 3840
2e13b764 3841@ifset ELF
c91d2e08 3842* Version:: @code{.version "@var{string}"}
c91d2e08
NC
3843* VTableEntry:: @code{.vtable_entry @var{table}, @var{offset}}
3844* VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}}
2e13b764 3845@end ifset
f0dc282c 3846
d190d046 3847* Warning:: @code{.warning @var{string}}
c87db184 3848* Weak:: @code{.weak @var{names}}
252b5132
RH
3849* Word:: @code{.word @var{expressions}}
3850* Deprecated:: Deprecated Directives
3851@end menu
3852
3853@node Abort
3854@section @code{.abort}
3855
3856@cindex @code{abort} directive
3857@cindex stopping the assembly
3858This directive stops the assembly immediately. It is for
3859compatibility with other assemblers. The original idea was that the
3860assembly language source would be piped into the assembler. If the sender
a4fb0134 3861of the source quit, it could use this directive tells @command{@value{AS}} to
252b5132
RH
3862quit also. One day @code{.abort} will not be supported.
3863
3864@ifset COFF
3865@node ABORT
3866@section @code{.ABORT}
3867
3868@cindex @code{ABORT} directive
a4fb0134 3869When producing COFF output, @command{@value{AS}} accepts this directive as a
252b5132
RH
3870synonym for @samp{.abort}.
3871
3872@ifset BOUT
a4fb0134 3873When producing @code{b.out} output, @command{@value{AS}} accepts this directive,
252b5132
RH
3874but ignores it.
3875@end ifset
3876@end ifset
3877
3878@node Align
3879@section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3880
3881@cindex padding the location counter
3882@cindex @code{align} directive
3883Pad the location counter (in the current subsection) to a particular storage
3884boundary. The first expression (which must be absolute) is the alignment
3885required, as described below.
3886
3887The second expression (also absolute) gives the fill value to be stored in the
3888padding bytes. It (and the comma) may be omitted. If it is omitted, the
3889padding bytes are normally zero. However, on some systems, if the section is
3890marked as containing code and the fill value is omitted, the space is filled
3891with no-op instructions.
3892
3893The third expression is also absolute, and is also optional. If it is present,
3894it is the maximum number of bytes that should be skipped by this alignment
3895directive. If doing the alignment would require skipping more bytes than the
3896specified maximum, then the alignment is not done at all. You can omit the
3897fill value (the second argument) entirely by simply using two commas after the
3898required alignment; this can be useful if you want the alignment to be filled
3899with no-op instructions when appropriate.
3900
3901The way the required alignment is specified varies from system to system.
60946ad0
AM
3902For the a29k, arc, hppa, i386 using ELF, i860, iq2000, m68k, m88k, or32,
3903s390, sparc, tic4x, tic80 and xtensa, the first expression is the
252b5132
RH
3904alignment request in bytes. For example @samp{.align 8} advances
3905the location counter until it is a multiple of 8. If the location counter
60946ad0
AM
3906is already a multiple of 8, no change is needed. For the tic54x, the
3907first expression is the alignment request in words.
252b5132 3908
adcf07e6
NC
3909For other systems, including the i386 using a.out format, and the arm and
3910strongarm, it is the
252b5132
RH
3911number of low-order zero bits the location counter must have after
3912advancement. For example @samp{.align 3} advances the location
3913counter until it a multiple of 8. If the location counter is already a
3914multiple of 8, no change is needed.
3915
3916This inconsistency is due to the different behaviors of the various
3917native assemblers for these systems which GAS must emulate.
3918GAS also provides @code{.balign} and @code{.p2align} directives,
3919described later, which have a consistent behavior across all
3920architectures (but are specific to GAS).
3921
3922@node Ascii
3923@section @code{.ascii "@var{string}"}@dots{}
3924
3925@cindex @code{ascii} directive
3926@cindex string literals
3927@code{.ascii} expects zero or more string literals (@pxref{Strings})
3928separated by commas. It assembles each string (with no automatic
3929trailing zero byte) into consecutive addresses.
3930
3931@node Asciz
3932@section @code{.asciz "@var{string}"}@dots{}
3933
3934@cindex @code{asciz} directive
3935@cindex zero-terminated strings
3936@cindex null-terminated strings
3937@code{.asciz} is just like @code{.ascii}, but each string is followed by
3938a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
3939
3940@node Balign
3941@section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3942
3943@cindex padding the location counter given number of bytes
3944@cindex @code{balign} directive
3945Pad the location counter (in the current subsection) to a particular
3946storage boundary. The first expression (which must be absolute) is the
3947alignment request in bytes. For example @samp{.balign 8} advances
3948the location counter until it is a multiple of 8. If the location counter
3949is already a multiple of 8, no change is needed.
3950
3951The second expression (also absolute) gives the fill value to be stored in the
3952padding bytes. It (and the comma) may be omitted. If it is omitted, the
3953padding bytes are normally zero. However, on some systems, if the section is
3954marked as containing code and the fill value is omitted, the space is filled
3955with no-op instructions.
3956
3957The third expression is also absolute, and is also optional. If it is present,
3958it is the maximum number of bytes that should be skipped by this alignment
3959directive. If doing the alignment would require skipping more bytes than the
3960specified maximum, then the alignment is not done at all. You can omit the
3961fill value (the second argument) entirely by simply using two commas after the
3962required alignment; this can be useful if you want the alignment to be filled
3963with no-op instructions when appropriate.
3964
3965@cindex @code{balignw} directive
3966@cindex @code{balignl} directive
3967The @code{.balignw} and @code{.balignl} directives are variants of the
3968@code{.balign} directive. The @code{.balignw} directive treats the fill
3969pattern as a two byte word value. The @code{.balignl} directives treats the
3970fill pattern as a four byte longword value. For example, @code{.balignw
39714,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
3972filled in with the value 0x368d (the exact placement of the bytes depends upon
3973the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
3974undefined.
3975
3976@node Byte
3977@section @code{.byte @var{expressions}}
3978
3979@cindex @code{byte} directive
3980@cindex integers, one byte
3981@code{.byte} expects zero or more expressions, separated by commas.
3982Each expression is assembled into the next byte.
3983
d88ef7a6
TT
3984@node Comm
3985@section @code{.comm @var{symbol} , @var{length} }
3986
3987@cindex @code{comm} directive
3988@cindex symbol, common
3989@code{.comm} declares a common symbol named @var{symbol}. When linking, a
3990common symbol in one object file may be merged with a defined or common symbol
3991of the same name in another object file. If @code{@value{LD}} does not see a
3992definition for the symbol--just one or more common symbols--then it will
3993allocate @var{length} bytes of uninitialized memory. @var{length} must be an
3994absolute expression. If @code{@value{LD}} sees multiple common symbols with
3995the same name, and they do not all have the same size, it will allocate space
3996using the largest size.
3997
3998@ifset ELF
3999When using ELF, the @code{.comm} directive takes an optional third argument.
4000This is the desired alignment of the symbol, specified as a byte boundary (for
4001example, an alignment of 16 means that the least significant 4 bits of the
4002address should be zero). The alignment must be an absolute expression, and it
4003must be a power of two. If @code{@value{LD}} allocates uninitialized memory
4004for the common symbol, it will use the alignment when placing the symbol. If
4005no alignment is specified, @command{@value{AS}} will set the alignment to the
4006largest power of two less than or equal to the size of the symbol, up to a
4007maximum of 16.
4008@end ifset
4009
4010@ifset HPPA
4011The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
4012@samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
4013@end ifset
4014
54cfded0
AM
4015@node CFI directives
4016@section @code{.cfi_startproc}
4017@cindex @code{cfi_startproc} directive
4018@code{.cfi_startproc} is used at the beginning of each function that
4019should have an entry in @code{.eh_frame}. It initializes some internal
4020data structures and emits architecture dependent initial CFI instructions.
4021Don't forget to close the function by
4022@code{.cfi_endproc}.
4023
4024@section @code{.cfi_endproc}
4025@cindex @code{cfi_endproc} directive
4026@code{.cfi_endproc} is used at the end of a function where it closes its
4027unwind entry previously opened by
4028@code{.cfi_startproc}. and emits it to @code{.eh_frame}.
4029
4030@section @code{.cfi_def_cfa @var{register}, @var{offset}}
4031@code{.cfi_def_cfa} defines a rule for computing CFA as: @i{take
4032address from @var{register} and add @var{offset} to it}.
4033
4034@section @code{.cfi_def_cfa_register @var{register}}
4035@code{.cfi_def_cfa_register} modifies a rule for computing CFA. From
4036now on @var{register} will be used instead of the old one. Offset
4037remains the same.
4038
4039@section @code{.cfi_def_cfa_offset @var{offset}}
4040@code{.cfi_def_cfa_offset} modifies a rule for computing CFA. Register
4041remains the same, but @var{offset} is new. Note that it is the
4042absolute offset that will be added to a defined register to compute
4043CFA address.
4044
4045@section @code{.cfi_adjust_cfa_offset @var{offset}}
4046Same as @code{.cfi_def_cfa_offset} but @var{offset} is a relative
4047value that is added/substracted from the previous offset.
4048
4049@section @code{.cfi_offset @var{register}, @var{offset}}
4050Previous value of @var{register} is saved at offset @var{offset} from
4051CFA.
4052
17076204
RH
4053@section @code{.cfi_rel_offset @var{register}, @var{offset}}
4054Previous value of @var{register} is saved at offset @var{offset} from
4055the current CFA register. This is transformed to @code{.cfi_offset}
4056using the known displacement of the CFA register from the CFA.
4057This is often easier to use, because the number will match the
4058code it's annotating.
54cfded0 4059
6749011b 4060@section @code{.cfi_window_save}
364b6d8b
JJ
4061SPARC register window has been saved.
4062
cdfbf930
RH
4063@section @code{.cfi_escape} @var{expression}[, @dots{}]
4064Allows the user to add arbitrary bytes to the unwind info. One
4065might use this to add OS-specific CFI opcodes, or generic CFI
4066opcodes that GAS does not yet support.
252b5132 4067
252b5132
RH
4068@node Data
4069@section @code{.data @var{subsection}}
4070
4071@cindex @code{data} directive
a4fb0134 4072@code{.data} tells @command{@value{AS}} to assemble the following statements onto the
252b5132
RH
4073end of the data subsection numbered @var{subsection} (which is an
4074absolute expression). If @var{subsection} is omitted, it defaults
4075to zero.
4076
4077@ifset COFF
4078@node Def
4079@section @code{.def @var{name}}
4080
4081@cindex @code{def} directive
4082@cindex COFF symbols, debugging
4083@cindex debugging COFF symbols
4084Begin defining debugging information for a symbol @var{name}; the
4085definition extends until the @code{.endef} directive is encountered.
4086@ifset BOUT
4087
a4fb0134 4088This directive is only observed when @command{@value{AS}} is configured for COFF
252b5132
RH
4089format output; when producing @code{b.out}, @samp{.def} is recognized,
4090but ignored.
4091@end ifset
4092@end ifset
4093
4094@ifset aout-bout
4095@node Desc
4096@section @code{.desc @var{symbol}, @var{abs-expression}}
4097
4098@cindex @code{desc} directive
4099@cindex COFF symbol descriptor
4100@cindex symbol descriptor, COFF
4101This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
4102to the low 16 bits of an absolute expression.
4103
4104@ifset COFF
a4fb0134 4105The @samp{.desc} directive is not available when @command{@value{AS}} is
252b5132 4106configured for COFF output; it is only for @code{a.out} or @code{b.out}
a4fb0134 4107object format. For the sake of compatibility, @command{@value{AS}} accepts
252b5132
RH
4108it, but produces no output, when configured for COFF.
4109@end ifset
4110@end ifset
4111
4112@ifset COFF
4113@node Dim
4114@section @code{.dim}
4115
4116@cindex @code{dim} directive
4117@cindex COFF auxiliary symbol information
4118@cindex auxiliary symbol information, COFF
4119This directive is generated by compilers to include auxiliary debugging
4120information in the symbol table. It is only permitted inside
4121@code{.def}/@code{.endef} pairs.
4122@ifset BOUT
4123
4124@samp{.dim} is only meaningful when generating COFF format output; when
a4fb0134 4125@command{@value{AS}} is generating @code{b.out}, it accepts this directive but
252b5132
RH
4126ignores it.
4127@end ifset
4128@end ifset
4129
4130@node Double
4131@section @code{.double @var{flonums}}
4132
4133@cindex @code{double} directive
4134@cindex floating point numbers (double)
4135@code{.double} expects zero or more flonums, separated by commas. It
4136assembles floating point numbers.
4137@ifset GENERIC
4138The exact kind of floating point numbers emitted depends on how
a4fb0134 4139@command{@value{AS}} is configured. @xref{Machine Dependencies}.
252b5132
RH
4140@end ifset
4141@ifclear GENERIC
4142@ifset IEEEFLOAT
4143On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
4144in @sc{ieee} format.
4145@end ifset
4146@end ifclear
4147
4148@node Eject
4149@section @code{.eject}
4150
4151@cindex @code{eject} directive
4152@cindex new page, in listings
4153@cindex page, in listings
4154@cindex listing control: new page
4155Force a page break at this point, when generating assembly listings.
4156
4157@node Else
4158@section @code{.else}
4159
4160@cindex @code{else} directive
a4fb0134 4161@code{.else} is part of the @command{@value{AS}} support for conditional
252b5132
RH
4162assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
4163of code to be assembled if the condition for the preceding @code{.if}
4164was false.
4165
3fd9f047
TW
4166@node Elseif
4167@section @code{.elseif}
4168
4169@cindex @code{elseif} directive
a4fb0134 4170@code{.elseif} is part of the @command{@value{AS}} support for conditional
3fd9f047
TW
4171assembly; @pxref{If,,@code{.if}}. It is shorthand for beginning a new
4172@code{.if} block that would otherwise fill the entire @code{.else} section.
4173
252b5132
RH
4174@node End
4175@section @code{.end}
4176
4177@cindex @code{end} directive
a4fb0134 4178@code{.end} marks the end of the assembly file. @command{@value{AS}} does not
252b5132
RH
4179process anything in the file past the @code{.end} directive.
4180
4181@ifset COFF
4182@node Endef
4183@section @code{.endef}
4184
4185@cindex @code{endef} directive
4186This directive flags the end of a symbol definition begun with
4187@code{.def}.
4188@ifset BOUT
4189
4190@samp{.endef} is only meaningful when generating COFF format output; if
a4fb0134 4191@command{@value{AS}} is configured to generate @code{b.out}, it accepts this
252b5132
RH
4192directive but ignores it.
4193@end ifset
4194@end ifset
4195
4196@node Endfunc
4197@section @code{.endfunc}
4198@cindex @code{endfunc} directive
4199@code{.endfunc} marks the end of a function specified with @code{.func}.
4200
4201@node Endif
4202@section @code{.endif}
4203
4204@cindex @code{endif} directive
a4fb0134 4205@code{.endif} is part of the @command{@value{AS}} support for conditional assembly;
252b5132
RH
4206it marks the end of a block of code that is only assembled
4207conditionally. @xref{If,,@code{.if}}.
4208
4209@node Equ
4210@section @code{.equ @var{symbol}, @var{expression}}
4211
4212@cindex @code{equ} directive
4213@cindex assigning values to symbols
4214@cindex symbols, assigning values to
4215This directive sets the value of @var{symbol} to @var{expression}.
4216It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
4217
4218@ifset HPPA
4219The syntax for @code{equ} on the HPPA is
4220@samp{@var{symbol} .equ @var{expression}}.
4221@end ifset
4222
4223@node Equiv
4224@section @code{.equiv @var{symbol}, @var{expression}}
4225@cindex @code{equiv} directive
4226The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that
8dfa0188
NC
4227the assembler will signal an error if @var{symbol} is already defined. Note a
4228symbol which has been referenced but not actually defined is considered to be
4229undefined.
252b5132
RH
4230
4231Except for the contents of the error message, this is roughly equivalent to
4232@smallexample
4233.ifdef SYM
4234.err
4235.endif
4236.equ SYM,VAL
4237@end smallexample
4238
4239@node Err
4240@section @code{.err}
4241@cindex @code{err} directive
a4fb0134
SC
4242If @command{@value{AS}} assembles a @code{.err} directive, it will print an error
4243message and, unless the @option{-Z} option was used, it will not generate an
252b5132
RH
4244object file. This can be used to signal error an conditionally compiled code.
4245
d190d046
HPN
4246@node Error
4247@section @code{.error "@var{string}"}
4248@cindex error directive
4249
4250Similarly to @code{.err}, this directive emits an error, but you can specify a
4251string that will be emitted as the error message. If you don't specify the
4252message, it defaults to @code{".error directive invoked in source file"}.
4253@xref{Errors, ,Error and Warning Messages}.
4254
4255@smallexample
4256 .error "This code has not been assembled and tested."
4257@end smallexample
4258
252b5132
RH
4259@node Exitm
4260@section @code{.exitm}
4261Exit early from the current macro definition. @xref{Macro}.
4262
4263@node Extern
4264@section @code{.extern}
4265
4266@cindex @code{extern} directive
4267@code{.extern} is accepted in the source program---for compatibility
a4fb0134 4268with other assemblers---but it is ignored. @command{@value{AS}} treats
252b5132
RH
4269all undefined symbols as external.
4270
4271@node Fail
4272@section @code{.fail @var{expression}}
4273
4274@cindex @code{fail} directive
4275Generates an error or a warning. If the value of the @var{expression} is 500
a4fb0134
SC
4276or more, @command{@value{AS}} will print a warning message. If the value is less
4277than 500, @command{@value{AS}} will print an error message. The message will
252b5132
RH
4278include the value of @var{expression}. This can occasionally be useful inside
4279complex nested macros or conditional assembly.
4280
4281@ifclear no-file-dir
4282@node File
4283@section @code{.file @var{string}}
4284
4285@cindex @code{file} directive
4286@cindex logical file name
4287@cindex file name, logical
a4fb0134 4288@code{.file} tells @command{@value{AS}} that we are about to start a new logical
252b5132
RH
4289file. @var{string} is the new file name. In general, the filename is
4290recognized whether or not it is surrounded by quotes @samp{"}; but if you wish
4291to specify an empty file name, you must give the quotes--@code{""}. This
4292statement may go away in future: it is only recognized to be compatible with
a4fb0134 4293old @command{@value{AS}} programs.
252b5132 4294@ifset A29K
a4fb0134 4295In some configurations of @command{@value{AS}}, @code{.file} has already been
252b5132
RH
4296removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
4297@end ifset
4298@end ifclear
4299
4300@node Fill
4301@section @code{.fill @var{repeat} , @var{size} , @var{value}}
4302
4303@cindex @code{fill} directive
4304@cindex writing patterns in memory
4305@cindex patterns, writing in memory
bc64be0c 4306@var{repeat}, @var{size} and @var{value} are absolute expressions.
252b5132
RH
4307This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
4308may be zero or more. @var{Size} may be zero or more, but if it is
4309more than 8, then it is deemed to have the value 8, compatible with
4310other people's assemblers. The contents of each @var{repeat} bytes
4311is taken from an 8-byte number. The highest order 4 bytes are
4312zero. The lowest order 4 bytes are @var{value} rendered in the
a4fb0134 4313byte-order of an integer on the computer @command{@value{AS}} is assembling for.
252b5132
RH
4314Each @var{size} bytes in a repetition is taken from the lowest order
4315@var{size} bytes of this number. Again, this bizarre behavior is
4316compatible with other people's assemblers.
4317
4318@var{size} and @var{value} are optional.
4319If the second comma and @var{value} are absent, @var{value} is
4320assumed zero. If the first comma and following tokens are absent,
4321@var{size} is assumed to be 1.
4322
4323@node Float
4324@section @code{.float @var{flonums}}
4325
4326@cindex floating point numbers (single)
4327@cindex @code{float} directive
4328This directive assembles zero or more flonums, separated by commas. It
4329has the same effect as @code{.single}.
4330@ifset GENERIC
4331The exact kind of floating point numbers emitted depends on how
a4fb0134 4332@command{@value{AS}} is configured.
252b5132
RH
4333@xref{Machine Dependencies}.
4334@end ifset
4335@ifclear GENERIC
4336@ifset IEEEFLOAT
4337On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
4338in @sc{ieee} format.
4339@end ifset
4340@end ifclear
4341
4342@node Func
4343@section @code{.func @var{name}[,@var{label}]}
4344@cindex @code{func} directive
4345@code{.func} emits debugging information to denote function @var{name}, and
4346is ignored unless the file is assembled with debugging enabled.
05da4302 4347Only @samp{--gstabs[+]} is currently supported.
252b5132
RH
4348@var{label} is the entry point of the function and if omitted @var{name}
4349prepended with the @samp{leading char} is used.
4350@samp{leading char} is usually @code{_} or nothing, depending on the target.
4351All functions are currently defined to have @code{void} return type.
4352The function must be terminated with @code{.endfunc}.
4353
4354@node Global
4355@section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
4356
4357@cindex @code{global} directive
4358@cindex symbol, making visible to linker
4359@code{.global} makes the symbol visible to @code{@value{LD}}. If you define
4360@var{symbol} in your partial program, its value is made available to
4361other partial programs that are linked with it. Otherwise,
4362@var{symbol} takes its attributes from a symbol of the same name
4363from another file linked into the same program.
4364
4365Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
4366compatibility with other assemblers.
4367
4368@ifset HPPA
4369On the HPPA, @code{.global} is not always enough to make it accessible to other
4370partial programs. You may need the HPPA-only @code{.EXPORT} directive as well.
4371@xref{HPPA Directives,, HPPA Assembler Directives}.
4372@end ifset
4373
c91d2e08
NC
4374@ifset ELF
4375@node Hidden
4376@section @code{.hidden @var{names}}
4377
c1253627
NC
4378@cindex @code{hidden} directive
4379@cindex visibility
ed9589d4 4380This is one of the ELF visibility directives. The other two are
a349d9dd
PB
4381@code{.internal} (@pxref{Internal,,@code{.internal}}) and
4382@code{.protected} (@pxref{Protected,,@code{.protected}}).
c91d2e08
NC
4383
4384This directive overrides the named symbols default visibility (which is set by
4385their binding: local, global or weak). The directive sets the visibility to
4386@code{hidden} which means that the symbols are not visible to other components.
4387Such symbols are always considered to be @code{protected} as well.
4388@end ifset
4389
252b5132
RH
4390@node hword
4391@section @code{.hword @var{expressions}}
4392
4393@cindex @code{hword} directive
4394@cindex integers, 16-bit
4395@cindex numbers, 16-bit
4396@cindex sixteen bit integers
4397This expects zero or more @var{expressions}, and emits
4398a 16 bit number for each.
4399
4400@ifset GENERIC
4401This directive is a synonym for @samp{.short}; depending on the target
4402architecture, it may also be a synonym for @samp{.word}.
4403@end ifset
4404@ifclear GENERIC
4405@ifset W32
4406This directive is a synonym for @samp{.short}.
4407@end ifset
4408@ifset W16
4409This directive is a synonym for both @samp{.short} and @samp{.word}.
4410@end ifset
4411@end ifclear
4412
4413@node Ident
4414@section @code{.ident}
4415
4416@cindex @code{ident} directive
4417This directive is used by some assemblers to place tags in object files.
a4fb0134 4418@command{@value{AS}} simply accepts the directive for source-file
252b5132
RH
4419compatibility with such assemblers, but does not actually emit anything
4420for it.
4421
4422@node If
4423@section @code{.if @var{absolute expression}}
4424
4425@cindex conditional assembly
4426@cindex @code{if} directive
4427@code{.if} marks the beginning of a section of code which is only
4428considered part of the source program being assembled if the argument
4429(which must be an @var{absolute expression}) is non-zero. The end of
4430the conditional section of code must be marked by @code{.endif}
4431(@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
4432alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}).
3fd9f047
TW
4433If you have several conditions to check, @code{.elseif} may be used to avoid
4434nesting blocks if/else within each subsequent @code{.else} block.
252b5132
RH
4435
4436The following variants of @code{.if} are also supported:
4437@table @code
4438@cindex @code{ifdef} directive
4439@item .ifdef @var{symbol}
4440Assembles the following section of code if the specified @var{symbol}
8dfa0188
NC
4441has been defined. Note a symbol which has been referenced but not yet defined
4442is considered to be undefined.
252b5132
RH
4443
4444@cindex @code{ifc} directive
4445@item .ifc @var{string1},@var{string2}
4446Assembles the following section of code if the two strings are the same. The
4447strings may be optionally quoted with single quotes. If they are not quoted,
4448the first string stops at the first comma, and the second string stops at the
4449end of the line. Strings which contain whitespace should be quoted. The
4450string comparison is case sensitive.
4451
4452@cindex @code{ifeq} directive
4453@item .ifeq @var{absolute expression}
4454Assembles the following section of code if the argument is zero.
4455
4456@cindex @code{ifeqs} directive
4457@item .ifeqs @var{string1},@var{string2}
4458Another form of @code{.ifc}. The strings must be quoted using double quotes.
4459
4460@cindex @code{ifge} directive
4461@item .ifge @var{absolute expression}
4462Assembles the following section of code if the argument is greater than or
4463equal to zero.
4464
4465@cindex @code{ifgt} directive
4466@item .ifgt @var{absolute expression}
4467Assembles the following section of code if the argument is greater than zero.
4468
4469@cindex @code{ifle} directive
4470@item .ifle @var{absolute expression}
4471Assembles the following section of code if the argument is less than or equal
4472to zero.
4473
4474@cindex @code{iflt} directive
4475@item .iflt @var{absolute expression}
4476Assembles the following section of code if the argument is less than zero.
4477
4478@cindex @code{ifnc} directive
4479@item .ifnc @var{string1},@var{string2}.
4480Like @code{.ifc}, but the sense of the test is reversed: this assembles the
4481following section of code if the two strings are not the same.
4482
4483@cindex @code{ifndef} directive
4484@cindex @code{ifnotdef} directive
4485@item .ifndef @var{symbol}
4486@itemx .ifnotdef @var{symbol}
4487Assembles the following section of code if the specified @var{symbol}
8dfa0188
NC
4488has not been defined. Both spelling variants are equivalent. Note a symbol
4489which has been referenced but not yet defined is considered to be undefined.
252b5132
RH
4490
4491@cindex @code{ifne} directive
4492@item .ifne @var{absolute expression}
4493Assembles the following section of code if the argument is not equal to zero
4494(in other words, this is equivalent to @code{.if}).
4495
4496@cindex @code{ifnes} directive
4497@item .ifnes @var{string1},@var{string2}
4498Like @code{.ifeqs}, but the sense of the test is reversed: this assembles the
4499following section of code if the two strings are not the same.
4500@end table
4501
7e005732
NC
4502@node Incbin
4503@section @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]}
4504
4505@cindex @code{incbin} directive
4506@cindex binary files, including
4507The @code{incbin} directive includes @var{file} verbatim at the current
4508location. You can control the search paths used with the @samp{-I} command-line
4509option (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
4510around @var{file}.
4511
4512The @var{skip} argument skips a number of bytes from the start of the
4513@var{file}. The @var{count} argument indicates the maximum number of bytes to
15dcfbc3
NC
4514read. Note that the data is not aligned in any way, so it is the user's
4515responsibility to make sure that proper alignment is provided both before and
4516after the @code{incbin} directive.
7e005732 4517
252b5132
RH
4518@node Include
4519@section @code{.include "@var{file}"}
4520
4521@cindex @code{include} directive
4522@cindex supporting files, including
4523@cindex files, including
4524This directive provides a way to include supporting files at specified
4525points in your source program. The code from @var{file} is assembled as
4526if it followed the point of the @code{.include}; when the end of the
4527included file is reached, assembly of the original file continues. You
4528can control the search paths used with the @samp{-I} command-line option
4529(@pxref{Invoking,,Command-Line Options}). Quotation marks are required
4530around @var{file}.
4531
4532@node Int
4533@section @code{.int @var{expressions}}
4534
4535@cindex @code{int} directive
4536@cindex integers, 32-bit
4537Expect zero or more @var{expressions}, of any section, separated by commas.
4538For each expression, emit a number that, at run time, is the value of that
4539expression. The byte order and bit size of the number depends on what kind
4540of target the assembly is for.
4541
4542@ifclear GENERIC
4543@ifset H8
4544On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
c2dcd04e 4545integers. On the H8/300H and the Renesas SH, however, @code{.int} emits
252b5132
RH
454632-bit integers.
4547@end ifset
4548@end ifclear
4549
c91d2e08
NC
4550@ifset ELF
4551@node Internal
4552@section @code{.internal @var{names}}
4553
c1253627
NC
4554@cindex @code{internal} directive
4555@cindex visibility
ed9589d4 4556This is one of the ELF visibility directives. The other two are
a349d9dd
PB
4557@code{.hidden} (@pxref{Hidden,,@code{.hidden}}) and
4558@code{.protected} (@pxref{Protected,,@code{.protected}}).
c91d2e08
NC
4559
4560This directive overrides the named symbols default visibility (which is set by
4561their binding: local, global or weak). The directive sets the visibility to
4562@code{internal} which means that the symbols are considered to be @code{hidden}
c1253627 4563(i.e., not visible to other components), and that some extra, processor specific
c91d2e08
NC
4564processing must also be performed upon the symbols as well.
4565@end ifset
4566
252b5132
RH
4567@node Irp
4568@section @code{.irp @var{symbol},@var{values}}@dots{}
4569
4570@cindex @code{irp} directive
4571Evaluate a sequence of statements assigning different values to @var{symbol}.
4572The sequence of statements starts at the @code{.irp} directive, and is
4573terminated by an @code{.endr} directive. For each @var{value}, @var{symbol} is
4574set to @var{value}, and the sequence of statements is assembled. If no
4575@var{value} is listed, the sequence of statements is assembled once, with
4576@var{symbol} set to the null string. To refer to @var{symbol} within the
4577sequence of statements, use @var{\symbol}.
4578
4579For example, assembling
4580
4581@example
4582 .irp param,1,2,3
4583 move d\param,sp@@-
4584 .endr
4585@end example
4586
4587is equivalent to assembling
4588
4589@example
4590 move d1,sp@@-
4591 move d2,sp@@-
4592 move d3,sp@@-
4593@end example
4594
4595@node Irpc
4596@section @code{.irpc @var{symbol},@var{values}}@dots{}
4597
4598@cindex @code{irpc} directive
4599Evaluate a sequence of statements assigning different values to @var{symbol}.
4600The sequence of statements starts at the @code{.irpc} directive, and is
4601terminated by an @code{.endr} directive. For each character in @var{value},
4602@var{symbol} is set to the character, and the sequence of statements is
4603assembled. If no @var{value} is listed, the sequence of statements is
4604assembled once, with @var{symbol} set to the null string. To refer to
4605@var{symbol} within the sequence of statements, use @var{\symbol}.
4606
4607For example, assembling
4608
4609@example
4610 .irpc param,123
4611 move d\param,sp@@-
4612 .endr
4613@end example
4614
4615is equivalent to assembling
4616
4617@example
4618 move d1,sp@@-
4619 move d2,sp@@-
4620 move d3,sp@@-
4621@end example
4622
4623@node Lcomm
4624@section @code{.lcomm @var{symbol} , @var{length}}
4625
4626@cindex @code{lcomm} directive
4627@cindex local common symbols
4628@cindex symbols, local common
4629Reserve @var{length} (an absolute expression) bytes for a local common
4630denoted by @var{symbol}. The section and value of @var{symbol} are
4631those of the new local common. The addresses are allocated in the bss
4632section, so that at run-time the bytes start off zeroed. @var{Symbol}
4633is not declared global (@pxref{Global,,@code{.global}}), so is normally
4634not visible to @code{@value{LD}}.
4635
4636@ifset GENERIC
4637Some targets permit a third argument to be used with @code{.lcomm}. This
4638argument specifies the desired alignment of the symbol in the bss section.
4639@end ifset
4640
4641@ifset HPPA
4642The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
4643@samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
4644@end ifset
4645
4646@node Lflags
4647@section @code{.lflags}
4648
4649@cindex @code{lflags} directive (ignored)
a4fb0134 4650@command{@value{AS}} accepts this directive, for compatibility with other
252b5132
RH
4651assemblers, but ignores it.
4652
4653@ifclear no-line-dir
4654@node Line
4655@section @code{.line @var{line-number}}
4656
4657@cindex @code{line} directive
4658@end ifclear
4659@ifset no-line-dir
4660@node Ln
4661@section @code{.ln @var{line-number}}
4662
4663@cindex @code{ln} directive
4664@end ifset
4665@cindex logical line number
4666@ifset aout-bout
4667Change the logical line number. @var{line-number} must be an absolute
4668expression. The next line has that logical line number. Therefore any other
4669statements on the current line (after a statement separator character) are
4670reported as on logical line number @var{line-number} @minus{} 1. One day
a4fb0134 4671@command{@value{AS}} will no longer support this directive: it is recognized only
252b5132
RH
4672for compatibility with existing assembler programs.
4673
4674@ifset GENERIC
4675@ifset A29K
4676@emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
4677not available; use the synonym @code{.ln} in that context.
4678@end ifset
4679@end ifset
4680@end ifset
4681
4682@ifclear no-line-dir
4683Even though this is a directive associated with the @code{a.out} or
a4fb0134 4684@code{b.out} object-code formats, @command{@value{AS}} still recognizes it
252b5132
RH
4685when producing COFF output, and treats @samp{.line} as though it
4686were the COFF @samp{.ln} @emph{if} it is found outside a
4687@code{.def}/@code{.endef} pair.
4688
4689Inside a @code{.def}, @samp{.line} is, instead, one of the directives
4690used by compilers to generate auxiliary symbol information for
4691debugging.
4692@end ifclear
4693
4694@node Linkonce
4695@section @code{.linkonce [@var{type}]}
4696@cindex COMDAT
4697@cindex @code{linkonce} directive
4698@cindex common sections
4699Mark the current section so that the linker only includes a single copy of it.
4700This may be used to include the same section in several different object files,
4701but ensure that the linker will only include it once in the final output file.
4702The @code{.linkonce} pseudo-op must be used for each instance of the section.
4703Duplicate sections are detected based on the section name, so it should be
4704unique.
4705
4706This directive is only supported by a few object file formats; as of this
4707writing, the only object file format which supports it is the Portable
4708Executable format used on Windows NT.
4709
4710The @var{type} argument is optional. If specified, it must be one of the
4711following strings. For example:
4712@smallexample
4713.linkonce same_size
4714@end smallexample
4715Not all types may be supported on all object file formats.
4716
4717@table @code
4718@item discard
4719Silently discard duplicate sections. This is the default.
4720
4721@item one_only
4722Warn if there are duplicate sections, but still keep only one copy.
4723
4724@item same_size
4725Warn if any of the duplicates have different sizes.
4726
4727@item same_contents
4728Warn if any of the duplicates do not have exactly the same contents.
4729@end table
4730
4731@node Ln
4732@section @code{.ln @var{line-number}}
4733
4734@cindex @code{ln} directive
4735@ifclear no-line-dir
4736@samp{.ln} is a synonym for @samp{.line}.
4737@end ifclear
4738@ifset no-line-dir
a4fb0134 4739Tell @command{@value{AS}} to change the logical line number. @var{line-number}
252b5132
RH
4740must be an absolute expression. The next line has that logical
4741line number, so any other statements on the current line (after a
4742statement separator character @code{;}) are reported as on logical
4743line number @var{line-number} @minus{} 1.
4744@ifset BOUT
4745
a4fb0134 4746This directive is accepted, but ignored, when @command{@value{AS}} is
252b5132
RH
4747configured for @code{b.out}; its effect is only associated with COFF
4748output format.
4749@end ifset
4750@end ifset
4751
4752@node MRI
4753@section @code{.mri @var{val}}
4754
4755@cindex @code{mri} directive
4756@cindex MRI mode, temporarily
a4fb0134
SC
4757If @var{val} is non-zero, this tells @command{@value{AS}} to enter MRI mode. If
4758@var{val} is zero, this tells @command{@value{AS}} to exit MRI mode. This change
252b5132
RH
4759affects code assembled until the next @code{.mri} directive, or until the end
4760of the file. @xref{M, MRI mode, MRI mode}.
4761
4762@node List
4763@section @code{.list}
4764
4765@cindex @code{list} directive
4766@cindex listing control, turning on
4767Control (in conjunction with the @code{.nolist} directive) whether or
4768not assembly listings are generated. These two directives maintain an
4769internal counter (which is zero initially). @code{.list} increments the
4770counter, and @code{.nolist} decrements it. Assembly listings are
4771generated whenever the counter is greater than zero.
4772
4773By default, listings are disabled. When you enable them (with the
4774@samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
4775the initial value of the listing counter is one.
4776
4777@node Long
4778@section @code{.long @var{expressions}}
4779
4780@cindex @code{long} directive
4781@code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
4782
4783@ignore
4784@c no one seems to know what this is for or whether this description is
4785@c what it really ought to do
4786@node Lsym
4787@section @code{.lsym @var{symbol}, @var{expression}}
4788
4789@cindex @code{lsym} directive
4790@cindex symbol, not referenced in assembly
4791@code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
4792the hash table, ensuring it cannot be referenced by name during the
4793rest of the assembly. This sets the attributes of the symbol to be
4794the same as the expression value:
4795@smallexample
4796@var{other} = @var{descriptor} = 0
4797@var{type} = @r{(section of @var{expression})}
4798@var{value} = @var{expression}
4799@end smallexample
4800@noindent
4801The new symbol is not flagged as external.
4802@end ignore
4803
4804@node Macro
4805@section @code{.macro}
4806
4807@cindex macros
4808The commands @code{.macro} and @code{.endm} allow you to define macros that
4809generate assembly output. For example, this definition specifies a macro
4810@code{sum} that puts a sequence of numbers into memory:
4811
4812@example
4813 .macro sum from=0, to=5
4814 .long \from
4815 .if \to-\from
4816 sum "(\from+1)",\to
4817 .endif
4818 .endm
4819@end example
4820
4821@noindent
4822With that definition, @samp{SUM 0,5} is equivalent to this assembly input:
4823
4824@example
4825 .long 0
4826 .long 1
4827 .long 2
4828 .long 3
4829 .long 4
4830 .long 5
4831@end example
4832
4833@ftable @code
4834@item .macro @var{macname}
4835@itemx .macro @var{macname} @var{macargs} @dots{}
4836@cindex @code{macro} directive
4837Begin the definition of a macro called @var{macname}. If your macro
4838definition requires arguments, specify their names after the macro name,
4839separated by commas or spaces. You can supply a default value for any
4840macro argument by following the name with @samp{=@var{deflt}}. For
4841example, these are all valid @code{.macro} statements:
4842
4843@table @code
4844@item .macro comm
4845Begin the definition of a macro called @code{comm}, which takes no
4846arguments.
4847
4848@item .macro plus1 p, p1
4849@itemx .macro plus1 p p1
4850Either statement begins the definition of a macro called @code{plus1},
4851which takes two arguments; within the macro definition, write
4852@samp{\p} or @samp{\p1} to evaluate the arguments.
4853
4854@item .macro reserve_str p1=0 p2
4855Begin the definition of a macro called @code{reserve_str}, with two
4856arguments. The first argument has a default value, but not the second.
4857After the definition is complete, you can call the macro either as
4858@samp{reserve_str @var{a},@var{b}} (with @samp{\p1} evaluating to
4859@var{a} and @samp{\p2} evaluating to @var{b}), or as @samp{reserve_str
4860,@var{b}} (with @samp{\p1} evaluating as the default, in this case
4861@samp{0}, and @samp{\p2} evaluating to @var{b}).
4862@end table
4863
4864When you call a macro, you can specify the argument values either by
4865position, or by keyword. For example, @samp{sum 9,17} is equivalent to
4866@samp{sum to=17, from=9}.
4867
4868@item .endm
4869@cindex @code{endm} directive
4870Mark the end of a macro definition.
4871
4872@item .exitm
4873@cindex @code{exitm} directive
4874Exit early from the current macro definition.
4875
4876@cindex number of macros executed
4877@cindex macros, count executed
4878@item \@@
a4fb0134 4879@command{@value{AS}} maintains a counter of how many macros it has
252b5132
RH
4880executed in this pseudo-variable; you can copy that number to your
4881output with @samp{\@@}, but @emph{only within a macro definition}.
4882
252b5132
RH
4883@item LOCAL @var{name} [ , @dots{} ]
4884@emph{Warning: @code{LOCAL} is only available if you select ``alternate
caa32fe5
NC
4885macro syntax'' with @samp{--alternate} or @code{.altmacro}.}
4886@xref{Altmacro,,@code{.altmacro}}.
4887@end ftable
252b5132 4888
caa32fe5
NC
4889@node Altmacro
4890@section @code{.altmacro}
4891Enable alternate macro mode, enabling:
4892
4893@ftable @code
4894@item LOCAL @var{name} [ , @dots{} ]
4895One additional directive, @code{LOCAL}, is available. It is used to
4896generate a string replacement for each of the @var{name} arguments, and
252b5132
RH
4897replace any instances of @var{name} in each macro expansion. The
4898replacement string is unique in the assembly, and different for each
4899separate macro expansion. @code{LOCAL} allows you to write macros that
4900define symbols, without fear of conflict between separate macro expansions.
caa32fe5
NC
4901
4902@item String delimiters
4903You can write strings delimited in these other ways besides
4904@code{"@var{string}"}:
4905
4906@table @code
4907@item '@var{string}'
4908You can delimit strings with single-quote charaters.
4909
4910@item <@var{string}>
4911You can delimit strings with matching angle brackets.
4912@end table
4913
4914@item single-character string escape
4915To include any single character literally in a string (even if the
4916character would otherwise have some special meaning), you can prefix the
4917character with @samp{!} (an exclamation mark). For example, you can
4918write @samp{<4.3 !> 5.4!!>} to get the literal text @samp{4.3 > 5.4!}.
4919
4920@item Expression results as strings
4921You can write @samp{%@var{expr}} to evaluate the expression @var{expr}
4922and use the result as a string.
252b5132
RH
4923@end ftable
4924
caa32fe5
NC
4925@node Noaltmacro
4926@section @code{.noaltmacro}
4927Disable alternate macro mode. @ref{Altmacro}
4928
252b5132
RH
4929@node Nolist
4930@section @code{.nolist}
4931
4932@cindex @code{nolist} directive
4933@cindex listing control, turning off
4934Control (in conjunction with the @code{.list} directive) whether or
4935not assembly listings are generated. These two directives maintain an
4936internal counter (which is zero initially). @code{.list} increments the
4937counter, and @code{.nolist} decrements it. Assembly listings are
4938generated whenever the counter is greater than zero.
4939
4940@node Octa
4941@section @code{.octa @var{bignums}}
4942
4943@c FIXME: double size emitted for "octa" on i960, others? Or warn?
4944@cindex @code{octa} directive
4945@cindex integer, 16-byte
4946@cindex sixteen byte integer
4947This directive expects zero or more bignums, separated by commas. For each
4948bignum, it emits a 16-byte integer.
4949
4950The term ``octa'' comes from contexts in which a ``word'' is two bytes;
4951hence @emph{octa}-word for 16 bytes.
4952
4953@node Org
4954@section @code{.org @var{new-lc} , @var{fill}}
4955
4956@cindex @code{org} directive
4957@cindex location counter, advancing
4958@cindex advancing location counter
4959@cindex current address, advancing
4960Advance the location counter of the current section to
4961@var{new-lc}. @var{new-lc} is either an absolute expression or an
4962expression with the same section as the current subsection. That is,
4963you can't use @code{.org} to cross sections: if @var{new-lc} has the
4964wrong section, the @code{.org} directive is ignored. To be compatible
4965with former assemblers, if the section of @var{new-lc} is absolute,
a4fb0134 4966@command{@value{AS}} issues a warning, then pretends the section of @var{new-lc}
252b5132
RH
4967is the same as the current subsection.
4968
4969@code{.org} may only increase the location counter, or leave it
4970unchanged; you cannot use @code{.org} to move the location counter
4971backwards.
4972
4973@c double negative used below "not undefined" because this is a specific
4974@c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
4975@c section. doc@cygnus.com 18feb91
a4fb0134 4976Because @command{@value{AS}} tries to assemble programs in one pass, @var{new-lc}
252b5132
RH
4977may not be undefined. If you really detest this restriction we eagerly await
4978a chance to share your improved assembler.
4979
4980Beware that the origin is relative to the start of the section, not
4981to the start of the subsection. This is compatible with other
4982people's assemblers.
4983
4984When the location counter (of the current subsection) is advanced, the
4985intervening bytes are filled with @var{fill} which should be an
4986absolute expression. If the comma and @var{fill} are omitted,
4987@var{fill} defaults to zero.
4988
4989@node P2align
4990@section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
4991
4992@cindex padding the location counter given a power of two
4993@cindex @code{p2align} directive
4994Pad the location counter (in the current subsection) to a particular
4995storage boundary. The first expression (which must be absolute) is the
4996number of low-order zero bits the location counter must have after
4997advancement. For example @samp{.p2align 3} advances the location
4998counter until it a multiple of 8. If the location counter is already a
4999multiple of 8, no change is needed.
5000
5001The second expression (also absolute) gives the fill value to be stored in the
5002padding bytes. It (and the comma) may be omitted. If it is omitted, the
5003padding bytes are normally zero. However, on some systems, if the section is
5004marked as containing code and the fill value is omitted, the space is filled
5005with no-op instructions.
5006
5007The third expression is also absolute, and is also optional. If it is present,
5008it is the maximum number of bytes that should be skipped by this alignment
5009directive. If doing the alignment would require skipping more bytes than the
5010specified maximum, then the alignment is not done at all. You can omit the
5011fill value (the second argument) entirely by simply using two commas after the
5012required alignment; this can be useful if you want the alignment to be filled
5013with no-op instructions when appropriate.
5014
5015@cindex @code{p2alignw} directive
5016@cindex @code{p2alignl} directive
5017The @code{.p2alignw} and @code{.p2alignl} directives are variants of the
5018@code{.p2align} directive. The @code{.p2alignw} directive treats the fill
5019pattern as a two byte word value. The @code{.p2alignl} directives treats the
5020fill pattern as a four byte longword value. For example, @code{.p2alignw
50212,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
5022filled in with the value 0x368d (the exact placement of the bytes depends upon
5023the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
5024undefined.
5025
c91d2e08
NC
5026@ifset ELF
5027@node Previous
5028@section @code{.previous}
5029
c1253627 5030@cindex @code{previous} directive
c91d2e08
NC
5031@cindex Section Stack
5032This is one of the ELF section stack manipulation directives. The others are
a349d9dd
PB
5033@code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5034@code{.pushsection} (@pxref{PushSection}), and @code{.popsection}
5035(@pxref{PopSection}).
c91d2e08
NC
5036
5037This directive swaps the current section (and subsection) with most recently
5038referenced section (and subsection) prior to this one. Multiple
5039@code{.previous} directives in a row will flip between two sections (and their
5040subsections).
5041
5042In terms of the section stack, this directive swaps the current section with
5043the top section on the section stack.
5044@end ifset
5045
5046@ifset ELF
5047@node PopSection
5048@section @code{.popsection}
5049
c1253627 5050@cindex @code{popsection} directive
c91d2e08
NC
5051@cindex Section Stack
5052This is one of the ELF section stack manipulation directives. The others are
a349d9dd
PB
5053@code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5054@code{.pushsection} (@pxref{PushSection}), and @code{.previous}
5055(@pxref{Previous}).
c91d2e08
NC
5056
5057This directive replaces the current section (and subsection) with the top
5058section (and subsection) on the section stack. This section is popped off the
5059stack.
c91d2e08
NC
5060@end ifset
5061
252b5132
RH
5062@node Print
5063@section @code{.print @var{string}}
5064
5065@cindex @code{print} directive
a4fb0134 5066@command{@value{AS}} will print @var{string} on the standard output during
252b5132
RH
5067assembly. You must put @var{string} in double quotes.
5068
c91d2e08
NC
5069@ifset ELF
5070@node Protected
5071@section @code{.protected @var{names}}
5072
c1253627
NC
5073@cindex @code{protected} directive
5074@cindex visibility
ed9589d4 5075This is one of the ELF visibility directives. The other two are
a349d9dd 5076@code{.hidden} (@pxref{Hidden}) and @code{.internal} (@pxref{Internal}).
c91d2e08
NC
5077
5078This directive overrides the named symbols default visibility (which is set by
5079their binding: local, global or weak). The directive sets the visibility to
5080@code{protected} which means that any references to the symbols from within the
5081components that defines them must be resolved to the definition in that
5082component, even if a definition in another component would normally preempt
5083this.
5084@end ifset
5085
252b5132
RH
5086@node Psize
5087@section @code{.psize @var{lines} , @var{columns}}
5088
5089@cindex @code{psize} directive
5090@cindex listing control: paper size
5091@cindex paper size, for listings
5092Use this directive to declare the number of lines---and, optionally, the
5093number of columns---to use for each page, when generating listings.
5094
5095If you do not use @code{.psize}, listings use a default line-count
5096of 60. You may omit the comma and @var{columns} specification; the
5097default width is 200 columns.
5098
a4fb0134 5099@command{@value{AS}} generates formfeeds whenever the specified number of
252b5132
RH
5100lines is exceeded (or whenever you explicitly request one, using
5101@code{.eject}).
5102
5103If you specify @var{lines} as @code{0}, no formfeeds are generated save
5104those explicitly specified with @code{.eject}.
5105
5106@node Purgem
5107@section @code{.purgem @var{name}}
5108
5109@cindex @code{purgem} directive
5110Undefine the macro @var{name}, so that later uses of the string will not be
5111expanded. @xref{Macro}.
5112
c91d2e08
NC
5113@ifset ELF
5114@node PushSection
5115@section @code{.pushsection @var{name} , @var{subsection}}
5116
c1253627 5117@cindex @code{pushsection} directive
c91d2e08
NC
5118@cindex Section Stack
5119This is one of the ELF section stack manipulation directives. The others are
a349d9dd
PB
5120@code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}),
5121@code{.popsection} (@pxref{PopSection}), and @code{.previous}
5122(@pxref{Previous}).
c91d2e08 5123
e9863d7f
DJ
5124This directive pushes the current section (and subsection) onto the
5125top of the section stack, and then replaces the current section and
5126subsection with @code{name} and @code{subsection}.
c91d2e08
NC
5127@end ifset
5128
252b5132
RH
5129@node Quad
5130@section @code{.quad @var{bignums}}
5131
5132@cindex @code{quad} directive
5133@code{.quad} expects zero or more bignums, separated by commas. For
5134each bignum, it emits
5135@ifclear bignum-16
5136an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
5137warning message; and just takes the lowest order 8 bytes of the bignum.
5138@cindex eight-byte integer
5139@cindex integer, 8-byte
5140
5141The term ``quad'' comes from contexts in which a ``word'' is two bytes;
5142hence @emph{quad}-word for 8 bytes.
5143@end ifclear
5144@ifset bignum-16
5145a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
5146warning message; and just takes the lowest order 16 bytes of the bignum.
5147@cindex sixteen-byte integer
5148@cindex integer, 16-byte
5149@end ifset
5150
5151@node Rept
5152@section @code{.rept @var{count}}
5153
5154@cindex @code{rept} directive
5155Repeat the sequence of lines between the @code{.rept} directive and the next
5156@code{.endr} directive @var{count} times.
5157
5158For example, assembling
5159
5160@example
5161 .rept 3
5162 .long 0
5163 .endr
5164@end example
5165
5166is equivalent to assembling
5167
5168@example
5169 .long 0
5170 .long 0
5171 .long 0
5172@end example
5173
5174@node Sbttl
5175@section @code{.sbttl "@var{subheading}"}
5176
5177@cindex @code{sbttl} directive
5178@cindex subtitles for listings
5179@cindex listing control: subtitle
5180Use @var{subheading} as the title (third line, immediately after the
5181title line) when generating assembly listings.
5182
5183This directive affects subsequent pages, as well as the current page if
5184it appears within ten lines of the top of a page.
5185
5186@ifset COFF
5187@node Scl
5188@section @code{.scl @var{class}}
5189
5190@cindex @code{scl} directive
5191@cindex symbol storage class (COFF)
5192@cindex COFF symbol storage class
5193Set the storage-class value for a symbol. This directive may only be
5194used inside a @code{.def}/@code{.endef} pair. Storage class may flag
5195whether a symbol is static or external, or it may record further
5196symbolic debugging information.
5197@ifset BOUT
5198
5199The @samp{.scl} directive is primarily associated with COFF output; when
a4fb0134 5200configured to generate @code{b.out} output format, @command{@value{AS}}
252b5132
RH
5201accepts this directive but ignores it.
5202@end ifset
5203@end ifset
5204
c1253627 5205@ifset COFF-ELF
252b5132 5206@node Section
c1253627 5207@section @code{.section @var{name}}
252b5132 5208
252b5132
RH
5209@cindex named section
5210Use the @code{.section} directive to assemble the following code into a section
5211named @var{name}.
5212
5213This directive is only supported for targets that actually support arbitrarily
5214named sections; on @code{a.out} targets, for example, it is not accepted, even
5215with a standard @code{a.out} section name.
5216
c1253627
NC
5217@ifset COFF
5218@ifset ELF
5219@c only print the extra heading if both COFF and ELF are set
5220@subheading COFF Version
5221@end ifset
5222
5223@cindex @code{section} directive (COFF version)
252b5132
RH
5224For COFF targets, the @code{.section} directive is used in one of the following
5225ways:
c91d2e08 5226
252b5132
RH
5227@smallexample
5228.section @var{name}[, "@var{flags}"]
5229.section @var{name}[, @var{subsegment}]
5230@end smallexample
5231
5232If the optional argument is quoted, it is taken as flags to use for the
5233section. Each flag is a single character. The following flags are recognized:
5234@table @code
5235@item b
5236bss section (uninitialized data)
5237@item n
5238section is not loaded
5239@item w
5240writable section
5241@item d
5242data section
5243@item r
5244read-only section
5245@item x
5246executable section
2dcc60be
ILT
5247@item s
5248shared section (meaningful for PE targets)
6ff96af6
NC
5249@item a
5250ignored. (For compatibility with the ELF version)
252b5132
RH
5251@end table
5252
5253If no flags are specified, the default flags depend upon the section name. If
5254the section name is not recognized, the default will be for the section to be
7e84d676
NC
5255loaded and writable. Note the @code{n} and @code{w} flags remove attributes
5256from the section, rather than adding them, so if they are used on their own it
5257will be as if no flags had been specified at all.
252b5132
RH
5258
5259If the optional argument to the @code{.section} directive is not quoted, it is
5260taken as a subsegment number (@pxref{Sub-Sections}).
c1253627 5261@end ifset
252b5132
RH
5262
5263@ifset ELF
c1253627
NC
5264@ifset COFF
5265@c only print the extra heading if both COFF and ELF are set
5266@subheading ELF Version
5267@end ifset
5268
c91d2e08
NC
5269@cindex Section Stack
5270This is one of the ELF section stack manipulation directives. The others are
a349d9dd
PB
5271@code{.subsection} (@pxref{SubSection}), @code{.pushsection}
5272(@pxref{PushSection}), @code{.popsection} (@pxref{PopSection}), and
5273@code{.previous} (@pxref{Previous}).
c91d2e08 5274
c1253627 5275@cindex @code{section} directive (ELF version)
252b5132 5276For ELF targets, the @code{.section} directive is used like this:
c91d2e08 5277
252b5132 5278@smallexample
22fe14ad 5279.section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]
252b5132 5280@end smallexample
c91d2e08 5281
252b5132 5282The optional @var{flags} argument is a quoted string which may contain any
a349d9dd 5283combination of the following characters:
252b5132
RH
5284@table @code
5285@item a
5286section is allocatable
5287@item w
5288section is writable
5289@item x
5290section is executable
ec38dd05
JJ
5291@item M
5292section is mergeable
5293@item S
5294section contains zero terminated strings
22fe14ad
NC
5295@item G
5296section is a member of a section group
5297@item T
5298section is used for thread-local-storage
252b5132
RH
5299@end table
5300
5301The optional @var{type} argument may contain one of the following constants:
5302@table @code
5303@item @@progbits
5304section contains data
5305@item @@nobits
5306section does not contain data (i.e., section only occupies space)
22fe14ad
NC
5307@item @@note
5308section contains data which is used by things other than the program
10b016c2
PB
5309@item @@init_array
5310section contains an array of pointers to init functions
5311@item @@fini_array
5312section contains an array of pointers to finish functions
5313@item @@preinit_array
5314section contains an array of pointers to pre-init functions
252b5132
RH
5315@end table
5316
10b016c2
PB
5317Many targets only support the first three section types.
5318
ececec60
NC
5319Note on targets where the @code{@@} character is the start of a comment (eg
5320ARM) then another character is used instead. For example the ARM port uses the
5321@code{%} character.
5322
22fe14ad
NC
5323If @var{flags} contains the @code{M} symbol then the @var{type} argument must
5324be specified as well as an extra argument - @var{entsize} - like this:
5325
5326@smallexample
5327.section @var{name} , "@var{flags}"M, @@@var{type}, @var{entsize}
5328@end smallexample
5329
5330Sections with the @code{M} flag but not @code{S} flag must contain fixed size
5331constants, each @var{entsize} octets long. Sections with both @code{M} and
5332@code{S} must contain zero terminated strings where each character is
5333@var{entsize} bytes long. The linker may remove duplicates within sections with
5334the same name, same entity size and same flags. @var{entsize} must be an
5335absolute expression.
5336
5337If @var{flags} contains the @code{G} symbol then the @var{type} argument must
5338be present along with an additional field like this:
5339
5340@smallexample
5341.section @var{name} , "@var{flags}"G, @@@var{type}, @var{GroupName}[, @var{linkage}]
5342@end smallexample
5343
5344The @var{GroupName} field specifies the name of the section group to which this
5345particular section belongs. The optional linkage field can contain:
5346@table @code
5347@item comdat
5348indicates that only one copy of this section should be retained
5349@item .gnu.linkonce
5350an alias for comdat
5351@end table
5352
5353Note - if both the @var{M} and @var{G} flags are present then the fields for
5354the Merge flag should come first, like this:
5355
5356@smallexample
5357.section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}]
5358@end smallexample
ec38dd05 5359
252b5132
RH
5360If no flags are specified, the default flags depend upon the section name. If
5361the section name is not recognized, the default will be for the section to have
5362none of the above flags: it will not be allocated in memory, nor writable, nor
5363executable. The section will contain data.
5364
5365For ELF targets, the assembler supports another type of @code{.section}
5366directive for compatibility with the Solaris assembler:
c91d2e08 5367
252b5132
RH
5368@smallexample
5369.section "@var{name}"[, @var{flags}...]
5370@end smallexample
c91d2e08 5371
252b5132
RH
5372Note that the section name is quoted. There may be a sequence of comma
5373separated flags:
5374@table @code
5375@item #alloc
5376section is allocatable
5377@item #write
5378section is writable
5379@item #execinstr
5380section is executable
22fe14ad
NC
5381@item #tls
5382section is used for thread local storage
252b5132 5383@end table
c91d2e08 5384
e9863d7f
DJ
5385This directive replaces the current section and subsection. See the
5386contents of the gas testsuite directory @code{gas/testsuite/gas/elf} for
5387some examples of how this directive and the other section stack directives
5388work.
c1253627
NC
5389@end ifset
5390@end ifset
252b5132
RH
5391
5392@node Set
5393@section @code{.set @var{symbol}, @var{expression}}
5394
5395@cindex @code{set} directive
5396@cindex symbol value, setting
5397Set the value of @var{symbol} to @var{expression}. This
5398changes @var{symbol}'s value and type to conform to
5399@var{expression}. If @var{symbol} was flagged as external, it remains
5400flagged (@pxref{Symbol Attributes}).
5401
5402You may @code{.set} a symbol many times in the same assembly.
5403
5404If you @code{.set} a global symbol, the value stored in the object
5405file is the last value stored into it.
5406
5407@ifset HPPA
5408The syntax for @code{set} on the HPPA is
5409@samp{@var{symbol} .set @var{expression}}.
5410@end ifset
5411
5412@node Short
5413@section @code{.short @var{expressions}}
5414
5415@cindex @code{short} directive
5416@ifset GENERIC
5417@code{.short} is normally the same as @samp{.word}.
5418@xref{Word,,@code{.word}}.
5419
5420In some configurations, however, @code{.short} and @code{.word} generate
5421numbers of different lengths; @pxref{Machine Dependencies}.
5422@end ifset
5423@ifclear GENERIC
5424@ifset W16
5425@code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
5426@end ifset
5427@ifset W32
5428This expects zero or more @var{expressions}, and emits
5429a 16 bit number for each.
5430@end ifset
5431@end ifclear
5432
5433@node Single
5434@section @code{.single @var{flonums}}
5435
5436@cindex @code{single} directive
5437@cindex floating point numbers (single)
5438This directive assembles zero or more flonums, separated by commas. It
5439has the same effect as @code{.float}.
5440@ifset GENERIC
5441The exact kind of floating point numbers emitted depends on how
a4fb0134 5442@command{@value{AS}} is configured. @xref{Machine Dependencies}.
252b5132
RH
5443@end ifset
5444@ifclear GENERIC
5445@ifset IEEEFLOAT
5446On the @value{TARGET} family, @code{.single} emits 32-bit floating point
5447numbers in @sc{ieee} format.
5448@end ifset
5449@end ifclear
5450
c1253627 5451@ifset COFF-ELF
252b5132 5452@node Size
c1253627 5453@section @code{.size}
c91d2e08 5454
c1253627
NC
5455This directive is used to set the size associated with a symbol.
5456
5457@ifset COFF
5458@ifset ELF
5459@c only print the extra heading if both COFF and ELF are set
5460@subheading COFF Version
5461@end ifset
5462
5463@cindex @code{size} directive (COFF version)
5464For COFF targets, the @code{.size} directive is only permitted inside
5465@code{.def}/@code{.endef} pairs. It is used like this:
5466
5467@smallexample
5468.size @var{expression}
5469@end smallexample
252b5132 5470
c91d2e08 5471@ifset BOUT
252b5132 5472@samp{.size} is only meaningful when generating COFF format output; when
a4fb0134 5473@command{@value{AS}} is generating @code{b.out}, it accepts this directive but
252b5132
RH
5474ignores it.
5475@end ifset
c1253627 5476@end ifset
c91d2e08 5477
c1253627
NC
5478@ifset ELF
5479@ifset COFF
5480@c only print the extra heading if both COFF and ELF are set
5481@subheading ELF Version
5482@end ifset
5483
5484@cindex @code{size} directive (ELF version)
5485For ELF targets, the @code{.size} directive is used like this:
c91d2e08 5486
c1253627
NC
5487@smallexample
5488.size @var{name} , @var{expression}
5489@end smallexample
5490
5491This directive sets the size associated with a symbol @var{name}.
c91d2e08
NC
5492The size in bytes is computed from @var{expression} which can make use of label
5493arithmetic. This directive is typically used to set the size of function
5494symbols.
c1253627
NC
5495@end ifset
5496@end ifset
252b5132
RH
5497
5498@node Sleb128
5499@section @code{.sleb128 @var{expressions}}
5500
5501@cindex @code{sleb128} directive
5502@var{sleb128} stands for ``signed little endian base 128.'' This is a
5503compact, variable length representation of numbers used by the DWARF
5504symbolic debugging format. @xref{Uleb128,@code{.uleb128}}.
5505
5506@ifclear no-space-dir
5507@node Skip
5508@section @code{.skip @var{size} , @var{fill}}
5509
5510@cindex @code{skip} directive
5511@cindex filling memory
5512This directive emits @var{size} bytes, each of value @var{fill}. Both
5513@var{size} and @var{fill} are absolute expressions. If the comma and
5514@var{fill} are omitted, @var{fill} is assumed to be zero. This is the same as
5515@samp{.space}.
5516
5517@node Space
5518@section @code{.space @var{size} , @var{fill}}
5519
5520@cindex @code{space} directive
5521@cindex filling memory
5522This directive emits @var{size} bytes, each of value @var{fill}. Both
5523@var{size} and @var{fill} are absolute expressions. If the comma
5524and @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same
5525as @samp{.skip}.
5526
5527@ifset HPPA
5528@quotation
5529@emph{Warning:} @code{.space} has a completely different meaning for HPPA
5530targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
5531Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the
5532@code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives},
5533for a summary.
5534@end quotation
5535@end ifset
5536@end ifclear
5537
5538@ifset A29K
5539@ifclear GENERIC
5540@node Space
5541@section @code{.space}
5542@cindex @code{space} directive
5543@end ifclear
5544On the AMD 29K, this directive is ignored; it is accepted for
5545compatibility with other AMD 29K assemblers.
5546
5547@quotation
5548@emph{Warning:} In most versions of the @sc{gnu} assembler, the directive
5549@code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
5550@end quotation
5551@end ifset
5552
5553@ifset have-stabs
5554@node Stab
5555@section @code{.stabd, .stabn, .stabs}
5556
5557@cindex symbolic debuggers, information for
5558@cindex @code{stab@var{x}} directives
5559There are three directives that begin @samp{.stab}.
5560All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
a4fb0134 5561The symbols are not entered in the @command{@value{AS}} hash table: they
252b5132
RH
5562cannot be referenced elsewhere in the source file.
5563Up to five fields are required:
5564
5565@table @var
5566@item string
5567This is the symbol's name. It may contain any character except
5568@samp{\000}, so is more general than ordinary symbol names. Some
5569debuggers used to code arbitrarily complex structures into symbol names
5570using this field.
5571
5572@item type
5573An absolute expression. The symbol's type is set to the low 8 bits of
5574this expression. Any bit pattern is permitted, but @code{@value{LD}}
5575and debuggers choke on silly bit patterns.
5576
5577@item other
5578An absolute expression. The symbol's ``other'' attribute is set to the
5579low 8 bits of this expression.
5580
5581@item desc
5582An absolute expression. The symbol's descriptor is set to the low 16
5583bits of this expression.
5584
5585@item value
5586An absolute expression which becomes the symbol's value.
5587@end table
5588
5589If a warning is detected while reading a @code{.stabd}, @code{.stabn},
5590or @code{.stabs} statement, the symbol has probably already been created;
5591you get a half-formed symbol in your object file. This is
5592compatible with earlier assemblers!
5593
5594@table @code
5595@cindex @code{stabd} directive
5596@item .stabd @var{type} , @var{other} , @var{desc}
5597
5598The ``name'' of the symbol generated is not even an empty string.
5599It is a null pointer, for compatibility. Older assemblers used a
5600null pointer so they didn't waste space in object files with empty
5601strings.
5602
5603The symbol's value is set to the location counter,
5604relocatably. When your program is linked, the value of this symbol
5605is the address of the location counter when the @code{.stabd} was
5606assembled.
5607
5608@cindex @code{stabn} directive
5609@item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
5610The name of the symbol is set to the empty string @code{""}.
5611
5612@cindex @code{stabs} directive
5613@item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
5614All five fields are specified.
5615@end table
5616@end ifset
5617@c end have-stabs
5618
5619@node String
5620@section @code{.string} "@var{str}"
5621
5622@cindex string, copying to object file
5623@cindex @code{string} directive
5624
5625Copy the characters in @var{str} to the object file. You may specify more than
5626one string to copy, separated by commas. Unless otherwise specified for a
5627particular machine, the assembler marks the end of each string with a 0 byte.
5628You can use any of the escape sequences described in @ref{Strings,,Strings}.
5629
5630@node Struct
5631@section @code{.struct @var{expression}}
5632
5633@cindex @code{struct} directive
5634Switch to the absolute section, and set the section offset to @var{expression},
5635which must be an absolute expression. You might use this as follows:
5636@smallexample
5637 .struct 0
5638field1:
5639 .struct field1 + 4
5640field2:
5641 .struct field2 + 4
5642field3:
5643@end smallexample
5644This would define the symbol @code{field1} to have the value 0, the symbol
5645@code{field2} to have the value 4, and the symbol @code{field3} to have the
5646value 8. Assembly would be left in the absolute section, and you would need to
5647use a @code{.section} directive of some sort to change to some other section
5648before further assembly.
5649
c91d2e08
NC
5650@ifset ELF
5651@node SubSection
5652@section @code{.subsection @var{name}}
5653
c1253627 5654@cindex @code{subsection} directive
c91d2e08
NC
5655@cindex Section Stack
5656This is one of the ELF section stack manipulation directives. The others are
a349d9dd
PB
5657@code{.section} (@pxref{Section}), @code{.pushsection} (@pxref{PushSection}),
5658@code{.popsection} (@pxref{PopSection}), and @code{.previous}
5659(@pxref{Previous}).
c91d2e08
NC
5660
5661This directive replaces the current subsection with @code{name}. The current
5662section is not changed. The replaced subsection is put onto the section stack
5663in place of the then current top of stack subsection.
c91d2e08
NC
5664@end ifset
5665
252b5132
RH
5666@ifset ELF
5667@node Symver
5668@section @code{.symver}
5669@cindex @code{symver} directive
5670@cindex symbol versioning
5671@cindex versions of symbols
5672Use the @code{.symver} directive to bind symbols to specific version nodes
5673within a source file. This is only supported on ELF platforms, and is
5674typically used when assembling files to be linked into a shared library.
5675There are cases where it may make sense to use this in objects to be bound
5676into an application itself so as to override a versioned symbol from a
5677shared library.
5678
79082ff0 5679For ELF targets, the @code{.symver} directive can be used like this:
252b5132
RH
5680@smallexample
5681.symver @var{name}, @var{name2@@nodename}
5682@end smallexample
339681c0 5683If the symbol @var{name} is defined within the file
79082ff0 5684being assembled, the @code{.symver} directive effectively creates a symbol
252b5132
RH
5685alias with the name @var{name2@@nodename}, and in fact the main reason that we
5686just don't try and create a regular alias is that the @var{@@} character isn't
5687permitted in symbol names. The @var{name2} part of the name is the actual name
5688of the symbol by which it will be externally referenced. The name @var{name}
5689itself is merely a name of convenience that is used so that it is possible to
5690have definitions for multiple versions of a function within a single source
5691file, and so that the compiler can unambiguously know which version of a
5692function is being mentioned. The @var{nodename} portion of the alias should be
5693the name of a node specified in the version script supplied to the linker when
5694building a shared library. If you are attempting to override a versioned
5695symbol from a shared library, then @var{nodename} should correspond to the
5696nodename of the symbol you are trying to override.
339681c0
L
5697
5698If the symbol @var{name} is not defined within the file being assembled, all
5699references to @var{name} will be changed to @var{name2@@nodename}. If no
5700reference to @var{name} is made, @var{name2@@nodename} will be removed from the
5701symbol table.
79082ff0
L
5702
5703Another usage of the @code{.symver} directive is:
5704@smallexample
5705.symver @var{name}, @var{name2@@@@nodename}
5706@end smallexample
5707In this case, the symbol @var{name} must exist and be defined within
a349d9dd 5708the file being assembled. It is similar to @var{name2@@nodename}. The
79082ff0
L
5709difference is @var{name2@@@@nodename} will also be used to resolve
5710references to @var{name2} by the linker.
5711
5712The third usage of the @code{.symver} directive is:
5713@smallexample
5714.symver @var{name}, @var{name2@@@@@@nodename}
5715@end smallexample
5716When @var{name} is not defined within the
5717file being assembled, it is treated as @var{name2@@nodename}. When
5718@var{name} is defined within the file being assembled, the symbol
5719name, @var{name}, will be changed to @var{name2@@@@nodename}.
252b5132
RH
5720@end ifset
5721
5722@ifset COFF
5723@node Tag
5724@section @code{.tag @var{structname}}
5725
5726@cindex COFF structure debugging
5727@cindex structure debugging, COFF
5728@cindex @code{tag} directive
5729This directive is generated by compilers to include auxiliary debugging
5730information in the symbol table. It is only permitted inside
5731@code{.def}/@code{.endef} pairs. Tags are used to link structure
5732definitions in the symbol table with instances of those structures.
5733@ifset BOUT
5734
5735@samp{.tag} is only used when generating COFF format output; when
a4fb0134 5736@command{@value{AS}} is generating @code{b.out}, it accepts this directive but
252b5132
RH
5737ignores it.
5738@end ifset
5739@end ifset
5740
5741@node Text
5742@section @code{.text @var{subsection}}
5743
5744@cindex @code{text} directive
a4fb0134 5745Tells @command{@value{AS}} to assemble the following statements onto the end of
252b5132
RH
5746the text subsection numbered @var{subsection}, which is an absolute
5747expression. If @var{subsection} is omitted, subsection number zero
5748is used.
5749
5750@node Title
5751@section @code{.title "@var{heading}"}
5752
5753@cindex @code{title} directive
5754@cindex listing control: title line
5755Use @var{heading} as the title (second line, immediately after the
5756source file name and pagenumber) when generating assembly listings.
5757
5758This directive affects subsequent pages, as well as the current page if
5759it appears within ten lines of the top of a page.
5760
c1253627 5761@ifset COFF-ELF
252b5132 5762@node Type
c1253627
NC
5763@section @code{.type}
5764
5765This directive is used to set the type of a symbol.
5766
5767@ifset COFF
5768@ifset ELF
5769@c only print the extra heading if both COFF and ELF are set
5770@subheading COFF Version
5771@end ifset
252b5132
RH
5772
5773@cindex COFF symbol type
5774@cindex symbol type, COFF
c1253627
NC
5775@cindex @code{type} directive (COFF version)
5776For COFF targets, this directive is permitted only within
5777@code{.def}/@code{.endef} pairs. It is used like this:
5778
5779@smallexample
5780.type @var{int}
5781@end smallexample
5782
5783This records the integer @var{int} as the type attribute of a symbol table
5784entry.
252b5132 5785
c91d2e08 5786@ifset BOUT
252b5132 5787@samp{.type} is associated only with COFF format output; when
a4fb0134 5788@command{@value{AS}} is configured for @code{b.out} output, it accepts this
252b5132
RH
5789directive but ignores it.
5790@end ifset
c1253627 5791@end ifset
c91d2e08 5792
c1253627
NC
5793@ifset ELF
5794@ifset COFF
5795@c only print the extra heading if both COFF and ELF are set
5796@subheading ELF Version
5797@end ifset
c91d2e08
NC
5798
5799@cindex ELF symbol type
5800@cindex symbol type, ELF
c1253627
NC
5801@cindex @code{type} directive (ELF version)
5802For ELF targets, the @code{.type} directive is used like this:
5803
5804@smallexample
5805.type @var{name} , @var{type description}
5806@end smallexample
5807
5808This sets the type of symbol @var{name} to be either a
a349d9dd 5809function symbol or an object symbol. There are five different syntaxes
c91d2e08 5810supported for the @var{type description} field, in order to provide
a349d9dd 5811compatibility with various other assemblers. The syntaxes supported are:
c91d2e08
NC
5812
5813@smallexample
5814 .type <name>,#function
5815 .type <name>,#object
5816
5817 .type <name>,@@function
5818 .type <name>,@@object
5819
5820 .type <name>,%function
5821 .type <name>,%object
5822
5823 .type <name>,"function"
5824 .type <name>,"object"
5825
5826 .type <name> STT_FUNCTION
5827 .type <name> STT_OBJECT
5828@end smallexample
c1253627
NC
5829@end ifset
5830@end ifset
c91d2e08
NC
5831
5832@node Uleb128
5833@section @code{.uleb128 @var{expressions}}
5834
5835@cindex @code{uleb128} directive
5836@var{uleb128} stands for ``unsigned little endian base 128.'' This is a
5837compact, variable length representation of numbers used by the DWARF
5838symbolic debugging format. @xref{Sleb128,@code{.sleb128}}.
252b5132
RH
5839
5840@ifset COFF
5841@node Val
5842@section @code{.val @var{addr}}
5843
5844@cindex @code{val} directive
5845@cindex COFF value attribute
5846@cindex value attribute, COFF
5847This directive, permitted only within @code{.def}/@code{.endef} pairs,
5848records the address @var{addr} as the value attribute of a symbol table
5849entry.
5850@ifset BOUT
5851
a4fb0134 5852@samp{.val} is used only for COFF output; when @command{@value{AS}} is
252b5132
RH
5853configured for @code{b.out}, it accepts this directive but ignores it.
5854@end ifset
5855@end ifset
5856
2e13b764 5857@ifset ELF
c91d2e08
NC
5858@node Version
5859@section @code{.version "@var{string}"}
2e13b764 5860
c1253627 5861@cindex @code{version} directive
c91d2e08
NC
5862This directive creates a @code{.note} section and places into it an ELF
5863formatted note of type NT_VERSION. The note's name is set to @code{string}.
9a297610 5864@end ifset
2e13b764 5865
c91d2e08
NC
5866@ifset ELF
5867@node VTableEntry
5868@section @code{.vtable_entry @var{table}, @var{offset}}
2e13b764 5869
653cfe85 5870@cindex @code{vtable_entry} directive
c91d2e08
NC
5871This directive finds or creates a symbol @code{table} and creates a
5872@code{VTABLE_ENTRY} relocation for it with an addend of @code{offset}.
2e13b764 5873
c91d2e08
NC
5874@node VTableInherit
5875@section @code{.vtable_inherit @var{child}, @var{parent}}
2e13b764 5876
653cfe85 5877@cindex @code{vtable_inherit} directive
c91d2e08
NC
5878This directive finds the symbol @code{child} and finds or creates the symbol
5879@code{parent} and then creates a @code{VTABLE_INHERIT} relocation for the
a349d9dd 5880parent whose addend is the value of the child symbol. As a special case the
c91d2e08
NC
5881parent name of @code{0} is treated as refering the @code{*ABS*} section.
5882@end ifset
2e13b764 5883
d190d046
HPN
5884@node Warning
5885@section @code{.warning "@var{string}"}
5886@cindex warning directive
5887Similar to the directive @code{.error}
5888(@pxref{Error,,@code{.error "@var{string}"}}), but just emits a warning.
5889
c91d2e08
NC
5890@node Weak
5891@section @code{.weak @var{names}}
2e13b764 5892
c1253627 5893@cindex @code{weak} directive
a349d9dd 5894This directive sets the weak attribute on the comma separated list of symbol
c91d2e08 5895@code{names}. If the symbols do not already exist, they will be created.
c87db184 5896
977cdf5a
NC
5897On COFF targets other than PE, weak symbols are a GNU extension. This
5898directive sets the weak attribute on the comma separated list of symbol
c87db184
CF
5899@code{names}. If the symbols do not already exist, they will be created.
5900
977cdf5a
NC
5901On the PE target, weak symbols are supported natively as weak aliases.
5902When a weak symbol is created that is not an alias, GAS creates an
5903alternate symbol to hold the default value.
2e13b764 5904
252b5132
RH
5905@node Word
5906@section @code{.word @var{expressions}}
5907
5908@cindex @code{word} directive
5909This directive expects zero or more @var{expressions}, of any section,
5910separated by commas.
5911@ifclear GENERIC
5912@ifset W32
a4fb0134 5913For each expression, @command{@value{AS}} emits a 32-bit number.
252b5132
RH
5914@end ifset
5915@ifset W16
a4fb0134 5916For each expression, @command{@value{AS}} emits a 16-bit number.
252b5132
RH
5917@end ifset
5918@end ifclear
5919@ifset GENERIC
5920
5921The size of the number emitted, and its byte order,
5922depend on what target computer the assembly is for.
5923@end ifset
5924
5925@c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
5926@c happen---32-bit addressability, period; no long/short jumps.
5927@ifset DIFF-TBL-KLUGE
5928@cindex difference tables altered
5929@cindex altered difference tables
5930@quotation
5931@emph{Warning: Special Treatment to support Compilers}
5932@end quotation
5933
5934@ifset GENERIC
5935Machines with a 32-bit address space, but that do less than 32-bit
5936addressing, require the following special treatment. If the machine of
5937interest to you does 32-bit addressing (or doesn't require it;
5938@pxref{Machine Dependencies}), you can ignore this issue.
5939
5940@end ifset
5941In order to assemble compiler output into something that works,
a4fb0134 5942@command{@value{AS}} occasionally does strange things to @samp{.word} directives.
252b5132 5943Directives of the form @samp{.word sym1-sym2} are often emitted by
a4fb0134 5944compilers as part of jump tables. Therefore, when @command{@value{AS}} assembles a
252b5132 5945directive of the form @samp{.word sym1-sym2}, and the difference between
a4fb0134 5946@code{sym1} and @code{sym2} does not fit in 16 bits, @command{@value{AS}}
252b5132
RH
5947creates a @dfn{secondary jump table}, immediately before the next label.
5948This secondary jump table is preceded by a short-jump to the
5949first byte after the secondary table. This short-jump prevents the flow
5950of control from accidentally falling into the new table. Inside the
5951table is a long-jump to @code{sym2}. The original @samp{.word}
5952contains @code{sym1} minus the address of the long-jump to
5953@code{sym2}.
5954
5955If there were several occurrences of @samp{.word sym1-sym2} before the
5956secondary jump table, all of them are adjusted. If there was a
5957@samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
5958long-jump to @code{sym4} is included in the secondary jump table,
5959and the @code{.word} directives are adjusted to contain @code{sym3}
5960minus the address of the long-jump to @code{sym4}; and so on, for as many
5961entries in the original jump table as necessary.
5962
5963@ifset INTERNALS
a4fb0134 5964@emph{This feature may be disabled by compiling @command{@value{AS}} with the
252b5132
RH
5965@samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
5966assembly language programmers.
5967@end ifset
5968@end ifset
5969@c end DIFF-TBL-KLUGE
5970
5971@node Deprecated
5972@section Deprecated Directives
5973
5974@cindex deprecated directives
5975@cindex obsolescent directives
5976One day these directives won't work.
5977They are included for compatibility with older assemblers.
5978@table @t
5979@item .abort
5980@item .line
5981@end table
5982
5983@ifset GENERIC
5984@node Machine Dependencies
5985@chapter Machine Dependent Features
5986
5987@cindex machine dependencies
5988The machine instruction sets are (almost by definition) different on
a4fb0134
SC
5989each machine where @command{@value{AS}} runs. Floating point representations
5990vary as well, and @command{@value{AS}} often supports a few additional
252b5132
RH
5991directives or command-line options for compatibility with other
5992assemblers on a particular platform. Finally, some versions of
a4fb0134 5993@command{@value{AS}} support special pseudo-instructions for branch
252b5132
RH
5994optimization.
5995
5996This chapter discusses most of these differences, though it does not
5997include details on any machine's instruction set. For details on that
5998subject, see the hardware manufacturer's manual.
5999
6000@menu
6001@ifset A29K
6002* AMD29K-Dependent:: AMD 29K Dependent Features
6003@end ifset
625e1353
RH
6004@ifset ALPHA
6005* Alpha-Dependent:: Alpha Dependent Features
6006@end ifset
252b5132
RH
6007@ifset ARC
6008* ARC-Dependent:: ARC Dependent Features
6009@end ifset
6010@ifset ARM
6011* ARM-Dependent:: ARM Dependent Features
6012@end ifset
8bf549a8 6013@ifset CRIS
328eb32e
HPN
6014* CRIS-Dependent:: CRIS Dependent Features
6015@end ifset
252b5132
RH
6016@ifset D10V
6017* D10V-Dependent:: D10V Dependent Features
6018@end ifset
6019@ifset D30V
6020* D30V-Dependent:: D30V Dependent Features
6021@end ifset
6022@ifset H8/300
c2dcd04e 6023* H8/300-Dependent:: Renesas H8/300 Dependent Features
252b5132
RH
6024@end ifset
6025@ifset H8/500
c2dcd04e 6026* H8/500-Dependent:: Renesas H8/500 Dependent Features
252b5132
RH
6027@end ifset
6028@ifset HPPA
6029* HPPA-Dependent:: HPPA Dependent Features
6030@end ifset
5b93d8bb
AM
6031@ifset I370
6032* ESA/390-Dependent:: IBM ESA/390 Dependent Features
6033@end ifset
252b5132 6034@ifset I80386
55b62671 6035* i386-Dependent:: Intel 80386 and AMD x86-64 Dependent Features
252b5132 6036@end ifset
e3308d0d
JE
6037@ifset I860
6038* i860-Dependent:: Intel 80860 Dependent Features
6039@end ifset
252b5132
RH
6040@ifset I960
6041* i960-Dependent:: Intel 80960 Dependent Features
6042@end ifset
5cb53c21
L
6043@ifset IA64
6044* IA-64-Dependent:: Intel IA-64 Dependent Features
6045@end ifset
a40cbfa3
NC
6046@ifset IP2K
6047* IP2K-Dependent:: IP2K Dependent Features
6048@end ifset
ec694b89
NC
6049@ifset M32R
6050* M32R-Dependent:: M32R Dependent Features
6051@end ifset
252b5132
RH
6052@ifset M680X0
6053* M68K-Dependent:: M680x0 Dependent Features
6054@end ifset
60bcf0fa
NC
6055@ifset M68HC11
6056* M68HC11-Dependent:: M68HC11 and 68HC12 Dependent Features
6057@end ifset
81b0b3f1
BE
6058@ifset M880X0
6059* M88K-Dependent:: M880x0 Dependent Features
6060@end ifset
252b5132
RH
6061@ifset MIPS
6062* MIPS-Dependent:: MIPS Dependent Features
6063@end ifset
3c3bdf30
NC
6064@ifset MMIX
6065* MMIX-Dependent:: MMIX Dependent Features
6066@end ifset
2469cfa2
NC
6067@ifset MSP430
6068* MSP430-Dependent:: MSP430 Dependent Features
6069@end ifset
252b5132 6070@ifset SH
ef230218
JR
6071* SH-Dependent:: Renesas / SuperH SH Dependent Features
6072* SH64-Dependent:: SuperH SH64 Dependent Features
252b5132 6073@end ifset
e135f41b
NC
6074@ifset PDP11
6075* PDP-11-Dependent:: PDP-11 Dependent Features
6076@end ifset
041dd5a9
ILT
6077@ifset PJ
6078* PJ-Dependent:: picoJava Dependent Features
6079@end ifset
418c1742
MG
6080@ifset PPC
6081* PPC-Dependent:: PowerPC Dependent Features
6082@end ifset
252b5132
RH
6083@ifset SPARC
6084* Sparc-Dependent:: SPARC Dependent Features
6085@end ifset
39bec121
TW
6086@ifset TIC54X
6087* TIC54X-Dependent:: TI TMS320C54x Dependent Features
6088@end ifset
252b5132
RH
6089@ifset V850
6090* V850-Dependent:: V850 Dependent Features
6091@end ifset
e0001a05
NC
6092@ifset XTENSA
6093* Xtensa-Dependent:: Xtensa Dependent Features
6094@end ifset
252b5132
RH
6095@ifset Z8000
6096* Z8000-Dependent:: Z8000 Dependent Features
6097@end ifset
6098@ifset VAX
6099* Vax-Dependent:: VAX Dependent Features
6100@end ifset
6101@end menu
6102
6103@lowersections
6104@end ifset
6105
6106@c The following major nodes are *sections* in the GENERIC version, *chapters*
6107@c in single-cpu versions. This is mainly achieved by @lowersections. There is a
6108@c peculiarity: to preserve cross-references, there must be a node called
6109@c "Machine Dependencies". Hence the conditional nodenames in each
6110@c major node below. Node defaulting in makeinfo requires adjacency of
6111@c node and sectioning commands; hence the repetition of @chapter BLAH
6112@c in both conditional blocks.
6113
252b5132
RH
6114@ifset A29K
6115@include c-a29k.texi
6116@end ifset
6117
625e1353
RH
6118@ifset ALPHA
6119@include c-alpha.texi
6120@end ifset
6121
6122@ifset ARC
6123@include c-arc.texi
6124@end ifset
6125
252b5132
RH
6126@ifset ARM
6127@include c-arm.texi
6128@end ifset
6129
328eb32e
HPN
6130@ifset CRIS
6131@include c-cris.texi
6132@end ifset
6133
c2dcd04e 6134@ifset Renesas-all
252b5132
RH
6135@ifclear GENERIC
6136@node Machine Dependencies
6137@chapter Machine Dependent Features
6138
c2dcd04e 6139The machine instruction sets are different on each Renesas chip family,
252b5132 6140and there are also some syntax differences among the families. This
a4fb0134 6141chapter describes the specific @command{@value{AS}} features for each
252b5132
RH
6142family.
6143
6144@menu
c2dcd04e
NC
6145* H8/300-Dependent:: Renesas H8/300 Dependent Features
6146* H8/500-Dependent:: Renesas H8/500 Dependent Features
6147* SH-Dependent:: Renesas SH Dependent Features
252b5132
RH
6148@end menu
6149@lowersections
6150@end ifclear
6151@end ifset
6152
6153@ifset D10V
6154@include c-d10v.texi
6155@end ifset
6156
6157@ifset D30V
6158@include c-d30v.texi
6159@end ifset
6160
6161@ifset H8/300
6162@include c-h8300.texi
6163@end ifset
6164
6165@ifset H8/500
6166@include c-h8500.texi
6167@end ifset
6168
6169@ifset HPPA
6170@include c-hppa.texi
6171@end ifset
6172
5b93d8bb
AM
6173@ifset I370
6174@include c-i370.texi
6175@end ifset
6176
252b5132
RH
6177@ifset I80386
6178@include c-i386.texi
6179@end ifset
6180
e3308d0d
JE
6181@ifset I860
6182@include c-i860.texi
6183@end ifset
6184
252b5132
RH
6185@ifset I960
6186@include c-i960.texi
6187@end ifset
6188
9e32ca89
NC
6189@ifset IA64
6190@include c-ia64.texi
6191@end ifset
6192
a40cbfa3
NC
6193@ifset IP2K
6194@include c-ip2k.texi
6195@end ifset
6196
ec694b89
NC
6197@ifset M32R
6198@include c-m32r.texi
6199@end ifset
252b5132
RH
6200
6201@ifset M680X0
6202@include c-m68k.texi
6203@end ifset
6204
60bcf0fa
NC
6205@ifset M68HC11
6206@include c-m68hc11.texi
6207@end ifset
6208
81b0b3f1
BE
6209@ifset M880X0
6210@include c-m88k.texi
6211@end ifset
6212
252b5132
RH
6213@ifset MIPS
6214@include c-mips.texi
6215@end ifset
6216
3c3bdf30
NC
6217@ifset MMIX
6218@include c-mmix.texi
6219@end ifset
6220
2469cfa2
NC
6221@ifset MSP430
6222@include c-msp430.texi
6223@end ifset
6224
252b5132
RH
6225@ifset NS32K
6226@include c-ns32k.texi
6227@end ifset
6228
e135f41b
NC
6229@ifset PDP11
6230@include c-pdp11.texi
6231@end ifset
6232
041dd5a9
ILT
6233@ifset PJ
6234@include c-pj.texi
6235@end ifset
6236
418c1742
MG
6237@ifset PPC
6238@include c-ppc.texi
6239@end ifset
6240
252b5132
RH
6241@ifset SH
6242@include c-sh.texi
324bfcf3 6243@include c-sh64.texi
252b5132
RH
6244@end ifset
6245
6246@ifset SPARC
6247@include c-sparc.texi
6248@end ifset
6249
39bec121
TW
6250@ifset TIC54X
6251@include c-tic54x.texi
6252@end ifset
6253
252b5132
RH
6254@ifset Z8000
6255@include c-z8k.texi
6256@end ifset
6257
6258@ifset VAX
6259@include c-vax.texi
6260@end ifset
6261
6262@ifset V850
6263@include c-v850.texi
6264@end ifset
6265
e0001a05
NC
6266@ifset XTENSA
6267@include c-xtensa.texi
6268@end ifset
6269
252b5132
RH
6270@ifset GENERIC
6271@c reverse effect of @down at top of generic Machine-Dep chapter
6272@raisesections
6273@end ifset
6274
6275@node Reporting Bugs
6276@chapter Reporting Bugs
6277@cindex bugs in assembler
6278@cindex reporting bugs in assembler
6279
a4fb0134 6280Your bug reports play an essential role in making @command{@value{AS}} reliable.
252b5132
RH
6281
6282Reporting a bug may help you by bringing a solution to your problem, or it may
6283not. But in any case the principal function of a bug report is to help the
a4fb0134
SC
6284entire community by making the next version of @command{@value{AS}} work better.
6285Bug reports are your contribution to the maintenance of @command{@value{AS}}.
252b5132
RH
6286
6287In order for a bug report to serve its purpose, you must include the
6288information that enables us to fix the bug.
6289
6290@menu
6291* Bug Criteria:: Have you found a bug?
6292* Bug Reporting:: How to report bugs
6293@end menu
6294
6295@node Bug Criteria
c1253627 6296@section Have You Found a Bug?
252b5132
RH
6297@cindex bug criteria
6298
6299If you are not sure whether you have found a bug, here are some guidelines:
6300
6301@itemize @bullet
6302@cindex fatal signal
6303@cindex assembler crash
6304@cindex crash of assembler
6305@item
6306If the assembler gets a fatal signal, for any input whatever, that is a
a4fb0134 6307@command{@value{AS}} bug. Reliable assemblers never crash.
252b5132
RH
6308
6309@cindex error on valid input
6310@item
a4fb0134 6311If @command{@value{AS}} produces an error message for valid input, that is a bug.
252b5132
RH
6312
6313@cindex invalid input
6314@item
a4fb0134 6315If @command{@value{AS}} does not produce an error message for invalid input, that
252b5132
RH
6316is a bug. However, you should note that your idea of ``invalid input'' might
6317be our idea of ``an extension'' or ``support for traditional practice''.
6318
6319@item
6320If you are an experienced user of assemblers, your suggestions for improvement
a4fb0134 6321of @command{@value{AS}} are welcome in any case.
252b5132
RH
6322@end itemize
6323
6324@node Bug Reporting
c1253627 6325@section How to Report Bugs
252b5132
RH
6326@cindex bug reports
6327@cindex assembler bugs, reporting
6328
6329A number of companies and individuals offer support for @sc{gnu} products. If
a4fb0134 6330you obtained @command{@value{AS}} from a support organization, we recommend you
252b5132
RH
6331contact that organization first.
6332
6333You can find contact information for many support companies and
6334individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
6335distribution.
6336
a4fb0134 6337In any event, we also recommend that you send bug reports for @command{@value{AS}}
46a04e3a 6338to @samp{bug-binutils@@gnu.org}.
252b5132
RH
6339
6340The fundamental principle of reporting bugs usefully is this:
6341@strong{report all the facts}. If you are not sure whether to state a
6342fact or leave it out, state it!
6343
6344Often people omit facts because they think they know what causes the problem
6345and assume that some details do not matter. Thus, you might assume that the
6346name of a symbol you use in an example does not matter. Well, probably it does
6347not, but one cannot be sure. Perhaps the bug is a stray memory reference which
6348happens to fetch from the location where that name is stored in memory;
6349perhaps, if the name were different, the contents of that location would fool
6350the assembler into doing the right thing despite the bug. Play it safe and
6351give a specific, complete example. That is the easiest thing for you to do,
6352and the most helpful.
6353
6354Keep in mind that the purpose of a bug report is to enable us to fix the bug if
6355it is new to us. Therefore, always write your bug reports on the assumption
6356that the bug has not been reported previously.
6357
6358Sometimes people give a few sketchy facts and ask, ``Does this ring a
c1253627
NC
6359bell?'' This cannot help us fix a bug, so it is basically useless. We
6360respond by asking for enough details to enable us to investigate.
6361You might as well expedite matters by sending them to begin with.
252b5132
RH
6362
6363To enable us to fix the bug, you should include all these things:
6364
6365@itemize @bullet
6366@item
a4fb0134 6367The version of @command{@value{AS}}. @command{@value{AS}} announces it if you start
252b5132
RH
6368it with the @samp{--version} argument.
6369
6370Without this, we will not know whether there is any point in looking for
a4fb0134 6371the bug in the current version of @command{@value{AS}}.
252b5132
RH
6372
6373@item
a4fb0134 6374Any patches you may have applied to the @command{@value{AS}} source.
252b5132
RH
6375
6376@item
6377The type of machine you are using, and the operating system name and
6378version number.
6379
6380@item
a4fb0134 6381What compiler (and its version) was used to compile @command{@value{AS}}---e.g.
252b5132
RH
6382``@code{gcc-2.7}''.
6383
6384@item
6385The command arguments you gave the assembler to assemble your example and
6386observe the bug. To guarantee you will not omit something important, list them
6387all. A copy of the Makefile (or the output from make) is sufficient.
6388
6389If we were to try to guess the arguments, we would probably guess wrong
6390and then we might not encounter the bug.
6391
6392@item
6393A complete input file that will reproduce the bug. If the bug is observed when
6394the assembler is invoked via a compiler, send the assembler source, not the
6395high level language source. Most compilers will produce the assembler source
6396when run with the @samp{-S} option. If you are using @code{@value{GCC}}, use
6397the options @samp{-v --save-temps}; this will save the assembler source in a
6398file with an extension of @file{.s}, and also show you exactly how
a4fb0134 6399@command{@value{AS}} is being run.
252b5132
RH
6400
6401@item
6402A description of what behavior you observe that you believe is
6403incorrect. For example, ``It gets a fatal signal.''
6404
a4fb0134 6405Of course, if the bug is that @command{@value{AS}} gets a fatal signal, then we
252b5132
RH
6406will certainly notice it. But if the bug is incorrect output, we might not
6407notice unless it is glaringly wrong. You might as well not give us a chance to
6408make a mistake.
6409
6410Even if the problem you experience is a fatal signal, you should still say so
6411explicitly. Suppose something strange is going on, such as, your copy of
a4fb0134 6412@command{@value{AS}} is out of synch, or you have encountered a bug in the C
252b5132
RH
6413library on your system. (This has happened!) Your copy might crash and ours
6414would not. If you told us to expect a crash, then when ours fails to crash, we
6415would know that the bug was not happening for us. If you had not told us to
6416expect a crash, then we would not be able to draw any conclusion from our
6417observations.
6418
6419@item
a4fb0134 6420If you wish to suggest changes to the @command{@value{AS}} source, send us context
252b5132
RH
6421diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p}
6422option. Always send diffs from the old file to the new file. If you even
a4fb0134 6423discuss something in the @command{@value{AS}} source, refer to it by context, not
252b5132
RH
6424by line number.
6425
6426The line numbers in our development sources will not match those in your
6427sources. Your line numbers would convey no useful information to us.
6428@end itemize
6429
6430Here are some things that are not necessary:
6431
6432@itemize @bullet
6433@item
6434A description of the envelope of the bug.
6435
6436Often people who encounter a bug spend a lot of time investigating
6437which changes to the input file will make the bug go away and which
6438changes will not affect it.
6439
6440This is often time consuming and not very useful, because the way we
6441will find the bug is by running a single example under the debugger
6442with breakpoints, not by pure deduction from a series of examples.
6443We recommend that you save your time for something else.
6444
6445Of course, if you can find a simpler example to report @emph{instead}
6446of the original one, that is a convenience for us. Errors in the
6447output will be easier to spot, running under the debugger will take
6448less time, and so on.
6449
6450However, simplification is not vital; if you do not want to do this,
6451report the bug anyway and send us the entire test case you used.
6452
6453@item
6454A patch for the bug.
6455
6456A patch for the bug does help us if it is a good one. But do not omit
6457the necessary information, such as the test case, on the assumption that
6458a patch is all we need. We might see problems with your patch and decide
6459to fix the problem another way, or we might not understand it at all.
6460
a4fb0134 6461Sometimes with a program as complicated as @command{@value{AS}} it is very hard to
252b5132
RH
6462construct an example that will make the program follow a certain path through
6463the code. If you do not send us the example, we will not be able to construct
6464one, so we will not be able to verify that the bug is fixed.
6465
6466And if we cannot understand what bug you are trying to fix, or why your
6467patch should be an improvement, we will not install it. A test case will
6468help us to understand.
6469
6470@item
6471A guess about what the bug is or what it depends on.
6472
6473Such guesses are usually wrong. Even we cannot guess right about such
6474things without first using the debugger to find the facts.
6475@end itemize
6476
6477@node Acknowledgements
6478@chapter Acknowledgements
6479
653cfe85 6480If you have contributed to GAS and your name isn't listed here,
252b5132
RH
6481it is not meant as a slight. We just don't know about it. Send mail to the
6482maintainer, and we'll correct the situation. Currently
6483@c (January 1994),
6484the maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
6485
6486Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any
6487more details?}
6488
6489Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug
6490information and the 68k series machines, most of the preprocessing pass, and
6491extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}.
6492
6493K. Richard Pixley maintained GAS for a while, adding various enhancements and
6494many bug fixes, including merging support for several processors, breaking GAS
6495up to handle multiple object file format back ends (including heavy rewrite,
6496testing, an integration of the coff and b.out back ends), adding configuration
6497including heavy testing and verification of cross assemblers and file splits
6498and renaming, converted GAS to strictly ANSI C including full prototypes, added
6499support for m680[34]0 and cpu32, did considerable work on i960 including a COFF
6500port (including considerable amounts of reverse engineering), a SPARC opcode
6501file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know''
6502assertions and made them work, much other reorganization, cleanup, and lint.
6503
6504Ken Raeburn wrote the high-level BFD interface code to replace most of the code
6505in format-specific I/O modules.
6506
6507The original VMS support was contributed by David L. Kashtan. Eric Youngdale
6508has done much work with it since.
6509
6510The Intel 80386 machine description was written by Eliot Dresselhaus.
6511
6512Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
6513
6514The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
6515University and Torbjorn Granlund of the Swedish Institute of Computer Science.
6516
6517Keith Knowles at the Open Software Foundation wrote the original MIPS back end
6518(@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support
6519(which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to
6520support a.out format.
6521
c2dcd04e 6522Support for the Zilog Z8k and Renesas H8/300 and H8/500 processors (tc-z8k,
252b5132
RH
6523tc-h8300, tc-h8500), and IEEE 695 object file format (obj-ieee), was written by
6524Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
6525use BFD for some low-level operations, for use with the H8/300 and AMD 29k
6526targets.
6527
6528John Gilmore built the AMD 29000 support, added @code{.include} support, and
6529simplified the configuration of which versions accept which directives. He
6530updated the 68k machine description so that Motorola's opcodes always produced
c1253627 6531fixed-size instructions (e.g., @code{jsr}), while synthetic instructions
252b5132
RH
6532remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested
6533cross-compilation support, and one bug in relaxation that took a week and
6534required the proverbial one-bit fix.
6535
6536Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the
653768k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
6538added support for MIPS ECOFF and ELF targets, wrote the initial RS/6000 and
6539PowerPC assembler, and made a few other minor patches.
6540
653cfe85 6541Steve Chamberlain made GAS able to generate listings.
252b5132
RH
6542
6543Hewlett-Packard contributed support for the HP9000/300.
6544
6545Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM)
6546along with a fairly extensive HPPA testsuite (for both SOM and ELF object
6547formats). This work was supported by both the Center for Software Science at
6548the University of Utah and Cygnus Support.
6549
6550Support for ELF format files has been worked on by Mark Eichin of Cygnus
6551Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
6552Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
6553Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
6554and some initial 64-bit support).
6555
c1253627 6556Linas Vepstas added GAS support for the ESA/390 ``IBM 370'' architecture.
5b93d8bb 6557
252b5132
RH
6558Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD
6559support for openVMS/Alpha.
6560
39bec121
TW
6561Timothy Wall, Michael Hayes, and Greg Smart contributed to the various tic*
6562flavors.
6563
e0001a05
NC
6564David Heine, Sterling Augustine, Bob Wilson and John Ruttenberg from Tensilica,
6565Inc. added support for Xtensa processors.
6566
252b5132
RH
6567Several engineers at Cygnus Support have also provided many small bug fixes and
6568configuration enhancements.
6569
6570Many others have contributed large or small bugfixes and enhancements. If
6571you have contributed significant work and are not mentioned on this list, and
6572want to be, let us know. Some of the history has been lost; we are not
6573intentionally leaving anyone out.
6574
c1253627 6575@include fdl.texi
cf055d54 6576
252b5132
RH
6577@node Index
6578@unnumbered Index
6579
6580@printindex cp
6581
6582@contents
6583@bye
6584@c Local Variables:
6585@c fill-column: 79
6586@c End:
This page took 0.582252 seconds and 4 git commands to generate.