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