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