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