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