0d165d62aa0427f83cd49ceae53a3981c0fe16e8
[deliverable/binutils-gdb.git] / gas / doc / as.texinfo
1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright (c) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
3 @c UPDATE!! On future updates--
4 @c (1) check for new machine-dep cmdline options in
5 @c md_parse_option definitions in config/tc-*.c
6 @c (2) for platform-specific directives, examine md_pseudo_op
7 @c in config/tc-*.c
8 @c (3) for object-format specific directives, examine obj_pseudo_op
9 @c in config/obj-*.c
10 @c (4) portable directives in potable[] in read.c
11 @c %**start of header
12 @setfilename as.info
13 @c ---config---
14 @c defaults, config file may override:
15 @set have-stabs
16 @c ---
17 @include asconfig.texi
18 @c ---
19 @c common OR combinations of conditions
20 @ifset AOUT
21 @set aout-bout
22 @end ifset
23 @ifset ARM/Thumb
24 @set ARM
25 @end ifset
26 @ifset BOUT
27 @set aout-bout
28 @end ifset
29 @ifset H8/300
30 @set H8
31 @end ifset
32 @ifset H8/500
33 @set H8
34 @end ifset
35 @ifset SH
36 @set H8
37 @end ifset
38 @ifset HPPA
39 @set abnormal-separator
40 @end ifset
41 @c ------------
42 @ifset GENERIC
43 @settitle Using @value{AS}
44 @end ifset
45 @ifclear GENERIC
46 @settitle Using @value{AS} (@value{TARGET})
47 @end ifclear
48 @setchapternewpage odd
49 @c %**end of header
50
51 @c @smallbook
52 @c @set SMALL
53 @c WARE! Some of the machine-dependent sections contain tables of machine
54 @c instructions. Except in multi-column format, these tables look silly.
55 @c Unfortunately, Texinfo doesn't have a general-purpose multi-col format, so
56 @c the multi-col format is faked within @example sections.
57 @c
58 @c Again unfortunately, the natural size that fits on a page, for these tables,
59 @c is different depending on whether or not smallbook is turned on.
60 @c This matters, because of order: text flow switches columns at each page
61 @c break.
62 @c
63 @c The format faked in this source works reasonably well for smallbook,
64 @c not well for the default large-page format. This manual expects that if you
65 @c turn on @smallbook, you will also uncomment the "@set SMALL" to enable the
66 @c tables in question. You can turn on one without the other at your
67 @c discretion, of course.
68 @ifinfo
69 @set SMALL
70 @c the insn tables look just as silly in info files regardless of smallbook,
71 @c might as well show 'em anyways.
72 @end ifinfo
73
74 @ifinfo
75 @format
76 START-INFO-DIR-ENTRY
77 * As: (as). The GNU assembler.
78 END-INFO-DIR-ENTRY
79 @end format
80 @end ifinfo
81
82 @finalout
83 @syncodeindex ky cp
84
85 @ifinfo
86 This file documents the GNU Assembler "@value{AS}".
87
88 Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
89
90 Permission is granted to make and distribute verbatim copies of
91 this manual provided the copyright notice and this permission notice
92 are preserved on all copies.
93
94 @ignore
95 Permission is granted to process this file through Tex and print the
96 results, provided the printed document carries copying permission
97 notice identical to this one except for the removal of this paragraph
98 (this paragraph not being relevant to the printed manual).
99
100 @end ignore
101 Permission is granted to copy and distribute modified versions of this manual
102 under the conditions for verbatim copying, provided that the entire resulting
103 derived work is distributed under the terms of a permission notice identical to
104 this one.
105
106 Permission is granted to copy and distribute translations of this manual
107 into another language, under the above conditions for modified versions.
108 @end ifinfo
109
110 @titlepage
111 @title Using @value{AS}
112 @subtitle The @sc{gnu} Assembler
113 @ifclear GENERIC
114 @subtitle for the @value{TARGET} family
115 @end ifclear
116 @sp 1
117 @subtitle January 1994
118 @sp 1
119 @sp 13
120 The Free Software Foundation Inc. thanks The Nice Computer
121 Company of Australia for loaning Dean Elsner to write the
122 first (Vax) version of @code{as} for Project @sc{gnu}.
123 The proprietors, management and staff of TNCCA thank FSF for
124 distracting the boss while they got some work
125 done.
126 @sp 3
127 @author Dean Elsner, Jay Fenlason & friends
128 @page
129 @tex
130 {\parskip=0pt
131 \hfill {\it Using {\tt @value{AS}}}\par
132 \hfill Edited by Cygnus Support\par
133 }
134 %"boxit" macro for figures:
135 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
136 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
137 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
138 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
139 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
140 @end tex
141
142 @vskip 0pt plus 1filll
143 Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
144
145 Permission is granted to make and distribute verbatim copies of
146 this manual provided the copyright notice and this permission notice
147 are preserved on all copies.
148
149 Permission is granted to copy and distribute modified versions of this manual
150 under the conditions for verbatim copying, provided that the entire resulting
151 derived work is distributed under the terms of a permission notice identical to
152 this one.
153
154 Permission is granted to copy and distribute translations of this manual
155 into another language, under the above conditions for modified versions.
156 @end titlepage
157
158 @ifinfo
159 @node Top
160 @top Using @value{AS}
161
162 This file is a user guide to the @sc{gnu} assembler @code{@value{AS}}.
163 @ifclear GENERIC
164 This version of the file describes @code{@value{AS}} configured to generate
165 code for @value{TARGET} architectures.
166 @end ifclear
167 @menu
168 * Overview:: Overview
169 * Invoking:: Command-Line Options
170 * Syntax:: Syntax
171 * Sections:: Sections and Relocation
172 * Symbols:: Symbols
173 * Expressions:: Expressions
174 * Pseudo Ops:: Assembler Directives
175 * Machine Dependencies:: Machine Dependent Features
176 * Reporting Bugs:: Reporting Bugs
177 * Acknowledgements:: Who Did What
178 * Index:: Index
179 @end menu
180 @end ifinfo
181
182 @node Overview
183 @chapter Overview
184 @iftex
185 This manual is a user guide to the @sc{gnu} assembler @code{@value{AS}}.
186 @ifclear GENERIC
187 This version of the manual describes @code{@value{AS}} configured to generate
188 code for @value{TARGET} architectures.
189 @end ifclear
190 @end iftex
191
192 @cindex invocation summary
193 @cindex option summary
194 @cindex summary of options
195 Here is a brief summary of how to invoke @code{@value{AS}}. For details,
196 @pxref{Invoking,,Comand-Line Options}.
197
198 @c We don't use deffn and friends for the following because they seem
199 @c to be limited to one line for the header.
200 @smallexample
201 @value{AS} [ -a[cdhlns][=file] ] [ -D ] [ --defsym @var{sym}=@var{val} ]
202 [ -f ] [ --help ] [ -I @var{dir} ] [ -J ] [ -K ] [ -L ]
203 [ -o @var{objfile} ] [ -R ] [ --statistics ] [ -v ] [ -version ]
204 [ --version ] [ -W ] [ -w ] [ -x ] [ -Z ]
205 @ifset A29K
206 @c am29k has no machine-dependent assembler options
207 @end ifset
208 @ifset ARC
209 [ -mbig-endian | -mlittle-endian ]
210 @end ifset
211 @ifset ARM
212 [ -m[arm]1 | -m[arm]2 | -m[arm]250 | -m[arm]3 | -m[arm]6 | -m[arm]7[t][[d]m[i]] ]
213 [ -m[arm]v2 | -m[arm]v2a | -m[arm]v3 | -m[arm]v3m | -m[arm]v4 | -m[arm]v4t ]
214 [ -mthumb | -mall ]
215 [ -mfpa10 | -mfpa11 | -mfpe-old | -mno-fpu ]
216 [ -EB | -EL ]
217 [ -mapcs-32 | -mapcs-26 ]
218 @end ifset
219 @ifset D10V
220 [ -O ]
221 @end ifset
222
223 @ifset H8
224 @c Hitachi family chips have no machine-dependent assembler options
225 @end ifset
226 @ifset HPPA
227 @c HPPA has no machine-dependent assembler options (yet).
228 @end ifset
229 @ifset SPARC
230 @c The order here is important. See c-sparc.texi.
231 [ -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite | -Av9 | -Av9a ]
232 [ -xarch=v8plus | -xarch=v8plusa ] [ -bump ]
233 @end ifset
234 @ifset Z8000
235 @c Z8000 has no machine-dependent assembler options
236 @end ifset
237 @ifset I960
238 @c see md_parse_option in tc-i960.c
239 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
240 [ -b ] [ -no-relax ]
241 @end ifset
242 @ifset M680X0
243 [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
244 @end ifset
245 @ifset MIPS
246 [ -nocpp ] [ -EL ] [ -EB ] [ -G @var{num} ] [ -mcpu=@var{CPU} ]
247 [ -mips1 ] [ -mips2 ] [ -mips3 ] [ -m4650 ] [ -no-m4650 ]
248 [ --trap ] [ --break ]
249 [ --emulation=@var{name} ]
250 @end ifset
251 [ -- | @var{files} @dots{} ]
252 @end smallexample
253
254 @table @code
255 @item -a[dhlns]
256 Turn on listings, in any of a variety of ways:
257
258 @table @code
259 @item -ad
260 omit debugging directives
261
262 @item -ah
263 include high-level source
264
265 @item -al
266 include assembly
267
268 @item -an
269 omit forms processing
270
271 @item -as
272 include symbols
273
274 @item =file
275 set the name of the listing file
276 @end table
277
278 You may combine these options; for example, use @samp{-aln} for assembly
279 listing without forms processing. The @samp{=file} option, if used, must be
280 the last one. By itself, @samp{-a} defaults to @samp{-ahls}---that is, all
281 listings turned on.
282
283 @item -D
284 Ignored. This option is accepted for script compatibility with calls to
285 other assemblers.
286
287 @item --defsym @var{sym}=@var{value}
288 Define the symbol @var{sym} to be @var{value} before assembling the input file.
289 @var{value} must be an integer constant. As in C, a leading @samp{0x}
290 indicates a hexadecimal value, and a leading @samp{0} indicates an octal value.
291
292 @item -f
293 ``fast''---skip whitespace and comment preprocessing (assume source is
294 compiler output).
295
296 @item --help
297 Print a summary of the command line options and exit.
298
299 @item -I @var{dir}
300 Add directory @var{dir} to the search list for @code{.include} directives.
301
302 @item -J
303 Don't warn about signed overflow.
304
305 @item -K
306 @ifclear DIFF-TBL-KLUGE
307 This option is accepted but has no effect on the @value{TARGET} family.
308 @end ifclear
309 @ifset DIFF-TBL-KLUGE
310 Issue warnings when difference tables altered for long displacements.
311 @end ifset
312
313 @item -L
314 Keep (in the symbol table) local symbols, starting with @samp{L}.
315
316 @item -o @var{objfile}
317 Name the object-file output from @code{@value{AS}} @var{objfile}.
318
319 @item -R
320 Fold the data section into the text section.
321
322 @item --statistics
323 Print the maximum space (in bytes) and total time (in seconds) used by
324 assembly.
325
326 @item -v
327 @itemx -version
328 Print the @code{as} version.
329
330 @item --version
331 Print the @code{as} version and exit.
332
333 @item -W
334 Suppress warning messages.
335
336 @item -w
337 Ignored.
338
339 @item -x
340 Ignored.
341
342 @item -Z
343 Generate an object file even after errors.
344
345 @item -- | @var{files} @dots{}
346 Standard input, or source files to assemble.
347
348 @end table
349
350 @ifset ARC
351 The following options are available when @value{AS} is configured for
352 an ARC processor.
353
354 @table @code
355
356 @cindex ARC endianness
357 @cindex endianness, ARC
358 @cindex big endian output, ARC
359 @item -mbig-endian
360 Generate ``big endian'' format output.
361
362 @cindex little endian output, ARC
363 @item -mlittle-endian
364 Generate ``little endian'' format output.
365
366 @end table
367 @end ifset
368
369 @ifset ARM
370 The following options are available when @value{AS} is configured for the ARM
371 processor family.
372
373 @table @code
374 @item -m[arm]1 | -m[arm]2 | -m[arm]250 | -m[arm]3 | -m[arm]6 | -m[arm]7[t][[d]m] | -m[arm]v2 | -m[arm]v2a | -m[arm]v3 | -m[arm]v3m | -m[arm]v4 | -m[arm]v4t
375 Specify which variant of the ARM architecture is the target.
376 @item -mthumb | -mall
377 Enable or disable Thumb only instruction decoding.
378 @item -mfpa10 | -mfpa11 | -mfpe-old | -mno-fpu
379 Select which Floating Point architcture is the target.
380 @item -mapcs-32 | -mapcs-26
381 Select which procedure calling convention is in use.
382 @item -EB | -EL
383 Select either big-endian (-EB) or little-endian (-EL) output.
384 @end table
385 @end ifset
386
387 @ifset D10V
388 The following options are available when @value{AS} is configured for
389 a D10V processor.
390 @table @code
391 @cindex D10V optimization
392 @cindex optimization, D10V
393 @item -O
394 Optimize output by parallelizing instructions.
395 @end table
396 @end ifset
397
398 @ifset I960
399 The following options are available when @value{AS} is configured for the
400 Intel 80960 processor.
401
402 @table @code
403 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
404 Specify which variant of the 960 architecture is the target.
405
406 @item -b
407 Add code to collect statistics about branches taken.
408
409 @item -no-relax
410 Do not alter compare-and-branch instructions for long displacements;
411 error if necessary.
412
413 @end table
414 @end ifset
415
416 @ifset M680X0
417 The following options are available when @value{AS} is configured for the
418 Motorola 68000 series.
419
420 @table @code
421
422 @item -l
423 Shorten references to undefined symbols, to one word instead of two.
424
425 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060
426 @itemx | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32 | -m5200
427 Specify what processor in the 68000 family is the target. The default
428 is normally the 68020, but this can be changed at configuration time.
429
430 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
431 The target machine does (or does not) have a floating-point coprocessor.
432 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
433 the basic 68000 is not compatible with the 68881, a combination of the
434 two can be specified, since it's possible to do emulation of the
435 coprocessor instructions with the main processor.
436
437 @item -m68851 | -mno-68851
438 The target machine does (or does not) have a memory-management
439 unit coprocessor. The default is to assume an MMU for 68020 and up.
440
441 @end table
442 @end ifset
443
444 @ifset SPARC
445 The following options are available when @code{@value{AS}} is configured
446 for the SPARC architecture:
447
448 @table @code
449 @item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite | -Av9 | -Av9a
450 Explicitly select a variant of the SPARC architecture.
451
452 @item -xarch=v8plus | -xarch=v8plusa
453 For compatibility with the Solaris v9 assembler. These options are
454 equivalent to -Av9 and -Av9a, respectively.
455
456 @item -bump
457 Warn when the assembler switches to another architecture.
458 @end table
459 @end ifset
460
461 @ifset MIPS
462 The following options are available when @value{AS} is configured for
463 a MIPS processor.
464
465 @table @code
466 @item -G @var{num}
467 This option sets the largest size of an object that can be referenced
468 implicitly with the @code{gp} register. It is only accepted for targets that
469 use ECOFF format, such as a DECstation running Ultrix. The default value is 8.
470
471 @cindex MIPS endianness
472 @cindex endianness, MIPS
473 @cindex big endian output, MIPS
474 @item -EB
475 Generate ``big endian'' format output.
476
477 @cindex little endian output, MIPS
478 @item -EL
479 Generate ``little endian'' format output.
480
481 @cindex MIPS ISA
482 @item -mips1
483 @itemx -mips2
484 @itemx -mips3
485 Generate code for a particular MIPS Instruction Set Architecture level.
486 @samp{-mips1} corresponds to the @sc{r2000} and @sc{r3000} processors,
487 @samp{-mips2} to the @sc{r6000} processor, and @samp{-mips3} to the @sc{r4000}
488 processor.
489
490 @item -m4650
491 @item -no-m4650
492 Generate code for the MIPS @sc{r4650} chip. This tells the assembler to accept
493 the @samp{mad} and @samp{madu} instruction, and to not schedule @samp{nop}
494 instructions around accesses to the @samp{HI} and @samp{LO} registers.
495 @samp{-no-m4650} turns off this option.
496
497 @item -mcpu=@var{CPU}
498 Generate code for a particular MIPS cpu. This has little effect on the
499 assembler, but it is passed by @code{@value{GCC}}.
500
501 @cindex emulation
502 @item --emulation=@var{name}
503 This option causes @code{@value{AS}} to emulate @code{@value{AS}} configured
504 for some other target, in all respects, including output format (choosing
505 between ELF and ECOFF only), handling of pseudo-opcodes which may generate
506 debugging information or store symbol table information, and default
507 endianness. The available configuration names are: @samp{mipsecoff},
508 @samp{mipself}, @samp{mipslecoff}, @samp{mipsbecoff}, @samp{mipslelf},
509 @samp{mipsbelf}. The first two do not alter the default endianness from that
510 of the primary target for which the assembler was configured; the others change
511 the default to little- or big-endian as indicated by the @samp{b} or @samp{l}
512 in the name. Using @samp{-EB} or @samp{-EL} will override the endianness
513 selection in any case.
514
515 This option is currently supported only when the primary target
516 @code{@value{AS}} is configured for is a MIPS ELF or ECOFF target.
517 Furthermore, the primary target or others specified with
518 @samp{--enable-targets=@dots{}} at configuration time must include support for
519 the other format, if both are to be available. For example, the Irix 5
520 configuration includes support for both.
521
522 Eventually, this option will support more configurations, with more
523 fine-grained control over the assembler's behavior, and will be supported for
524 more processors.
525
526 @item -nocpp
527 @code{@value{AS}} ignores this option. It is accepted for compatibility with
528 the native tools.
529
530 @need 900
531 @item --trap
532 @itemx --no-trap
533 @itemx --break
534 @itemx --no-break
535 Control how to deal with multiplication overflow and division by zero.
536 @samp{--trap} or @samp{--no-break} (which are synonyms) take a trap exception
537 (and only work for Instruction Set Architecture level 2 and higher);
538 @samp{--break} or @samp{--no-trap} (also synonyms, and the default) take a
539 break exception.
540 @end table
541 @end ifset
542
543 @menu
544 * Manual:: Structure of this Manual
545 * GNU Assembler:: The GNU Assembler
546 * Object Formats:: Object File Formats
547 * Command Line:: Command Line
548 * Input Files:: Input Files
549 * Object:: Output (Object) File
550 * Errors:: Error and Warning Messages
551 @end menu
552
553 @node Manual
554 @section Structure of this Manual
555
556 @cindex manual, structure and purpose
557 This manual is intended to describe what you need to know to use
558 @sc{gnu} @code{@value{AS}}. We cover the syntax expected in source files, including
559 notation for symbols, constants, and expressions; the directives that
560 @code{@value{AS}} understands; and of course how to invoke @code{@value{AS}}.
561
562 @ifclear GENERIC
563 We also cover special features in the @value{TARGET}
564 configuration of @code{@value{AS}}, including assembler directives.
565 @end ifclear
566 @ifset GENERIC
567 This manual also describes some of the machine-dependent features of
568 various flavors of the assembler.
569 @end ifset
570
571 @cindex machine instructions (not covered)
572 On the other hand, this manual is @emph{not} intended as an introduction
573 to programming in assembly language---let alone programming in general!
574 In a similar vein, we make no attempt to introduce the machine
575 architecture; we do @emph{not} describe the instruction set, standard
576 mnemonics, registers or addressing modes that are standard to a
577 particular architecture.
578 @ifset GENERIC
579 You may want to consult the manufacturer's
580 machine architecture manual for this information.
581 @end ifset
582 @ifclear GENERIC
583 @ifset H8/300
584 For information on the H8/300 machine instruction set, see @cite{H8/300
585 Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,
586 see @cite{H8/300H Series Programming Manual} (Hitachi).
587 @end ifset
588 @ifset H8/500
589 For information on the H8/500 machine instruction set, see @cite{H8/500
590 Series Programming Manual} (Hitachi M21T001).
591 @end ifset
592 @ifset SH
593 For information on the Hitachi SH machine instruction set, see
594 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
595 @end ifset
596 @ifset Z8000
597 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
598 @end ifset
599 @end ifclear
600
601 @c I think this is premature---doc@cygnus.com, 17jan1991
602 @ignore
603 Throughout this manual, we assume that you are running @dfn{GNU},
604 the portable operating system from the @dfn{Free Software
605 Foundation, Inc.}. This restricts our attention to certain kinds of
606 computer (in particular, the kinds of computers that @sc{gnu} can run on);
607 once this assumption is granted examples and definitions need less
608 qualification.
609
610 @code{@value{AS}} is part of a team of programs that turn a high-level
611 human-readable series of instructions into a low-level
612 computer-readable series of instructions. Different versions of
613 @code{@value{AS}} are used for different kinds of computer.
614 @end ignore
615
616 @c There used to be a section "Terminology" here, which defined
617 @c "contents", "byte", "word", and "long". Defining "word" to any
618 @c particular size is confusing when the .word directive may generate 16
619 @c bits on one machine and 32 bits on another; in general, for the user
620 @c version of this manual, none of these terms seem essential to define.
621 @c They were used very little even in the former draft of the manual;
622 @c this draft makes an effort to avoid them (except in names of
623 @c directives).
624
625 @node GNU Assembler
626 @section The GNU Assembler
627
628 @sc{gnu} @code{as} is really a family of assemblers.
629 @ifclear GENERIC
630 This manual describes @code{@value{AS}}, a member of that family which is
631 configured for the @value{TARGET} architectures.
632 @end ifclear
633 If you use (or have used) the @sc{gnu} assembler on one architecture, you
634 should find a fairly similar environment when you use it on another
635 architecture. Each version has much in common with the others,
636 including object file formats, most assembler directives (often called
637 @dfn{pseudo-ops}) and assembler syntax.@refill
638
639 @cindex purpose of @sc{gnu} assembler
640 @code{@value{AS}} is primarily intended to assemble the output of the
641 @sc{gnu} C compiler @code{@value{GCC}} for use by the linker
642 @code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}
643 assemble correctly everything that other assemblers for the same
644 machine would assemble.
645 @ifset VAX
646 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
647 @end ifset
648 @ifset M680X0
649 @c This remark should appear in generic version of manual; assumption
650 @c here is that generic version sets M680x0.
651 This doesn't mean @code{@value{AS}} always uses the same syntax as another
652 assembler for the same architecture; for example, we know of several
653 incompatible versions of 680x0 assembly language syntax.
654 @end ifset
655
656 Unlike older assemblers, @code{@value{AS}} is designed to assemble a source
657 program in one pass of the source file. This has a subtle impact on the
658 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
659
660 @node Object Formats
661 @section Object File Formats
662
663 @cindex object file format
664 The @sc{gnu} assembler can be configured to produce several alternative
665 object file formats. For the most part, this does not affect how you
666 write assembly language programs; but directives for debugging symbols
667 are typically different in different file formats. @xref{Symbol
668 Attributes,,Symbol Attributes}.
669 @ifclear GENERIC
670 @ifclear MULTI-OBJ
671 On the @value{TARGET}, @code{@value{AS}} is configured to produce
672 @value{OBJ-NAME} format object files.
673 @end ifclear
674 @c The following should exhaust all configs that set MULTI-OBJ, ideally
675 @ifset A29K
676 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
677 @code{a.out} or COFF format object files.
678 @end ifset
679 @ifset I960
680 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
681 @code{b.out} or COFF format object files.
682 @end ifset
683 @ifset HPPA
684 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
685 SOM or ELF format object files.
686 @end ifset
687 @end ifclear
688
689 @node Command Line
690 @section Command Line
691
692 @cindex command line conventions
693 After the program name @code{@value{AS}}, the command line may contain
694 options and file names. Options may appear in any order, and may be
695 before, after, or between file names. The order of file names is
696 significant.
697
698 @cindex standard input, as input file
699 @kindex --
700 @file{--} (two hyphens) by itself names the standard input file
701 explicitly, as one of the files for @code{@value{AS}} to assemble.
702
703 @cindex options, command line
704 Except for @samp{--} any command line argument that begins with a
705 hyphen (@samp{-}) is an option. Each option changes the behavior of
706 @code{@value{AS}}. No option changes the way another option works. An
707 option is a @samp{-} followed by one or more letters; the case of
708 the letter is important. All options are optional.
709
710 Some options expect exactly one file name to follow them. The file
711 name may either immediately follow the option's letter (compatible
712 with older assemblers) or it may be the next command argument (@sc{gnu}
713 standard). These two command lines are equivalent:
714
715 @smallexample
716 @value{AS} -o my-object-file.o mumble.s
717 @value{AS} -omy-object-file.o mumble.s
718 @end smallexample
719
720 @node Input Files
721 @section Input Files
722
723 @cindex input
724 @cindex source program
725 @cindex files, input
726 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
727 describe the program input to one run of @code{@value{AS}}. The program may
728 be in one or more files; how the source is partitioned into files
729 doesn't change the meaning of the source.
730
731 @c I added "con" prefix to "catenation" just to prove I can overcome my
732 @c APL training... doc@cygnus.com
733 The source program is a concatenation of the text in all the files, in the
734 order specified.
735
736 Each time you run @code{@value{AS}} it assembles exactly one source
737 program. The source program is made up of one or more files.
738 (The standard input is also a file.)
739
740 You give @code{@value{AS}} a command line that has zero or more input file
741 names. The input files are read (from left file name to right). A
742 command line argument (in any position) that has no special meaning
743 is taken to be an input file name.
744
745 If you give @code{@value{AS}} no file names it attempts to read one input file
746 from the @code{@value{AS}} standard input, which is normally your terminal. You
747 may have to type @key{ctl-D} to tell @code{@value{AS}} there is no more program
748 to assemble.
749
750 Use @samp{--} if you need to explicitly name the standard input file
751 in your command line.
752
753 If the source is empty, @code{@value{AS}} produces a small, empty object
754 file.
755
756 @subheading Filenames and Line-numbers
757
758 @cindex input file linenumbers
759 @cindex line numbers, in input files
760 There are two ways of locating a line in the input file (or files) and
761 either may be used in reporting error messages. One way refers to a line
762 number in a physical file; the other refers to a line number in a
763 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
764
765 @dfn{Physical files} are those files named in the command line given
766 to @code{@value{AS}}.
767
768 @dfn{Logical files} are simply names declared explicitly by assembler
769 directives; they bear no relation to physical files. Logical file names
770 help error messages reflect the original source file, when @code{@value{AS}}
771 source is itself synthesized from other files.
772 @xref{App-File,,@code{.app-file}}.
773
774 @node Object
775 @section Output (Object) File
776
777 @cindex object file
778 @cindex output file
779 @kindex a.out
780 @kindex .o
781 Every time you run @code{@value{AS}} it produces an output file, which is
782 your assembly language program translated into numbers. This file
783 is the object file. Its default name is
784 @ifclear BOUT
785 @code{a.out}.
786 @end ifclear
787 @ifset BOUT
788 @ifset GENERIC
789 @code{a.out}, or
790 @end ifset
791 @code{b.out} when @code{@value{AS}} is configured for the Intel 80960.
792 @end ifset
793 You can give it another name by using the @code{-o} option. Conventionally,
794 object file names end with @file{.o}. The default name is used for historical
795 reasons: older assemblers were capable of assembling self-contained programs
796 directly into a runnable program. (For some formats, this isn't currently
797 possible, but it can be done for the @code{a.out} format.)
798
799 @cindex linker
800 @kindex ld
801 The object file is meant for input to the linker @code{@value{LD}}. It contains
802 assembled program code, information to help @code{@value{LD}} integrate
803 the assembled program into a runnable file, and (optionally) symbolic
804 information for the debugger.
805
806 @c link above to some info file(s) like the description of a.out.
807 @c don't forget to describe @sc{gnu} info as well as Unix lossage.
808
809 @node Errors
810 @section Error and Warning Messages
811
812 @cindex error messsages
813 @cindex warning messages
814 @cindex messages from assembler
815 @code{@value{AS}} may write warnings and error messages to the standard error
816 file (usually your terminal). This should not happen when a compiler
817 runs @code{@value{AS}} automatically. Warnings report an assumption made so
818 that @code{@value{AS}} could keep assembling a flawed program; errors report a
819 grave problem that stops the assembly.
820
821 @cindex format of warning messages
822 Warning messages have the format
823
824 @smallexample
825 file_name:@b{NNN}:Warning Message Text
826 @end smallexample
827
828 @noindent
829 @cindex line numbers, in warnings/errors
830 (where @b{NNN} is a line number). If a logical file name has been given
831 (@pxref{App-File,,@code{.app-file}}) it is used for the filename,
832 otherwise the name of the current input file is used. If a logical line
833 number was given
834 @ifset GENERIC
835 (@pxref{Line,,@code{.line}})
836 @end ifset
837 @ifclear GENERIC
838 @ifclear A29K
839 (@pxref{Line,,@code{.line}})
840 @end ifclear
841 @ifset A29K
842 (@pxref{Ln,,@code{.ln}})
843 @end ifset
844 @end ifclear
845 then it is used to calculate the number printed,
846 otherwise the actual line in the current source file is printed. The
847 message text is intended to be self explanatory (in the grand Unix
848 tradition).
849
850 @cindex format of error messages
851 Error messages have the format
852 @smallexample
853 file_name:@b{NNN}:FATAL:Error Message Text
854 @end smallexample
855 The file name and line number are derived as for warning
856 messages. The actual message text may be rather less explanatory
857 because many of them aren't supposed to happen.
858
859 @node Invoking
860 @chapter Command-Line Options
861
862 @cindex options, all versions of assembler
863 This chapter describes command-line options available in @emph{all}
864 versions of the @sc{gnu} assembler; @pxref{Machine Dependencies}, for options specific
865 @ifclear GENERIC
866 to the @value{TARGET}.
867 @end ifclear
868 @ifset GENERIC
869 to particular machine architectures.
870 @end ifset
871
872 If you are invoking @code{@value{AS}} via the @sc{gnu} C compiler (version 2), you
873 can use the @samp{-Wa} option to pass arguments through to the
874 assembler. The assembler arguments must be separated from each other
875 (and the @samp{-Wa}) by commas. For example:
876
877 @smallexample
878 gcc -c -g -O -Wa,-alh,-L file.c
879 @end smallexample
880
881 @noindent
882 emits a listing to standard output with high-level
883 and assembly source.
884
885 Usually you do not need to use this @samp{-Wa} mechanism, since many compiler
886 command-line options are automatically passed to the assembler by the compiler.
887 (You can call the @sc{gnu} compiler driver with the @samp{-v} option to see
888 precisely what options it passes to each compilation pass, including the
889 assembler.)
890
891 @menu
892 * a:: -a[cdhlns] enable listings
893 * D:: -D for compatibility
894 * f:: -f to work faster
895 * I:: -I for .include search path
896 @ifclear DIFF-TBL-KLUGE
897 * K:: -K for compatibility
898 @end ifclear
899 @ifset DIFF-TBL-KLUGE
900 * K:: -K for difference tables
901 @end ifset
902
903 * L:: -L to retain local labels
904 * M:: -M or --mri to assemble in MRI compatibility mode
905 * MD:: --MD for dependency tracking
906 * o:: -o to name the object file
907 * R:: -R to join data and text sections
908 * statistics:: --statistics to see statistics about assembly
909 * v:: -v to announce version
910 * W:: -W to suppress warnings
911 * Z:: -Z to make object file even after errors
912 @end menu
913
914 @node a
915 @section Enable Listings: @code{-a[cdhlns]}
916
917 @kindex -a
918 @kindex -ac
919 @kindex -ad
920 @kindex -ah
921 @kindex -al
922 @kindex -an
923 @kindex -as
924 @cindex listings, enabling
925 @cindex assembly listings, enabling
926
927 These options enable listing output from the assembler. By itself,
928 @samp{-a} requests high-level, assembly, and symbols listing.
929 You can use other letters to select specific options for the list:
930 @samp{-ah} requests a high-level language listing,
931 @samp{-al} requests an output-program assembly listing, and
932 @samp{-as} requests a symbol table listing.
933 High-level listings require that a compiler debugging option like
934 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
935 also.
936
937 Use the @samp{-ac} option to omit false conditionals from a listing. Any lines
938 which are not assembled because of a false @code{.if} (or @code{.ifdef}, or any
939 other conditional), or a true @code{.if} followed by an @code{.else}, will be
940 omitted from the listing.
941
942 Use the @samp{-ad} option to omit debugging directives from the
943 listing.
944
945 Once you have specified one of these options, you can further control
946 listing output and its appearance using the directives @code{.list},
947 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
948 @code{.sbttl}.
949 The @samp{-an} option turns off all forms processing.
950 If you do not request listing output with one of the @samp{-a} options, the
951 listing-control directives have no effect.
952
953 The letters after @samp{-a} may be combined into one option,
954 @emph{e.g.}, @samp{-aln}.
955
956 @node D
957 @section @code{-D}
958
959 @kindex -D
960 This option has no effect whatsoever, but it is accepted to make it more
961 likely that scripts written for other assemblers also work with
962 @code{@value{AS}}.
963
964 @node f
965 @section Work Faster: @code{-f}
966
967 @kindex -f
968 @cindex trusted compiler
969 @cindex faster processing (@code{-f})
970 @samp{-f} should only be used when assembling programs written by a
971 (trusted) compiler. @samp{-f} stops the assembler from doing whitespace
972 and comment preprocessing on
973 the input file(s) before assembling them. @xref{Preprocessing,
974 ,Preprocessing}.
975
976 @quotation
977 @emph{Warning:} if you use @samp{-f} when the files actually need to be
978 preprocessed (if they contain comments, for example), @code{@value{AS}} does
979 not work correctly.
980 @end quotation
981
982 @node I
983 @section @code{.include} search path: @code{-I} @var{path}
984
985 @kindex -I @var{path}
986 @cindex paths for @code{.include}
987 @cindex search path for @code{.include}
988 @cindex @code{include} directive search path
989 Use this option to add a @var{path} to the list of directories
990 @code{@value{AS}} searches for files specified in @code{.include}
991 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
992 many times as necessary to include a variety of paths. The current
993 working directory is always searched first; after that, @code{@value{AS}}
994 searches any @samp{-I} directories in the same order as they were
995 specified (left to right) on the command line.
996
997 @node K
998 @section Difference Tables: @code{-K}
999
1000 @kindex -K
1001 @ifclear DIFF-TBL-KLUGE
1002 On the @value{TARGET} family, this option is allowed, but has no effect. It is
1003 permitted for compatibility with the @sc{gnu} assembler on other platforms,
1004 where it can be used to warn when the assembler alters the machine code
1005 generated for @samp{.word} directives in difference tables. The @value{TARGET}
1006 family does not have the addressing limitations that sometimes lead to this
1007 alteration on other platforms.
1008 @end ifclear
1009
1010 @ifset DIFF-TBL-KLUGE
1011 @cindex difference tables, warning
1012 @cindex warning for altered difference tables
1013 @code{@value{AS}} sometimes alters the code emitted for directives of the form
1014 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
1015 You can use the @samp{-K} option if you want a warning issued when this
1016 is done.
1017 @end ifset
1018
1019 @node L
1020 @section Include Local Labels: @code{-L}
1021
1022 @kindex -L
1023 @cindex local labels, retaining in output
1024 Labels beginning with @samp{L} (upper case only) are called @dfn{local
1025 labels}. @xref{Symbol Names}. Normally you do not see such labels when
1026 debugging, because they are intended for the use of programs (like
1027 compilers) that compose assembler programs, not for your notice.
1028 Normally both @code{@value{AS}} and @code{@value{LD}} discard such labels, so you do not
1029 normally debug with them.
1030
1031 This option tells @code{@value{AS}} to retain those @samp{L@dots{}} symbols
1032 in the object file. Usually if you do this you also tell the linker
1033 @code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
1034
1035 By default, a local label is any label beginning with @samp{L}, but each
1036 target is allowed to redefine the local label prefix.
1037 @ifset HPPA
1038 On the HPPA local labels begin with @samp{L$}.
1039 @end ifset
1040 @ifset ARM
1041 @samp{;} for the ARM family;
1042 @end ifset
1043
1044 @node M
1045 @section Assemble in MRI Compatibility Mode: @code{-M}
1046
1047 @kindex -M
1048 @cindex MRI compatibility mode
1049 The @code{-M} or @code{--mri} option selects MRI compatibility mode. This
1050 changes the syntax and pseudo-op handling of @code{@value{AS}} to make it
1051 compatible with the @code{ASM68K} or the @code{ASM960} (depending upon the
1052 configured target) assembler from Microtec Research. The exact nature of the
1053 MRI syntax will not be documented here; see the MRI manuals for more
1054 information. Note in particular that the handling of macros and macro
1055 arguments is somewhat different. The purpose of this option is to permit
1056 assembling existing MRI assembler code using @code{@value{AS}}.
1057
1058 The MRI compatibility is not complete. Certain operations of the MRI assembler
1059 depend upon its object file format, and can not be supported using other object
1060 file formats. Supporting these would require enhancing each object file format
1061 individually. These are:
1062
1063 @itemize @bullet
1064 @item global symbols in common section
1065
1066 The m68k MRI assembler supports common sections which are merged by the linker.
1067 Other object file formats do not support this. @code{@value{AS}} handles
1068 common sections by treating them as a single common symbol. It permits local
1069 symbols to be defined within a common section, but it can not support global
1070 symbols, since it has no way to describe them.
1071
1072 @item complex relocations
1073
1074 The MRI assemblers support relocations against a negated section address, and
1075 relocations which combine the start addresses of two or more sections. These
1076 are not support by other object file formats.
1077
1078 @item @code{END} pseudo-op specifying start address
1079
1080 The MRI @code{END} pseudo-op permits the specification of a start address.
1081 This is not supported by other object file formats. The start address may
1082 instead be specified using the @code{-e} option to the linker, or in a linker
1083 script.
1084
1085 @item @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops
1086
1087 The MRI @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops assign a module
1088 name to the output file. This is not supported by other object file formats.
1089
1090 @item @code{ORG} pseudo-op
1091
1092 The m68k MRI @code{ORG} pseudo-op begins an absolute section at a given
1093 address. This differs from the usual @code{@value{AS}} @code{.org} pseudo-op,
1094 which changes the location within the current section. Absolute sections are
1095 not supported by other object file formats. The address of a section may be
1096 assigned within a linker script.
1097 @end itemize
1098
1099 There are some other features of the MRI assembler which are not supported by
1100 @code{@value{AS}}, typically either because they are difficult or because they
1101 seem of little consequence. Some of these may be supported in future releases.
1102
1103 @itemize @bullet
1104
1105 @item EBCDIC strings
1106
1107 EBCDIC strings are not supported.
1108
1109 @item packed binary coded decimal
1110
1111 Packed binary coded decimal is not supported. This means that the @code{DC.P}
1112 and @code{DCB.P} pseudo-ops are not supported.
1113
1114 @item @code{FEQU} pseudo-op
1115
1116 The m68k @code{FEQU} pseudo-op is not supported.
1117
1118 @item @code{NOOBJ} pseudo-op
1119
1120 The m68k @code{NOOBJ} pseudo-op is not supported.
1121
1122 @item @code{OPT} branch control options
1123
1124 The m68k @code{OPT} branch control options---@code{B}, @code{BRS}, @code{BRB},
1125 @code{BRL}, and @code{BRW}---are ignored. @code{@value{AS}} automatically
1126 relaxes all branches, whether forward or backward, to an appropriate size, so
1127 these options serve no purpose.
1128
1129 @item @code{OPT} list control options
1130
1131 The following m68k @code{OPT} list control options are ignored: @code{C},
1132 @code{CEX}, @code{CL}, @code{CRE}, @code{E}, @code{G}, @code{I}, @code{M},
1133 @code{MEX}, @code{MC}, @code{MD}, @code{X}.
1134
1135 @item other @code{OPT} options
1136
1137 The following m68k @code{OPT} options are ignored: @code{NEST}, @code{O},
1138 @code{OLD}, @code{OP}, @code{P}, @code{PCO}, @code{PCR}, @code{PCS}, @code{R}.
1139
1140 @item @code{OPT} @code{D} option is default
1141
1142 The m68k @code{OPT} @code{D} option is the default, unlike the MRI assembler.
1143 @code{OPT NOD} may be used to turn it off.
1144
1145 @item @code{XREF} pseudo-op.
1146
1147 The m68k @code{XREF} pseudo-op is ignored.
1148
1149 @item @code{.debug} pseudo-op
1150
1151 The i960 @code{.debug} pseudo-op is not supported.
1152
1153 @item @code{.extended} pseudo-op
1154
1155 The i960 @code{.extended} pseudo-op is not supported.
1156
1157 @item @code{.list} pseudo-op.
1158
1159 The various options of the i960 @code{.list} pseudo-op are not supported.
1160
1161 @item @code{.optimize} pseudo-op
1162
1163 The i960 @code{.optimize} pseudo-op is not supported.
1164
1165 @item @code{.output} pseudo-op
1166
1167 The i960 @code{.output} pseudo-op is not supported.
1168
1169 @item @code{.setreal} pseudo-op
1170
1171 The i960 @code{.setreal} pseudo-op is not supported.
1172
1173 @end itemize
1174
1175 @node MD
1176 @section Dependency tracking: @code{--MD}
1177
1178 @kindex --MD
1179 @cindex dependency tracking
1180 @cindex make rules
1181
1182 @code{@value{AS}} can generate a dependency file for the file it creates. This
1183 file consists of a single rule suitable for @code{make} describing the
1184 dependencies of the main source file.
1185
1186 The rule is written to the file named in its argument.
1187
1188 This feature is used in the automatic updating of makefiles.
1189
1190 @node o
1191 @section Name the Object File: @code{-o}
1192
1193 @kindex -o
1194 @cindex naming object file
1195 @cindex object file name
1196 There is always one object file output when you run @code{@value{AS}}. By
1197 default it has the name
1198 @ifset GENERIC
1199 @ifset I960
1200 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
1201 @end ifset
1202 @ifclear I960
1203 @file{a.out}.
1204 @end ifclear
1205 @end ifset
1206 @ifclear GENERIC
1207 @ifset I960
1208 @file{b.out}.
1209 @end ifset
1210 @ifclear I960
1211 @file{a.out}.
1212 @end ifclear
1213 @end ifclear
1214 You use this option (which takes exactly one filename) to give the
1215 object file a different name.
1216
1217 Whatever the object file is called, @code{@value{AS}} overwrites any
1218 existing file of the same name.
1219
1220 @node R
1221 @section Join Data and Text Sections: @code{-R}
1222
1223 @kindex -R
1224 @cindex data and text sections, joining
1225 @cindex text and data sections, joining
1226 @cindex joining text and data sections
1227 @cindex merging text and data sections
1228 @code{-R} tells @code{@value{AS}} to write the object file as if all
1229 data-section data lives in the text section. This is only done at
1230 the very last moment: your binary data are the same, but data
1231 section parts are relocated differently. The data section part of
1232 your object file is zero bytes long because all its bytes are
1233 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
1234
1235 When you specify @code{-R} it would be possible to generate shorter
1236 address displacements (because we do not have to cross between text and
1237 data section). We refrain from doing this simply for compatibility with
1238 older versions of @code{@value{AS}}. In future, @code{-R} may work this way.
1239
1240 @ifset COFF
1241 When @code{@value{AS}} is configured for COFF output,
1242 this option is only useful if you use sections named @samp{.text} and
1243 @samp{.data}.
1244 @end ifset
1245
1246 @ifset HPPA
1247 @code{-R} is not supported for any of the HPPA targets. Using
1248 @code{-R} generates a warning from @code{@value{AS}}.
1249 @end ifset
1250
1251 @node statistics
1252 @section Display Assembly Statistics: @code{--statistics}
1253
1254 @kindex --statistics
1255 @cindex statistics, about assembly
1256 @cindex time, total for assembly
1257 @cindex space used, maximum for assembly
1258 Use @samp{--statistics} to display two statistics about the resources used by
1259 @code{@value{AS}}: the maximum amount of space allocated during the assembly
1260 (in bytes), and the total execution time taken for the assembly (in @sc{cpu}
1261 seconds).
1262
1263 @node v
1264 @section Announce Version: @code{-v}
1265
1266 @kindex -v
1267 @kindex -version
1268 @cindex assembler version
1269 @cindex version of assembler
1270 You can find out what version of as is running by including the
1271 option @samp{-v} (which you can also spell as @samp{-version}) on the
1272 command line.
1273
1274 @node W
1275 @section Suppress Warnings: @code{-W}
1276
1277 @kindex -W
1278 @cindex suppressing warnings
1279 @cindex warnings, suppressing
1280 @code{@value{AS}} should never give a warning or error message when
1281 assembling compiler output. But programs written by people often
1282 cause @code{@value{AS}} to give a warning that a particular assumption was
1283 made. All such warnings are directed to the standard error file.
1284 If you use this option, no warnings are issued. This option only
1285 affects the warning messages: it does not change any particular of how
1286 @code{@value{AS}} assembles your file. Errors, which stop the assembly, are
1287 still reported.
1288
1289 @node Z
1290 @section Generate Object File in Spite of Errors: @code{-Z}
1291 @cindex object file, after errors
1292 @cindex errors, continuing after
1293 After an error message, @code{@value{AS}} normally produces no output. If for
1294 some reason you are interested in object file output even after
1295 @code{@value{AS}} gives an error message on your program, use the @samp{-Z}
1296 option. If there are any errors, @code{@value{AS}} continues anyways, and
1297 writes an object file after a final warning message of the form @samp{@var{n}
1298 errors, @var{m} warnings, generating bad object file.}
1299
1300 @node Syntax
1301 @chapter Syntax
1302
1303 @cindex machine-independent syntax
1304 @cindex syntax, machine-independent
1305 This chapter describes the machine-independent syntax allowed in a
1306 source file. @code{@value{AS}} syntax is similar to what many other
1307 assemblers use; it is inspired by the BSD 4.2
1308 @ifclear VAX
1309 assembler.
1310 @end ifclear
1311 @ifset VAX
1312 assembler, except that @code{@value{AS}} does not assemble Vax bit-fields.
1313 @end ifset
1314
1315 @menu
1316 * Preprocessing:: Preprocessing
1317 * Whitespace:: Whitespace
1318 * Comments:: Comments
1319 * Symbol Intro:: Symbols
1320 * Statements:: Statements
1321 * Constants:: Constants
1322 @end menu
1323
1324 @node Preprocessing
1325 @section Preprocessing
1326
1327 @cindex preprocessing
1328 The @code{@value{AS}} internal preprocessor:
1329 @itemize @bullet
1330 @cindex whitespace, removed by preprocessor
1331 @item
1332 adjusts and removes extra whitespace. It leaves one space or tab before
1333 the keywords on a line, and turns any other whitespace on the line into
1334 a single space.
1335
1336 @cindex comments, removed by preprocessor
1337 @item
1338 removes all comments, replacing them with a single space, or an
1339 appropriate number of newlines.
1340
1341 @cindex constants, converted by preprocessor
1342 @item
1343 converts character constants into the appropriate numeric values.
1344 @end itemize
1345
1346 It does not do macro processing, include file handling, or
1347 anything else you may get from your C compiler's preprocessor. You can
1348 do include file processing with the @code{.include} directive
1349 (@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
1350 to get other ``CPP'' style preprocessing, by giving the input file a
1351 @samp{.S} suffix. @xref{Overall Options,, Options Controlling the Kind of
1352 Output, gcc.info, Using GNU CC}.
1353
1354 Excess whitespace, comments, and character constants
1355 cannot be used in the portions of the input text that are not
1356 preprocessed.
1357
1358 @cindex turning preprocessing on and off
1359 @cindex preprocessing, turning on and off
1360 @kindex #NO_APP
1361 @kindex #APP
1362 If the first line of an input file is @code{#NO_APP} or if you use the
1363 @samp{-f} option, whitespace and comments are not removed from the input file.
1364 Within an input file, you can ask for whitespace and comment removal in
1365 specific portions of the by putting a line that says @code{#APP} before the
1366 text that may contain whitespace or comments, and putting a line that says
1367 @code{#NO_APP} after this text. This feature is mainly intend to support
1368 @code{asm} statements in compilers whose output is otherwise free of comments
1369 and whitespace.
1370
1371 @node Whitespace
1372 @section Whitespace
1373
1374 @cindex whitespace
1375 @dfn{Whitespace} is one or more blanks or tabs, in any order.
1376 Whitespace is used to separate symbols, and to make programs neater for
1377 people to read. Unless within character constants
1378 (@pxref{Characters,,Character Constants}), any whitespace means the same
1379 as exactly one space.
1380
1381 @node Comments
1382 @section Comments
1383
1384 @cindex comments
1385 There are two ways of rendering comments to @code{@value{AS}}. In both
1386 cases the comment is equivalent to one space.
1387
1388 Anything from @samp{/*} through the next @samp{*/} is a comment.
1389 This means you may not nest these comments.
1390
1391 @smallexample
1392 /*
1393 The only way to include a newline ('\n') in a comment
1394 is to use this sort of comment.
1395 */
1396
1397 /* This sort of comment does not nest. */
1398 @end smallexample
1399
1400 @cindex line comment character
1401 Anything from the @dfn{line comment} character to the next newline
1402 is considered a comment and is ignored. The line comment character is
1403 @ifset A29K
1404 @samp{;} for the AMD 29K family;
1405 @end ifset
1406 @ifset ARC
1407 @samp{;} on the ARC;
1408 @end ifset
1409 @ifset H8/300
1410 @samp{;} for the H8/300 family;
1411 @end ifset
1412 @ifset H8/500
1413 @samp{!} for the H8/500 family;
1414 @end ifset
1415 @ifset HPPA
1416 @samp{;} for the HPPA;
1417 @end ifset
1418 @ifset I960
1419 @samp{#} on the i960;
1420 @end ifset
1421 @ifset SH
1422 @samp{!} for the Hitachi SH;
1423 @end ifset
1424 @ifset SPARC
1425 @samp{!} on the SPARC;
1426 @end ifset
1427 @ifset M680X0
1428 @samp{|} on the 680x0;
1429 @end ifset
1430 @ifset VAX
1431 @samp{#} on the Vax;
1432 @end ifset
1433 @ifset Z8000
1434 @samp{!} for the Z8000;
1435 @end ifset
1436 see @ref{Machine Dependencies}. @refill
1437 @c FIXME What about i386, m88k, i860?
1438
1439 @ifset GENERIC
1440 On some machines there are two different line comment characters. One
1441 character only begins a comment if it is the first non-whitespace character on
1442 a line, while the other always begins a comment.
1443 @end ifset
1444
1445 @kindex #
1446 @cindex lines starting with @code{#}
1447 @cindex logical line numbers
1448 To be compatible with past assemblers, lines that begin with @samp{#} have a
1449 special interpretation. Following the @samp{#} should be an absolute
1450 expression (@pxref{Expressions}): the logical line number of the @emph{next}
1451 line. Then a string (@pxref{Strings,, Strings}) is allowed: if present it is a
1452 new logical file name. The rest of the line, if any, should be whitespace.
1453
1454 If the first non-whitespace characters on the line are not numeric,
1455 the line is ignored. (Just like a comment.)
1456
1457 @smallexample
1458 # This is an ordinary comment.
1459 # 42-6 "new_file_name" # New logical file name
1460 # This is logical line # 36.
1461 @end smallexample
1462 This feature is deprecated, and may disappear from future versions
1463 of @code{@value{AS}}.
1464
1465 @node Symbol Intro
1466 @section Symbols
1467
1468 @cindex characters used in symbols
1469 @ifclear SPECIAL-SYMS
1470 A @dfn{symbol} is one or more characters chosen from the set of all
1471 letters (both upper and lower case), digits and the three characters
1472 @samp{_.$}.
1473 @end ifclear
1474 @ifset SPECIAL-SYMS
1475 @ifclear GENERIC
1476 @ifset H8
1477 A @dfn{symbol} is one or more characters chosen from the set of all
1478 letters (both upper and lower case), digits and the three characters
1479 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
1480 symbol names.)
1481 @end ifset
1482 @end ifclear
1483 @end ifset
1484 @ifset GENERIC
1485 On most machines, you can also use @code{$} in symbol names; exceptions
1486 are noted in @ref{Machine Dependencies}.
1487 @end ifset
1488 No symbol may begin with a digit. Case is significant.
1489 There is no length limit: all characters are significant. Symbols are
1490 delimited by characters not in that set, or by the beginning of a file
1491 (since the source program must end with a newline, the end of a file is
1492 not a possible symbol delimiter). @xref{Symbols}.
1493 @cindex length of symbols
1494
1495 @node Statements
1496 @section Statements
1497
1498 @cindex statements, structure of
1499 @cindex line separator character
1500 @cindex statement separator character
1501 @ifclear GENERIC
1502 @ifclear abnormal-separator
1503 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
1504 semicolon (@samp{;}). The newline or semicolon is considered part of
1505 the preceding statement. Newlines and semicolons within character
1506 constants are an exception: they do not end statements.
1507 @end ifclear
1508 @ifset abnormal-separator
1509 @ifset A29K
1510 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
1511 sign (@samp{@@}). The newline or at sign is considered part of the
1512 preceding statement. Newlines and at signs within character constants
1513 are an exception: they do not end statements.
1514 @end ifset
1515 @ifset HPPA
1516 A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
1517 point (@samp{!}). The newline or exclamation point is considered part of the
1518 preceding statement. Newlines and exclamation points within character
1519 constants are an exception: they do not end statements.
1520 @end ifset
1521 @ifset H8
1522 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
1523 H8/300) a dollar sign (@samp{$}); or (for the
1524 Hitachi-SH or the
1525 H8/500) a semicolon
1526 (@samp{;}). The newline or separator character is considered part of
1527 the preceding statement. Newlines and separators within character
1528 constants are an exception: they do not end statements.
1529 @end ifset
1530 @end ifset
1531 @end ifclear
1532 @ifset GENERIC
1533 A @dfn{statement} ends at a newline character (@samp{\n}) or line
1534 separator character. (The line separator is usually @samp{;}, unless
1535 this conflicts with the comment character; @pxref{Machine Dependencies}.) The
1536 newline or separator character is considered part of the preceding
1537 statement. Newlines and separators within character constants are an
1538 exception: they do not end statements.
1539 @end ifset
1540
1541 @cindex newline, required at file end
1542 @cindex EOF, newline must precede
1543 It is an error to end any statement with end-of-file: the last
1544 character of any input file should be a newline.@refill
1545
1546 @cindex continuing statements
1547 @cindex multi-line statements
1548 @cindex statement on multiple lines
1549 You may write a statement on more than one line if you put a
1550 backslash (@kbd{\}) immediately in front of any newlines within the
1551 statement. When @code{@value{AS}} reads a backslashed newline both
1552 characters are ignored. You can even put backslashed newlines in
1553 the middle of symbol names without changing the meaning of your
1554 source program.
1555
1556 An empty statement is allowed, and may include whitespace. It is ignored.
1557
1558 @cindex instructions and directives
1559 @cindex directives and instructions
1560 @c "key symbol" is not used elsewhere in the document; seems pedantic to
1561 @c @defn{} it in that case, as was done previously... doc@cygnus.com,
1562 @c 13feb91.
1563 A statement begins with zero or more labels, optionally followed by a
1564 key symbol which determines what kind of statement it is. The key
1565 symbol determines the syntax of the rest of the statement. If the
1566 symbol begins with a dot @samp{.} then the statement is an assembler
1567 directive: typically valid for any computer. If the symbol begins with
1568 a letter the statement is an assembly language @dfn{instruction}: it
1569 assembles into a machine language instruction.
1570 @ifset GENERIC
1571 Different versions of @code{@value{AS}} for different computers
1572 recognize different instructions. In fact, the same symbol may
1573 represent a different instruction in a different computer's assembly
1574 language.@refill
1575 @end ifset
1576
1577 @cindex @code{:} (label)
1578 @cindex label (@code{:})
1579 A label is a symbol immediately followed by a colon (@code{:}).
1580 Whitespace before a label or after a colon is permitted, but you may not
1581 have whitespace between a label's symbol and its colon. @xref{Labels}.
1582
1583 @ifset HPPA
1584 For HPPA targets, labels need not be immediately followed by a colon, but
1585 the definition of a label must begin in column zero. This also implies that
1586 only one label may be defined on each line.
1587 @end ifset
1588
1589 @smallexample
1590 label: .directive followed by something
1591 another_label: # This is an empty statement.
1592 instruction operand_1, operand_2, @dots{}
1593 @end smallexample
1594
1595 @node Constants
1596 @section Constants
1597
1598 @cindex constants
1599 A constant is a number, written so that its value is known by
1600 inspection, without knowing any context. Like this:
1601 @smallexample
1602 @group
1603 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
1604 .ascii "Ring the bell\7" # A string constant.
1605 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
1606 .float 0f-314159265358979323846264338327\
1607 95028841971.693993751E-40 # - pi, a flonum.
1608 @end group
1609 @end smallexample
1610
1611 @menu
1612 * Characters:: Character Constants
1613 * Numbers:: Number Constants
1614 @end menu
1615
1616 @node Characters
1617 @subsection Character Constants
1618
1619 @cindex character constants
1620 @cindex constants, character
1621 There are two kinds of character constants. A @dfn{character} stands
1622 for one character in one byte and its value may be used in
1623 numeric expressions. String constants (properly called string
1624 @emph{literals}) are potentially many bytes and their values may not be
1625 used in arithmetic expressions.
1626
1627 @menu
1628 * Strings:: Strings
1629 * Chars:: Characters
1630 @end menu
1631
1632 @node Strings
1633 @subsubsection Strings
1634
1635 @cindex string constants
1636 @cindex constants, string
1637 A @dfn{string} is written between double-quotes. It may contain
1638 double-quotes or null characters. The way to get special characters
1639 into a string is to @dfn{escape} these characters: precede them with
1640 a backslash @samp{\} character. For example @samp{\\} represents
1641 one backslash: the first @code{\} is an escape which tells
1642 @code{@value{AS}} to interpret the second character literally as a backslash
1643 (which prevents @code{@value{AS}} from recognizing the second @code{\} as an
1644 escape character). The complete list of escapes follows.
1645
1646 @cindex escape codes, character
1647 @cindex character escape codes
1648 @table @kbd
1649 @c @item \a
1650 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
1651 @c
1652 @cindex @code{\b} (backspace character)
1653 @cindex backspace (@code{\b})
1654 @item \b
1655 Mnemonic for backspace; for ASCII this is octal code 010.
1656
1657 @c @item \e
1658 @c Mnemonic for EOText; for ASCII this is octal code 004.
1659 @c
1660 @cindex @code{\f} (formfeed character)
1661 @cindex formfeed (@code{\f})
1662 @item \f
1663 Mnemonic for FormFeed; for ASCII this is octal code 014.
1664
1665 @cindex @code{\n} (newline character)
1666 @cindex newline (@code{\n})
1667 @item \n
1668 Mnemonic for newline; for ASCII this is octal code 012.
1669
1670 @c @item \p
1671 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
1672 @c
1673 @cindex @code{\r} (carriage return character)
1674 @cindex carriage return (@code{\r})
1675 @item \r
1676 Mnemonic for carriage-Return; for ASCII this is octal code 015.
1677
1678 @c @item \s
1679 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
1680 @c other assemblers.
1681 @c
1682 @cindex @code{\t} (tab)
1683 @cindex tab (@code{\t})
1684 @item \t
1685 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
1686
1687 @c @item \v
1688 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
1689 @c @item \x @var{digit} @var{digit} @var{digit}
1690 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
1691 @c
1692 @cindex @code{\@var{ddd}} (octal character code)
1693 @cindex octal character code (@code{\@var{ddd}})
1694 @item \ @var{digit} @var{digit} @var{digit}
1695 An octal character code. The numeric code is 3 octal digits.
1696 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
1697 for example, @code{\008} has the value 010, and @code{\009} the value 011.
1698
1699 @cindex @code{\@var{xd...}} (hex character code)
1700 @cindex hex character code (@code{\@var{xd...}})
1701 @item \@code{x} @var{hex-digits...}
1702 A hex character code. All trailing hex digits are combined. Either upper or
1703 lower case @code{x} works.
1704
1705 @cindex @code{\\} (@samp{\} character)
1706 @cindex backslash (@code{\\})
1707 @item \\
1708 Represents one @samp{\} character.
1709
1710 @c @item \'
1711 @c Represents one @samp{'} (accent acute) character.
1712 @c This is needed in single character literals
1713 @c (@xref{Characters,,Character Constants}.) to represent
1714 @c a @samp{'}.
1715 @c
1716 @cindex @code{\"} (doublequote character)
1717 @cindex doublequote (@code{\"})
1718 @item \"
1719 Represents one @samp{"} character. Needed in strings to represent
1720 this character, because an unescaped @samp{"} would end the string.
1721
1722 @item \ @var{anything-else}
1723 Any other character when escaped by @kbd{\} gives a warning, but
1724 assembles as if the @samp{\} was not present. The idea is that if
1725 you used an escape sequence you clearly didn't want the literal
1726 interpretation of the following character. However @code{@value{AS}} has no
1727 other interpretation, so @code{@value{AS}} knows it is giving you the wrong
1728 code and warns you of the fact.
1729 @end table
1730
1731 Which characters are escapable, and what those escapes represent,
1732 varies widely among assemblers. The current set is what we think
1733 the BSD 4.2 assembler recognizes, and is a subset of what most C
1734 compilers recognize. If you are in doubt, do not use an escape
1735 sequence.
1736
1737 @node Chars
1738 @subsubsection Characters
1739
1740 @cindex single character constant
1741 @cindex character, single
1742 @cindex constant, single character
1743 A single character may be written as a single quote immediately
1744 followed by that character. The same escapes apply to characters as
1745 to strings. So if you want to write the character backslash, you
1746 must write @kbd{'\\} where the first @code{\} escapes the second
1747 @code{\}. As you can see, the quote is an acute accent, not a
1748 grave accent. A newline
1749 @ifclear GENERIC
1750 @ifclear abnormal-separator
1751 (or semicolon @samp{;})
1752 @end ifclear
1753 @ifset abnormal-separator
1754 @ifset A29K
1755 (or at sign @samp{@@})
1756 @end ifset
1757 @ifset H8
1758 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
1759 Hitachi SH or
1760 H8/500)
1761 @end ifset
1762 @end ifset
1763 @end ifclear
1764 immediately following an acute accent is taken as a literal character
1765 and does not count as the end of a statement. The value of a character
1766 constant in a numeric expression is the machine's byte-wide code for
1767 that character. @code{@value{AS}} assumes your character code is ASCII:
1768 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
1769
1770 @node Numbers
1771 @subsection Number Constants
1772
1773 @cindex constants, number
1774 @cindex number constants
1775 @code{@value{AS}} distinguishes three kinds of numbers according to how they
1776 are stored in the target machine. @emph{Integers} are numbers that
1777 would fit into an @code{int} in the C language. @emph{Bignums} are
1778 integers, but they are stored in more than 32 bits. @emph{Flonums}
1779 are floating point numbers, described below.
1780
1781 @menu
1782 * Integers:: Integers
1783 * Bignums:: Bignums
1784 * Flonums:: Flonums
1785 @ifclear GENERIC
1786 @ifset I960
1787 * Bit Fields:: Bit Fields
1788 @end ifset
1789 @end ifclear
1790 @end menu
1791
1792 @node Integers
1793 @subsubsection Integers
1794 @cindex integers
1795 @cindex constants, integer
1796
1797 @cindex binary integers
1798 @cindex integers, binary
1799 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
1800 the binary digits @samp{01}.
1801
1802 @cindex octal integers
1803 @cindex integers, octal
1804 An octal integer is @samp{0} followed by zero or more of the octal
1805 digits (@samp{01234567}).
1806
1807 @cindex decimal integers
1808 @cindex integers, decimal
1809 A decimal integer starts with a non-zero digit followed by zero or
1810 more digits (@samp{0123456789}).
1811
1812 @cindex hexadecimal integers
1813 @cindex integers, hexadecimal
1814 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1815 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
1816
1817 Integers have the usual values. To denote a negative integer, use
1818 the prefix operator @samp{-} discussed under expressions
1819 (@pxref{Prefix Ops,,Prefix Operators}).
1820
1821 @node Bignums
1822 @subsubsection Bignums
1823
1824 @cindex bignums
1825 @cindex constants, bignum
1826 A @dfn{bignum} has the same syntax and semantics as an integer
1827 except that the number (or its negative) takes more than 32 bits to
1828 represent in binary. The distinction is made because in some places
1829 integers are permitted while bignums are not.
1830
1831 @node Flonums
1832 @subsubsection Flonums
1833 @cindex flonums
1834 @cindex floating point numbers
1835 @cindex constants, floating point
1836
1837 @cindex precision, floating point
1838 A @dfn{flonum} represents a floating point number. The translation is
1839 indirect: a decimal floating point number from the text is converted by
1840 @code{@value{AS}} to a generic binary floating point number of more than
1841 sufficient precision. This generic floating point number is converted
1842 to a particular computer's floating point format (or formats) by a
1843 portion of @code{@value{AS}} specialized to that computer.
1844
1845 A flonum is written by writing (in order)
1846 @itemize @bullet
1847 @item
1848 The digit @samp{0}.
1849 @ifset HPPA
1850 (@samp{0} is optional on the HPPA.)
1851 @end ifset
1852
1853 @item
1854 A letter, to tell @code{@value{AS}} the rest of the number is a flonum.
1855 @ifset GENERIC
1856 @kbd{e} is recommended. Case is not important.
1857 @ignore
1858 @c FIXME: verify if flonum syntax really this vague for most cases
1859 (Any otherwise illegal letter works here, but that might be changed. Vax BSD
1860 4.2 assembler seems to allow any of @samp{defghDEFGH}.)
1861 @end ignore
1862
1863 On the H8/300, H8/500,
1864 Hitachi SH,
1865 and AMD 29K architectures, the letter must be
1866 one of the letters @samp{DFPRSX} (in upper or lower case).
1867
1868 On the ARC, the letter must be one of the letters @samp{DFRS}
1869 (in upper or lower case).
1870
1871 On the Intel 960 architecture, the letter must be
1872 one of the letters @samp{DFT} (in upper or lower case).
1873
1874 On the HPPA architecture, the letter must be @samp{E} (upper case only).
1875 @end ifset
1876 @ifclear GENERIC
1877 @ifset A29K
1878 One of the letters @samp{DFPRSX} (in upper or lower case).
1879 @end ifset
1880 @ifset ARC
1881 One of the letters @samp{DFRS} (in upper or lower case).
1882 @end ifset
1883 @ifset H8
1884 One of the letters @samp{DFPRSX} (in upper or lower case).
1885 @end ifset
1886 @ifset HPPA
1887 The letter @samp{E} (upper case only).
1888 @end ifset
1889 @ifset I960
1890 One of the letters @samp{DFT} (in upper or lower case).
1891 @end ifset
1892 @end ifclear
1893
1894 @item
1895 An optional sign: either @samp{+} or @samp{-}.
1896
1897 @item
1898 An optional @dfn{integer part}: zero or more decimal digits.
1899
1900 @item
1901 An optional @dfn{fractional part}: @samp{.} followed by zero
1902 or more decimal digits.
1903
1904 @item
1905 An optional exponent, consisting of:
1906
1907 @itemize @bullet
1908 @item
1909 An @samp{E} or @samp{e}.
1910 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1911 @c principle this can perfectly well be different on different targets.
1912 @item
1913 Optional sign: either @samp{+} or @samp{-}.
1914 @item
1915 One or more decimal digits.
1916 @end itemize
1917
1918 @end itemize
1919
1920 At least one of the integer part or the fractional part must be
1921 present. The floating point number has the usual base-10 value.
1922
1923 @code{@value{AS}} does all processing using integers. Flonums are computed
1924 independently of any floating point hardware in the computer running
1925 @code{@value{AS}}.
1926
1927 @ifclear GENERIC
1928 @ifset I960
1929 @c Bit fields are written as a general facility but are also controlled
1930 @c by a conditional-compilation flag---which is as of now (21mar91)
1931 @c turned on only by the i960 config of GAS.
1932 @node Bit Fields
1933 @subsubsection Bit Fields
1934
1935 @cindex bit fields
1936 @cindex constants, bit field
1937 You can also define numeric constants as @dfn{bit fields}.
1938 specify two numbers separated by a colon---
1939 @example
1940 @var{mask}:@var{value}
1941 @end example
1942 @noindent
1943 @code{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
1944 @var{value}.
1945
1946 The resulting number is then packed
1947 @ifset GENERIC
1948 @c this conditional paren in case bit fields turned on elsewhere than 960
1949 (in host-dependent byte order)
1950 @end ifset
1951 into a field whose width depends on which assembler directive has the
1952 bit-field as its argument. Overflow (a result from the bitwise and
1953 requiring more binary digits to represent) is not an error; instead,
1954 more constants are generated, of the specified width, beginning with the
1955 least significant digits.@refill
1956
1957 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1958 @code{.short}, and @code{.word} accept bit-field arguments.
1959 @end ifset
1960 @end ifclear
1961
1962 @node Sections
1963 @chapter Sections and Relocation
1964 @cindex sections
1965 @cindex relocation
1966
1967 @menu
1968 * Secs Background:: Background
1969 * Ld Sections:: Linker Sections
1970 * As Sections:: Assembler Internal Sections
1971 * Sub-Sections:: Sub-Sections
1972 * bss:: bss Section
1973 @end menu
1974
1975 @node Secs Background
1976 @section Background
1977
1978 Roughly, a section is a range of addresses, with no gaps; all data
1979 ``in'' those addresses is treated the same for some particular purpose.
1980 For example there may be a ``read only'' section.
1981
1982 @cindex linker, and assembler
1983 @cindex assembler, and linker
1984 The linker @code{@value{LD}} reads many object files (partial programs) and
1985 combines their contents to form a runnable program. When @code{@value{AS}}
1986 emits an object file, the partial program is assumed to start at address 0.
1987 @code{@value{LD}} assigns the final addresses for the partial program, so that
1988 different partial programs do not overlap. This is actually an
1989 oversimplification, but it suffices to explain how @code{@value{AS}} uses
1990 sections.
1991
1992 @code{@value{LD}} moves blocks of bytes of your program to their run-time
1993 addresses. These blocks slide to their run-time addresses as rigid
1994 units; their length does not change and neither does the order of bytes
1995 within them. Such a rigid unit is called a @emph{section}. Assigning
1996 run-time addresses to sections is called @dfn{relocation}. It includes
1997 the task of adjusting mentions of object-file addresses so they refer to
1998 the proper run-time addresses.
1999 @ifset H8
2000 For the H8/300 and H8/500,
2001 and for the Hitachi SH,
2002 @code{@value{AS}} pads sections if needed to
2003 ensure they end on a word (sixteen bit) boundary.
2004 @end ifset
2005
2006 @cindex standard assembler sections
2007 An object file written by @code{@value{AS}} has at least three sections, any
2008 of which may be empty. These are named @dfn{text}, @dfn{data} and
2009 @dfn{bss} sections.
2010
2011 @ifset COFF
2012 @ifset GENERIC
2013 When it generates COFF output,
2014 @end ifset
2015 @code{@value{AS}} can also generate whatever other named sections you specify
2016 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
2017 If you do not use any directives that place output in the @samp{.text}
2018 or @samp{.data} sections, these sections still exist, but are empty.
2019 @end ifset
2020
2021 @ifset HPPA
2022 @ifset GENERIC
2023 When @code{@value{AS}} generates SOM or ELF output for the HPPA,
2024 @end ifset
2025 @code{@value{AS}} can also generate whatever other named sections you
2026 specify using the @samp{.space} and @samp{.subspace} directives. See
2027 @cite{HP9000 Series 800 Assembly Language Reference Manual}
2028 (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
2029 assembler directives.
2030
2031 @ifset SOM
2032 Additionally, @code{@value{AS}} uses different names for the standard
2033 text, data, and bss sections when generating SOM output. Program text
2034 is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
2035 BSS into @samp{$BSS$}.
2036 @end ifset
2037 @end ifset
2038
2039 Within the object file, the text section starts at address @code{0}, the
2040 data section follows, and the bss section follows the data section.
2041
2042 @ifset HPPA
2043 When generating either SOM or ELF output files on the HPPA, the text
2044 section starts at address @code{0}, the data section at address
2045 @code{0x4000000}, and the bss section follows the data section.
2046 @end ifset
2047
2048 To let @code{@value{LD}} know which data changes when the sections are
2049 relocated, and how to change that data, @code{@value{AS}} also writes to the
2050 object file details of the relocation needed. To perform relocation
2051 @code{@value{LD}} must know, each time an address in the object
2052 file is mentioned:
2053 @itemize @bullet
2054 @item
2055 Where in the object file is the beginning of this reference to
2056 an address?
2057 @item
2058 How long (in bytes) is this reference?
2059 @item
2060 Which section does the address refer to? What is the numeric value of
2061 @display
2062 (@var{address}) @minus{} (@var{start-address of section})?
2063 @end display
2064 @item
2065 Is the reference to an address ``Program-Counter relative''?
2066 @end itemize
2067
2068 @cindex addresses, format of
2069 @cindex section-relative addressing
2070 In fact, every address @code{@value{AS}} ever uses is expressed as
2071 @display
2072 (@var{section}) + (@var{offset into section})
2073 @end display
2074 @noindent
2075 Further, most expressions @code{@value{AS}} computes have this section-relative
2076 nature.
2077 @ifset SOM
2078 (For some object formats, such as SOM for the HPPA, some expressions are
2079 symbol-relative instead.)
2080 @end ifset
2081
2082 In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset
2083 @var{N} into section @var{secname}.''
2084
2085 Apart from text, data and bss sections you need to know about the
2086 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
2087 addresses in the absolute section remain unchanged. For example, address
2088 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by
2089 @code{@value{LD}}. Although the linker never arranges two partial programs'
2090 data sections with overlapping addresses after linking, @emph{by definition}
2091 their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one
2092 part of a program is always the same address when the program is running as
2093 address @code{@{absolute@ 239@}} in any other part of the program.
2094
2095 The idea of sections is extended to the @dfn{undefined} section. Any
2096 address whose section is unknown at assembly time is by definition
2097 rendered @{undefined @var{U}@}---where @var{U} is filled in later.
2098 Since numbers are always defined, the only way to generate an undefined
2099 address is to mention an undefined symbol. A reference to a named
2100 common block would be such a symbol: its value is unknown at assembly
2101 time so it has section @emph{undefined}.
2102
2103 By analogy the word @emph{section} is used to describe groups of sections in
2104 the linked program. @code{@value{LD}} puts all partial programs' text
2105 sections in contiguous addresses in the linked program. It is
2106 customary to refer to the @emph{text section} of a program, meaning all
2107 the addresses of all partial programs' text sections. Likewise for
2108 data and bss sections.
2109
2110 Some sections are manipulated by @code{@value{LD}}; others are invented for
2111 use of @code{@value{AS}} and have no meaning except during assembly.
2112
2113 @node Ld Sections
2114 @section Linker Sections
2115 @code{@value{LD}} deals with just four kinds of sections, summarized below.
2116
2117 @table @strong
2118
2119 @ifset COFF
2120 @cindex named sections
2121 @cindex sections, named
2122 @item named sections
2123 @end ifset
2124 @ifset aout-bout
2125 @cindex text section
2126 @cindex data section
2127 @itemx text section
2128 @itemx data section
2129 @end ifset
2130 These sections hold your program. @code{@value{AS}} and @code{@value{LD}} treat them as
2131 separate but equal sections. Anything you can say of one section is
2132 true another.
2133 @ifset aout-bout
2134 When the program is running, however, it is
2135 customary for the text section to be unalterable. The
2136 text section is often shared among processes: it contains
2137 instructions, constants and the like. The data section of a running
2138 program is usually alterable: for example, C variables would be stored
2139 in the data section.
2140 @end ifset
2141
2142 @cindex bss section
2143 @item bss section
2144 This section contains zeroed bytes when your program begins running. It
2145 is used to hold unitialized variables or common storage. The length of
2146 each partial program's bss section is important, but because it starts
2147 out containing zeroed bytes there is no need to store explicit zero
2148 bytes in the object file. The bss section was invented to eliminate
2149 those explicit zeros from object files.
2150
2151 @cindex absolute section
2152 @item absolute section
2153 Address 0 of this section is always ``relocated'' to runtime address 0.
2154 This is useful if you want to refer to an address that @code{@value{LD}} must
2155 not change when relocating. In this sense we speak of absolute
2156 addresses being ``unrelocatable'': they do not change during relocation.
2157
2158 @cindex undefined section
2159 @item undefined section
2160 This ``section'' is a catch-all for address references to objects not in
2161 the preceding sections.
2162 @c FIXME: ref to some other doc on obj-file formats could go here.
2163 @end table
2164
2165 @cindex relocation example
2166 An idealized example of three relocatable sections follows.
2167 @ifset COFF
2168 The example uses the traditional section names @samp{.text} and @samp{.data}.
2169 @end ifset
2170 Memory addresses are on the horizontal axis.
2171
2172 @c TEXI2ROFF-KILL
2173 @ifinfo
2174 @c END TEXI2ROFF-KILL
2175 @smallexample
2176 +-----+----+--+
2177 partial program # 1: |ttttt|dddd|00|
2178 +-----+----+--+
2179
2180 text data bss
2181 seg. seg. seg.
2182
2183 +---+---+---+
2184 partial program # 2: |TTT|DDD|000|
2185 +---+---+---+
2186
2187 +--+---+-----+--+----+---+-----+~~
2188 linked program: | |TTT|ttttt| |dddd|DDD|00000|
2189 +--+---+-----+--+----+---+-----+~~
2190
2191 addresses: 0 @dots{}
2192 @end smallexample
2193 @c TEXI2ROFF-KILL
2194 @end ifinfo
2195 @need 5000
2196 @tex
2197
2198 \line{\it Partial program \#1: \hfil}
2199 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2200 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
2201
2202 \line{\it Partial program \#2: \hfil}
2203 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2204 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
2205
2206 \line{\it linked program: \hfil}
2207 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
2208 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
2209 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
2210 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
2211
2212 \line{\it addresses: \hfil}
2213 \line{0\dots\hfil}
2214
2215 @end tex
2216 @c END TEXI2ROFF-KILL
2217
2218 @node As Sections
2219 @section Assembler Internal Sections
2220
2221 @cindex internal assembler sections
2222 @cindex sections in messages, internal
2223 These sections are meant only for the internal use of @code{@value{AS}}. They
2224 have no meaning at run-time. You do not really need to know about these
2225 sections for most purposes; but they can be mentioned in @code{@value{AS}}
2226 warning messages, so it might be helpful to have an idea of their
2227 meanings to @code{@value{AS}}. These sections are used to permit the
2228 value of every expression in your assembly language program to be a
2229 section-relative address.
2230
2231 @table @b
2232 @cindex assembler internal logic error
2233 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
2234 An internal assembler logic error has been found. This means there is a
2235 bug in the assembler.
2236
2237 @cindex expr (internal section)
2238 @item expr section
2239 The assembler stores complex expression internally as combinations of
2240 symbols. When it needs to represent an expression as a symbol, it puts
2241 it in the expr section.
2242 @c FIXME item debug
2243 @c FIXME item transfer[t] vector preload
2244 @c FIXME item transfer[t] vector postload
2245 @c FIXME item register
2246 @end table
2247
2248 @node Sub-Sections
2249 @section Sub-Sections
2250
2251 @cindex numbered subsections
2252 @cindex grouping data
2253 @ifset aout-bout
2254 Assembled bytes
2255 @ifset COFF
2256 conventionally
2257 @end ifset
2258 fall into two sections: text and data.
2259 @end ifset
2260 You may have separate groups of
2261 @ifset GENERIC
2262 data in named sections
2263 @end ifset
2264 @ifclear GENERIC
2265 @ifclear aout-bout
2266 data in named sections
2267 @end ifclear
2268 @ifset aout-bout
2269 text or data
2270 @end ifset
2271 @end ifclear
2272 that you want to end up near to each other in the object file, even though they
2273 are not contiguous in the assembler source. @code{@value{AS}} allows you to
2274 use @dfn{subsections} for this purpose. Within each section, there can be
2275 numbered subsections with values from 0 to 8192. Objects assembled into the
2276 same subsection go into the object file together with other objects in the same
2277 subsection. For example, a compiler might want to store constants in the text
2278 section, but might not want to have them interspersed with the program being
2279 assembled. In this case, the compiler could issue a @samp{.text 0} before each
2280 section of code being output, and a @samp{.text 1} before each group of
2281 constants being output.
2282
2283 Subsections are optional. If you do not use subsections, everything
2284 goes in subsection number zero.
2285
2286 @ifset GENERIC
2287 Each subsection is zero-padded up to a multiple of four bytes.
2288 (Subsections may be padded a different amount on different flavors
2289 of @code{@value{AS}}.)
2290 @end ifset
2291 @ifclear GENERIC
2292 @ifset H8
2293 On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
2294 boundary (two bytes).
2295 The same is true on the Hitachi SH.
2296 @end ifset
2297 @ifset I960
2298 @c FIXME section padding (alignment)?
2299 @c Rich Pixley says padding here depends on target obj code format; that
2300 @c doesn't seem particularly useful to say without further elaboration,
2301 @c so for now I say nothing about it. If this is a generic BFD issue,
2302 @c these paragraphs might need to vanish from this manual, and be
2303 @c discussed in BFD chapter of binutils (or some such).
2304 @end ifset
2305 @ifset A29K
2306 On the AMD 29K family, no particular padding is added to section or
2307 subsection sizes; @value{AS} forces no alignment on this platform.
2308 @end ifset
2309 @end ifclear
2310
2311 Subsections appear in your object file in numeric order, lowest numbered
2312 to highest. (All this to be compatible with other people's assemblers.)
2313 The object file contains no representation of subsections; @code{@value{LD}} and
2314 other programs that manipulate object files see no trace of them.
2315 They just see all your text subsections as a text section, and all your
2316 data subsections as a data section.
2317
2318 To specify which subsection you want subsequent statements assembled
2319 into, use a numeric argument to specify it, in a @samp{.text
2320 @var{expression}} or a @samp{.data @var{expression}} statement.
2321 @ifset COFF
2322 @ifset GENERIC
2323 When generating COFF output, you
2324 @end ifset
2325 @ifclear GENERIC
2326 You
2327 @end ifclear
2328 can also use an extra subsection
2329 argument with arbitrary named sections: @samp{.section @var{name},
2330 @var{expression}}.
2331 @end ifset
2332 @var{Expression} should be an absolute expression.
2333 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
2334 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
2335 begins in @code{text 0}. For instance:
2336 @smallexample
2337 .text 0 # The default subsection is text 0 anyway.
2338 .ascii "This lives in the first text subsection. *"
2339 .text 1
2340 .ascii "But this lives in the second text subsection."
2341 .data 0
2342 .ascii "This lives in the data section,"
2343 .ascii "in the first data subsection."
2344 .text 0
2345 .ascii "This lives in the first text section,"
2346 .ascii "immediately following the asterisk (*)."
2347 @end smallexample
2348
2349 Each section has a @dfn{location counter} incremented by one for every byte
2350 assembled into that section. Because subsections are merely a convenience
2351 restricted to @code{@value{AS}} there is no concept of a subsection location
2352 counter. There is no way to directly manipulate a location counter---but the
2353 @code{.align} directive changes it, and any label definition captures its
2354 current value. The location counter of the section where statements are being
2355 assembled is said to be the @dfn{active} location counter.
2356
2357 @node bss
2358 @section bss Section
2359
2360 @cindex bss section
2361 @cindex common variable storage
2362 The bss section is used for local common variable storage.
2363 You may allocate address space in the bss section, but you may
2364 not dictate data to load into it before your program executes. When
2365 your program starts running, all the contents of the bss
2366 section are zeroed bytes.
2367
2368 The @code{.lcomm} pseudo-op defines a symbol in the bss section; see
2369 @ref{Lcomm,,@code{.lcomm}}.
2370
2371 The @code{.comm} pseudo-op may be used to declare a common symbol, which is
2372 another form of uninitialized symbol; see @xref{Comm,,@code{.comm}}.
2373
2374 @ifset GENERIC
2375 When assembling for a target which supports multiple sections, such as ELF or
2376 COFF, you may switch into the @code{.bss} section and define symbols as usual;
2377 see @ref{Section,,@code{.section}}. You may only assemble zero values into the
2378 section. Typically the section will only contain symbol definitions and
2379 @code{.skip} directives (@pxref{Skip,,@code{.skip}}).
2380 @end ifset
2381
2382 @node Symbols
2383 @chapter Symbols
2384
2385 @cindex symbols
2386 Symbols are a central concept: the programmer uses symbols to name
2387 things, the linker uses symbols to link, and the debugger uses symbols
2388 to debug.
2389
2390 @quotation
2391 @cindex debuggers, and symbol order
2392 @emph{Warning:} @code{@value{AS}} does not place symbols in the object file in
2393 the same order they were declared. This may break some debuggers.
2394 @end quotation
2395
2396 @menu
2397 * Labels:: Labels
2398 * Setting Symbols:: Giving Symbols Other Values
2399 * Symbol Names:: Symbol Names
2400 * Dot:: The Special Dot Symbol
2401 * Symbol Attributes:: Symbol Attributes
2402 @end menu
2403
2404 @node Labels
2405 @section Labels
2406
2407 @cindex labels
2408 A @dfn{label} is written as a symbol immediately followed by a colon
2409 @samp{:}. The symbol then represents the current value of the
2410 active location counter, and is, for example, a suitable instruction
2411 operand. You are warned if you use the same symbol to represent two
2412 different locations: the first definition overrides any other
2413 definitions.
2414
2415 @ifset HPPA
2416 On the HPPA, the usual form for a label need not be immediately followed by a
2417 colon, but instead must start in column zero. Only one label may be defined on
2418 a single line. To work around this, the HPPA version of @code{@value{AS}} also
2419 provides a special directive @code{.label} for defining labels more flexibly.
2420 @end ifset
2421
2422 @node Setting Symbols
2423 @section Giving Symbols Other Values
2424
2425 @cindex assigning values to symbols
2426 @cindex symbol values, assigning
2427 A symbol can be given an arbitrary value by writing a symbol, followed
2428 by an equals sign @samp{=}, followed by an expression
2429 (@pxref{Expressions}). This is equivalent to using the @code{.set}
2430 directive. @xref{Set,,@code{.set}}.
2431
2432 @node Symbol Names
2433 @section Symbol Names
2434
2435 @cindex symbol names
2436 @cindex names, symbol
2437 @ifclear SPECIAL-SYMS
2438 Symbol names begin with a letter or with one of @samp{._}. On most
2439 machines, you can also use @code{$} in symbol names; exceptions are
2440 noted in @ref{Machine Dependencies}. That character may be followed by any
2441 string of digits, letters, dollar signs (unless otherwise noted in
2442 @ref{Machine Dependencies}), and underscores.
2443 @end ifclear
2444 @ifset A29K
2445 For the AMD 29K family, @samp{?} is also allowed in the
2446 body of a symbol name, though not at its beginning.
2447 @end ifset
2448
2449 @ifset SPECIAL-SYMS
2450 @ifset H8
2451 Symbol names begin with a letter or with one of @samp{._}. On the
2452 Hitachi SH or the
2453 H8/500, you can also use @code{$} in symbol names. That character may
2454 be followed by any string of digits, letters, dollar signs (save on the
2455 H8/300), and underscores.
2456 @end ifset
2457 @end ifset
2458
2459 Case of letters is significant: @code{foo} is a different symbol name
2460 than @code{Foo}.
2461
2462 Each symbol has exactly one name. Each name in an assembly language program
2463 refers to exactly one symbol. You may use that symbol name any number of times
2464 in a program.
2465
2466 @subheading Local Symbol Names
2467
2468 @cindex local symbol names
2469 @cindex symbol names, local
2470 @cindex temporary symbol names
2471 @cindex symbol names, temporary
2472 Local symbols help compilers and programmers use names temporarily.
2473 There are ten local symbol names, which are re-used throughout the
2474 program. You may refer to them using the names @samp{0} @samp{1}
2475 @dots{} @samp{9}. To define a local symbol, write a label of the form
2476 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
2477 recent previous definition of that symbol write @samp{@b{N}b}, using the
2478 same digit as when you defined the label. To refer to the next
2479 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
2480 a choice of 10 forward references. The @samp{b} stands for
2481 ``backwards'' and the @samp{f} stands for ``forwards''.
2482
2483 Local symbols are not emitted by the current @sc{gnu} C compiler.
2484
2485 There is no restriction on how you can use these labels, but
2486 remember that at any point in the assembly you can refer to at most
2487 10 prior local labels and to at most 10 forward local labels.
2488
2489 Local symbol names are only a notation device. They are immediately
2490 transformed into more conventional symbol names before the assembler
2491 uses them. The symbol names stored in the symbol table, appearing in
2492 error messages and optionally emitted to the object file have these
2493 parts:
2494
2495 @table @code
2496 @item L
2497 All local labels begin with @samp{L}. Normally both @code{@value{AS}} and
2498 @code{@value{LD}} forget symbols that start with @samp{L}. These labels are
2499 used for symbols you are never intended to see. If you use the
2500 @samp{-L} option then @code{@value{AS}} retains these symbols in the
2501 object file. If you also instruct @code{@value{LD}} to retain these symbols,
2502 you may use them in debugging.
2503
2504 @item @var{digit}
2505 If the label is written @samp{0:} then the digit is @samp{0}.
2506 If the label is written @samp{1:} then the digit is @samp{1}.
2507 And so on up through @samp{9:}.
2508
2509 @item @kbd{C-A}
2510 This unusual character is included so you do not accidentally invent
2511 a symbol of the same name. The character has ASCII value
2512 @samp{\001}.
2513
2514 @item @emph{ordinal number}
2515 This is a serial number to keep the labels distinct. The first
2516 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
2517 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
2518 through @samp{9:}.
2519 @end table
2520
2521 For instance, the first @code{1:} is named @code{L1@kbd{C-A}1}, the 44th
2522 @code{3:} is named @code{L3@kbd{C-A}44}.
2523
2524 @node Dot
2525 @section The Special Dot Symbol
2526
2527 @cindex dot (symbol)
2528 @cindex @code{.} (symbol)
2529 @cindex current address
2530 @cindex location counter
2531 The special symbol @samp{.} refers to the current address that
2532 @code{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
2533 .long .} defines @code{melvin} to contain its own address.
2534 Assigning a value to @code{.} is treated the same as a @code{.org}
2535 directive. Thus, the expression @samp{.=.+4} is the same as saying
2536 @ifclear no-space-dir
2537 @samp{.space 4}.
2538 @end ifclear
2539 @ifset no-space-dir
2540 @ifset A29K
2541 @samp{.block 4}.
2542 @end ifset
2543 @end ifset
2544
2545 @node Symbol Attributes
2546 @section Symbol Attributes
2547
2548 @cindex symbol attributes
2549 @cindex attributes, symbol
2550 Every symbol has, as well as its name, the attributes ``Value'' and
2551 ``Type''. Depending on output format, symbols can also have auxiliary
2552 attributes.
2553 @ifset INTERNALS
2554 The detailed definitions are in @file{a.out.h}.
2555 @end ifset
2556
2557 If you use a symbol without defining it, @code{@value{AS}} assumes zero for
2558 all these attributes, and probably won't warn you. This makes the
2559 symbol an externally defined symbol, which is generally what you
2560 would want.
2561
2562 @menu
2563 * Symbol Value:: Value
2564 * Symbol Type:: Type
2565 @ifset aout-bout
2566 @ifset GENERIC
2567 * a.out Symbols:: Symbol Attributes: @code{a.out}
2568 @end ifset
2569 @ifclear GENERIC
2570 @ifclear BOUT
2571 * a.out Symbols:: Symbol Attributes: @code{a.out}
2572 @end ifclear
2573 @ifset BOUT
2574 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
2575 @end ifset
2576 @end ifclear
2577 @end ifset
2578 @ifset COFF
2579 * COFF Symbols:: Symbol Attributes for COFF
2580 @end ifset
2581 @ifset SOM
2582 * SOM Symbols:: Symbol Attributes for SOM
2583 @end ifset
2584 @end menu
2585
2586 @node Symbol Value
2587 @subsection Value
2588
2589 @cindex value of a symbol
2590 @cindex symbol value
2591 The value of a symbol is (usually) 32 bits. For a symbol which labels a
2592 location in the text, data, bss or absolute sections the value is the
2593 number of addresses from the start of that section to the label.
2594 Naturally for text, data and bss sections the value of a symbol changes
2595 as @code{@value{LD}} changes section base addresses during linking. Absolute
2596 symbols' values do not change during linking: that is why they are
2597 called absolute.
2598
2599 The value of an undefined symbol is treated in a special way. If it is
2600 0 then the symbol is not defined in this assembler source file, and
2601 @code{@value{LD}} tries to determine its value from other files linked into the
2602 same program. You make this kind of symbol simply by mentioning a symbol
2603 name without defining it. A non-zero value represents a @code{.comm}
2604 common declaration. The value is how much common storage to reserve, in
2605 bytes (addresses). The symbol refers to the first address of the
2606 allocated storage.
2607
2608 @node Symbol Type
2609 @subsection Type
2610
2611 @cindex type of a symbol
2612 @cindex symbol type
2613 The type attribute of a symbol contains relocation (section)
2614 information, any flag settings indicating that a symbol is external, and
2615 (optionally), other information for linkers and debuggers. The exact
2616 format depends on the object-code output format in use.
2617
2618 @ifset aout-bout
2619 @ifclear GENERIC
2620 @ifset BOUT
2621 @c The following avoids a "widow" subsection title. @group would be
2622 @c better if it were available outside examples.
2623 @need 1000
2624 @node a.out Symbols
2625 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
2626
2627 @cindex @code{b.out} symbol attributes
2628 @cindex symbol attributes, @code{b.out}
2629 These symbol attributes appear only when @code{@value{AS}} is configured for
2630 one of the Berkeley-descended object output formats---@code{a.out} or
2631 @code{b.out}.
2632
2633 @end ifset
2634 @ifclear BOUT
2635 @node a.out Symbols
2636 @subsection Symbol Attributes: @code{a.out}
2637
2638 @cindex @code{a.out} symbol attributes
2639 @cindex symbol attributes, @code{a.out}
2640
2641 @end ifclear
2642 @end ifclear
2643 @ifset GENERIC
2644 @node a.out Symbols
2645 @subsection Symbol Attributes: @code{a.out}
2646
2647 @cindex @code{a.out} symbol attributes
2648 @cindex symbol attributes, @code{a.out}
2649
2650 @end ifset
2651 @menu
2652 * Symbol Desc:: Descriptor
2653 * Symbol Other:: Other
2654 @end menu
2655
2656 @node Symbol Desc
2657 @subsubsection Descriptor
2658
2659 @cindex descriptor, of @code{a.out} symbol
2660 This is an arbitrary 16-bit value. You may establish a symbol's
2661 descriptor value by using a @code{.desc} statement
2662 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
2663 @code{@value{AS}}.
2664
2665 @node Symbol Other
2666 @subsubsection Other
2667
2668 @cindex other attribute, of @code{a.out} symbol
2669 This is an arbitrary 8-bit value. It means nothing to @code{@value{AS}}.
2670 @end ifset
2671
2672 @ifset COFF
2673 @node COFF Symbols
2674 @subsection Symbol Attributes for COFF
2675
2676 @cindex COFF symbol attributes
2677 @cindex symbol attributes, COFF
2678
2679 The COFF format supports a multitude of auxiliary symbol attributes;
2680 like the primary symbol attributes, they are set between @code{.def} and
2681 @code{.endef} directives.
2682
2683 @subsubsection Primary Attributes
2684
2685 @cindex primary attributes, COFF symbols
2686 The symbol name is set with @code{.def}; the value and type,
2687 respectively, with @code{.val} and @code{.type}.
2688
2689 @subsubsection Auxiliary Attributes
2690
2691 @cindex auxiliary attributes, COFF symbols
2692 The @code{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
2693 @code{.size}, and @code{.tag} can generate auxiliary symbol table
2694 information for COFF.
2695 @end ifset
2696
2697 @ifset SOM
2698 @node SOM Symbols
2699 @subsection Symbol Attributes for SOM
2700
2701 @cindex SOM symbol attributes
2702 @cindex symbol attributes, SOM
2703
2704 The SOM format for the HPPA supports a multitude of symbol attributes set with
2705 the @code{.EXPORT} and @code{.IMPORT} directives.
2706
2707 The attributes are described in @cite{HP9000 Series 800 Assembly
2708 Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
2709 @code{EXPORT} assembler directive documentation.
2710 @end ifset
2711
2712 @node Expressions
2713 @chapter Expressions
2714
2715 @cindex expressions
2716 @cindex addresses
2717 @cindex numeric values
2718 An @dfn{expression} specifies an address or numeric value.
2719 Whitespace may precede and/or follow an expression.
2720
2721 The result of an expression must be an absolute number, or else an offset into
2722 a particular section. If an expression is not absolute, and there is not
2723 enough information when @code{@value{AS}} sees the expression to know its
2724 section, a second pass over the source program might be necessary to interpret
2725 the expression---but the second pass is currently not implemented.
2726 @code{@value{AS}} aborts with an error message in this situation.
2727
2728 @menu
2729 * Empty Exprs:: Empty Expressions
2730 * Integer Exprs:: Integer Expressions
2731 @end menu
2732
2733 @node Empty Exprs
2734 @section Empty Expressions
2735
2736 @cindex empty expressions
2737 @cindex expressions, empty
2738 An empty expression has no value: it is just whitespace or null.
2739 Wherever an absolute expression is required, you may omit the
2740 expression, and @code{@value{AS}} assumes a value of (absolute) 0. This
2741 is compatible with other assemblers.
2742
2743 @node Integer Exprs
2744 @section Integer Expressions
2745
2746 @cindex integer expressions
2747 @cindex expressions, integer
2748 An @dfn{integer expression} is one or more @emph{arguments} delimited
2749 by @emph{operators}.
2750
2751 @menu
2752 * Arguments:: Arguments
2753 * Operators:: Operators
2754 * Prefix Ops:: Prefix Operators
2755 * Infix Ops:: Infix Operators
2756 @end menu
2757
2758 @node Arguments
2759 @subsection Arguments
2760
2761 @cindex expression arguments
2762 @cindex arguments in expressions
2763 @cindex operands in expressions
2764 @cindex arithmetic operands
2765 @dfn{Arguments} are symbols, numbers or subexpressions. In other
2766 contexts arguments are sometimes called ``arithmetic operands''. In
2767 this manual, to avoid confusing them with the ``instruction operands'' of
2768 the machine language, we use the term ``argument'' to refer to parts of
2769 expressions only, reserving the word ``operand'' to refer only to machine
2770 instruction operands.
2771
2772 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
2773 @var{section} is one of text, data, bss, absolute,
2774 or undefined. @var{NNN} is a signed, 2's complement 32 bit
2775 integer.
2776
2777 Numbers are usually integers.
2778
2779 A number can be a flonum or bignum. In this case, you are warned
2780 that only the low order 32 bits are used, and @code{@value{AS}} pretends
2781 these 32 bits are an integer. You may write integer-manipulating
2782 instructions that act on exotic constants, compatible with other
2783 assemblers.
2784
2785 @cindex subexpressions
2786 Subexpressions are a left parenthesis @samp{(} followed by an integer
2787 expression, followed by a right parenthesis @samp{)}; or a prefix
2788 operator followed by an argument.
2789
2790 @node Operators
2791 @subsection Operators
2792
2793 @cindex operators, in expressions
2794 @cindex arithmetic functions
2795 @cindex functions, in expressions
2796 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
2797 operators are followed by an argument. Infix operators appear
2798 between their arguments. Operators may be preceded and/or followed by
2799 whitespace.
2800
2801 @node Prefix Ops
2802 @subsection Prefix Operator
2803
2804 @cindex prefix operators
2805 @code{@value{AS}} has the following @dfn{prefix operators}. They each take
2806 one argument, which must be absolute.
2807
2808 @c the tex/end tex stuff surrounding this small table is meant to make
2809 @c it align, on the printed page, with the similar table in the next
2810 @c section (which is inside an enumerate).
2811 @tex
2812 \global\advance\leftskip by \itemindent
2813 @end tex
2814
2815 @table @code
2816 @item -
2817 @dfn{Negation}. Two's complement negation.
2818 @item ~
2819 @dfn{Complementation}. Bitwise not.
2820 @end table
2821
2822 @tex
2823 \global\advance\leftskip by -\itemindent
2824 @end tex
2825
2826 @node Infix Ops
2827 @subsection Infix Operators
2828
2829 @cindex infix operators
2830 @cindex operators, permitted arguments
2831 @dfn{Infix operators} take two arguments, one on either side. Operators
2832 have precedence, but operations with equal precedence are performed left
2833 to right. Apart from @code{+} or @code{-}, both arguments must be
2834 absolute, and the result is absolute.
2835
2836 @enumerate
2837 @cindex operator precedence
2838 @cindex precedence of operators
2839
2840 @item
2841 Highest Precedence
2842
2843 @table @code
2844 @item *
2845 @dfn{Multiplication}.
2846
2847 @item /
2848 @dfn{Division}. Truncation is the same as the C operator @samp{/}
2849
2850 @item %
2851 @dfn{Remainder}.
2852
2853 @item <
2854 @itemx <<
2855 @dfn{Shift Left}. Same as the C operator @samp{<<}.
2856
2857 @item >
2858 @itemx >>
2859 @dfn{Shift Right}. Same as the C operator @samp{>>}.
2860 @end table
2861
2862 @item
2863 Intermediate precedence
2864
2865 @table @code
2866 @item |
2867
2868 @dfn{Bitwise Inclusive Or}.
2869
2870 @item &
2871 @dfn{Bitwise And}.
2872
2873 @item ^
2874 @dfn{Bitwise Exclusive Or}.
2875
2876 @item !
2877 @dfn{Bitwise Or Not}.
2878 @end table
2879
2880 @item
2881 Lowest Precedence
2882
2883 @table @code
2884 @cindex addition, permitted arguments
2885 @cindex plus, permitted arguments
2886 @cindex arguments for addition
2887 @item +
2888 @dfn{Addition}. If either argument is absolute, the result has the section of
2889 the other argument. You may not add together arguments from different
2890 sections.
2891
2892 @cindex subtraction, permitted arguments
2893 @cindex minus, permitted arguments
2894 @cindex arguments for subtraction
2895 @item -
2896 @dfn{Subtraction}. If the right argument is absolute, the
2897 result has the section of the left argument.
2898 If both arguments are in the same section, the result is absolute.
2899 You may not subtract arguments from different sections.
2900 @c FIXME is there still something useful to say about undefined - undefined ?
2901 @end table
2902 @end enumerate
2903
2904 In short, it's only meaningful to add or subtract the @emph{offsets} in an
2905 address; you can only have a defined section in one of the two arguments.
2906
2907 @node Pseudo Ops
2908 @chapter Assembler Directives
2909
2910 @cindex directives, machine independent
2911 @cindex pseudo-ops, machine independent
2912 @cindex machine independent directives
2913 All assembler directives have names that begin with a period (@samp{.}).
2914 The rest of the name is letters, usually in lower case.
2915
2916 This chapter discusses directives that are available regardless of the
2917 target machine configuration for the @sc{gnu} assembler.
2918 @ifset GENERIC
2919 Some machine configurations provide additional directives.
2920 @xref{Machine Dependencies}.
2921 @end ifset
2922 @ifclear GENERIC
2923 @ifset machine-directives
2924 @xref{Machine Dependencies} for additional directives.
2925 @end ifset
2926 @end ifclear
2927
2928 @menu
2929 * Abort:: @code{.abort}
2930 @ifset COFF
2931 * ABORT:: @code{.ABORT}
2932 @end ifset
2933
2934 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
2935 * App-File:: @code{.app-file @var{string}}
2936 * Ascii:: @code{.ascii "@var{string}"}@dots{}
2937 * Asciz:: @code{.asciz "@var{string}"}@dots{}
2938 * Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}}
2939 * Byte:: @code{.byte @var{expressions}}
2940 * Comm:: @code{.comm @var{symbol} , @var{length} }
2941 * Data:: @code{.data @var{subsection}}
2942 @ifset COFF
2943 * Def:: @code{.def @var{name}}
2944 @end ifset
2945 @ifset aout-bout
2946 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
2947 @end ifset
2948 @ifset COFF
2949 * Dim:: @code{.dim}
2950 @end ifset
2951
2952 * Double:: @code{.double @var{flonums}}
2953 * Eject:: @code{.eject}
2954 * Else:: @code{.else}
2955 @ifset COFF
2956 * Endef:: @code{.endef}
2957 @end ifset
2958
2959 * Endif:: @code{.endif}
2960 * Equ:: @code{.equ @var{symbol}, @var{expression}}
2961 * Equiv:: @code{.equiv @var{symbol}, @var{expression}}
2962 * Err:: @code{.err}
2963 * Extern:: @code{.extern}
2964 @ifclear no-file-dir
2965 * File:: @code{.file @var{string}}
2966 @end ifclear
2967
2968 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
2969 * Float:: @code{.float @var{flonums}}
2970 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2971 * hword:: @code{.hword @var{expressions}}
2972 * Ident:: @code{.ident}
2973 * If:: @code{.if @var{absolute expression}}
2974 * Include:: @code{.include "@var{file}"}
2975 * Int:: @code{.int @var{expressions}}
2976 * Irp:: @code{.irp @var{symbol},@var{values}}@dots{}
2977 * Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{}
2978 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
2979 * Lflags:: @code{.lflags}
2980 @ifclear no-line-dir
2981 * Line:: @code{.line @var{line-number}}
2982 @end ifclear
2983
2984 * Ln:: @code{.ln @var{line-number}}
2985 * Linkonce:: @code{.linkonce [@var{type}]}
2986 * List:: @code{.list}
2987 * Long:: @code{.long @var{expressions}}
2988 @ignore
2989 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
2990 @end ignore
2991
2992 * Macro:: @code{.macro @var{name} @var{args}}@dots{}
2993 * MRI:: @code{.mri @var{val}}
2994
2995 * Nolist:: @code{.nolist}
2996 * Octa:: @code{.octa @var{bignums}}
2997 * Org:: @code{.org @var{new-lc} , @var{fill}}
2998 * P2align:: @code{.p2align @var{abs-expr} , @var{abs-expr}}
2999 * Psize:: @code{.psize @var{lines}, @var{columns}}
3000 * Quad:: @code{.quad @var{bignums}}
3001 * Rept:: @code{.rept @var{count}}
3002 * Sbttl:: @code{.sbttl "@var{subheading}"}
3003 @ifset COFF
3004 * Scl:: @code{.scl @var{class}}
3005 * Section:: @code{.section @var{name}, @var{subsection}}
3006 @end ifset
3007
3008 * Set:: @code{.set @var{symbol}, @var{expression}}
3009 * Short:: @code{.short @var{expressions}}
3010 * Single:: @code{.single @var{flonums}}
3011 @ifset COFF
3012 * Size:: @code{.size}
3013 @end ifset
3014
3015 * Skip:: @code{.skip @var{size} , @var{fill}}
3016 * Sleb128:: @code{.sleb128 @var{expressions}}
3017 * Space:: @code{.space @var{size} , @var{fill}}
3018 @ifset have-stabs
3019 * Stab:: @code{.stabd, .stabn, .stabs}
3020 @end ifset
3021
3022 * String:: @code{.string "@var{str}"}
3023 @ifset ELF
3024 * Symver:: @code{.symver @var{name},@var{name2@@nodename}}
3025 @end ifset
3026 @ifset COFF
3027 * Tag:: @code{.tag @var{structname}}
3028 @end ifset
3029
3030 * Text:: @code{.text @var{subsection}}
3031 * Title:: @code{.title "@var{heading}"}
3032 @ifset COFF
3033 * Type:: @code{.type @var{int}}
3034 * Val:: @code{.val @var{addr}}
3035 @end ifset
3036
3037 * Uleb128:: @code{.uleb128 @var{expressions}}
3038 * Word:: @code{.word @var{expressions}}
3039 * Deprecated:: Deprecated Directives
3040 @end menu
3041
3042 @node Abort
3043 @section @code{.abort}
3044
3045 @cindex @code{abort} directive
3046 @cindex stopping the assembly
3047 This directive stops the assembly immediately. It is for
3048 compatibility with other assemblers. The original idea was that the
3049 assembly language source would be piped into the assembler. If the sender
3050 of the source quit, it could use this directive tells @code{@value{AS}} to
3051 quit also. One day @code{.abort} will not be supported.
3052
3053 @ifset COFF
3054 @node ABORT
3055 @section @code{.ABORT}
3056
3057 @cindex @code{ABORT} directive
3058 When producing COFF output, @code{@value{AS}} accepts this directive as a
3059 synonym for @samp{.abort}.
3060
3061 @ifset BOUT
3062 When producing @code{b.out} output, @code{@value{AS}} accepts this directive,
3063 but ignores it.
3064 @end ifset
3065 @end ifset
3066
3067 @node Align
3068 @section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3069
3070 @cindex padding the location counter
3071 @cindex @code{align} directive
3072 Pad the location counter (in the current subsection) to a particular storage
3073 boundary. The first expression (which must be absolute) is the alignment
3074 required, as described below.
3075
3076 The second expression (also absolute) gives the fill value to be stored in the
3077 padding bytes. It (and the comma) may be omitted. If it is omitted, the
3078 padding bytes are normally zero. However, on some systems, if the section is
3079 marked as containing code and the fill value is omitted, the space is filled
3080 with no-op instructions.
3081
3082 The third expression is also absolute, and is also optional. If it is present,
3083 it is the maximum number of bytes that should be skipped by this alignment
3084 directive. If doing the alignment would require skipping more bytes than the
3085 specified maximum, then the alignment is not done at all. You can omit the
3086 fill value (the second argument) entirely by simply using two commas after the
3087 required alignment; this can be useful if you want the alignment to be filled
3088 with no-op instructions when appropriate.
3089
3090 The way the required alignment is specified varies from system to system.
3091 For the a29k, hppa, m68k, m88k, w65, sparc, and Hitachi SH, and i386 using ELF
3092 format,
3093 the first expression is the
3094 alignment request in bytes. For example @samp{.align 8} advances
3095 the location counter until it is a multiple of 8. If the location counter
3096 is already a multiple of 8, no change is needed.
3097
3098 For other systems, including the i386 using a.out format, it is the
3099 number of low-order zero bits the location counter must have after
3100 advancement. For example @samp{.align 3} advances the location
3101 counter until it a multiple of 8. If the location counter is already a
3102 multiple of 8, no change is needed.
3103
3104 This inconsistency is due to the different behaviors of the various
3105 native assemblers for these systems which GAS must emulate.
3106 GAS also provides @code{.balign} and @code{.p2align} directives,
3107 described later, which have a consistent behavior across all
3108 architectures (but are specific to GAS).
3109
3110 @node App-File
3111 @section @code{.app-file @var{string}}
3112
3113 @cindex logical file name
3114 @cindex file name, logical
3115 @cindex @code{app-file} directive
3116 @code{.app-file}
3117 @ifclear no-file-dir
3118 (which may also be spelled @samp{.file})
3119 @end ifclear
3120 tells @code{@value{AS}} that we are about to start a new
3121 logical file. @var{string} is the new file name. In general, the
3122 filename is recognized whether or not it is surrounded by quotes @samp{"};
3123 but if you wish to specify an empty file name is permitted,
3124 you must give the quotes--@code{""}. This statement may go away in
3125 future: it is only recognized to be compatible with old @code{@value{AS}}
3126 programs.@refill
3127
3128 @node Ascii
3129 @section @code{.ascii "@var{string}"}@dots{}
3130
3131 @cindex @code{ascii} directive
3132 @cindex string literals
3133 @code{.ascii} expects zero or more string literals (@pxref{Strings})
3134 separated by commas. It assembles each string (with no automatic
3135 trailing zero byte) into consecutive addresses.
3136
3137 @node Asciz
3138 @section @code{.asciz "@var{string}"}@dots{}
3139
3140 @cindex @code{asciz} directive
3141 @cindex zero-terminated strings
3142 @cindex null-terminated strings
3143 @code{.asciz} is just like @code{.ascii}, but each string is followed by
3144 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
3145
3146 @node Balign
3147 @section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3148
3149 @cindex padding the location counter given number of bytes
3150 @cindex @code{balign} directive
3151 Pad the location counter (in the current subsection) to a particular
3152 storage boundary. The first expression (which must be absolute) is the
3153 alignment request in bytes. For example @samp{.balign 8} advances
3154 the location counter until it is a multiple of 8. If the location counter
3155 is already a multiple of 8, no change is needed.
3156
3157 The second expression (also absolute) gives the fill value to be stored in the
3158 padding bytes. It (and the comma) may be omitted. If it is omitted, the
3159 padding bytes are normally zero. However, on some systems, if the section is
3160 marked as containing code and the fill value is omitted, the space is filled
3161 with no-op instructions.
3162
3163 The third expression is also absolute, and is also optional. If it is present,
3164 it is the maximum number of bytes that should be skipped by this alignment
3165 directive. If doing the alignment would require skipping more bytes than the
3166 specified maximum, then the alignment is not done at all. You can omit the
3167 fill value (the second argument) entirely by simply using two commas after the
3168 required alignment; this can be useful if you want the alignment to be filled
3169 with no-op instructions when appropriate.
3170
3171 @cindex @code{balignw} directive
3172 @cindex @code{balignl} directive
3173 The @code{.balignw} and @code{.balignl} directives are variants of the
3174 @code{.balign} directive. The @code{.balignw} directive treats the fill
3175 pattern as a two byte word value. The @code{.balignl} directives treats the
3176 fill pattern as a four byte longword value. For example, @code{.balignw
3177 4,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
3178 filled in with the value 0x368d (the exact placement of the bytes depends upon
3179 the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
3180 undefined.
3181
3182 @node Byte
3183 @section @code{.byte @var{expressions}}
3184
3185 @cindex @code{byte} directive
3186 @cindex integers, one byte
3187 @code{.byte} expects zero or more expressions, separated by commas.
3188 Each expression is assembled into the next byte.
3189
3190 @node Comm
3191 @section @code{.comm @var{symbol} , @var{length} }
3192
3193 @cindex @code{comm} directive
3194 @cindex symbol, common
3195 @code{.comm} declares a common symbol named @var{symbol}. When linking, a
3196 common symbol in one object file may be merged with a defined or common symbol
3197 of the same name in another object file. If @code{@value{LD}} does not see a
3198 definition for the symbol--just one or more common symbols--then it will
3199 allocate @var{length} bytes of uninitialized memory. @var{length} must be an
3200 absolute expression. If @code{@value{LD}} sees multiple common symbols with
3201 the same name, and they do not all have the same size, it will allocate space
3202 using the largest size.
3203
3204 @ifset ELF
3205 When using ELF, the @code{.comm} directive takes an optional third argument.
3206 This is the desired alignment of the symbol, specified as a byte boundary (for
3207 example, an alignment of 16 means that the least significant 4 bits of the
3208 address should be zero). The alignment must be an absolute expression, and it
3209 must be a power of two. If @code{@value{LD}} allocates uninitialized memory
3210 for the common symbol, it will use the alignment when placing the symbol. If
3211 no alignment is specified, @code{@value{AS}} will set the alignment to the
3212 largest power of two less than or equal to the size of the symbol, up to a
3213 maximum of 16.
3214 @end ifset
3215
3216 @ifset HPPA
3217 The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
3218 @samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
3219 @end ifset
3220
3221 @node Data
3222 @section @code{.data @var{subsection}}
3223
3224 @cindex @code{data} directive
3225 @code{.data} tells @code{@value{AS}} to assemble the following statements onto the
3226 end of the data subsection numbered @var{subsection} (which is an
3227 absolute expression). If @var{subsection} is omitted, it defaults
3228 to zero.
3229
3230 @ifset COFF
3231 @node Def
3232 @section @code{.def @var{name}}
3233
3234 @cindex @code{def} directive
3235 @cindex COFF symbols, debugging
3236 @cindex debugging COFF symbols
3237 Begin defining debugging information for a symbol @var{name}; the
3238 definition extends until the @code{.endef} directive is encountered.
3239 @ifset BOUT
3240
3241 This directive is only observed when @code{@value{AS}} is configured for COFF
3242 format output; when producing @code{b.out}, @samp{.def} is recognized,
3243 but ignored.
3244 @end ifset
3245 @end ifset
3246
3247 @ifset aout-bout
3248 @node Desc
3249 @section @code{.desc @var{symbol}, @var{abs-expression}}
3250
3251 @cindex @code{desc} directive
3252 @cindex COFF symbol descriptor
3253 @cindex symbol descriptor, COFF
3254 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
3255 to the low 16 bits of an absolute expression.
3256
3257 @ifset COFF
3258 The @samp{.desc} directive is not available when @code{@value{AS}} is
3259 configured for COFF output; it is only for @code{a.out} or @code{b.out}
3260 object format. For the sake of compatibility, @code{@value{AS}} accepts
3261 it, but produces no output, when configured for COFF.
3262 @end ifset
3263 @end ifset
3264
3265 @ifset COFF
3266 @node Dim
3267 @section @code{.dim}
3268
3269 @cindex @code{dim} directive
3270 @cindex COFF auxiliary symbol information
3271 @cindex auxiliary symbol information, COFF
3272 This directive is generated by compilers to include auxiliary debugging
3273 information in the symbol table. It is only permitted inside
3274 @code{.def}/@code{.endef} pairs.
3275 @ifset BOUT
3276
3277 @samp{.dim} is only meaningful when generating COFF format output; when
3278 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3279 ignores it.
3280 @end ifset
3281 @end ifset
3282
3283 @node Double
3284 @section @code{.double @var{flonums}}
3285
3286 @cindex @code{double} directive
3287 @cindex floating point numbers (double)
3288 @code{.double} expects zero or more flonums, separated by commas. It
3289 assembles floating point numbers.
3290 @ifset GENERIC
3291 The exact kind of floating point numbers emitted depends on how
3292 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3293 @end ifset
3294 @ifclear GENERIC
3295 @ifset IEEEFLOAT
3296 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
3297 in @sc{ieee} format.
3298 @end ifset
3299 @end ifclear
3300
3301 @node Eject
3302 @section @code{.eject}
3303
3304 @cindex @code{eject} directive
3305 @cindex new page, in listings
3306 @cindex page, in listings
3307 @cindex listing control: new page
3308 Force a page break at this point, when generating assembly listings.
3309
3310 @node Else
3311 @section @code{.else}
3312
3313 @cindex @code{else} directive
3314 @code{.else} is part of the @code{@value{AS}} support for conditional
3315 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
3316 of code to be assembled if the condition for the preceding @code{.if}
3317 was false.
3318
3319 @ignore
3320 @node End, Endef, Else, Pseudo Ops
3321 @section @code{.end}
3322
3323 @cindex @code{end} directive
3324 This doesn't do anything---but isn't an s_ignore, so I suspect it's
3325 meant to do something eventually (which is why it isn't documented here
3326 as "for compatibility with blah").
3327 @end ignore
3328
3329 @ifset COFF
3330 @node Endef
3331 @section @code{.endef}
3332
3333 @cindex @code{endef} directive
3334 This directive flags the end of a symbol definition begun with
3335 @code{.def}.
3336 @ifset BOUT
3337
3338 @samp{.endef} is only meaningful when generating COFF format output; if
3339 @code{@value{AS}} is configured to generate @code{b.out}, it accepts this
3340 directive but ignores it.
3341 @end ifset
3342 @end ifset
3343
3344 @node Endif
3345 @section @code{.endif}
3346
3347 @cindex @code{endif} directive
3348 @code{.endif} is part of the @code{@value{AS}} support for conditional assembly;
3349 it marks the end of a block of code that is only assembled
3350 conditionally. @xref{If,,@code{.if}}.
3351
3352 @node Equ
3353 @section @code{.equ @var{symbol}, @var{expression}}
3354
3355 @cindex @code{equ} directive
3356 @cindex assigning values to symbols
3357 @cindex symbols, assigning values to
3358 This directive sets the value of @var{symbol} to @var{expression}.
3359 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
3360
3361 @ifset HPPA
3362 The syntax for @code{equ} on the HPPA is
3363 @samp{@var{symbol} .equ @var{expression}}.
3364 @end ifset
3365
3366 @node Equiv
3367 @section @code{.equiv @var{symbol}, @var{expression}}
3368 @cindex @code{equiv} directive
3369 The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that
3370 the assembler will signal an error if @var{symbol} is already defined.
3371
3372 Except for the contents of the error message, this is roughly equivalent to
3373 @smallexample
3374 .ifdef SYM
3375 .err
3376 .endif
3377 .equ SYM,VAL
3378 @end smallexample
3379
3380 @node Err
3381 @section @code{.err}
3382 @cindex @code{err} directive
3383 If @code{@value{AS}} assembles a @code{.err} directive, it will print an error
3384 message and, unless the @code{-Z} option was used, it will not generate an
3385 object file. This can be used to signal error an conditionally compiled code.
3386
3387 @node Extern
3388 @section @code{.extern}
3389
3390 @cindex @code{extern} directive
3391 @code{.extern} is accepted in the source program---for compatibility
3392 with other assemblers---but it is ignored. @code{@value{AS}} treats
3393 all undefined symbols as external.
3394
3395 @ifclear no-file-dir
3396 @node File
3397 @section @code{.file @var{string}}
3398
3399 @cindex @code{file} directive
3400 @cindex logical file name
3401 @cindex file name, logical
3402 @code{.file} (which may also be spelled @samp{.app-file}) tells
3403 @code{@value{AS}} that we are about to start a new logical file.
3404 @var{string} is the new file name. In general, the filename is
3405 recognized whether or not it is surrounded by quotes @samp{"}; but if
3406 you wish to specify an empty file name, you must give the
3407 quotes--@code{""}. This statement may go away in future: it is only
3408 recognized to be compatible with old @code{@value{AS}} programs.
3409 @ifset A29K
3410 In some configurations of @code{@value{AS}}, @code{.file} has already been
3411 removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
3412 @end ifset
3413 @end ifclear
3414
3415 @node Fill
3416 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
3417
3418 @cindex @code{fill} directive
3419 @cindex writing patterns in memory
3420 @cindex patterns, writing in memory
3421 @var{result}, @var{size} and @var{value} are absolute expressions.
3422 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
3423 may be zero or more. @var{Size} may be zero or more, but if it is
3424 more than 8, then it is deemed to have the value 8, compatible with
3425 other people's assemblers. The contents of each @var{repeat} bytes
3426 is taken from an 8-byte number. The highest order 4 bytes are
3427 zero. The lowest order 4 bytes are @var{value} rendered in the
3428 byte-order of an integer on the computer @code{@value{AS}} is assembling for.
3429 Each @var{size} bytes in a repetition is taken from the lowest order
3430 @var{size} bytes of this number. Again, this bizarre behavior is
3431 compatible with other people's assemblers.
3432
3433 @var{size} and @var{value} are optional.
3434 If the second comma and @var{value} are absent, @var{value} is
3435 assumed zero. If the first comma and following tokens are absent,
3436 @var{size} is assumed to be 1.
3437
3438 @node Float
3439 @section @code{.float @var{flonums}}
3440
3441 @cindex floating point numbers (single)
3442 @cindex @code{float} directive
3443 This directive assembles zero or more flonums, separated by commas. It
3444 has the same effect as @code{.single}.
3445 @ifset GENERIC
3446 The exact kind of floating point numbers emitted depends on how
3447 @code{@value{AS}} is configured.
3448 @xref{Machine Dependencies}.
3449 @end ifset
3450 @ifclear GENERIC
3451 @ifset IEEEFLOAT
3452 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
3453 in @sc{ieee} format.
3454 @end ifset
3455 @end ifclear
3456
3457 @node Global
3458 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
3459
3460 @cindex @code{global} directive
3461 @cindex symbol, making visible to linker
3462 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
3463 @var{symbol} in your partial program, its value is made available to
3464 other partial programs that are linked with it. Otherwise,
3465 @var{symbol} takes its attributes from a symbol of the same name
3466 from another file linked into the same program.
3467
3468 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
3469 compatibility with other assemblers.
3470
3471 @ifset HPPA
3472 On the HPPA, @code{.global} is not always enough to make it accessible to other
3473 partial programs. You may need the HPPA-only @code{.EXPORT} directive as well.
3474 @xref{HPPA Directives,, HPPA Assembler Directives}.
3475 @end ifset
3476
3477 @node hword
3478 @section @code{.hword @var{expressions}}
3479
3480 @cindex @code{hword} directive
3481 @cindex integers, 16-bit
3482 @cindex numbers, 16-bit
3483 @cindex sixteen bit integers
3484 This expects zero or more @var{expressions}, and emits
3485 a 16 bit number for each.
3486
3487 @ifset GENERIC
3488 This directive is a synonym for @samp{.short}; depending on the target
3489 architecture, it may also be a synonym for @samp{.word}.
3490 @end ifset
3491 @ifclear GENERIC
3492 @ifset W32
3493 This directive is a synonym for @samp{.short}.
3494 @end ifset
3495 @ifset W16
3496 This directive is a synonym for both @samp{.short} and @samp{.word}.
3497 @end ifset
3498 @end ifclear
3499
3500 @node Ident
3501 @section @code{.ident}
3502
3503 @cindex @code{ident} directive
3504 This directive is used by some assemblers to place tags in object files.
3505 @code{@value{AS}} simply accepts the directive for source-file
3506 compatibility with such assemblers, but does not actually emit anything
3507 for it.
3508
3509 @node If
3510 @section @code{.if @var{absolute expression}}
3511
3512 @cindex conditional assembly
3513 @cindex @code{if} directive
3514 @code{.if} marks the beginning of a section of code which is only
3515 considered part of the source program being assembled if the argument
3516 (which must be an @var{absolute expression}) is non-zero. The end of
3517 the conditional section of code must be marked by @code{.endif}
3518 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
3519 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}).
3520
3521 The following variants of @code{.if} are also supported:
3522 @table @code
3523 @cindex @code{ifdef} directive
3524 @item .ifdef @var{symbol}
3525 Assembles the following section of code if the specified @var{symbol}
3526 has been defined.
3527
3528 @ignore
3529 @cindex @code{ifeqs} directive
3530 @item .ifeqs
3531 Not yet implemented.
3532 @end ignore
3533
3534 @cindex @code{ifndef} directive
3535 @cindex @code{ifnotdef} directive
3536 @item .ifndef @var{symbol}
3537 @itemx .ifnotdef @var{symbol}
3538 Assembles the following section of code if the specified @var{symbol}
3539 has not been defined. Both spelling variants are equivalent.
3540
3541 @ignore
3542 @item ifnes
3543 Not yet implemented.
3544 @end ignore
3545 @end table
3546
3547 @node Include
3548 @section @code{.include "@var{file}"}
3549
3550 @cindex @code{include} directive
3551 @cindex supporting files, including
3552 @cindex files, including
3553 This directive provides a way to include supporting files at specified
3554 points in your source program. The code from @var{file} is assembled as
3555 if it followed the point of the @code{.include}; when the end of the
3556 included file is reached, assembly of the original file continues. You
3557 can control the search paths used with the @samp{-I} command-line option
3558 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
3559 around @var{file}.
3560
3561 @node Int
3562 @section @code{.int @var{expressions}}
3563
3564 @cindex @code{int} directive
3565 @cindex integers, 32-bit
3566 Expect zero or more @var{expressions}, of any section, separated by commas.
3567 For each expression, emit a number that, at run time, is the value of that
3568 expression. The byte order and bit size of the number depends on what kind
3569 of target the assembly is for.
3570
3571 @ifclear GENERIC
3572 @ifset H8
3573 On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
3574 integers. On the H8/300H and the Hitachi SH, however, @code{.int} emits
3575 32-bit integers.
3576 @end ifset
3577 @end ifclear
3578
3579 @node Irp
3580 @section @code{.irp @var{symbol},@var{values}}@dots{}
3581
3582 @cindex @code{irp} directive
3583 Evaluate a sequence of statements assigning different values to @var{symbol}.
3584 The sequence of statements starts at the @code{.irp} directive, and is
3585 terminated by an @code{.endr} directive. For each @var{value}, @var{symbol} is
3586 set to @var{value}, and the sequence of statements is assembled. If no
3587 @var{value} is listed, the sequence of statements is assembled once, with
3588 @var{symbol} set to the null string. To refer to @var{symbol} within the
3589 sequence of statements, use @var{\symbol}.
3590
3591 For example, assembling
3592
3593 @example
3594 .irp param,1,2,3
3595 move d\param,sp@@-
3596 .endr
3597 @end example
3598
3599 is equivalent to assembling
3600
3601 @example
3602 move d1,sp@@-
3603 move d2,sp@@-
3604 move d3,sp@@-
3605 @end example
3606
3607 @node Irpc
3608 @section @code{.irpc @var{symbol},@var{values}}@dots{}
3609
3610 @cindex @code{irpc} directive
3611 Evaluate a sequence of statements assigning different values to @var{symbol}.
3612 The sequence of statements starts at the @code{.irpc} directive, and is
3613 terminated by an @code{.endr} directive. For each character in @var{value},
3614 @var{symbol} is set to the character, and the sequence of statements is
3615 assembled. If no @var{value} is listed, the sequence of statements is
3616 assembled once, with @var{symbol} set to the null string. To refer to
3617 @var{symbol} within the sequence of statements, use @var{\symbol}.
3618
3619 For example, assembling
3620
3621 @example
3622 .irpc param,123
3623 move d\param,sp@@-
3624 .endr
3625 @end example
3626
3627 is equivalent to assembling
3628
3629 @example
3630 move d1,sp@@-
3631 move d2,sp@@-
3632 move d3,sp@@-
3633 @end example
3634
3635 @node Lcomm
3636 @section @code{.lcomm @var{symbol} , @var{length}}
3637
3638 @cindex @code{lcomm} directive
3639 @cindex local common symbols
3640 @cindex symbols, local common
3641 Reserve @var{length} (an absolute expression) bytes for a local common
3642 denoted by @var{symbol}. The section and value of @var{symbol} are
3643 those of the new local common. The addresses are allocated in the bss
3644 section, so that at run-time the bytes start off zeroed. @var{Symbol}
3645 is not declared global (@pxref{Global,,@code{.global}}), so is normally
3646 not visible to @code{@value{LD}}.
3647
3648 @ifset GENERIC
3649 Some targets permit a third argument to be used with @code{.lcomm}. This
3650 argument specifies the desired alignment of the symbol in the bss section.
3651 @end ifset
3652
3653 @ifset HPPA
3654 The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
3655 @samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
3656 @end ifset
3657
3658 @node Lflags
3659 @section @code{.lflags}
3660
3661 @cindex @code{lflags} directive (ignored)
3662 @code{@value{AS}} accepts this directive, for compatibility with other
3663 assemblers, but ignores it.
3664
3665 @ifclear no-line-dir
3666 @node Line
3667 @section @code{.line @var{line-number}}
3668
3669 @cindex @code{line} directive
3670 @end ifclear
3671 @ifset no-line-dir
3672 @node Ln
3673 @section @code{.ln @var{line-number}}
3674
3675 @cindex @code{ln} directive
3676 @end ifset
3677 @cindex logical line number
3678 @ifset aout-bout
3679 Change the logical line number. @var{line-number} must be an absolute
3680 expression. The next line has that logical line number. Therefore any other
3681 statements on the current line (after a statement separator character) are
3682 reported as on logical line number @var{line-number} @minus{} 1. One day
3683 @code{@value{AS}} will no longer support this directive: it is recognized only
3684 for compatibility with existing assembler programs.
3685
3686 @ifset GENERIC
3687 @ifset A29K
3688 @emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
3689 not available; use the synonym @code{.ln} in that context.
3690 @end ifset
3691 @end ifset
3692 @end ifset
3693
3694 @ifclear no-line-dir
3695 Even though this is a directive associated with the @code{a.out} or
3696 @code{b.out} object-code formats, @code{@value{AS}} still recognizes it
3697 when producing COFF output, and treats @samp{.line} as though it
3698 were the COFF @samp{.ln} @emph{if} it is found outside a
3699 @code{.def}/@code{.endef} pair.
3700
3701 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
3702 used by compilers to generate auxiliary symbol information for
3703 debugging.
3704 @end ifclear
3705
3706 @node Linkonce
3707 @section @code{.linkonce [@var{type}]}
3708 @cindex COMDAT
3709 @cindex @code{linkonce} directive
3710 @cindex common sections
3711 Mark the current section so that the linker only includes a single copy of it.
3712 This may be used to include the same section in several different object files,
3713 but ensure that the linker will only include it once in the final output file.
3714 The @code{.linkonce} pseudo-op must be used for each instance of the section.
3715 Duplicate sections are detected based on the section name, so it should be
3716 unique.
3717
3718 This directive is only supported by a few object file formats; as of this
3719 writing, the only object file format which supports it is the Portable
3720 Executable format used on Windows NT.
3721
3722 The @var{type} argument is optional. If specified, it must be one of the
3723 following strings. For example:
3724 @smallexample
3725 .linkonce same_size
3726 @end smallexample
3727 Not all types may be supported on all object file formats.
3728
3729 @table @code
3730 @item discard
3731 Silently discard duplicate sections. This is the default.
3732
3733 @item one_only
3734 Warn if there are duplicate sections, but still keep only one copy.
3735
3736 @item same_size
3737 Warn if any of the duplicates have different sizes.
3738
3739 @item same_contents
3740 Warn if any of the duplicates do not have exactly the same contents.
3741 @end table
3742
3743 @node Ln
3744 @section @code{.ln @var{line-number}}
3745
3746 @cindex @code{ln} directive
3747 @ifclear no-line-dir
3748 @samp{.ln} is a synonym for @samp{.line}.
3749 @end ifclear
3750 @ifset no-line-dir
3751 Tell @code{@value{AS}} to change the logical line number. @var{line-number}
3752 must be an absolute expression. The next line has that logical
3753 line number, so any other statements on the current line (after a
3754 statement separator character @code{;}) are reported as on logical
3755 line number @var{line-number} @minus{} 1.
3756 @ifset BOUT
3757
3758 This directive is accepted, but ignored, when @code{@value{AS}} is
3759 configured for @code{b.out}; its effect is only associated with COFF
3760 output format.
3761 @end ifset
3762 @end ifset
3763
3764 @node MRI
3765 @section @code{.mri @var{val}}
3766
3767 @cindex @code{mri} directive
3768 @cindex MRI mode, temporarily
3769 If @var{val} is non-zero, this tells @code{@value{AS}} to enter MRI mode. If
3770 @var{val} is zero, this tells @code{@value{AS}} to exit MRI mode. This change
3771 affects code assembled until the next @code{.mri} directive, or until the end
3772 of the file. @xref{M, MRI mode, MRI mode}.
3773
3774 @node List
3775 @section @code{.list}
3776
3777 @cindex @code{list} directive
3778 @cindex listing control, turning on
3779 Control (in conjunction with the @code{.nolist} directive) whether or
3780 not assembly listings are generated. These two directives maintain an
3781 internal counter (which is zero initially). @code{.list} increments the
3782 counter, and @code{.nolist} decrements it. Assembly listings are
3783 generated whenever the counter is greater than zero.
3784
3785 By default, listings are disabled. When you enable them (with the
3786 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
3787 the initial value of the listing counter is one.
3788
3789 @node Long
3790 @section @code{.long @var{expressions}}
3791
3792 @cindex @code{long} directive
3793 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
3794
3795 @ignore
3796 @c no one seems to know what this is for or whether this description is
3797 @c what it really ought to do
3798 @node Lsym
3799 @section @code{.lsym @var{symbol}, @var{expression}}
3800
3801 @cindex @code{lsym} directive
3802 @cindex symbol, not referenced in assembly
3803 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
3804 the hash table, ensuring it cannot be referenced by name during the
3805 rest of the assembly. This sets the attributes of the symbol to be
3806 the same as the expression value:
3807 @smallexample
3808 @var{other} = @var{descriptor} = 0
3809 @var{type} = @r{(section of @var{expression})}
3810 @var{value} = @var{expression}
3811 @end smallexample
3812 @noindent
3813 The new symbol is not flagged as external.
3814 @end ignore
3815
3816 @node Macro
3817 @section @code{.macro}
3818
3819 @cindex macros
3820 The commands @code{.macro} and @code{.endm} allow you to define macros that
3821 generate assembly output. For example, this definition specifies a macro
3822 @code{sum} that puts a sequence of numbers into memory:
3823
3824 @example
3825 .macro sum from=0, to=5
3826 .long \from
3827 .if \to-\from
3828 sum "(\from+1)",\to
3829 .endif
3830 .endm
3831 @end example
3832
3833 @noindent
3834 With that definition, @samp{SUM 0,5} is equivalent to this assembly input:
3835
3836 @example
3837 .long 0
3838 .long 1
3839 .long 2
3840 .long 3
3841 .long 4
3842 .long 5
3843 @end example
3844
3845 @ftable @code
3846 @item .macro @var{macname}
3847 @itemx .macro @var{macname} @var{macargs} @dots{}
3848 @cindex @code{macro} directive
3849 Begin the definition of a macro called @var{macname}. If your macro
3850 definition requires arguments, specify their names after the macro name,
3851 separated by commas or spaces. You can supply a default value for any
3852 macro argument by following the name with @samp{=@var{deflt}}. For
3853 example, these are all valid @code{.macro} statements:
3854
3855 @table @code
3856 @item .macro comm
3857 Begin the definition of a macro called @code{comm}, which takes no
3858 arguments.
3859
3860 @item .macro plus1 p, p1
3861 @itemx .macro plus1 p p1
3862 Either statement begins the definition of a macro called @code{plus1},
3863 which takes two arguments; within the macro definition, write
3864 @samp{\p} or @samp{\p1} to evaluate the arguments.
3865
3866 @item .macro reserve_str p1=0 p2
3867 Begin the definition of a macro called @code{reserve_str}, with two
3868 arguments. The first argument has a default value, but not the second.
3869 After the definition is complete, you can call the macro either as
3870 @samp{reserve_str @var{a},@var{b}} (with @samp{\p1} evaluating to
3871 @var{a} and @samp{\p2} evaluating to @var{b}), or as @samp{reserve_str
3872 ,@var{b}} (with @samp{\p1} evaluating as the default, in this case
3873 @samp{0}, and @samp{\p2} evaluating to @var{b}).
3874 @end table
3875
3876 When you call a macro, you can specify the argument values either by
3877 position, or by keyword. For example, @samp{sum 9,17} is equivalent to
3878 @samp{sum to=17, from=9}.
3879
3880 @item .endm
3881 @cindex @code{endm} directive
3882 Mark the end of a macro definition.
3883
3884 @item .exitm
3885 @cindex @code{exitm} directive
3886 Exit early from the current macro definition.
3887
3888 @cindex number of macros executed
3889 @cindex macros, count executed
3890 @item \@@
3891 @code{@value{AS}} maintains a counter of how many macros it has
3892 executed in this pseudo-variable; you can copy that number to your
3893 output with @samp{\@@}, but @emph{only within a macro definition}.
3894
3895 @ignore
3896 @item LOCAL @var{name} [ , @dots{} ]
3897 @emph{Warning: @code{LOCAL} is only available if you select ``alternate
3898 macro syntax'' with @samp{-a} or @samp{--alternate}.} @xref{Alternate,,
3899 Alternate macro syntax}.
3900
3901 Generate a string replacement for each of the @var{name} arguments, and
3902 replace any instances of @var{name} in each macro expansion. The
3903 replacement string is unique in the assembly, and different for each
3904 separate macro expansion. @code{LOCAL} allows you to write macros that
3905 define symbols, without fear of conflict between separate macro expansions.
3906 @end ignore
3907 @end ftable
3908
3909 @node Nolist
3910 @section @code{.nolist}
3911
3912 @cindex @code{nolist} directive
3913 @cindex listing control, turning off
3914 Control (in conjunction with the @code{.list} directive) whether or
3915 not assembly listings are generated. These two directives maintain an
3916 internal counter (which is zero initially). @code{.list} increments the
3917 counter, and @code{.nolist} decrements it. Assembly listings are
3918 generated whenever the counter is greater than zero.
3919
3920 @node Octa
3921 @section @code{.octa @var{bignums}}
3922
3923 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
3924 @cindex @code{octa} directive
3925 @cindex integer, 16-byte
3926 @cindex sixteen byte integer
3927 This directive expects zero or more bignums, separated by commas. For each
3928 bignum, it emits a 16-byte integer.
3929
3930 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
3931 hence @emph{octa}-word for 16 bytes.
3932
3933 @node Org
3934 @section @code{.org @var{new-lc} , @var{fill}}
3935
3936 @cindex @code{org} directive
3937 @cindex location counter, advancing
3938 @cindex advancing location counter
3939 @cindex current address, advancing
3940 Advance the location counter of the current section to
3941 @var{new-lc}. @var{new-lc} is either an absolute expression or an
3942 expression with the same section as the current subsection. That is,
3943 you can't use @code{.org} to cross sections: if @var{new-lc} has the
3944 wrong section, the @code{.org} directive is ignored. To be compatible
3945 with former assemblers, if the section of @var{new-lc} is absolute,
3946 @code{@value{AS}} issues a warning, then pretends the section of @var{new-lc}
3947 is the same as the current subsection.
3948
3949 @code{.org} may only increase the location counter, or leave it
3950 unchanged; you cannot use @code{.org} to move the location counter
3951 backwards.
3952
3953 @c double negative used below "not undefined" because this is a specific
3954 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
3955 @c section. doc@cygnus.com 18feb91
3956 Because @code{@value{AS}} tries to assemble programs in one pass, @var{new-lc}
3957 may not be undefined. If you really detest this restriction we eagerly await
3958 a chance to share your improved assembler.
3959
3960 Beware that the origin is relative to the start of the section, not
3961 to the start of the subsection. This is compatible with other
3962 people's assemblers.
3963
3964 When the location counter (of the current subsection) is advanced, the
3965 intervening bytes are filled with @var{fill} which should be an
3966 absolute expression. If the comma and @var{fill} are omitted,
3967 @var{fill} defaults to zero.
3968
3969 @node P2align
3970 @section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
3971
3972 @cindex padding the location counter given a power of two
3973 @cindex @code{p2align} directive
3974 Pad the location counter (in the current subsection) to a particular
3975 storage boundary. The first expression (which must be absolute) is the
3976 number of low-order zero bits the location counter must have after
3977 advancement. For example @samp{.p2align 3} advances the location
3978 counter until it a multiple of 8. If the location counter is already a
3979 multiple of 8, no change is needed.
3980
3981 The second expression (also absolute) gives the fill value to be stored in the
3982 padding bytes. It (and the comma) may be omitted. If it is omitted, the
3983 padding bytes are normally zero. However, on some systems, if the section is
3984 marked as containing code and the fill value is omitted, the space is filled
3985 with no-op instructions.
3986
3987 The third expression is also absolute, and is also optional. If it is present,
3988 it is the maximum number of bytes that should be skipped by this alignment
3989 directive. If doing the alignment would require skipping more bytes than the
3990 specified maximum, then the alignment is not done at all. You can omit the
3991 fill value (the second argument) entirely by simply using two commas after the
3992 required alignment; this can be useful if you want the alignment to be filled
3993 with no-op instructions when appropriate.
3994
3995 @cindex @code{p2alignw} directive
3996 @cindex @code{p2alignl} directive
3997 The @code{.p2alignw} and @code{.p2alignl} directives are variants of the
3998 @code{.p2align} directive. The @code{.p2alignw} directive treats the fill
3999 pattern as a two byte word value. The @code{.p2alignl} directives treats the
4000 fill pattern as a four byte longword value. For example, @code{.p2alignw
4001 2,0x368d} will align to a multiple of 4. If it skips two bytes, they will be
4002 filled in with the value 0x368d (the exact placement of the bytes depends upon
4003 the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
4004 undefined.
4005
4006 @node Psize
4007 @section @code{.psize @var{lines} , @var{columns}}
4008
4009 @cindex @code{psize} directive
4010 @cindex listing control: paper size
4011 @cindex paper size, for listings
4012 Use this directive to declare the number of lines---and, optionally, the
4013 number of columns---to use for each page, when generating listings.
4014
4015 If you do not use @code{.psize}, listings use a default line-count
4016 of 60. You may omit the comma and @var{columns} specification; the
4017 default width is 200 columns.
4018
4019 @code{@value{AS}} generates formfeeds whenever the specified number of
4020 lines is exceeded (or whenever you explicitly request one, using
4021 @code{.eject}).
4022
4023 If you specify @var{lines} as @code{0}, no formfeeds are generated save
4024 those explicitly specified with @code{.eject}.
4025
4026 @node Quad
4027 @section @code{.quad @var{bignums}}
4028
4029 @cindex @code{quad} directive
4030 @code{.quad} expects zero or more bignums, separated by commas. For
4031 each bignum, it emits
4032 @ifclear bignum-16
4033 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
4034 warning message; and just takes the lowest order 8 bytes of the bignum.
4035 @cindex eight-byte integer
4036 @cindex integer, 8-byte
4037
4038 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
4039 hence @emph{quad}-word for 8 bytes.
4040 @end ifclear
4041 @ifset bignum-16
4042 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
4043 warning message; and just takes the lowest order 16 bytes of the bignum.
4044 @cindex sixteen-byte integer
4045 @cindex integer, 16-byte
4046 @end ifset
4047
4048 @node Rept
4049 @section @code{.rept @var{count}}
4050
4051 @cindex @code{rept} directive
4052 Repeat the sequence of lines between the @code{.rept} directive and the next
4053 @code{.endr} directive @var{count} times.
4054
4055 For example, assembling
4056
4057 @example
4058 .rept 3
4059 .long 0
4060 .endr
4061 @end example
4062
4063 is equivalent to assembling
4064
4065 @example
4066 .long 0
4067 .long 0
4068 .long 0
4069 @end example
4070
4071 @node Sbttl
4072 @section @code{.sbttl "@var{subheading}"}
4073
4074 @cindex @code{sbttl} directive
4075 @cindex subtitles for listings
4076 @cindex listing control: subtitle
4077 Use @var{subheading} as the title (third line, immediately after the
4078 title line) when generating assembly listings.
4079
4080 This directive affects subsequent pages, as well as the current page if
4081 it appears within ten lines of the top of a page.
4082
4083 @ifset COFF
4084 @node Scl
4085 @section @code{.scl @var{class}}
4086
4087 @cindex @code{scl} directive
4088 @cindex symbol storage class (COFF)
4089 @cindex COFF symbol storage class
4090 Set the storage-class value for a symbol. This directive may only be
4091 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
4092 whether a symbol is static or external, or it may record further
4093 symbolic debugging information.
4094 @ifset BOUT
4095
4096 The @samp{.scl} directive is primarily associated with COFF output; when
4097 configured to generate @code{b.out} output format, @code{@value{AS}}
4098 accepts this directive but ignores it.
4099 @end ifset
4100 @end ifset
4101
4102 @node Section
4103 @section @code{.section @var{name}}
4104
4105 @cindex @code{section} directive
4106 @cindex named section
4107 Use the @code{.section} directive to assemble the following code into a section
4108 named @var{name}.
4109
4110 This directive is only supported for targets that actually support arbitrarily
4111 named sections; on @code{a.out} targets, for example, it is not accepted, even
4112 with a standard @code{a.out} section name.
4113
4114 @ifset COFF
4115 For COFF targets, the @code{.section} directive is used in one of the following
4116 ways:
4117 @smallexample
4118 .section @var{name}[, "@var{flags}"]
4119 .section @var{name}[, @var{subsegment}]
4120 @end smallexample
4121
4122 If the optional argument is quoted, it is taken as flags to use for the
4123 section. Each flag is a single character. The following flags are recognized:
4124 @table @code
4125 @item b
4126 bss section (uninitialized data)
4127 @item n
4128 section is not loaded
4129 @item w
4130 writable section
4131 @item d
4132 data section
4133 @item r
4134 read-only section
4135 @item x
4136 executable section
4137 @end table
4138
4139 If no flags are specified, the default flags depend upon the section name. If
4140 the section name is not recognized, the default will be for the section to be
4141 loaded and writable.
4142
4143 If the optional argument to the @code{.section} directive is not quoted, it is
4144 taken as a subsegment number (@pxref{Sub-Sections}).
4145 @end ifset
4146
4147 @ifset ELF
4148 For ELF targets, the @code{.section} directive is used like this:
4149 @smallexample
4150 .section @var{name}[, "@var{flags}"[, @@@var{type}]]
4151 @end smallexample
4152 The optional @var{flags} argument is a quoted string which may contain any
4153 combintion of the following characters:
4154 @table @code
4155 @item a
4156 section is allocatable
4157 @item w
4158 section is writable
4159 @item x
4160 section is executable
4161 @end table
4162
4163 The optional @var{type} argument may contain one of the following constants:
4164 @table @code
4165 @item @@progbits
4166 section contains data
4167 @item @@nobits
4168 section does not contain data (i.e., section only occupies space)
4169 @end table
4170
4171 If no flags are specified, the default flags depend upon the section name. If
4172 the section name is not recognized, the default will be for the section to have
4173 none of the above flags: it will not be allocated in memory, nor writable, nor
4174 executable. The section will contain data.
4175
4176 For ELF targets, the assembler supports another type of @code{.section}
4177 directive for compatibility with the Solaris assembler:
4178 @smallexample
4179 .section "@var{name}"[, @var{flags}...]
4180 @end smallexample
4181 Note that the section name is quoted. There may be a sequence of comma
4182 separated flags:
4183 @table @code
4184 @item #alloc
4185 section is allocatable
4186 @item #write
4187 section is writable
4188 @item #execinstr
4189 section is executable
4190 @end table
4191 @end ifset
4192
4193 @node Set
4194 @section @code{.set @var{symbol}, @var{expression}}
4195
4196 @cindex @code{set} directive
4197 @cindex symbol value, setting
4198 Set the value of @var{symbol} to @var{expression}. This
4199 changes @var{symbol}'s value and type to conform to
4200 @var{expression}. If @var{symbol} was flagged as external, it remains
4201 flagged (@pxref{Symbol Attributes}).
4202
4203 You may @code{.set} a symbol many times in the same assembly.
4204
4205 If you @code{.set} a global symbol, the value stored in the object
4206 file is the last value stored into it.
4207
4208 @ifset HPPA
4209 The syntax for @code{set} on the HPPA is
4210 @samp{@var{symbol} .set @var{expression}}.
4211 @end ifset
4212
4213 @node Short
4214 @section @code{.short @var{expressions}}
4215
4216 @cindex @code{short} directive
4217 @ifset GENERIC
4218 @code{.short} is normally the same as @samp{.word}.
4219 @xref{Word,,@code{.word}}.
4220
4221 In some configurations, however, @code{.short} and @code{.word} generate
4222 numbers of different lengths; @pxref{Machine Dependencies}.
4223 @end ifset
4224 @ifclear GENERIC
4225 @ifset W16
4226 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
4227 @end ifset
4228 @ifset W32
4229 This expects zero or more @var{expressions}, and emits
4230 a 16 bit number for each.
4231 @end ifset
4232 @end ifclear
4233
4234 @node Single
4235 @section @code{.single @var{flonums}}
4236
4237 @cindex @code{single} directive
4238 @cindex floating point numbers (single)
4239 This directive assembles zero or more flonums, separated by commas. It
4240 has the same effect as @code{.float}.
4241 @ifset GENERIC
4242 The exact kind of floating point numbers emitted depends on how
4243 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
4244 @end ifset
4245 @ifclear GENERIC
4246 @ifset IEEEFLOAT
4247 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
4248 numbers in @sc{ieee} format.
4249 @end ifset
4250 @end ifclear
4251
4252 @ifset COFF
4253 @node Size
4254 @section @code{.size}
4255
4256 @cindex @code{size} directive
4257 This directive is generated by compilers to include auxiliary debugging
4258 information in the symbol table. It is only permitted inside
4259 @code{.def}/@code{.endef} pairs.
4260 @ifset BOUT
4261
4262 @samp{.size} is only meaningful when generating COFF format output; when
4263 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
4264 ignores it.
4265 @end ifset
4266 @end ifset
4267
4268 @node Sleb128
4269 @section @code{.sleb128 @var{expressions}}
4270
4271 @cindex @code{sleb128} directive
4272 @var{sleb128} stands for ``signed little endian base 128.'' This is a
4273 compact, variable length representation of numbers used by the DWARF
4274 symbolic debugging format. @xref{Uleb128,@code{.uleb128}}.
4275
4276 @ifclear no-space-dir
4277 @node Skip
4278 @section @code{.skip @var{size} , @var{fill}}
4279
4280 @cindex @code{skip} directive
4281 @cindex filling memory
4282 This directive emits @var{size} bytes, each of value @var{fill}. Both
4283 @var{size} and @var{fill} are absolute expressions. If the comma and
4284 @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same as
4285 @samp{.space}.
4286
4287 @node Space
4288 @section @code{.space @var{size} , @var{fill}}
4289
4290 @cindex @code{space} directive
4291 @cindex filling memory
4292 This directive emits @var{size} bytes, each of value @var{fill}. Both
4293 @var{size} and @var{fill} are absolute expressions. If the comma
4294 and @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same
4295 as @samp{.skip}.
4296
4297 @ifset HPPA
4298 @quotation
4299 @emph{Warning:} @code{.space} has a completely different meaning for HPPA
4300 targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
4301 Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the
4302 @code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives},
4303 for a summary.
4304 @end quotation
4305 @end ifset
4306 @end ifclear
4307
4308 @ifset A29K
4309 @ifclear GENERIC
4310 @node Space
4311 @section @code{.space}
4312 @cindex @code{space} directive
4313 @end ifclear
4314 On the AMD 29K, this directive is ignored; it is accepted for
4315 compatibility with other AMD 29K assemblers.
4316
4317 @quotation
4318 @emph{Warning:} In most versions of the @sc{gnu} assembler, the directive
4319 @code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
4320 @end quotation
4321 @end ifset
4322
4323 @ifset have-stabs
4324 @node Stab
4325 @section @code{.stabd, .stabn, .stabs}
4326
4327 @cindex symbolic debuggers, information for
4328 @cindex @code{stab@var{x}} directives
4329 There are three directives that begin @samp{.stab}.
4330 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
4331 The symbols are not entered in the @code{@value{AS}} hash table: they
4332 cannot be referenced elsewhere in the source file.
4333 Up to five fields are required:
4334
4335 @table @var
4336 @item string
4337 This is the symbol's name. It may contain any character except
4338 @samp{\000}, so is more general than ordinary symbol names. Some
4339 debuggers used to code arbitrarily complex structures into symbol names
4340 using this field.
4341
4342 @item type
4343 An absolute expression. The symbol's type is set to the low 8 bits of
4344 this expression. Any bit pattern is permitted, but @code{@value{LD}}
4345 and debuggers choke on silly bit patterns.
4346
4347 @item other
4348 An absolute expression. The symbol's ``other'' attribute is set to the
4349 low 8 bits of this expression.
4350
4351 @item desc
4352 An absolute expression. The symbol's descriptor is set to the low 16
4353 bits of this expression.
4354
4355 @item value
4356 An absolute expression which becomes the symbol's value.
4357 @end table
4358
4359 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
4360 or @code{.stabs} statement, the symbol has probably already been created;
4361 you get a half-formed symbol in your object file. This is
4362 compatible with earlier assemblers!
4363
4364 @table @code
4365 @cindex @code{stabd} directive
4366 @item .stabd @var{type} , @var{other} , @var{desc}
4367
4368 The ``name'' of the symbol generated is not even an empty string.
4369 It is a null pointer, for compatibility. Older assemblers used a
4370 null pointer so they didn't waste space in object files with empty
4371 strings.
4372
4373 The symbol's value is set to the location counter,
4374 relocatably. When your program is linked, the value of this symbol
4375 is the address of the location counter when the @code{.stabd} was
4376 assembled.
4377
4378 @cindex @code{stabn} directive
4379 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
4380 The name of the symbol is set to the empty string @code{""}.
4381
4382 @cindex @code{stabs} directive
4383 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
4384 All five fields are specified.
4385 @end table
4386 @end ifset
4387 @c end have-stabs
4388
4389 @node String
4390 @section @code{.string} "@var{str}"
4391
4392 @cindex string, copying to object file
4393 @cindex @code{string} directive
4394
4395 Copy the characters in @var{str} to the object file. You may specify more than
4396 one string to copy, separated by commas. Unless otherwise specified for a
4397 particular machine, the assembler marks the end of each string with a 0 byte.
4398 You can use any of the escape sequences described in @ref{Strings,,Strings}.
4399
4400 @ifset ELF
4401 @node Symver
4402 @section @code{.symver}
4403 @cindex @code{symver} directive
4404 @cindex symbol versioning
4405 @cindex versions of symbols
4406 Use the @code{.symver} directive to bind symbols to specific version nodes
4407 within a source file. This is only supported on ELF platforms, and is
4408 typically used when assembling files to be linked into a shared library.
4409 There are cases where it may make sense to use this in objects to be bound
4410 into an application itself so as to override a versioned symbol from a
4411 shared library.
4412
4413 For ELF targets, the @code{.symver} directive is used like this:
4414 @smallexample
4415 .symver @var{name}, @var{name2@@nodename}
4416 @end smallexample
4417 In this case, the symbol @var{name} must exist and be defined within the file
4418 being assembled. The @code{.versym} directive effectively creates a symbol
4419 alias with the name @var{name2@@nodename}, and in fact the main reason that we
4420 just don't try and create a regular alias is that the @var{@@} character isn't
4421 permitted in symbol names. The @var{name2} part of the name is the actual name
4422 of the symbol by which it will be externally referenced. The name @var{name}
4423 itself is merely a name of convenience that is used so that it is possible to
4424 have definitions for multiple versions of a function within a single source
4425 file, and so that the compiler can unambiguously know which version of a
4426 function is being mentioned. The @var{nodename} portion of the alias should be
4427 the name of a node specified in the version script supplied to the linker when
4428 building a shared library. If you are attempting to override a versioned
4429 symbol from a shared library, then @var{nodename} should correspond to the
4430 nodename of the symbol you are trying to override.
4431 @end ifset
4432
4433 @ifset COFF
4434 @node Tag
4435 @section @code{.tag @var{structname}}
4436
4437 @cindex COFF structure debugging
4438 @cindex structure debugging, COFF
4439 @cindex @code{tag} directive
4440 This directive is generated by compilers to include auxiliary debugging
4441 information in the symbol table. It is only permitted inside
4442 @code{.def}/@code{.endef} pairs. Tags are used to link structure
4443 definitions in the symbol table with instances of those structures.
4444 @ifset BOUT
4445
4446 @samp{.tag} is only used when generating COFF format output; when
4447 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
4448 ignores it.
4449 @end ifset
4450 @end ifset
4451
4452 @node Text
4453 @section @code{.text @var{subsection}}
4454
4455 @cindex @code{text} directive
4456 Tells @code{@value{AS}} to assemble the following statements onto the end of
4457 the text subsection numbered @var{subsection}, which is an absolute
4458 expression. If @var{subsection} is omitted, subsection number zero
4459 is used.
4460
4461 @node Title
4462 @section @code{.title "@var{heading}"}
4463
4464 @cindex @code{title} directive
4465 @cindex listing control: title line
4466 Use @var{heading} as the title (second line, immediately after the
4467 source file name and pagenumber) when generating assembly listings.
4468
4469 This directive affects subsequent pages, as well as the current page if
4470 it appears within ten lines of the top of a page.
4471
4472 @ifset COFF
4473 @node Type
4474 @section @code{.type @var{int}}
4475
4476 @cindex COFF symbol type
4477 @cindex symbol type, COFF
4478 @cindex @code{type} directive
4479 This directive, permitted only within @code{.def}/@code{.endef} pairs,
4480 records the integer @var{int} as the type attribute of a symbol table entry.
4481 @ifset BOUT
4482
4483 @samp{.type} is associated only with COFF format output; when
4484 @code{@value{AS}} is configured for @code{b.out} output, it accepts this
4485 directive but ignores it.
4486 @end ifset
4487 @end ifset
4488
4489 @ifset COFF
4490 @node Val
4491 @section @code{.val @var{addr}}
4492
4493 @cindex @code{val} directive
4494 @cindex COFF value attribute
4495 @cindex value attribute, COFF
4496 This directive, permitted only within @code{.def}/@code{.endef} pairs,
4497 records the address @var{addr} as the value attribute of a symbol table
4498 entry.
4499 @ifset BOUT
4500
4501 @samp{.val} is used only for COFF output; when @code{@value{AS}} is
4502 configured for @code{b.out}, it accepts this directive but ignores it.
4503 @end ifset
4504 @end ifset
4505
4506 @node Uleb128
4507 @section @code{.uleb128 @var{expressions}}
4508
4509 @cindex @code{uleb128} directive
4510 @var{uleb128} stands for ``unsigned little endian base 128.'' This is a
4511 compact, variable length representation of numbers used by the DWARF
4512 symbolic debugging format. @xref{Sleb128,@code{.sleb128}}.
4513
4514 @node Word
4515 @section @code{.word @var{expressions}}
4516
4517 @cindex @code{word} directive
4518 This directive expects zero or more @var{expressions}, of any section,
4519 separated by commas.
4520 @ifclear GENERIC
4521 @ifset W32
4522 For each expression, @code{@value{AS}} emits a 32-bit number.
4523 @end ifset
4524 @ifset W16
4525 For each expression, @code{@value{AS}} emits a 16-bit number.
4526 @end ifset
4527 @end ifclear
4528 @ifset GENERIC
4529
4530 The size of the number emitted, and its byte order,
4531 depend on what target computer the assembly is for.
4532 @end ifset
4533
4534 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
4535 @c happen---32-bit addressability, period; no long/short jumps.
4536 @ifset DIFF-TBL-KLUGE
4537 @cindex difference tables altered
4538 @cindex altered difference tables
4539 @quotation
4540 @emph{Warning: Special Treatment to support Compilers}
4541 @end quotation
4542
4543 @ifset GENERIC
4544 Machines with a 32-bit address space, but that do less than 32-bit
4545 addressing, require the following special treatment. If the machine of
4546 interest to you does 32-bit addressing (or doesn't require it;
4547 @pxref{Machine Dependencies}), you can ignore this issue.
4548
4549 @end ifset
4550 In order to assemble compiler output into something that works,
4551 @code{@value{AS}} occasionlly does strange things to @samp{.word} directives.
4552 Directives of the form @samp{.word sym1-sym2} are often emitted by
4553 compilers as part of jump tables. Therefore, when @code{@value{AS}} assembles a
4554 directive of the form @samp{.word sym1-sym2}, and the difference between
4555 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{@value{AS}}
4556 creates a @dfn{secondary jump table}, immediately before the next label.
4557 This secondary jump table is preceded by a short-jump to the
4558 first byte after the secondary table. This short-jump prevents the flow
4559 of control from accidentally falling into the new table. Inside the
4560 table is a long-jump to @code{sym2}. The original @samp{.word}
4561 contains @code{sym1} minus the address of the long-jump to
4562 @code{sym2}.
4563
4564 If there were several occurrences of @samp{.word sym1-sym2} before the
4565 secondary jump table, all of them are adjusted. If there was a
4566 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
4567 long-jump to @code{sym4} is included in the secondary jump table,
4568 and the @code{.word} directives are adjusted to contain @code{sym3}
4569 minus the address of the long-jump to @code{sym4}; and so on, for as many
4570 entries in the original jump table as necessary.
4571
4572 @ifset INTERNALS
4573 @emph{This feature may be disabled by compiling @code{@value{AS}} with the
4574 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
4575 assembly language programmers.
4576 @end ifset
4577 @end ifset
4578 @c end DIFF-TBL-KLUGE
4579
4580 @node Deprecated
4581 @section Deprecated Directives
4582
4583 @cindex deprecated directives
4584 @cindex obsolescent directives
4585 One day these directives won't work.
4586 They are included for compatibility with older assemblers.
4587 @table @t
4588 @item .abort
4589 @item .app-file
4590 @item .line
4591 @end table
4592
4593 @ifset GENERIC
4594 @node Machine Dependencies
4595 @chapter Machine Dependent Features
4596
4597 @cindex machine dependencies
4598 The machine instruction sets are (almost by definition) different on
4599 each machine where @code{@value{AS}} runs. Floating point representations
4600 vary as well, and @code{@value{AS}} often supports a few additional
4601 directives or command-line options for compatibility with other
4602 assemblers on a particular platform. Finally, some versions of
4603 @code{@value{AS}} support special pseudo-instructions for branch
4604 optimization.
4605
4606 This chapter discusses most of these differences, though it does not
4607 include details on any machine's instruction set. For details on that
4608 subject, see the hardware manufacturer's manual.
4609
4610 @menu
4611 @ifset A29K
4612 * AMD29K-Dependent:: AMD 29K Dependent Features
4613 @end ifset
4614 @ifset ARC
4615 * ARC-Dependent:: ARC Dependent Features
4616 @end ifset
4617 @ifset ARM
4618 * ARM-Dependent:: ARM Dependent Features
4619 @end ifset
4620 @ifset D10V
4621 * D10V-Dependent:: D10V Dependent Features
4622 @end ifset
4623 @ifset H8/300
4624 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4625 @end ifset
4626 @ifset H8/500
4627 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4628 @end ifset
4629 @ifset HPPA
4630 * HPPA-Dependent:: HPPA Dependent Features
4631 @end ifset
4632 @ifset I80386
4633 * i386-Dependent:: Intel 80386 Dependent Features
4634 @end ifset
4635 @ifset I960
4636 * i960-Dependent:: Intel 80960 Dependent Features
4637 @end ifset
4638 @ifset M680X0
4639 * M68K-Dependent:: M680x0 Dependent Features
4640 @end ifset
4641 @ifset MIPS
4642 * MIPS-Dependent:: MIPS Dependent Features
4643 @end ifset
4644 @ifset SH
4645 * SH-Dependent:: Hitachi SH Dependent Features
4646 @end ifset
4647 @ifset SPARC
4648 * Sparc-Dependent:: SPARC Dependent Features
4649 @end ifset
4650 @ifset Z8000
4651 * Z8000-Dependent:: Z8000 Dependent Features
4652 @end ifset
4653 @ifset VAX
4654 * Vax-Dependent:: VAX Dependent Features
4655 @end ifset
4656 @end menu
4657
4658 @lowersections
4659 @end ifset
4660
4661 @c The following major nodes are *sections* in the GENERIC version, *chapters*
4662 @c in single-cpu versions. This is mainly achieved by @lowersections. There is a
4663 @c peculiarity: to preserve cross-references, there must be a node called
4664 @c "Machine Dependencies". Hence the conditional nodenames in each
4665 @c major node below. Node defaulting in makeinfo requires adjacency of
4666 @c node and sectioning commands; hence the repetition of @chapter BLAH
4667 @c in both conditional blocks.
4668
4669 @ifset ARC
4670 @ifset GENERIC
4671 @page
4672 @node ARC-Dependent
4673 @chapter ARC Dependent Features
4674 @end ifset
4675 @ifclear GENERIC
4676 @node Machine Dependencies
4677 @chapter ARC Dependent Features
4678 @end ifclear
4679
4680 @cindex ARC support
4681 @menu
4682 * ARC-Opts:: Options
4683 * ARC-Float:: Floating Point
4684 * ARC-Directives:: Sparc Machine Directives
4685 @end menu
4686
4687 @node ARC-Opts
4688 @section Options
4689
4690 @cindex options for ARC
4691 @cindex ARC options
4692 @cindex architectures, ARC
4693 @cindex ARC architectures
4694 The ARC chip family includes several successive levels (or other
4695 variants) of chip, using the same core instruction set, but including
4696 a few additional instructions at each level.
4697
4698 By default, @code{@value{AS}} assumes the core instruction set (ARC
4699 base). The @code{.cpu} pseudo-op is intended to be used to select
4700 the variant.
4701
4702 @table @code
4703 @cindex @code{-mbig-endian} option (ARC)
4704 @cindex @code{-mlittle-endian} option (ARC)
4705 @cindex ARC big-endian output
4706 @cindex ARC little-endian output
4707 @cindex big-endian output, ARC
4708 @cindex little-endian output, ARC
4709 @item -mbig-endian
4710 @itemx -mlittle-endian
4711 Any @sc{arc} configuration of @code{@value{AS}} can select big-endian or
4712 little-endian output at run time (unlike most other @sc{gnu} development
4713 tools, which must be configured for one or the other). Use
4714 @samp{-mbig-endian} to select big-endian output, and @samp{-mlittle-endian}
4715 for little-endian.
4716 @end table
4717
4718 @node ARC-Float
4719 @section Floating Point
4720
4721 @cindex floating point, ARC (@sc{ieee})
4722 @cindex ARC floating point (@sc{ieee})
4723 The ARC cpu family currently does not have hardware floating point
4724 support. Software floating point support is provided by @code{GCC}
4725 and uses @sc{ieee} floating-point numbers.
4726
4727 @node ARC-Directives
4728 @section ARC Machine Directives
4729
4730 @cindex ARC machine directives
4731 @cindex machine directives, ARC
4732 The ARC version of @code{@value{AS}} supports the following additional
4733 machine directives:
4734
4735 @table @code
4736 @item .cpu
4737 @cindex @code{cpu} directive, SPARC
4738 This must be followed by the desired cpu.
4739 The ARC is intended to be customizable, @code{.cpu} is used to
4740 select the desired variant [though currently there are none].
4741
4742 @end table
4743
4744 @end ifset
4745
4746 @ifset A29K
4747 @include c-a29k.texi
4748 @end ifset
4749
4750 @ifset ARM
4751 @include c-arm.texi
4752 @end ifset
4753
4754 @ifset Hitachi-all
4755 @ifclear GENERIC
4756 @node Machine Dependencies
4757 @chapter Machine Dependent Features
4758
4759 The machine instruction sets are different on each Hitachi chip family,
4760 and there are also some syntax differences among the families. This
4761 chapter describes the specific @code{@value{AS}} features for each
4762 family.
4763
4764 @menu
4765 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4766 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4767 * SH-Dependent:: Hitachi SH Dependent Features
4768 @end menu
4769 @lowersections
4770 @end ifclear
4771 @end ifset
4772
4773 @ifset D10V
4774 @include c-d10v.texi
4775 @end ifset
4776
4777 @ifset H8/300
4778 @include c-h8300.texi
4779 @end ifset
4780
4781 @ifset H8/500
4782 @include c-h8500.texi
4783 @end ifset
4784
4785 @ifset HPPA
4786 @include c-hppa.texi
4787 @end ifset
4788
4789 @ifset I80386
4790 @include c-i386.texi
4791 @end ifset
4792
4793 @ifset I960
4794 @include c-i960.texi
4795 @end ifset
4796
4797 @ifset M680X0
4798 @include c-m68k.texi
4799 @end ifset
4800
4801 @ifset MIPS
4802 @include c-mips.texi
4803 @end ifset
4804
4805 @ifset NS32K
4806 @include c-ns32k.texi
4807 @end ifset
4808
4809 @ifset SH
4810 @include c-sh.texi
4811 @end ifset
4812
4813 @ifset SPARC
4814 @include c-sparc.texi
4815 @end ifset
4816
4817 @ifset Z8000
4818 @include c-z8k.texi
4819 @end ifset
4820
4821 @ifset VAX
4822 @include c-vax.texi
4823 @end ifset
4824
4825 @ifset GENERIC
4826 @c reverse effect of @down at top of generic Machine-Dep chapter
4827 @raisesections
4828 @end ifset
4829
4830 @node Reporting Bugs
4831 @chapter Reporting Bugs
4832 @cindex bugs in assembler
4833 @cindex reporting bugs in assembler
4834
4835 Your bug reports play an essential role in making @code{@value{AS}} reliable.
4836
4837 Reporting a bug may help you by bringing a solution to your problem, or it may
4838 not. But in any case the principal function of a bug report is to help the
4839 entire community by making the next version of @code{@value{AS}} work better.
4840 Bug reports are your contribution to the maintenance of @code{@value{AS}}.
4841
4842 In order for a bug report to serve its purpose, you must include the
4843 information that enables us to fix the bug.
4844
4845 @menu
4846 * Bug Criteria:: Have you found a bug?
4847 * Bug Reporting:: How to report bugs
4848 @end menu
4849
4850 @node Bug Criteria
4851 @section Have you found a bug?
4852 @cindex bug criteria
4853
4854 If you are not sure whether you have found a bug, here are some guidelines:
4855
4856 @itemize @bullet
4857 @cindex fatal signal
4858 @cindex assembler crash
4859 @cindex crash of assembler
4860 @item
4861 If the assembler gets a fatal signal, for any input whatever, that is a
4862 @code{@value{AS}} bug. Reliable assemblers never crash.
4863
4864 @cindex error on valid input
4865 @item
4866 If @code{@value{AS}} produces an error message for valid input, that is a bug.
4867
4868 @cindex invalid input
4869 @item
4870 If @code{@value{AS}} does not produce an error message for invalid input, that
4871 is a bug. However, you should note that your idea of ``invalid input'' might
4872 be our idea of ``an extension'' or ``support for traditional practice''.
4873
4874 @item
4875 If you are an experienced user of assemblers, your suggestions for improvement
4876 of @code{@value{AS}} are welcome in any case.
4877 @end itemize
4878
4879 @node Bug Reporting
4880 @section How to report bugs
4881 @cindex bug reports
4882 @cindex assembler bugs, reporting
4883
4884 A number of companies and individuals offer support for @sc{gnu} products. If
4885 you obtained @code{@value{AS}} from a support organization, we recommend you
4886 contact that organization first.
4887
4888 You can find contact information for many support companies and
4889 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
4890 distribution.
4891
4892 In any event, we also recommend that you send bug reports for @code{@value{AS}}
4893 to @samp{bug-gnu-utils@@prep.ai.mit.edu}.
4894
4895 The fundamental principle of reporting bugs usefully is this:
4896 @strong{report all the facts}. If you are not sure whether to state a
4897 fact or leave it out, state it!
4898
4899 Often people omit facts because they think they know what causes the problem
4900 and assume that some details do not matter. Thus, you might assume that the
4901 name of a symbol you use in an example does not matter. Well, probably it does
4902 not, but one cannot be sure. Perhaps the bug is a stray memory reference which
4903 happens to fetch from the location where that name is stored in memory;
4904 perhaps, if the name were different, the contents of that location would fool
4905 the assembler into doing the right thing despite the bug. Play it safe and
4906 give a specific, complete example. That is the easiest thing for you to do,
4907 and the most helpful.
4908
4909 Keep in mind that the purpose of a bug report is to enable us to fix the bug if
4910 it is new to us. Therefore, always write your bug reports on the assumption
4911 that the bug has not been reported previously.
4912
4913 Sometimes people give a few sketchy facts and ask, ``Does this ring a
4914 bell?'' Those bug reports are useless, and we urge everyone to
4915 @emph{refuse to respond to them} except to chide the sender to report
4916 bugs properly.
4917
4918 To enable us to fix the bug, you should include all these things:
4919
4920 @itemize @bullet
4921 @item
4922 The version of @code{@value{AS}}. @code{@value{AS}} announces it if you start
4923 it with the @samp{--version} argument.
4924
4925 Without this, we will not know whether there is any point in looking for
4926 the bug in the current version of @code{@value{AS}}.
4927
4928 @item
4929 Any patches you may have applied to the @code{@value{AS}} source.
4930
4931 @item
4932 The type of machine you are using, and the operating system name and
4933 version number.
4934
4935 @item
4936 What compiler (and its version) was used to compile @code{@value{AS}}---e.g.
4937 ``@code{gcc-2.7}''.
4938
4939 @item
4940 The command arguments you gave the assembler to assemble your example and
4941 observe the bug. To guarantee you will not omit something important, list them
4942 all. A copy of the Makefile (or the output from make) is sufficient.
4943
4944 If we were to try to guess the arguments, we would probably guess wrong
4945 and then we might not encounter the bug.
4946
4947 @item
4948 A complete input file that will reproduce the bug. If the bug is observed when
4949 the assembler is invoked via a compiler, send the assembler source, not the
4950 high level language source. Most compilers will produce the assembler source
4951 when run with the @samp{-S} option. If you are using @code{@value{GCC}}, use
4952 the options @samp{-v --save-temps}; this will save the assembler source in a
4953 file with an extension of @file{.s}, and also show you exactly how
4954 @code{@value{AS}} is being run.
4955
4956 @item
4957 A description of what behavior you observe that you believe is
4958 incorrect. For example, ``It gets a fatal signal.''
4959
4960 Of course, if the bug is that @code{@value{AS}} gets a fatal signal, then we
4961 will certainly notice it. But if the bug is incorrect output, we might not
4962 notice unless it is glaringly wrong. You might as well not give us a chance to
4963 make a mistake.
4964
4965 Even if the problem you experience is a fatal signal, you should still say so
4966 explicitly. Suppose something strange is going on, such as, your copy of
4967 @code{@value{AS}} is out of synch, or you have encountered a bug in the C
4968 library on your system. (This has happened!) Your copy might crash and ours
4969 would not. If you told us to expect a crash, then when ours fails to crash, we
4970 would know that the bug was not happening for us. If you had not told us to
4971 expect a crash, then we would not be able to draw any conclusion from our
4972 observations.
4973
4974 @item
4975 If you wish to suggest changes to the @code{@value{AS}} source, send us context
4976 diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p}
4977 option. Always send diffs from the old file to the new file. If you even
4978 discuss something in the @code{@value{AS}} source, refer to it by context, not
4979 by line number.
4980
4981 The line numbers in our development sources will not match those in your
4982 sources. Your line numbers would convey no useful information to us.
4983 @end itemize
4984
4985 Here are some things that are not necessary:
4986
4987 @itemize @bullet
4988 @item
4989 A description of the envelope of the bug.
4990
4991 Often people who encounter a bug spend a lot of time investigating
4992 which changes to the input file will make the bug go away and which
4993 changes will not affect it.
4994
4995 This is often time consuming and not very useful, because the way we
4996 will find the bug is by running a single example under the debugger
4997 with breakpoints, not by pure deduction from a series of examples.
4998 We recommend that you save your time for something else.
4999
5000 Of course, if you can find a simpler example to report @emph{instead}
5001 of the original one, that is a convenience for us. Errors in the
5002 output will be easier to spot, running under the debugger will take
5003 less time, and so on.
5004
5005 However, simplification is not vital; if you do not want to do this,
5006 report the bug anyway and send us the entire test case you used.
5007
5008 @item
5009 A patch for the bug.
5010
5011 A patch for the bug does help us if it is a good one. But do not omit
5012 the necessary information, such as the test case, on the assumption that
5013 a patch is all we need. We might see problems with your patch and decide
5014 to fix the problem another way, or we might not understand it at all.
5015
5016 Sometimes with a program as complicated as @code{@value{AS}} it is very hard to
5017 construct an example that will make the program follow a certain path through
5018 the code. If you do not send us the example, we will not be able to construct
5019 one, so we will not be able to verify that the bug is fixed.
5020
5021 And if we cannot understand what bug you are trying to fix, or why your
5022 patch should be an improvement, we will not install it. A test case will
5023 help us to understand.
5024
5025 @item
5026 A guess about what the bug is or what it depends on.
5027
5028 Such guesses are usually wrong. Even we cannot guess right about such
5029 things without first using the debugger to find the facts.
5030 @end itemize
5031
5032 @node Acknowledgements
5033 @chapter Acknowledgements
5034
5035 If you have contributed to @code{@value{AS}} and your name isn't listed here,
5036 it is not meant as a slight. We just don't know about it. Send mail to the
5037 maintainer, and we'll correct the situation. Currently
5038 @c (January 1994),
5039 the maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
5040
5041 Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any
5042 more details?}
5043
5044 Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug
5045 information and the 68k series machines, most of the preprocessing pass, and
5046 extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}.
5047
5048 K. Richard Pixley maintained GAS for a while, adding various enhancements and
5049 many bug fixes, including merging support for several processors, breaking GAS
5050 up to handle multiple object file format back ends (including heavy rewrite,
5051 testing, an integration of the coff and b.out back ends), adding configuration
5052 including heavy testing and verification of cross assemblers and file splits
5053 and renaming, converted GAS to strictly ANSI C including full prototypes, added
5054 support for m680[34]0 and cpu32, did considerable work on i960 including a COFF
5055 port (including considerable amounts of reverse engineering), a SPARC opcode
5056 file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know''
5057 assertions and made them work, much other reorganization, cleanup, and lint.
5058
5059 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
5060 in format-specific I/O modules.
5061
5062 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
5063 has done much work with it since.
5064
5065 The Intel 80386 machine description was written by Eliot Dresselhaus.
5066
5067 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
5068
5069 The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
5070 University and Torbjorn Granlund of the Swedish Institute of Computer Science.
5071
5072 Keith Knowles at the Open Software Foundation wrote the original MIPS back end
5073 (@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support
5074 (which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to
5075 support a.out format.
5076
5077 Support for the Zilog Z8k and Hitachi H8/300 and H8/500 processors (tc-z8k,
5078 tc-h8300, tc-h8500), and IEEE 695 object file format (obj-ieee), was written by
5079 Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
5080 use BFD for some low-level operations, for use with the H8/300 and AMD 29k
5081 targets.
5082
5083 John Gilmore built the AMD 29000 support, added @code{.include} support, and
5084 simplified the configuration of which versions accept which directives. He
5085 updated the 68k machine description so that Motorola's opcodes always produced
5086 fixed-size instructions (e.g. @code{jsr}), while synthetic instructions
5087 remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested
5088 cross-compilation support, and one bug in relaxation that took a week and
5089 required the proverbial one-bit fix.
5090
5091 Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the
5092 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
5093 added support for MIPS ECOFF and ELF targets, wrote the initial RS/6000 and
5094 PowerPC assembler, and made a few other minor patches.
5095
5096 Steve Chamberlain made @code{@value{AS}} able to generate listings.
5097
5098 Hewlett-Packard contributed support for the HP9000/300.
5099
5100 Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM)
5101 along with a fairly extensive HPPA testsuite (for both SOM and ELF object
5102 formats). This work was supported by both the Center for Software Science at
5103 the University of Utah and Cygnus Support.
5104
5105 Support for ELF format files has been worked on by Mark Eichin of Cygnus
5106 Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
5107 Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
5108 Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
5109 and some initial 64-bit support).
5110
5111 Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD
5112 support for openVMS/Alpha.
5113
5114 Several engineers at Cygnus Support have also provided many small bug fixes and
5115 configuration enhancements.
5116
5117 Many others have contributed large or small bugfixes and enhancements. If
5118 you have contributed significant work and are not mentioned on this list, and
5119 want to be, let us know. Some of the history has been lost; we are not
5120 intentionally leaving anyone out.
5121
5122 @node Index
5123 @unnumbered Index
5124
5125 @printindex cp
5126
5127 @contents
5128 @bye
5129 @c Local Variables:
5130 @c fill-column: 79
5131 @c End:
This page took 0.13921 seconds and 4 git commands to generate.