Hitachi h8/300 config of GAS manual (first draft), and a few config
[binutils-gdb.git] / gas / doc / as.texinfo
1 \input texinfo
2 @c $Id$
3 _if__(_GENERIC__)
4 @setfilename as.info
5 _fi__(_GENERIC__)
6 _if__(_A29K__ && !_GENERIC__)
7 @setfilename as-29k.info
8 _fi__(_A29K__ && !_GENERIC__)
9 _if__(_H8__ && !_GENERIC__)
10 @setfilename h8-300.info
11 _fi__(_H8__ && !_GENERIC__)
12 _if__(_I960__ && !_GENERIC__)
13 @setfilename as-960.info
14 _fi__(_I960__ && !_GENERIC__)
15 _if__(_M680X0__ && !_GENERIC__)
16 @setfilename as-m680x0.info
17 _fi__(_M680X0__ && !_GENERIC__)
18 _if__(0)
19
20 NOTE: this manual is marked up for preprocessing with a collection
21 of m4 macros called "pretex.m4".
22
23 THIS IS THE FULL SOURCE. The full source needs to be run through m4
24 before either tex- or info- formatting: for example,
25 m4 pretex.m4 none.m4 m680x0.m4 as.texinfo >as-680x0.texinfo
26 will produce (assuming your path finds either GNU or SysV m4; Berkeley
27 won't do) a file suitable for formatting. See the text in "pretex.m4"
28 for a fuller explanation (and the macro definitions).
29
30 _fi__(0)
31 @c
32 @synindex ky cp
33 @ifinfo
34 This file documents the GNU Assembler "_AS__".
35
36 Copyright (C) 1991 Free Software Foundation, Inc.
37
38 Permission is granted to make and distribute verbatim copies of
39 this manual provided the copyright notice and this permission notice
40 are preserved on all copies.
41
42 @ignore
43 Permission is granted to process this file through Tex and print the
44 results, provided the printed document carries copying permission
45 notice identical to this one except for the removal of this paragraph
46 (this paragraph not being relevant to the printed manual).
47
48 @end ignore
49 Permission is granted to copy and distribute modified versions of this
50 manual under the conditions for verbatim copying, provided also that the
51 section entitled ``GNU General Public License'' is included exactly as
52 in the original, and provided that the entire resulting derived work is
53 distributed under the terms of a permission notice identical to this
54 one.
55
56 Permission is granted to copy and distribute translations of this manual
57 into another language, under the above conditions for modified versions,
58 except that the section entitled ``GNU General Public License'' may be
59 included in a translation approved by the Free Software Foundation
60 instead of in the original English.
61 @end ifinfo
62 @iftex
63 @finalout
64 @c @smallbook
65 @end iftex
66 @setchapternewpage odd
67 _if__(_GENERIC__)
68 @settitle Using _AS__
69 _fi__(_GENERIC__)
70 _if__(!_GENERIC__)
71 @settitle Using _AS__ (_HOST__)
72 _fi__(!_GENERIC__)
73 @titlepage
74 @title Using _AS__
75 @subtitle The GNU Assembler
76 _if__(!_GENERIC__)
77 @subtitle for the _HOST__ family
78 _fi__(!_GENERIC__)
79 @sp 1
80 @subtitle March 1991
81 @sp 1
82 @sp 13
83 The Free Software Foundation Inc. thanks The Nice Computer
84 Company of Australia for loaning Dean Elsner to write the
85 first (Vax) version of @code{as} for Project GNU.
86 The proprietors, management and staff of TNCCA thank FSF for
87 distracting the boss while they got some work
88 done.
89 @sp 3
90 @author Dean Elsner, Jay Fenlason & friends
91 @c edited by: pesch@cygnus.com
92 @page
93 @tex
94 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
95 \xdef\manvers{\$Revision$} % For use in headers, footers too
96 {\parskip=0pt
97 \hfill \manvers\par
98 \hfill \TeX{}info \texinfoversion\par
99 }
100 %"boxit" macro for figures:
101 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
102 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
103 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
104 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
105 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
106 @end tex
107
108 Edited by Roland Pesch for Cygnus Support.
109
110 @vskip 0pt plus 1filll
111 Copyright @copyright{} 1991 Free Software Foundation, Inc.
112
113 Permission is granted to make and distribute verbatim copies of
114 this manual provided the copyright notice and this permission notice
115 are preserved on all copies.
116
117 Permission is granted to copy and distribute modified versions of this
118 manual under the conditions for verbatim copying, provided also that the
119 section entitled ``GNU General Public License'' is included exactly as
120 in the original, and provided that the entire resulting derived work is
121 distributed under the terms of a permission notice identical to this
122 one.
123
124 Permission is granted to copy and distribute translations of this manual
125 into another language, under the above conditions for modified versions,
126 except that the section entitled ``GNU General Public License'' may be
127 included in a translation approved by the Free Software Foundation
128 instead of in the original English.
129 @end titlepage
130 @page
131 @node Top, Overview, (dir), (dir)
132 @ifinfo
133 This file is a user guide to the GNU assembler @code{_AS__}.
134 _if__(!_GENERIC__)
135 This version of the file describes @code{_AS__} configured to generate
136 code for _HOST__ architectures.
137 _fi__(!_GENERIC__)
138 @end ifinfo
139 @menu
140 * Overview:: Overview
141 * Invoking:: Command-Line Options
142 * Syntax:: Syntax
143 * Sections:: Sections and Relocation
144 * Symbols:: Symbols
145 * Expressions:: Expressions
146 * Pseudo Ops:: Assembler Directives
147 * Machine Dependent:: Machine Dependent Features
148 * Copying:: GNU GENERAL PUBLIC LICENSE
149 @end menu
150
151 @node Overview, Invoking, Top, Top
152 @chapter Overview
153 @iftex
154 This manual is a user guide to the GNU assembler @code{_AS__}.
155 _if__(!_GENERIC__)
156 This version of the manual describes @code{_AS__} configured to generate
157 code for _HOST__ architectures.
158 _fi__(!_GENERIC__)
159 @end iftex
160
161 @heading Invoking @code{_AS__}
162
163 Here is a brief summary of how to invoke @code{_AS__}. For details,
164 @pxref{Invoking,,Comand-Line Options}.
165
166 @c We don't use deffn and friends for the following because they seem
167 @c to be limited to one line for the header.
168 @smallexample
169 _AS__ [ -D ] [ -f ] [ -I @var{path} ] [ -k ] [ -L ]
170 [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ]
171 _if__(_A29K__)
172 @c am29k has no machine-dependent assembler options
173 _fi__(_A29K__)
174 _if__(_H8__)
175 @c h8/300 has no machine-dependent assembler options
176 _fi__(_H8__)
177 _if__(_I960__)
178 @c see md_parse_option in i960.c
179 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
180 [ -b ] [ -norelax ]
181 _fi__(_I960__)
182 _if__(_M680X0__)
183 [ -l ] [ -mc68000 | -mc68010 | -mc68020 ]
184 _fi__(_M680X0__)
185 [ -- | @var{files} @dots{} ]
186 @end smallexample
187
188 @table @code
189
190 @item -D
191 This option is accepted only for script compatibility with calls to
192 other assemblers; it has no effect on @code{_AS__}.
193
194 @item -f
195 ``fast''---skip preprocessing (assume source is compiler output)
196
197 @item -I @var{path}
198 Add @var{path} to the search list for @code{.include} directives
199
200 @item -k
201 _if__((!_GENERIC__) && _DIFFTABKLUG__)
202 This option is accepted but has no effect on the _HOST__ family.
203 _fi__((!_GENERIC__) && _DIFFTABKLUG__)
204 _if__(_GENERIC__)
205 Issue warnings when difference tables altered for long displacements.
206 _fi__(_GENERIC__)
207
208 @item -L
209 Keep (in symbol table) local symbols, starting with @samp{L}
210
211 @item -o @var{objfile}
212 Name the object-file output from @code{_AS__}
213
214 @item -R
215 Fold data section into text section
216
217 @item -v
218 Announce @code{as} version
219
220 @item -W
221 Suppress warning messages
222
223 _if__(_I960__)
224 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
225 Specify which variant of the 960 architecture is the target.
226
227 @item -b
228 Add code to collect statistics about branches taken.
229
230 @item -norelax
231 Do not alter compare-and-branch instructions for long displaements;
232 error if necessary.
233 _fi__(_I960__)
234
235 _if__(_M680X0__)
236 @item -l
237 _if__(_GENERIC__)
238 (When configured for Motorola 68000).
239 _fi__(_GENERIC__)
240 Shorten references to undefined symbols, to one word instead of two
241
242 @item -mc68000 | -mc68010 | -mc68020
243 _if__(_GENERIC__)
244 (When configured for Motorola 68000).
245 _fi__(_GENERIC__)
246 Specify what processor in the 68000 family is the target (default 68020)
247 _fi__(_M680X0__)
248
249 @item -- | @var{files} @dots{}
250 Source files to assemble, or standard input
251 @end table
252
253 @menu
254 * Manual:: Structure of this Manual
255 * GNU Assembler:: _AS__, the GNU Assembler
256 * Object Formats:: Object File Formats
257 * Command Line:: Command Line
258 * Input Files:: Input Files
259 * Object:: Output (Object) File
260 * Errors:: Error and Warning Messages
261 @end menu
262
263 @node Manual, GNU Assembler, Overview, Overview
264 @section Structure of this Manual
265 This document is intended to describe what you need to know to use
266 @code{_AS__}. We cover the syntax expected in source files, including
267 notation for symbols, constants, and expressions; the directives that
268 @code{_AS__} understands; and of course how to invoke @code{_AS__}.
269
270 _if__(!_GENERIC__)
271 We also cover special features in the _HOST__
272 configuration of @code{_AS__}, including assembler directives.
273 _fi__(!_GENERIC__)
274 _if__(_GENERIC__)
275 This document also describes some of the machine-dependent features of
276 various flavors of the assembler.
277 _fi__(_GENERIC__)
278 _if__(_INTERNALS__)
279 This document also describes how the assembler works internally, and
280 provides some information that may be useful to people attempting to
281 port the assembler to another machine.
282 _fi__(_INTERNALS__)
283 @refill
284
285 On the other hand, this manual is @emph{not} intended as an introduction
286 to programming in assembly language---let alone programming in general!
287 In a similar vein, we make no attempt to introduce the machine
288 architecture; we do @emph{not} describe the instruction set, standard
289 mnemonics, registers or addressing modes that are standard to a
290 particular architecture. You may want to consult the manufacturer's
291 machine architecture manual for this information.
292
293
294 @c I think this is premature---pesch@cygnus.com, 17jan1991
295 @ignore
296 Throughout this document, we assume that you are running @dfn{GNU},
297 the portable operating system from the @dfn{Free Software
298 Foundation, Inc.}. This restricts our attention to certain kinds of
299 computer (in particular, the kinds of computers that GNU can run on);
300 once this assumption is granted examples and definitions need less
301 qualification.
302
303 @code{_AS__} is part of a team of programs that turn a high-level
304 human-readable series of instructions into a low-level
305 computer-readable series of instructions. Different versions of
306 @code{_AS__} are used for different kinds of computer.
307 @end ignore
308
309 @c There used to be a section "Terminology" here, which defined
310 @c "contents", "byte", "word", and "long". Defining "word" to any
311 @c particular size is confusing when the .word directive may generate 16
312 @c bits on one machine and 32 bits on another; in general, for the user
313 @c version of this manual, none of these terms seem essential to define.
314 @c They were used very little even in the former draft of the manual;
315 @c this draft makes an effort to avoid them (except in names of
316 @c directives).
317
318 @node GNU Assembler, Object Formats, Manual, Overview
319 @section _AS__, the GNU Assembler
320 GNU @code{as} is really a family of assemblers.
321 _if__(!_GENERIC__)
322 This manual describes @samp{_AS__}, a member of that family which is
323 configured for the _HOST__ architectures.
324 _fi__(!_GENERIC__)
325 If you use (or have used) the GNU assembler on one architecture, you
326 should find a fairly similar environment when you use it on another
327 architecture. Each version has much in common with the others,
328 including object file formats, most assembler directives (often called
329 @dfn{pseudo-ops)} and assembler syntax.@refill
330
331 @code{_AS__} is primarily intended to assemble the output of the GNU C
332 compiler @code{_GCC__} for use by the linker @code{_LD__}. Nevertheless,
333 we've tried to make @code{_AS__} assemble correctly everything that the native
334 assembler would.
335 _if__(_VAX__)
336 Any exceptions are documented explicitly (@pxref{_MACH_DEP__}).
337 _fi__(_VAX__)
338 _if__(_GENERIC__||_M680X0__)
339 This doesn't mean @code{_AS__} always uses the same syntax as another
340 assembler for the same architecture; for example, we know of several
341 incompatible versions of 680x0 assembly language syntax.
342 _fi__(_GENERIC__||_M680X0__)
343
344 Unlike older assemblers, @code{_AS__} is designed to assemble a source
345 program in one pass of the source file. This has a subtle impact on the
346 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
347
348 @node Object Formats, Command Line, GNU Assembler, Overview
349 @section Object File Formats
350 The GNU assembler can be configured to produce several alternative
351 object file formats. For the most part, this does not affect how you
352 write assembly language programs; but directives for debugging symbols
353 are typically different in different file formats. @xref{Symbol
354 Attributes,,Symbol Attributes}.
355 _if__(!_GENERIC__)
356 _if__(!(_I960__||_A29K__))
357 _if__(_AOUT__ && (!_COFF__) && (!_ELF__))
358 On the _HOST__, @code{_AS__} is configured to produce @code{a.out} format object
359 files.@refill
360 _fi__(_AOUT__ && (!_COFF__) && (!_ELF__))
361 _if__((!_AOUT__) && _COFF__ && (!_ELF__))
362 On the _HOST__, @code{_AS__} is configured to produce COFF format object
363 files.@refill
364 _fi__((!_AOUT__) && _COFF__ && (!_ELF__))
365 _fi__(!(_I960__||_A29K__))
366 _if__(_A29K__)
367 On the _HOST__, @code{_AS__} can be configured to produce either
368 @code{a.out} or COFF format object files.
369 _fi__(_A29K__)
370 _if__(_I960__)
371 On the _HOST__, @code{_AS__} can be configured to produce either @code{b.out} or COFF
372 format object files.
373 _fi__(_I960__)
374 _fi__(!_GENERIC__)
375
376 @node Command Line, Input Files, Object Formats, Overview
377 @section Command Line
378
379 After the program name @code{_AS__}, the command line may contain
380 options and file names. Options may be in any order, and may be
381 before, after, or between file names. The order of file names is
382 significant.
383
384 @file{--} (two hyphens) by itself names the standard input file
385 explicitly, as one of the files for @code{_AS__} to assemble.
386
387 Except for @samp{--} any command line argument that begins with a
388 hyphen (@samp{-}) is an option. Each option changes the behavior of
389 @code{_AS__}. No option changes the way another option works. An
390 option is a @samp{-} followed by one or more letters; the case of
391 the letter is important. All options are optional.
392
393 Some options expect exactly one file name to follow them. The file
394 name may either immediately follow the option's letter (compatible
395 with older assemblers) or it may be the next command argument (GNU
396 standard). These two command lines are equivalent:
397
398 @smallexample
399 _AS__ -o my-object-file.o mumble.s
400 _AS__ -omy-object-file.o mumble.s
401 @end smallexample
402
403 @node Input Files, Object, Command Line, Overview
404 @section Input Files
405
406 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
407 describe the program input to one run of @code{_AS__}. The program may
408 be in one or more files; how the source is partitioned into files
409 doesn't change the meaning of the source.
410
411 @c I added "con" prefix to "catenation" just to prove I can overcome my
412 @c APL training... pesch@cygnus.com
413 The source program is a concatenation of the text in all the files, in the
414 order specified.
415
416 Each time you run @code{_AS__} it assembles exactly one source
417 program. The source program is made up of one or more files.
418 (The standard input is also a file.)
419
420 You give @code{_AS__} a command line that has zero or more input file
421 names. The input files are read (from left file name to right). A
422 command line argument (in any position) that has no special meaning
423 is taken to be an input file name.
424
425 If @code{_AS__} is given no file names it attempts to read one input file
426 from the @code{_AS__} standard input, which is normally your terminal. You
427 may have to type @key{ctl-D} to tell @code{_AS__} there is no more program
428 to assemble.
429
430 Use @samp{--} if you need to explicitly name the standard input file
431 in your command line.
432
433 If the source is empty, @code{_AS__} will produce a small, empty object
434 file.
435
436 @subheading Filenames and Line-numbers
437 There are two ways of locating a line in the input file (or files) and both
438 are used in reporting error messages. One way refers to a line
439 number in a physical file; the other refers to a line number in a
440 ``logical'' file.
441
442 @dfn{Physical files} are those files named in the command line given
443 to @code{_AS__}.
444
445 @dfn{Logical files} are simply names declared explicitly by assembler
446 directives; they bear no relation to physical files. Logical file names
447 help error messages reflect the original source file, when @code{_AS__}
448 source is itself synthesized from other files.
449 @xref{App-File,,@code{.app-file}}.
450
451 @node Object, Errors, Input Files, Overview
452 @section Output (Object) File
453 Every time you run @code{_AS__} it produces an output file, which is
454 your assembly language program translated into numbers. This file
455 is the object file, named @code{a.out} unless you tell @code{_AS__} to
456 give it another name by using the @code{-o} option. Conventionally,
457 object file names end with @file{.o}. The default name of
458 @file{a.out} is used for historical reasons: older assemblers were
459 capable of assembling self-contained programs directly into a
460 runnable program.
461 @c This may still work, but hasn't been tested.
462
463 The object file is meant for input to the linker @code{_LD__}. It contains
464 assembled program code, information to help @code{_LD__} integrate
465 the assembled program into a runnable file, and (optionally) symbolic
466 information for the debugger.
467
468 @comment link above to some info file(s) like the description of a.out.
469 @comment don't forget to describe GNU info as well as Unix lossage.
470
471 @node Errors, , Object, Overview
472 @section Error and Warning Messages
473
474 @code{_AS__} may write warnings and error messages to the standard error
475 file (usually your terminal). This should not happen when @code{_AS__} is
476 run automatically by a compiler. Warnings report an assumption made so
477 that @code{_AS__} could keep assembling a flawed program; errors report a
478 grave problem that stops the assembly.
479
480 Warning messages have the format
481 @smallexample
482 file_name:@b{NNN}:Warning Message Text
483 @end smallexample
484 @noindent
485 (where @b{NNN} is a line number). If a logical file name has
486 been given (@pxref{App-File,,@code{.app-file}}) it is used for the filename, otherwise the
487 name of the current input file is used. If a logical line number was
488 given
489 _if__(!_A29K__)
490 (@pxref{Line,,@code{.line}})
491 _fi__(!_A29K__)
492 _if__(_A29K__)
493 (@pxref{Ln,,@code{.ln}})
494 _fi__(_A29K__)
495 then it is used to calculate the number printed,
496 otherwise the actual line in the current source file is printed. The
497 message text is intended to be self explanatory (in the grand Unix
498 tradition). @refill
499
500 Error messages have the format
501 @smallexample
502 file_name:@b{NNN}:FATAL:Error Message Text
503 @end smallexample
504 The file name and line number are derived as for warning
505 messages. The actual message text may be rather less explanatory
506 because many of them aren't supposed to happen.
507
508 @node Invoking, Syntax, Overview, Top
509 @chapter Command-Line Options
510 This section describes command-line options available in @emph{all}
511 versions of the GNU assembler; @pxref{_MACH_DEP__}, for options specific
512 _if__(!_GENERIC__)
513 to the _HOST__.
514 _fi__(!_GENERIC__)
515 _if__(_GENERIC__)
516 to particular machine architectures.
517 _fi__(_GENERIC__)
518
519 @subsection @code{-D}
520 This option has no effect whatsoever, but it is accepted to make it more
521 likely that scripts written for other assemblers will also work with
522 @code{_AS__}.
523
524 @subsection Work Faster: @code{-f}
525 @samp{-f} should only be used when assembling programs written by a
526 (trusted) compiler. @samp{-f} stops the assembler from pre-processing
527 the input file(s) before assembling them.
528 @quotation
529 @emph{Warning:} if the files actually need to be pre-processed (if they
530 contain comments, for example), @code{_AS__} will not work correctly if
531 @samp{-f} is used.
532 @end quotation
533
534 @subsection @code{.include} search path: @code{-I} @var{path}
535 Use this option to add a @var{path} to the list of directories
536 @code{_AS__} will search for files specified in @code{.include}
537 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
538 many times as necessary to include a variety of paths. The current
539 working directory is always searched first; after that, @code{_AS__}
540 searches any @samp{-I} directories in the same order as they were
541 specified (left to right) on the command line.
542
543 @subsection Difference Tables: @code{-k}
544 _if__((!_GENERIC__) && (!_DIFFTABKLUG__))
545 On the _HOST__ family, this option is allowed, but has no effect. It is
546 permitted for compatibility with the GNU assembler on other platforms,
547 where it can be used to warn when the assembler alters the machine code
548 generated for @samp{.word} directives in difference tables. The _HOST__
549 family does not have the addressing limitations that sometimes lead to this
550 alteration on other platforms.
551 _fi__((!_GENERIC__) && (!_DIFFTABKLUG__))
552
553 _if__(_GENERIC__ || _DIFFTABKLUG__ )
554 @code{_AS__} sometimes alters the code emitted for directives of the form
555 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
556 You can use the @samp{-k} option if you want a warning issued when this
557 is done.
558 _fi__(_GENERIC__ || _DIFFTABKLUG__ )
559
560 @subsection Include Local Labels: @code{-L}
561 Labels beginning with @samp{L} (upper case only) are called @dfn{local
562 labels}. @xref{Symbol Names}. Normally you don't see such labels when
563 debugging, because they are intended for the use of programs (like
564 compilers) that compose assembler programs, not for your notice.
565 Normally both @code{_AS__} and @code{_LD__} discard such labels, so you don't
566 normally debug with them.
567
568 This option tells @code{_AS__} to retain those @samp{L@dots{}} symbols
569 in the object file. Usually if you do this you also tell the linker
570 @code{_LD__} to preserve symbols whose names begin with @samp{L}.
571
572 @subsection Name the Object File: @code{-o}
573 There is always one object file output when you run @code{_AS__}. By
574 default it has the name @file{a.out}. You use this option (which
575 takes exactly one filename) to give the object file a different name.
576
577 Whatever the object file is called, @code{_AS__} will overwrite any
578 existing file of the same name.
579
580 @subsection Join Data and Text Sections: @code{-R}
581 _if__(_COFF__)
582 This option is only useful if you use sections named @samp{.text} and
583 @samp{.data}.
584 _fi__(_COFF__)
585 @code{-R} tells @code{_AS__} to write the object file as if all
586 data-section data lives in the text section. This is only done at
587 the very last moment: your binary data are the same, but data
588 section parts are relocated differently. The data section part of
589 your object file is zero bytes long because all it bytes are
590 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
591
592 When you specify @code{-R} it would be possible to generate shorter
593 address displacements (because we don't have to cross between text and
594 data section). We refrain from doing this simply for compatibility with
595 older versions of @code{_AS__}. In future, @code{-R} may work this way.
596
597 @subsection Announce Version: @code{-v}
598 You can find out what version of as is running by including the
599 option @samp{-v} (which you can also spell as @samp{-version}) on the
600 command line.
601
602 @subsection Suppress Warnings: @code{-W}
603 @code{_AS__} should never give a warning or error message when
604 assembling compiler output. But programs written by people often
605 cause @code{_AS__} to give a warning that a particular assumption was
606 made. All such warnings are directed to the standard error file.
607 If you use this option, no warnings are issued. This option only
608 affects the warning messages: it does not change any particular of how
609 @code{_AS__} assembles your file. Errors, which stop the assembly, are
610 still reported.
611
612 @node Syntax, Sections, Invoking, Top
613 @chapter Syntax
614 This chapter describes the machine-independent syntax allowed in a
615 source file. @code{_AS__} syntax is similar to what many other assemblers
616 use; it is inspired in BSD 4.2
617 _if__(!_VAX__)
618 assembler. @refill
619 _fi__(!_VAX__)
620 _if__(_VAX__)
621 assembler, except that @code{_AS__} does not assemble Vax bit-fields.
622 _fi__(_VAX__)
623
624 @menu
625 * Pre-processing:: Pre-processing
626 * Whitespace:: Whitespace
627 * Comments:: Comments
628 * Symbol Intro:: Symbols
629 * Statements:: Statements
630 * Constants:: Constants
631 @end menu
632
633 @node Pre-processing, Whitespace, Syntax, Syntax
634 @section Pre-processing
635
636 The pre-processor:
637 @itemize @bullet
638 @item
639 adjusts and removes extra whitespace. It leaves one space or tab before
640 the keywords on a line, and turns any other whitespace on the line into
641 a single space.
642
643 @item
644 removes all comments, replacing them with a single space, or an
645 appropriate number of newlines.
646
647 @item
648 converts character constants into the appropriate numeric values.
649 @end itemize
650
651 Excess whitespace, comments, and character constants
652 cannot be used in the portions of the input text that are not
653 pre-processed.
654
655 If the first line of an input file is @code{#NO_APP} or the @samp{-f}
656 option is given, the input file will not be pre-processed. Within such
657 an input file, parts of the file can be pre-processed by putting a line
658 that says @code{#APP} before the text that should be pre-processed, and
659 putting a line that says @code{#NO_APP} after them. This feature is
660 mainly intend to support @code{asm} statements in compilers whose output
661 normally does not need to be pre-processed.
662
663 @node Whitespace, Comments, Pre-processing, Syntax
664 @section Whitespace
665 @dfn{Whitespace} is one or more blanks or tabs, in any order.
666 Whitespace is used to separate symbols, and to make programs neater for
667 people to read. Unless within character constants
668 (@pxref{Characters,,Character Constants}), any whitespace means the same
669 as exactly one space.
670
671 @node Comments, Symbol Intro, Whitespace, Syntax
672 @section Comments
673 There are two ways of rendering comments to @code{_AS__}. In both
674 cases the comment is equivalent to one space.
675
676 Anything from @samp{/*} through the next @samp{*/} is a comment.
677 This means you may not nest these comments.
678
679 @smallexample
680 /*
681 The only way to include a newline ('\n') in a comment
682 is to use this sort of comment.
683 */
684
685 /* This sort of comment does not nest. */
686 @end smallexample
687
688 Anything from the @dfn{line comment} character to the next newline
689 is considered a comment and is ignored. The line comment character is
690 _if__(_VAX__)
691 @samp{#} on the Vax;
692 _fi__(_VAX__)
693 _if__(_I960__)
694 @samp{#} on the i960;
695 _fi__(_I960__)
696 _if__(_M680X0__)
697 @samp{|} on the 680x0;
698 _fi__(_M680X0__)
699 _if__(_A29K__)
700 @samp{;} for the AMD 29K family;
701 _fi__(_A29K__)
702 _if__(_H8__)
703 @samp{;} for the _HOST__ family;
704 _fi__(_H8__)
705 @pxref{_MACH_DEP__}. @refill
706 @c FIXME: fill in SPARC line comment char
707
708 _if__(_GENERIC__)
709 On some machines there are two different line comment characters. One
710 will only begin a comment if it is the first non-whitespace character on
711 a line, while the other will always begin a comment.
712 _fi__(_GENERIC__)
713
714 To be compatible with past assemblers a special interpretation is
715 given to lines that begin with @samp{#}. Following the @samp{#} an
716 absolute expression (@pxref{Expressions}) is expected: this will be
717 the logical line number of the @b{next} line. Then a string
718 (@xref{Strings}.) is allowed: if present it is a new logical file
719 name. The rest of the line, if any, should be whitespace.
720
721 If the first non-whitespace characters on the line are not numeric,
722 the line is ignored. (Just like a comment.)
723 @smallexample
724 # This is an ordinary comment.
725 # 42-6 "new_file_name" # New logical file name
726 # This is logical line # 36.
727 @end smallexample
728 This feature is deprecated, and may disappear from future versions
729 of @code{_AS__}.
730
731 @node Symbol Intro, Statements, Comments, Syntax
732 @section Symbols
733 A @dfn{symbol} is one or more characters chosen from the set of all
734 letters (both upper and lower case), digits and
735 _if__(!_H8__)
736 the three characters @samp{_.$}
737 _fi__(!_H8__)
738 _if__(_H8__)
739 the two characters @samp{_.}
740 _if__(_GENERIC__)
741 On most machines, you can also use @code{$} in symbol names; exceptions
742 are noted in @ref{_MACH_DEP__}.
743 _fi__(_GENERIC__)
744 _fi__(_H8__)
745 No symbol may begin with a digit. Case is significant.
746 There is no length limit: all characters are significant. Symbols are
747 delimited by characters not in that set, or by the beginning of a file
748 (since the source program must end with a newline, the end of a file is
749 not a possible symbol delimiter). @xref{Symbols}.
750
751 @node Statements, Constants, Symbol Intro, Syntax
752 @section Statements
753 _if__(!_GENERIC__)
754 _if__(!(_A29K__||_H8__))
755 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
756 semicolon (@samp{;}). The newline or semicolon is considered part of
757 the preceding statement. Newlines and semicolons within character
758 constants are an exception: they don't end statements.
759 _fi__(!(_A29K__||_H8__))
760 _if__(_A29K__)
761 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
762 sign (@samp{@@}). The newline or at sign is considered part of the
763 preceding statement. Newlines and at signs within character constants
764 are an exception: they don't end statements.
765 _fi__(_A29K__)
766 _if__(_H8__)
767 A @dfn{statement} ends at a newline character (@samp{\n}) or a dollar
768 sign (@samp{$}). The newline or dollar sign is considered part of the
769 preceding statement. Newlines and dollar signs within character constants
770 are an exception: they don't end statements.
771 _fi__(_H8__)
772 _fi__(!_GENERIC__)
773 _if__(_GENERIC__)
774 A @dfn{statement} ends at a newline character (@samp{\n}) or line
775 separator character. (The line separator is usually @samp{;}, unless
776 this conflicts with the comment character; @pxref{_MACH_DEP__}.) The
777 newline or separator character is considered part of the preceding
778 statement. Newlines and separators within character constants are an
779 exception: they don't end statements.
780 _fi__(_GENERIC__)
781
782 It is an error to end any statement with end-of-file: the last
783 character of any input file should be a newline.@refill
784
785 You may write a statement on more than one line if you put a
786 backslash (@kbd{\}) immediately in front of any newlines within the
787 statement. When @code{_AS__} reads a backslashed newline both
788 characters are ignored. You can even put backslashed newlines in
789 the middle of symbol names without changing the meaning of your
790 source program.
791
792 An empty statement is allowed, and may include whitespace. It is ignored.
793
794 @c "key symbol" is not used elsewhere in the document; seems pedantic to
795 @c @defn{} it in that case, as was done previously... pesch@cygnus.com,
796 @c 13feb91.
797 A statement begins with zero or more labels, optionally followed by a
798 key symbol which determines what kind of statement it is. The key
799 symbol determines the syntax of the rest of the statement. If the
800 symbol begins with a dot @samp{.} then the statement is an assembler
801 directive: typically valid for any computer. If the symbol begins with
802 a letter the statement is an assembly language @dfn{instruction}: it
803 will assemble into a machine language instruction.
804 _if__(_GENERIC__)
805 Different versions of @code{_AS__} for different computers will
806 recognize different instructions. In fact, the same symbol may
807 represent a different instruction in a different computer's assembly
808 language.@refill
809 _fi__(_GENERIC__)
810
811 A label is a symbol immediately followed by a colon (@code{:}).
812 Whitespace before a label or after a colon is permitted, but you may not
813 have whitespace between a label's symbol and its colon. @xref{Labels}.
814
815 @smallexample
816 label: .directive followed by something
817 another_label: # This is an empty statement.
818 instruction operand_1, operand_2, @dots{}
819 @end smallexample
820
821 @node Constants, , Statements, Syntax
822 @section Constants
823 A constant is a number, written so that its value is known by
824 inspection, without knowing any context. Like this:
825 @smallexample
826 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
827 .ascii "Ring the bell\7" # A string constant.
828 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
829 .float 0f-314159265358979323846264338327\
830 95028841971.693993751E-40 # - pi, a flonum.
831 @end smallexample
832
833 @menu
834 * Characters:: Character Constants
835 * Numbers:: Number Constants
836 @end menu
837
838 @node Characters, Numbers, Constants, Constants
839 @subsection Character Constants
840 There are two kinds of character constants. A @dfn{character} stands
841 for one character in one byte and its value may be used in
842 numeric expressions. String constants (properly called string
843 @emph{literals}) are potentially many bytes and their values may not be
844 used in arithmetic expressions.
845
846 @menu
847 * Strings:: Strings
848 * Chars:: Characters
849 @end menu
850
851 @node Strings, Chars, Characters, Characters
852 @subsubsection Strings
853 A @dfn{string} is written between double-quotes. It may contain
854 double-quotes or null characters. The way to get special characters
855 into a string is to @dfn{escape} these characters: precede them with
856 a backslash @samp{\} character. For example @samp{\\} represents
857 one backslash: the first @code{\} is an escape which tells
858 @code{_AS__} to interpret the second character literally as a backslash
859 (which prevents @code{_AS__} from recognizing the second @code{\} as an
860 escape character). The complete list of escapes follows.
861
862 @table @kbd
863 @c @item \a
864 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
865 @item \b
866 Mnemonic for backspace; for ASCII this is octal code 010.
867 @c @item \e
868 @c Mnemonic for EOText; for ASCII this is octal code 004.
869 @item \f
870 Mnemonic for FormFeed; for ASCII this is octal code 014.
871 @item \n
872 Mnemonic for newline; for ASCII this is octal code 012.
873 @c @item \p
874 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
875 @item \r
876 Mnemonic for carriage-Return; for ASCII this is octal code 015.
877 @c @item \s
878 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
879 @c other assemblers.
880 @item \t
881 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
882 @c @item \v
883 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
884 @c @item \x @var{digit} @var{digit} @var{digit}
885 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
886 @item \ @var{digit} @var{digit} @var{digit}
887 An octal character code. The numeric code is 3 octal digits.
888 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
889 for example, @code{\008} has the value 010, and @code{\009} the value 011.
890 @item \\
891 Represents one @samp{\} character.
892 @c @item \'
893 @c Represents one @samp{'} (accent acute) character.
894 @c This is needed in single character literals
895 @c (@xref{Characters,,Character Constants}.) to represent
896 @c a @samp{'}.
897 @item \"
898 Represents one @samp{"} character. Needed in strings to represent
899 this character, because an unescaped @samp{"} would end the string.
900 @item \ @var{anything-else}
901 Any other character when escaped by @kbd{\} will give a warning, but
902 assemble as if the @samp{\} was not present. The idea is that if
903 you used an escape sequence you clearly didn't want the literal
904 interpretation of the following character. However @code{_AS__} has no
905 other interpretation, so @code{_AS__} knows it is giving you the wrong
906 code and warns you of the fact.
907 @end table
908
909 Which characters are escapable, and what those escapes represent,
910 varies widely among assemblers. The current set is what we think
911 the BSD 4.2 assembler recognizes, and is a subset of what most C
912 compilers recognize. If you are in doubt, don't use an escape
913 sequence.
914
915 @node Chars, , Strings, Characters
916 @subsubsection Characters
917 A single character may be written as a single quote immediately
918 followed by that character. The same escapes apply to characters as
919 to strings. So if you want to write the character backslash, you
920 must write @kbd{'\\} where the first @code{\} escapes the second
921 @code{\}. As you can see, the quote is an acute accent, not a
922 grave accent. A newline
923 _if__(!_GENERIC__)
924 _if__(!(_A29K__||_H8__))
925 (or semicolon @samp{;})
926 _fi__(!(_A29K__||_H8__))
927 _if__(_A29K__)
928 (or at sign @samp{@@})
929 _fi__(_A29K__)
930 _if__(_H8__)
931 (or dollar sign @samp{$})
932 _fi__(_H8__)
933 _fi__(!_GENERIC__)
934 immediately following an acute accent is taken as a literal character
935 and does not count as the end of a statement. The value of a character
936 constant in a numeric expression is the machine's byte-wide code for
937 that character. @code{_AS__} assumes your character code is ASCII:
938 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
939
940 @node Numbers, , Characters, Constants
941 @subsection Number Constants
942 @code{_AS__} distinguishes three kinds of numbers according to how they
943 are stored in the target machine. @emph{Integers} are numbers that
944 would fit into an @code{int} in the C language. @emph{Bignums} are
945 integers, but they are stored in more than 32 bits. @emph{Flonums}
946 are floating point numbers, described below.
947
948 @menu
949 * Integers:: Integers
950 * Bignums:: Bignums
951 * Flonums:: Flonums
952 _if__(_I960__&&!_GENERIC__)
953 * Bit Fields:: Bit Fields
954 _fi__(_I960__&&!_GENERIC__)
955 @end menu
956
957 @node Integers, Bignums, Numbers, Numbers
958 @subsubsection Integers
959 @c FIXME: are binary integers in vintage as?
960 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
961 the binary digits @samp{01}.
962
963 An octal integer is @samp{0} followed by zero or more of the octal
964 digits (@samp{01234567}).
965
966 A decimal integer starts with a non-zero digit followed by zero or
967 more digits (@samp{0123456789}).
968
969 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
970 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
971
972 Integers have the usual values. To denote a negative integer, use
973 the prefix operator @samp{-} discussed under expressions
974 (@pxref{Prefix Ops,,Prefix Operators}).
975
976 @node Bignums, Flonums, Integers, Numbers
977 @subsubsection Bignums
978 A @dfn{bignum} has the same syntax and semantics as an integer
979 except that the number (or its negative) takes more than 32 bits to
980 represent in binary. The distinction is made because in some places
981 integers are permitted while bignums are not.
982
983 _if__(_I960__&&!_GENERIC__)
984 @node Flonums, Bit Fields, Bignums, Numbers
985 _fi__(_I960__&&!_GENERIC__)
986 _if__(_GENERIC__||!_I960__)
987 @node Flonums, , Bignums, Numbers
988 _fi__(_GENERIC__||!_I960__)
989 @subsubsection Flonums
990 A @dfn{flonum} represents a floating point number. The translation is
991 complex: a decimal floating point number from the text is converted by
992 @code{_AS__} to a generic binary floating point number of more than
993 sufficient precision. This generic floating point number is converted
994 to a particular computer's floating point format (or formats) by a
995 portion of @code{_AS__} specialized to that computer.
996
997 A flonum is written by writing (in order)
998 @itemize @bullet
999 @item
1000 The digit @samp{0}.
1001 @item
1002 _if__(_GENERIC__)
1003 A letter, to tell @code{_AS__} the rest of the number is a flonum. @kbd{e}
1004 is recommended. Case is not important.
1005 @ignore
1006 @c FIXME: verify if flonum syntax really this vague for most cases
1007 (Any otherwise illegal letter
1008 will work here, but that might be changed. Vax BSD 4.2 assembler seems
1009 to allow any of @samp{defghDEFGH}.)
1010 @end ignore
1011 _fi__(_GENERIC__)
1012 _if__(_A29K__||_H8__)
1013 _if__(_GENERIC__)
1014 On the AMD 29K and H8/300 architectures, the letter must be:
1015 _fi__(_GENERIC__)
1016 One of the letters @samp{DFPRSX} (in upper or lower case), to tell
1017 @code{_AS__} the rest of the number is a flonum.
1018 _fi__(_A29K__||_H8__)
1019 _if__(_I960__)
1020 _if__(_GENERIC__)
1021 On the Intel 960 architecture, the letter must be:
1022 _fi__(_GENERIC__)
1023 One of the letters @samp{DFT} (in upper or lower case), to tell
1024 @code{_AS__} the rest of the number is a flonum.
1025 _fi__(_I960__)
1026 @item
1027 An optional sign: either @samp{+} or @samp{-}.
1028 @item
1029 An optional @dfn{integer part}: zero or more decimal digits.
1030 @item
1031 An optional @dfn{fraction part}: @samp{.} followed by zero
1032 or more decimal digits.
1033 @item
1034 An optional exponent, consisting of:
1035 @itemize @bullet
1036 @item
1037 An @samp{E} or @samp{e}.
1038 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1039 @c principle this can perfectly well be different on different targets.
1040 @item
1041 Optional sign: either @samp{+} or @samp{-}.
1042 @item
1043 One or more decimal digits.
1044 @end itemize
1045 @end itemize
1046
1047 At least one of @var{integer part} or @var{fraction part} must be
1048 present. The floating point number has the usual base-10 value.
1049
1050 @code{_AS__} does all processing using integers. Flonums are computed
1051 independently of any floating point hardware in the computer running
1052 @code{_AS__}.
1053
1054 _if__(_I960__&&!_GENERIC__)
1055 @c Bit fields are written as a general facility but are also controlled
1056 @c by a conditional-compilation flag---which is as of now (21mar91)
1057 @c turned on only by the i960 config of GAS.
1058 @node Bit Fields, , Flonums, Numbers
1059 @subsubsection Bit Fields
1060 You can also define numeric constants as @dfn{bit fields}.
1061 specify two numbers separated by a colon---
1062 @example
1063 @var{mask}:@var{value}
1064 @end example
1065 @noindent
1066 the first will act as a mask; @code{_AS__} will bitwise-and it with the
1067 second value.
1068
1069 The resulting number is then packed
1070 _if__(_GENERIC__)
1071 @c this conditional paren in case bit fields turned on elsewhere than 960
1072 (in host-dependent byte order)
1073 _fi__(_GENERIC__)
1074 into a field whose width depends on which assembler directive has the
1075 bit-field as its argument. Overflow (a result from the bitwise and
1076 requiring more binary digits to represent) is not an error; instead,
1077 more constants are generated, of the specified width, beginning with the
1078 least significant digits.@refill
1079
1080 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1081 @code{.short}, and @code{.word} accept bit-field arguments.
1082 _fi__(_I960__&&!_GENERIC__)
1083
1084 @node Sections, Symbols, Syntax, Top
1085 @chapter Sections and Relocation
1086
1087 @menu
1088 * Secs Background:: Background
1089 * _LD__ Sections:: _LD__ Sections
1090 * _AS__ Sections:: _AS__ Internal Sections
1091 _if__(!_H8__)
1092 * Sub-Sections:: Sub-Sections
1093 _fi__(!_H8__)
1094 * bss:: bss Section
1095 @end menu
1096
1097 @node Secs Background, _LD__ Sections, Sections, Sections
1098 @section Background
1099 Roughly, a section is a range of addresses, with no gaps; all data
1100 ``in'' those addresses is treated the same for some particular purpose.
1101 For example there may be a ``read only'' section.
1102
1103 The linker @code{_LD__} reads many object files (partial programs) and
1104 combines their contents to form a runnable program. When @code{_AS__}
1105 emits an object file, the partial program is assumed to start at address
1106 0. @code{_LD__} will assign the final addresses the partial program
1107 occupies, so that different partial programs don't overlap. This is
1108 actually an over-simplification, but it will suffice to explain how
1109 @code{_AS__} uses sections.
1110
1111 @code{_LD__} moves blocks of bytes of your program to their run-time
1112 addresses. These blocks slide to their run-time addresses as rigid
1113 units; their length does not change and neither does the order of bytes
1114 within them. Such a rigid unit is called a @emph{section}. Assigning
1115 run-time addresses to sections is called @dfn{relocation}. It includes
1116 the task of adjusting mentions of object-file addresses so they refer to
1117 the proper run-time addresses.
1118
1119 An object file written by @code{_AS__} has at least three sections, any
1120 of which may be empty. These are named @dfn{text}, @dfn{data} and
1121 @dfn{bss} sections.
1122
1123 _if__(_COFF__)
1124 _if__(_GENERIC__)
1125 When it generates COFF output,
1126 _fi__(_GENERIC__)
1127 @code{_AS__} can also generate whatever other named sections you specify
1128 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1129 If you don't use any directives that place output in the @samp{.text}
1130 or @samp{.data} sections, these sections will still exist, but will be empty.
1131 _fi__(_COFF__)
1132
1133 Within the object file, the text section starts at address @code{0}, the
1134 data section follows, and the bss section follows the data section.
1135
1136 To let @code{_LD__} know which data will change when the sections are
1137 relocated, and how to change that data, @code{_AS__} also writes to the
1138 object file details of the relocation needed. To perform relocation
1139 @code{_LD__} must know, each time an address in the object
1140 file is mentioned:
1141 @itemize @bullet
1142 @item
1143 Where in the object file is the beginning of this reference to
1144 an address?
1145 @item
1146 How long (in bytes) is this reference?
1147 @item
1148 Which section does the address refer to? What is the numeric value of
1149 @display
1150 (@var{address}) @minus{} (@var{start-address of section})?
1151 @end display
1152 @item
1153 Is the reference to an address ``Program-Counter relative''?
1154 @end itemize
1155
1156 In fact, every address @code{_AS__} ever uses is expressed as
1157 @display
1158 (@var{section}) + (@var{offset into section})
1159 @end display
1160 @noindent
1161 Further, every expression @code{_AS__} computes is of this section-relative
1162 nature. @dfn{Absolute expression} means an expression with section
1163 ``absolute'' (@pxref{_LD__ Sections}). A @dfn{pass1 expression} means
1164 an expression with section ``pass1'' (@pxref{_AS__ Sections,,_AS__
1165 Internal Sections}). In this manual we use the notation @{@var{secname}
1166 @var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1167
1168 Apart from text, data and bss sections you need to know about the
1169 @dfn{absolute} section. When @code{_LD__} mixes partial programs,
1170 addresses in the absolute section remain unchanged. That is, address
1171 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{_LD__}.
1172 Although two partial programs' data sections will not overlap addresses
1173 after linking, @emph{by definition} their absolute sections will overlap.
1174 Address @code{@{absolute@ 239@}} in one partial program will always be the same
1175 address when the program is running as address @code{@{absolute@ 239@}} in any
1176 other partial program.
1177
1178 The idea of sections is extended to the @dfn{undefined} section. Any
1179 address whose section is unknown at assembly time is by definition
1180 rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
1181 Since numbers are always defined, the only way to generate an undefined
1182 address is to mention an undefined symbol. A reference to a named
1183 common block would be such a symbol: its value is unknown at assembly
1184 time so it has section @emph{undefined}.
1185
1186 By analogy the word @emph{section} is used to describe groups of sections in
1187 the linked program. @code{_LD__} puts all partial programs' text
1188 sections in contiguous addresses in the linked program. It is
1189 customary to refer to the @emph{text section} of a program, meaning all
1190 the addresses of all partial program's text sections. Likewise for
1191 data and bss sections.
1192
1193 Some sections are manipulated by @code{_LD__}; others are invented for
1194 use of @code{_AS__} and have no meaning except during assembly.
1195
1196 @node _LD__ Sections, _AS__ Sections, Secs Background, Sections
1197 @section _LD__ Sections
1198 @code{_LD__} deals with just four kinds of sections, summarized below.
1199
1200 @table @strong
1201
1202 _if__(_GENERIC__||_COFF__)
1203 @item named sections
1204 _fi__(_GENERIC__||_COFF__)
1205 _if__(_AOUT__||_BOUT__)
1206 @item text section
1207 @itemx data section
1208 _fi__(_AOUT__||_BOUT__)
1209 These sections hold your program. @code{_AS__} and @code{_LD__} treat them as
1210 separate but equal sections. Anything you can say of one section is
1211 true another.
1212 _if__(_AOUT__||_BOUT__)
1213 When the program is running, however, it is
1214 customary for the text section to be unalterable. The
1215 text section is often shared among processes: it will contain
1216 instructions, constants and the like. The data section of a running
1217 program is usually alterable: for example, C variables would be stored
1218 in the data section.
1219 _fi__(_AOUT__||_BOUT__)
1220
1221 @item bss section
1222 This section contains zeroed bytes when your program begins running. It
1223 is used to hold unitialized variables or common storage. The length of
1224 each partial program's bss section is important, but because it starts
1225 out containing zeroed bytes there is no need to store explicit zero
1226 bytes in the object file. The bss section was invented to eliminate
1227 those explicit zeros from object files.
1228
1229 @item absolute section
1230 Address 0 of this section is always ``relocated'' to runtime address 0.
1231 This is useful if you want to refer to an address that @code{_LD__} must
1232 not change when relocating. In this sense we speak of absolute
1233 addresses being ``unrelocatable'': they don't change during relocation.
1234
1235 @item undefined section
1236 This ``section'' is a catch-all for address references to objects not in
1237 the preceding sections.
1238 @c FIXME: ref to some other doc on obj-file formats could go here.
1239
1240 @end table
1241
1242 An idealized example of three relocatable sections follows.
1243 _if__(_COFF__)
1244 The example uses the traditional names @samp{.text} and @samp{.data} for
1245 two named sections.
1246 _fi__(_COFF__)
1247 Memory addresses are on the horizontal axis.
1248
1249 @c TEXI2ROFF-KILL
1250 @ifinfo
1251 @c END TEXI2ROFF-KILL
1252 @smallexample
1253 +-----+----+--+
1254 partial program # 1: |ttttt|dddd|00|
1255 +-----+----+--+
1256
1257 text data bss
1258 seg. seg. seg.
1259
1260 +---+---+---+
1261 partial program # 2: |TTT|DDD|000|
1262 +---+---+---+
1263
1264 +--+---+-----+--+----+---+-----+~~
1265 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1266 +--+---+-----+--+----+---+-----+~~
1267
1268 addresses: 0 @dots{}
1269 @end smallexample
1270 @c TEXI2ROFF-KILL
1271 @end ifinfo
1272 @c FIXME make sure no page breaks inside figure!!
1273 @tex
1274
1275 {\it Partial program \#1: }
1276
1277 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1278 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1279
1280 {\it Partial program \#2:}
1281
1282 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1283 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
1284
1285 {\it linked program: }
1286
1287 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
1288 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
1289 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1290 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1291
1292 {\it addresses:}
1293
1294 \line{0\dots\hfil}
1295
1296 @end tex
1297 @c END TEXI2ROFF-KILL
1298
1299 _if__(!_H8__)
1300 @node _AS__ Sections, Sub-Sections, _LD__ Sections, Sections
1301 _fi__(!_H8__)
1302 _if__(_H8__)
1303 @node _AS__ Sections, bss, _LD__ Sections, Sections
1304 _fi__(_H8__)
1305 @section _AS__ Internal Sections
1306 These sections are meant only for the internal use of @code{_AS__}. They
1307 have no meaning at run-time. You don't really need to know about these
1308 sections for most purposes; but they can be mentioned in @code{_AS__}
1309 warning messages, so it might be helpful to have an idea of their
1310 meanings to @code{_AS__}. These sections are used to permit the
1311 value of every expression in your assembly language program to be a
1312 section-relative address.
1313
1314 @table @b
1315 @item absent
1316 An expression was expected and none was found.
1317
1318 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1319 An internal assembler logic error has been found. This means there is a
1320 bug in the assembler.
1321
1322 @item bignum/flonum
1323 If a number can't be written as a C @code{int} constant (a bignum or a
1324 flonum, but not an integer), it is recorded as belonging to this
1325 ``section''. @code{_AS__} has to remember that a flonum or a bignum
1326 does not fit into 32 bits, and cannot be an argument (@pxref{Arguments})
1327 in an expression: this is done by making a flonum or bignum be in a
1328 separate internal section. This is purely for internal @code{_AS__}
1329 convenience; bignum/flonum section behaves similarly to absolute
1330 section.
1331
1332 @item pass1 section
1333 The expression was impossible to evaluate in the first pass. The
1334 assembler will attempt a second pass (second reading of the source) to
1335 evaluate the expression. Your expression mentioned an undefined symbol
1336 in a way that defies the one-pass (section + offset in section) assembly
1337 process. No compiler need emit such an expression.
1338
1339 @quotation
1340 @emph{Warning:} the second pass is currently not implemented. @code{_AS__}
1341 will abort with an error message if one is required.
1342 @end quotation
1343
1344 @item difference section
1345 As an assist to the C compiler, expressions of the forms
1346 @display
1347 (@var{undefined symbol}) @minus{} (@var{expression})
1348 @var{something} @minus{} (@var{undefined symbol})
1349 (@var{undefined symbol}) @minus{} (@var{undefined symbol})
1350 @end display
1351 are permitted, and belong to the difference section. @code{_AS__}
1352 re-evaluates such expressions after the source file has been read and
1353 the symbol table built. If by that time there are no undefined symbols
1354 in the expression then the expression assumes a new section. The
1355 intention is to permit statements like
1356 @samp{.word label - base_of_table}
1357 to be assembled in one pass where both @code{label} and
1358 @code{base_of_table} are undefined. This is useful for compiling C and
1359 Algol switch statements, Pascal case statements, FORTRAN computed goto
1360 statements and the like.
1361 @c FIXME item debug
1362 @c FIXME item transfer[t] vector preload
1363 @c FIXME item transfer[t] vector postload
1364 @c FIXME item register
1365 @end table
1366
1367 @node Sub-Sections, bss, _AS__ Sections, Sections
1368 @section Sub-Sections
1369 Assembled bytes
1370 _if__(_COFF__)
1371 conventionally
1372 _fi__(_COFF__)
1373 fall into two sections: text and data. Because you may have groups of
1374 text or data that you want to end up near to each other in the object
1375 file, @code{_AS__} allows you to use @dfn{subsections} of these two
1376 sections. Within each section, there can be numbered subsections with
1377 values from 0 to 8192. Objects assembled into the same subsection will
1378 be grouped with other objects in the same subsection when they are all
1379 put into the object file. For example, a compiler might want to store
1380 constants in the text section, but might not want to have them
1381 interspersed with the program being assembled. In this case, the
1382 compiler could issue a @samp{.text 0} before each section of code being
1383 output, and a @samp{.text 1} before each group of constants being output.
1384
1385 Subsections are optional. If you don't use subsections, everything
1386 will be stored in subsection number zero.
1387
1388 _if__(_GENERIC__)
1389 Each subsection is zero-padded up to a multiple of four bytes.
1390 (Subsections may be padded a different amount on different flavors
1391 of @code{_AS__}.)
1392 _fi__(_GENERIC__)
1393 _if__(_I960__)
1394 @c FIXME section padding (alignment)?
1395 @c Rich Pixley says padding here depends on target obj code format; that
1396 @c doesn't seem particularly useful to say without further elaboration,
1397 @c so for now I say nothing about it. If this is a generic BFD issue,
1398 @c these paragraphs might need to vanish from this manual, and be
1399 @c discussed in BFD chapter of binutils (or some such).
1400 _fi__(_I960__)
1401 _if__(_A29K__)
1402 On the AMD 29K family, no particular padding is added to section sizes;
1403 _AS__ forces no alignment on this platform.
1404 _fi__(_A29K__)
1405 Subsections appear in your object file in numeric order, lowest numbered
1406 to highest. (All this to be compatible with other people's assemblers.)
1407 The object file contains no representation of subsections; @code{_LD__} and
1408 other programs that manipulate object files will see no trace of them.
1409 They just see all your text subsections as a text section, and all your
1410 data subsections as a data section.
1411
1412 To specify which subsection you want subsequent statements assembled
1413 into, use a @samp{.text @var{expression}} or a @samp{.data
1414 @var{expression}} statement. @var{Expression} should be an absolute
1415 expression. (@xref{Expressions}.) If you just say @samp{.text}
1416 then @samp{.text 0} is assumed. Likewise @samp{.data} means
1417 @samp{.data 0}. Assembly begins in @code{text 0}.
1418 For instance:
1419 @smallexample
1420 .text 0 # The default subsection is text 0 anyway.
1421 .ascii "This lives in the first text subsection. *"
1422 .text 1
1423 .ascii "But this lives in the second text subsection."
1424 .data 0
1425 .ascii "This lives in the data section,"
1426 .ascii "in the first data subsection."
1427 .text 0
1428 .ascii "This lives in the first text section,"
1429 .ascii "immediately following the asterisk (*)."
1430 @end smallexample
1431
1432 Each section has a @dfn{location counter} incremented by one for every
1433 byte assembled into that section. Because subsections are merely a
1434 convenience restricted to @code{_AS__} there is no concept of a subsection
1435 location counter. There is no way to directly manipulate a location
1436 counter---but the @code{.align} directive will change it, and any label
1437 definition will capture its current value. The location counter of the
1438 section that statements are being assembled into is said to be the
1439 @dfn{active} location counter.
1440
1441 _if__(!_H8__)
1442 @node bss, , Sub-Sections, Sections
1443 _fi__(!_H8__)
1444 _if__(_H8__)
1445 @node bss, , _AS__ Sections, Sections
1446 _fi__(_H8__)
1447 @section bss Section
1448 The bss section is used for local common variable storage.
1449 You may allocate address space in the bss section, but you may
1450 not dictate data to load into it before your program executes. When
1451 your program starts running, all the contents of the bss
1452 section are zeroed bytes.
1453
1454 Addresses in the bss section are allocated with special directives; you
1455 may not assemble anything directly into the bss section. Hence there
1456 are no bss subsections. @xref{Comm,,@code{.comm}},
1457 @pxref{Lcomm,,@code{.lcomm}}.
1458
1459 @node Symbols, Expressions, Sections, Top
1460 @chapter Symbols
1461 Symbols are a central concept: the programmer uses symbols to name
1462 things, the linker uses symbols to link, and the debugger uses symbols
1463 to debug.
1464
1465 @quotation
1466 @emph{Warning:} @code{_AS__} does not place symbols in the object file in
1467 the same order they were declared. This may break some debuggers.
1468 @end quotation
1469
1470 @menu
1471 * Labels:: Labels
1472 * Setting Symbols:: Giving Symbols Other Values
1473 * Symbol Names:: Symbol Names
1474 * Dot:: The Special Dot Symbol
1475 * Symbol Attributes:: Symbol Attributes
1476 @end menu
1477
1478 @node Labels, Setting Symbols, Symbols, Symbols
1479 @section Labels
1480 A @dfn{label} is written as a symbol immediately followed by a colon
1481 @samp{:}. The symbol then represents the current value of the
1482 active location counter, and is, for example, a suitable instruction
1483 operand. You are warned if you use the same symbol to represent two
1484 different locations: the first definition overrides any other
1485 definitions.
1486
1487 @node Setting Symbols, Symbol Names, Labels, Symbols
1488 @section Giving Symbols Other Values
1489 A symbol can be given an arbitrary value by writing a symbol, followed
1490 by an equals sign @samp{=}, followed by an expression
1491 (@pxref{Expressions}). This is equivalent to using the @code{.set}
1492 directive. @xref{Set,,@code{.set}}.
1493
1494 @node Symbol Names, Dot, Setting Symbols, Symbols
1495 @section Symbol Names
1496 Symbol names begin with a letter or with one of
1497 _if__(!_H8__)
1498 @samp{_.$}
1499 _fi__(!_H8__)
1500 _if__(_H8__)
1501 @samp{_.}
1502 _if__(_GENERIC__)
1503 (On most machines, you can also use @code{$} in symbol names; exceptions
1504 are noted in @ref{_MACH_DEP__}.)
1505 _fi__(_GENERIC__)
1506 _fi__(_H8__)
1507 That character may be followed by any string of digits, letters,
1508 _if__(!_H8__)
1509 underscores and dollar signs.
1510 _fi__(!_H8__)
1511 _if__(_H8__)
1512 _if__(_GENERIC__)
1513 dollar signs (unless otherwise noted in @ref{_MACH_DEP}),
1514 _fi__(_GENERIC__)
1515 and underscores.
1516 _fi__(_H8__)
1517 Case of letters is significant:
1518 @code{foo} is a different symbol name than @code{Foo}.
1519
1520 _if__(_A29K__)
1521 For the AMD 29K family, @samp{?} is also allowed in the
1522 body of a symbol name, though not at its beginning.
1523 _fi__(_A29K__)
1524
1525 Each symbol has exactly one name. Each name in an assembly language
1526 program refers to exactly one symbol. You may use that symbol name any
1527 number of times in a program.
1528
1529 @subheading Local Symbol Names
1530
1531 Local symbols help compilers and programmers use names temporarily.
1532 There are ten local symbol names, which are re-used throughout the
1533 program. You may refer to them using the names @samp{0} @samp{1}
1534 @dots{} @samp{9}. To define a local symbol, write a label of the form
1535 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
1536 recent previous definition of that symbol write @samp{@b{N}b}, using the
1537 same digit as when you defined the label. To refer to the next
1538 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
1539 a choice of 10 forward references. The @samp{b} stands for
1540 ``backwards'' and the @samp{f} stands for ``forwards''.
1541
1542 Local symbols are not emitted by the current GNU C compiler.
1543
1544 There is no restriction on how you can use these labels, but
1545 remember that at any point in the assembly you can refer to at most
1546 10 prior local labels and to at most 10 forward local labels.
1547
1548 Local symbol names are only a notation device. They are immediately
1549 transformed into more conventional symbol names before the assembler
1550 uses them. The symbol names stored in the symbol table, appearing in
1551 error messages and optionally emitted to the object file have these
1552 parts:
1553
1554 @table @code
1555 @item L
1556 All local labels begin with @samp{L}. Normally both @code{_AS__} and
1557 @code{_LD__} forget symbols that start with @samp{L}. These labels are
1558 used for symbols you are never intended to see. If you give the
1559 @samp{-L} option then @code{_AS__} will retain these symbols in the
1560 object file. If you also instruct @code{_LD__} to retain these symbols,
1561 you may use them in debugging.
1562
1563 @item @var{digit}
1564 If the label is written @samp{0:} then the digit is @samp{0}.
1565 If the label is written @samp{1:} then the digit is @samp{1}.
1566 And so on up through @samp{9:}.
1567
1568 @item @ctrl{A}
1569 This unusual character is included so you don't accidentally invent
1570 a symbol of the same name. The character has ASCII value
1571 @samp{\001}.
1572
1573 @item @emph{ordinal number}
1574 This is a serial number to keep the labels distinct. The first
1575 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
1576 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
1577 through @samp{9:}.
1578 @end table
1579
1580 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
1581 @code{3:} is named @code{L3@ctrl{A}44}.
1582
1583 @node Dot, Symbol Attributes, Symbol Names, Symbols
1584 @section The Special Dot Symbol
1585
1586 The special symbol @samp{.} refers to the current address that
1587 @code{_AS__} is assembling into. Thus, the expression @samp{melvin:
1588 .long .} will cause @code{melvin} to contain its own address.
1589 Assigning a value to @code{.} is treated the same as a @code{.org}
1590 directive. Thus, the expression @samp{.=.+4} is the same as saying
1591 _if__(!_A29K__)
1592 @samp{.space 4}.
1593 _fi__(!_A29K__)
1594 _if__(_A29K__)
1595 @samp{.block 4}.
1596 _fi__(_A29K__)
1597
1598 @node Symbol Attributes, , Dot, Symbols
1599 @section Symbol Attributes
1600 Every symbol has, as well as its name, the attributes ``Value'' and
1601 ``Type''. Depending on output format, symbols also have auxiliary attributes.
1602 _if__(_INTERNALS__)
1603 The detailed definitions are in _0__<a.out.h>_1__.
1604 _fi__(_INTERNALS__)
1605
1606 If you use a symbol without defining it, @code{_AS__} assumes zero for
1607 all these attributes, and probably won't warn you. This makes the
1608 symbol an externally defined symbol, which is generally what you
1609 would want.
1610
1611 @menu
1612 * Symbol Value:: Value
1613 * Symbol Type:: Type
1614 _if__(_GENERIC__||!_BOUT__)
1615 * a.out Symbols:: Symbol Attributes: @code{a.out}
1616 _fi__(_GENERIC__||!_BOUT__)
1617 _if__(_BOUT__&&!_GENERIC__)
1618 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
1619 _fi__(_BOUT__&&!_GENERIC__)
1620 _if__(_COFF__)
1621 * COFF Symbols:: Symbol Attributes for COFF
1622 _fi__(_COFF__)
1623 @end menu
1624
1625 @node Symbol Value, Symbol Type, Symbol Attributes, Symbol Attributes
1626 @subsection Value
1627 The value of a symbol is (usually) 32 bits. For a symbol which labels a
1628 location in the text, data, bss or absolute sections the value is the
1629 number of addresses from the start of that section to the label.
1630 Naturally for text, data and bss sections the value of a symbol changes
1631 as @code{_LD__} changes section base addresses during linking. Absolute
1632 symbols' values do not change during linking: that is why they are
1633 called absolute.
1634
1635 The value of an undefined symbol is treated in a special way. If it is
1636 0 then the symbol is not defined in this assembler source program, and
1637 @code{_LD__} will try to determine its value from other programs it is
1638 linked with. You make this kind of symbol simply by mentioning a symbol
1639 name without defining it. A non-zero value represents a @code{.comm}
1640 common declaration. The value is how much common storage to reserve, in
1641 bytes (addresses). The symbol refers to the first address of the
1642 allocated storage.
1643
1644 @node Symbol Type, a.out Symbols, Symbol Value, Symbol Attributes
1645 @subsection Type
1646 The type attribute of a symbol contains relocation (section)
1647 information, any flag settings indicating that a symbol is external, and
1648 (optionally), other information for linkers and debuggers. The exact
1649 format depends on the object-code output format in use.
1650
1651 _if__(_AOUT__||_BOUT__)
1652 @menu
1653 * Symbol Desc:: Descriptor
1654 * Symbol Other:: Other
1655 @end menu
1656
1657 _if__(_COFF__)
1658 @node a.out Symbols, COFF Symbols, Symbol Type, Symbol Attributes
1659 _fi__(_COFF__)
1660 _if__(!_COFF__)
1661 @node a.out Symbols, , Symbol Type, Symbol Attributes
1662 _fi__(!_COFF__)
1663 _if__(_BOUT__&&!_GENERIC__)
1664 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
1665 These symbol attributes appear only when @code{_AS__} is configured for
1666 one of the Berkeley-descended object output formats.
1667 _fi__(_BOUT__&&!_GENERIC__)
1668 _if__(_GENERIC__||!_BOUT__)
1669 @subsection Symbol Attributes: @code{a.out}
1670 _fi__(_GENERIC__||!_BOUT__)
1671
1672 @menu
1673 * Symbol Desc:: Descriptor
1674 * Symbol Other:: Other
1675 @end menu
1676
1677 @node Symbol Desc, Symbol Other, a.out Symbols, a.out Symbols
1678 @subsubsection Descriptor
1679 This is an arbitrary 16-bit value. You may establish a symbol's
1680 descriptor value by using a @code{.desc} statement
1681 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
1682 @code{_AS__}.
1683
1684 @node Symbol Other, , Symbol Desc, a.out Symbols
1685 @subsubsection Other
1686 This is an arbitrary 8-bit value. It means nothing to @code{_AS__}.
1687 _fi__(_AOUT__||_BOUT__)
1688
1689 _if__(_COFF__)
1690 @node COFF Symbols, , a.out Symbols, Symbol Attributes
1691 @subsection Symbol Attributes for COFF
1692 The COFF format supports a multitude of auxiliary symbol attributes;
1693 like the primary symbol attributes, they are set between @code{.def} and
1694 @code{.endef} directives.
1695
1696 @subsubsection Primary Attributes
1697 The symbol name is set with @code{.def}; the value and type,
1698 respectively, with @code{.val} and @code{.type}.
1699
1700 @subsubsection Auxiliary Attributes
1701 The @code{_AS__} directives @code{.dim}, @code{.line}, @code{.scl},
1702 @code{.size}, and @code{.tag} can generate auxiliary symbol table
1703 information for COFF.
1704 _fi__(_COFF__)
1705
1706 @node Expressions, Pseudo Ops, Symbols, Top
1707 @chapter Expressions
1708 An @dfn{expression} specifies an address or numeric value.
1709 Whitespace may precede and/or follow an expression.
1710
1711 @menu
1712 * Empty Exprs:: Empty Expressions
1713 * Integer Exprs:: Integer Expressions
1714 @end menu
1715
1716 @node Empty Exprs, Integer Exprs, Expressions, Expressions
1717 @section Empty Expressions
1718 An empty expression has no value: it is just whitespace or null.
1719 Wherever an absolute expression is required, you may omit the
1720 expression and @code{_AS__} will assume a value of (absolute) 0. This
1721 is compatible with other assemblers.
1722
1723 @node Integer Exprs, , Empty Exprs, Expressions
1724 @section Integer Expressions
1725 An @dfn{integer expression} is one or more @emph{arguments} delimited
1726 by @emph{operators}.
1727
1728 @menu
1729 * Arguments:: Arguments
1730 * Operators:: Operators
1731 * Prefix Ops:: Prefix Operators
1732 * Infix Ops:: Infix Operators
1733 @end menu
1734
1735 @node Arguments, Operators, Integer Exprs, Integer Exprs
1736 @subsection Arguments
1737
1738 @dfn{Arguments} are symbols, numbers or subexpressions. In other
1739 contexts arguments are sometimes called ``arithmetic operands''. In
1740 this manual, to avoid confusing them with the ``instruction operands'' of
1741 the machine language, we use the term ``argument'' to refer to parts of
1742 expressions only, reserving the word ``operand'' to refer only to machine
1743 instruction operands.
1744
1745 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
1746 @var{section} is one of text, data, bss, absolute,
1747 or undefined. @var{NNN} is a signed, 2's complement 32 bit
1748 integer.
1749
1750 Numbers are usually integers.
1751
1752 A number can be a flonum or bignum. In this case, you are warned
1753 that only the low order 32 bits are used, and @code{_AS__} pretends
1754 these 32 bits are an integer. You may write integer-manipulating
1755 instructions that act on exotic constants, compatible with other
1756 assemblers.
1757
1758 Subexpressions are a left parenthesis @samp{(} followed by an integer
1759 expression, followed by a right parenthesis @samp{)}; or a prefix
1760 operator followed by an argument.
1761
1762 @node Operators, Prefix Ops, Arguments, Integer Exprs
1763 @subsection Operators
1764 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
1765 operators are followed by an argument. Infix operators appear
1766 between their arguments. Operators may be preceded and/or followed by
1767 whitespace.
1768
1769 @node Prefix Ops, Infix Ops, Operators, Integer Exprs
1770 @subsection Prefix Operators
1771 @code{_AS__} has the following @dfn{prefix operators}. They each take
1772 one argument, which must be absolute.
1773
1774 @c the tex/end tex stuff surrounding this small table is meant to make
1775 @c it align, on the printed page, with the similar table in the next
1776 @c section (which is inside an enumerate).
1777 @tex
1778 \global\advance\leftskip by \itemindent
1779 @end tex
1780
1781 @table @code
1782 @item -
1783 @dfn{Negation}. Two's complement negation.
1784 @item ~
1785 @dfn{Complementation}. Bitwise not.
1786 @end table
1787
1788 @tex
1789 \global\advance\leftskip by -\itemindent
1790 @end tex
1791
1792 @node Infix Ops, , Prefix Ops, Integer Exprs
1793 @subsection Infix Operators
1794
1795 @dfn{Infix operators} take two arguments, one on either side. Operators
1796 have precedence, but operations with equal precedence are performed left
1797 to right. Apart from @code{+} or @code{-}, both arguments must be
1798 absolute, and the result is absolute.
1799
1800 @enumerate
1801
1802 @item
1803 Highest Precedence
1804 @table @code
1805 @item *
1806 @dfn{Multiplication}.
1807 @item /
1808 @dfn{Division}. Truncation is the same as the C operator @samp{/}
1809 @item %
1810 @dfn{Remainder}.
1811 @item _0__<_1__
1812 @itemx _0__<<_1__
1813 @dfn{Shift Left}. Same as the C operator @samp{_0__<<_1__}
1814 @item _0__>_1__
1815 @itemx _0__>>_1__
1816 @dfn{Shift Right}. Same as the C operator @samp{_0__>>_1__}
1817 @end table
1818
1819 @item
1820 Intermediate precedence
1821 @table @code
1822 @item |
1823 @dfn{Bitwise Inclusive Or}.
1824 @item &
1825 @dfn{Bitwise And}.
1826 @item ^
1827 @dfn{Bitwise Exclusive Or}.
1828 @item !
1829 @dfn{Bitwise Or Not}.
1830 @end table
1831
1832 @item
1833 Lowest Precedence
1834 @table @code
1835 @item +
1836 @dfn{Addition}. If either argument is absolute, the result
1837 has the section of the other argument.
1838 If either argument is pass1 or undefined, the result is pass1.
1839 Otherwise @code{+} is illegal.
1840 @item -
1841 @dfn{Subtraction}. If the right argument is absolute, the
1842 result has the section of the left argument.
1843 If either argument is pass1 the result is pass1.
1844 If either argument is undefined the result is difference section.
1845 If both arguments are in the same section, the result is absolute---provided
1846 that section is one of text, data or bss.
1847 Otherwise subtraction is illegal.
1848 @end table
1849 @end enumerate
1850
1851 The sense of the rule for addition is that it's only meaningful to add
1852 the @emph{offsets} in an address; you can only have a defined section in
1853 one of the two arguments.
1854
1855 Similarly, you can't subtract quantities from two different sections.
1856
1857 @node Pseudo Ops, _MACH_DEP__, Expressions, Top
1858 @chapter Assembler Directives
1859
1860 All assembler directives have names that begin with a period (@samp{.}).
1861 The rest of the name is letters: their case does not matter.
1862
1863 This chapter discusses directives present regardless of the target
1864 machine configuration for the GNU assembler; @pxref{_MACH_DEP__} for
1865 additional directives.
1866
1867 @menu
1868 * Abort:: @code{.abort}
1869 _if__(_COFF__)
1870 * coff-ABORT:: @code{.ABORT}
1871 _fi__(_COFF__)
1872 _if__(_BOUT__&&!_COFF__)
1873 * bout-ABORT:: @code{.ABORT}
1874 _fi__(_BOUT__&&!_COFF__)
1875 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
1876 * App-File:: @code{.app-file @var{string}}
1877 * Ascii:: @code{.ascii "@var{string}"}@dots{}
1878 * Asciz:: @code{.asciz "@var{string}"}@dots{}
1879 * Byte:: @code{.byte @var{expressions}}
1880 * Comm:: @code{.comm @var{symbol} , @var{length} }
1881 * Data:: @code{.data @var{subsection}}
1882 _if__(_COFF__||_BOUT__)
1883 * Def:: @code{.def @var{name}}
1884 _fi__(_COFF__||_BOUT__)
1885 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
1886 _if__(_COFF__||_BOUT__)
1887 * Dim:: @code{.dim}
1888 _fi__(_COFF__||_BOUT__)
1889 * Double:: @code{.double @var{flonums}}
1890 * Else:: @code{.else}
1891 _if__(_COFF__||_BOUT__)
1892 * Endef:: @code{.endef}
1893 _fi__(_COFF__||_BOUT__)
1894 * Endif:: @code{.endif}
1895 * Equ:: @code{.equ @var{symbol}, @var{expression}}
1896 * Extern:: @code{.extern}
1897 _if__(_GENERIC__||!_A29K__)
1898 * File:: @code{.file @var{string}}
1899 _fi__(_GENERIC__||!_A29K__)
1900 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
1901 * Float:: @code{.float @var{flonums}}
1902 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
1903 * hword:: @code{.hword @var{expressions}}
1904 * Ident:: @code{.ident}
1905 * If:: @code{.if @var{absolute expression}}
1906 * Include:: @code{.include "@var{file}"}
1907 * Int:: @code{.int @var{expressions}}
1908 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
1909 _if__(_GENERIC__||!_A29K__)
1910 * Line:: @code{.line @var{line-number}}
1911 _fi__(_GENERIC__||!_A29K__)
1912 * Ln:: @code{.ln @var{line-number}}
1913 * List:: @code{.list} and related directives
1914 * Long:: @code{.long @var{expressions}}
1915 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
1916 * Octa:: @code{.octa @var{bignums}}
1917 * Org:: @code{.org @var{new-lc} , @var{fill}}
1918 * Quad:: @code{.quad @var{bignums}}
1919 _if__(_COFF__||_BOUT__)
1920 * Scl:: @code{.scl @var{class}}
1921 _fi__(_COFF__||_BOUT__)
1922 _if__(_COFF__)
1923 * Section:: @code{.section @var{name}}
1924 _fi__(_COFF__)
1925 * Set:: @code{.set @var{symbol}, @var{expression}}
1926 * Short:: @code{.short @var{expressions}}
1927 * Single:: @code{.single @var{flonums}}
1928 _if__(_COFF__||_BOUT__)
1929 * Size:: @code{.size}
1930 _fi__(_COFF__||_BOUT__)
1931 * Space:: @code{.space @var{size} , @var{fill}}
1932 _if__(_GENERIC__||!_H8__)
1933 * Stab:: @code{.stabd, .stabn, .stabs}
1934 _fi__(_GENERIC__||!_H8__)
1935 _if__(_COFF__||_BOUT__)
1936 * Tag:: @code{.tag @var{structname}}
1937 _fi__(_COFF__||_BOUT__)
1938 * Text:: @code{.text @var{subsection}}
1939 _if__(_COFF__||_BOUT__)
1940 * Type:: @code{.type @var{int}}
1941 * Val:: @code{.val @var{addr}}
1942 _fi__(_COFF__||_BOUT__)
1943 * Word:: @code{.word @var{expressions}}
1944 * Deprecated:: Deprecated Directives
1945 @end menu
1946
1947 _if__(_COFF__)
1948 @node Abort, coff-ABORT, Pseudo Ops, Pseudo Ops
1949 _fi__(_COFF__)
1950 _if__((!_COFF__) && _BOUT__)
1951 @node Abort, bout-ABORT, Pseudo Ops, Pseudo Ops
1952 _fi__((!_COFF__) && _BOUT__)
1953 _if__(! (_BOUT__ || _COFF__) )
1954 @node Abort, Align, Pseudo Ops, Pseudo Ops
1955 _fi__(! (_BOUT__ || _COFF__) )
1956 @section @code{.abort}
1957 This directive stops the assembly immediately. It is for
1958 compatibility with other assemblers. The original idea was that the
1959 assembly language source would be piped into the assembler. If the sender
1960 of the source quit, it could use this directive tells @code{_AS__} to
1961 quit also. One day @code{.abort} will not be supported.
1962
1963 _if__(_COFF__)
1964 @node coff-ABORT, Align, Abort, Pseudo Ops
1965 @section @code{.ABORT}
1966 When producing COFF output, @code{_AS__} accepts this directive as a
1967 synonym for @samp{.abort}.
1968 _fi__(_COFF__)
1969
1970 _if__(_BOUT__)
1971 _if__(!_COFF__)
1972 @node bout-ABORT, Align, Abort, Pseudo Ops
1973 @section @code{.ABORT}
1974 _fi__(!_COFF__)
1975
1976 When producing @code{b.out} output, @code{_AS__} accepts this directive,
1977 but ignores it.
1978 _fi__(_BOUT__)
1979
1980 _if__( ! (_COFF__ || _BOUT__) )
1981 @node Align, App-File, Abort, Pseudo Ops
1982 _fi__( ! (_COFF__ || _BOUT__) )
1983 _if__( _COFF__)
1984 @node Align, App-File, coff-ABORT, Pseudo Ops
1985 _fi__( _COFF__)
1986 _if__( _BOUT__ && (! _COFF__))
1987 @node Align, App-File, bout-ABORT, Pseudo Ops
1988 _fi__( _BOUT__ && (! _COFF__))
1989 @section @code{.align @var{abs-expr} , @var{abs-expr}}
1990 Pad the location counter (in the current subsection) to a particular
1991 storage boundary. The first expression (which must be absolute) is the
1992 number of low-order zero bits the location counter will have after
1993 advancement. For example @samp{.align 3} will advance the location
1994 counter until it a multiple of 8. If the location counter is already a
1995 multiple of 8, no change is needed.
1996
1997 The second expression (also absolute) gives the value to be stored in
1998 the padding bytes. It (and the comma) may be omitted. If it is
1999 omitted, the padding bytes are zero.
2000
2001 @node App-File, Ascii, Align, Pseudo Ops
2002 @section @code{.app-file @var{string}}
2003 @code{.app-file}
2004 _if__(!_A29K__)
2005 (which may also be spelled @samp{.file})
2006 _fi__(!_A29K__)
2007 tells @code{_AS__} that we are about to start a new
2008 logical file. @var{string} is the new file name. In general, the
2009 filename is recognized whether or not it is surrounded by quotes @samp{"};
2010 but if you wish to specify an empty file name is permitted,
2011 you must give the quotes--@code{""}. This statement may go away in
2012 future: it is only recognized to be compatible with old @code{_AS__}
2013 programs.@refill
2014
2015 @node Ascii, Asciz, App-File, Pseudo Ops
2016 @section @code{.ascii "@var{string}"}@dots{}
2017 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2018 separated by commas. It assembles each string (with no automatic
2019 trailing zero byte) into consecutive addresses.
2020
2021 @node Asciz, Byte, Ascii, Pseudo Ops
2022 @section @code{.asciz "@var{string}"}@dots{}
2023 @code{.asciz} is just like @code{.ascii}, but each string is followed by
2024 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2025
2026 @node Byte, Comm, Asciz, Pseudo Ops
2027 @section @code{.byte @var{expressions}}
2028
2029 @code{.byte} expects zero or more expressions, separated by commas.
2030 Each expression is assembled into the next byte.
2031
2032 @node Comm, Data, Byte, Pseudo Ops
2033 @section @code{.comm @var{symbol} , @var{length} }
2034 @code{.comm} declares a named common area in the bss section. Normally
2035 @code{_LD__} reserves memory addresses for it during linking, so no partial
2036 program defines the location of the symbol. Use @code{.comm} to tell
2037 @code{_LD__} that it must be at least @var{length} bytes long. @code{_LD__}
2038 will allocate space for each @code{.comm} symbol that is at least as
2039 long as the longest @code{.comm} request in any of the partial programs
2040 linked. @var{length} is an absolute expression.
2041
2042 _if__(_COFF__ || _BOUT__)
2043 @node Data, Def, Comm, Pseudo Ops
2044 _fi__(_COFF__ || _BOUT__)
2045 _if__(!(_COFF__ || _BOUT__) && _AOUT__)
2046 @node Data, Desc, Comm, Pseudo Ops
2047 _fi__(!(_COFF__ || _BOUT__) && _AOUT__)
2048 _if__(! (_COFF__ || _BOUT__ || _AOUT__) )
2049 @c Well, this *might* happen...
2050 @node Data, Double, Comm, Pseudo Ops
2051 _fi__(! (_COFF__ || _BOUT__ || _AOUT__) )
2052 @section @code{.data @var{subsection}}
2053 @code{.data} tells @code{_AS__} to assemble the following statements onto the
2054 end of the data subsection numbered @var{subsection} (which is an
2055 absolute expression). If @var{subsection} is omitted, it defaults
2056 to zero.
2057
2058 _if__(_COFF__ || _BOUT__)
2059 _if__(_AOUT__ || _BOUT__)
2060 @node Def, Desc, Data, Pseudo Ops
2061 _fi__(_AOUT__ || _BOUT__)
2062 _if__(!(_AOUT__ || _BOUT__))
2063 @node Def, Dim, Data, Pseudo Ops
2064 _fi__(!(_AOUT__ || _BOUT__))
2065 @section @code{.def @var{name}}
2066 Begin defining debugging information for a symbol @var{name}; the
2067 definition extends until the @code{.endef} directive is encountered.
2068 _if__(_BOUT__)
2069
2070 This directive is only observed when @code{_AS__} is configured for COFF
2071 format output; when producing @code{b.out}, @samp{.def} is recognized,
2072 but ignored.
2073 _fi__(_BOUT__)
2074 _fi__(_COFF__ || _BOUT__)
2075
2076 _if__(_AOUT__||_BOUT__)
2077 _if__(_COFF__||_BOUT__)
2078 @node Desc, Dim, Def, Pseudo Ops
2079 _fi__(_COFF__||_BOUT__)
2080 _if__(!(_COFF__||_BOUT__))
2081 @node Desc, Double, Data, Pseudo Ops
2082 _fi__(!(_COFF__||_BOUT__))
2083 @section @code{.desc @var{symbol}, @var{abs-expression}}
2084 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2085 to the low 16 bits of an absolute expression.
2086
2087 _if__(_COFF__)
2088 The @samp{.desc} directive is not available when @code{_AS__} is
2089 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2090 object format. For the sake of compatibility, @code{_AS__} will accept
2091 it, but produce no output, when configured for COFF.
2092 _fi__(_COFF__)
2093 _fi__(_AOUT__||_BOUT__)
2094
2095 _if__(_COFF__ || _BOUT__)
2096 _if__(_AOUT__ || _BOUT__)
2097 @node Dim, Double, Desc, Pseudo Ops
2098 _fi__(_AOUT__ || _BOUT__)
2099 _if__(!(_AOUT__ || _BOUT__))
2100 @node Dim, Double, Def, Pseudo Ops
2101 _fi__(!(_AOUT__ || _BOUT__))
2102 @section @code{.dim}
2103 This directive is generated by compilers to include auxiliary debugging
2104 information in the symbol table. It is only permitted inside
2105 @code{.def}/@code{.endef} pairs.
2106 _if__(_BOUT__)
2107
2108 @samp{.dim} is only meaningful when generating COFF format output; when
2109 @code{_AS__} is generating @code{b.out}, it accepts this directive but
2110 ignores it.
2111 _fi__(_BOUT__)
2112 _fi__(_COFF__ || _BOUT__)
2113
2114 _if__(_COFF__||_BOUT__)
2115 @node Double, Else, Dim, Pseudo Ops
2116 _fi__(_COFF__||_BOUT__)
2117 _if__(!(_COFF__||_BOUT__))
2118 @node Double, Else, Desc, Pseudo Ops
2119 _fi__(!(_COFF__||_BOUT__))
2120 @section @code{.double @var{flonums}}
2121 @code{.double} expects zero or more flonums, separated by commas. It
2122 assembles floating point numbers.
2123 _if__(_GENERIC__)
2124 The exact kind of floating point numbers emitted depends on how
2125 @code{_AS__} is configured. @xref{_MACH_DEP__}.
2126 _fi__(_GENERIC__)
2127 _if__((!_GENERIC__) && _IEEEFLOAT__)
2128 On the _HOST__ family @samp{.double} emits 64-bit floating-point numbers
2129 in IEEE format.
2130 _fi__((!_GENERIC__) && _IEEEFLOAT__)
2131
2132 _if__(_COFF__||_BOUT__)
2133 @node Else, Endef, Double, Pseudo Ops
2134 _fi__(_COFF__||_BOUT__)
2135 _if__(!(_COFF__||_BOUT__))
2136 @node Else, Endif, Double, Pseudo Ops
2137 _fi__(!(_COFF__||_BOUT__))
2138 @section @code{.else}
2139 @code{.else} is part of the @code{_AS__} support for conditional
2140 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2141 of code to be assembled if the condition for the preceding @code{.if}
2142 was false.
2143
2144 _if__(0)
2145 @node End, Endef, Else, Pseudo Ops
2146 @section @code{.end}
2147 This doesn't do anything---but isn't an s_ignore, so I suspect it's
2148 meant to do something eventually (which is why it isn't documented here
2149 as "for compatibility with blah").
2150 _fi__(0)
2151
2152 _if__(_COFF__||_BOUT__)
2153 @node Endef, Endif, Else, Pseudo Ops
2154 @section @code{.endef}
2155 This directive flags the end of a symbol definition begun with
2156 @code{.def}.
2157 _if__(_BOUT__)
2158
2159 @samp{.endef} is only meaningful when generating COFF format output; if
2160 @code{_AS__} is configured to generate @code{b.out}, it accepts this
2161 directive but ignores it.
2162 _fi__(_BOUT__)
2163 _fi__(_COFF__||_BOUT__)
2164
2165 _if__(_COFF__||_BOUT__)
2166 @node Endif, Equ, Endef, Pseudo Ops
2167 _fi__(_COFF__||_BOUT__)
2168 _if__(!(_COFF__||_BOUT__))
2169 @node Endif, Equ, Else, Pseudo Ops
2170 _fi__(!(_COFF__||_BOUT__))
2171 @section @code{.endif}
2172 @code{.endif} is part of the @code{_AS__} support for conditional assembly;
2173 it marks the end of a block of code that is only assembled
2174 conditionally. @xref{If,,@code{.if}}.
2175
2176 @node Equ, Extern, Endif, Pseudo Ops
2177 @section @code{.equ @var{symbol}, @var{expression}}
2178
2179 This directive sets the value of @var{symbol} to @var{expression}.
2180 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2181
2182 _if__(_GENERIC__||!_A29K__)
2183 @node Extern, File, Equ, Pseudo Ops
2184 _fi__(_GENERIC__||!_A29K__)
2185 _if__(_A29K__&&!_GENERIC__)
2186 @node Extern, Fill, Equ, Pseudo Ops
2187 _fi__(_A29K__&&!_GENERIC__)
2188 @section @code{.extern}
2189 @code{.extern} is accepted in the source program---for compatibility
2190 with other assemblers---but it is ignored. @code{_AS__} treats
2191 all undefined symbols as external.
2192
2193 _if__(_GENERIC__||!_A29K__)
2194 @node File, Fill, Extern, Pseudo Ops
2195 @section @code{.app-file @var{string}}
2196 @code{.file} (which may also be spelled @samp{.app-file}) tells
2197 @code{_AS__} that we are about to start a new logical file.
2198 @var{string} is the new file name. In general, the filename is
2199 recognized whether or not it is surrounded by quotes @samp{"}; but if
2200 you wish to specify an empty file name, you must give the
2201 quotes--@code{""}. This statement may go away in future: it is only
2202 recognized to be compatible with old @code{_AS__} programs.
2203 _if__(_A29K__)
2204 In some configurations of @code{_AS__}, @code{.file} has already been
2205 removed to avoid conflicts with other assemblers. @xref{_MACH_DEP__}.
2206 _fi__(_A29K__)
2207 _fi__(_GENERIC__||!_A29K__)
2208
2209 _if__(_GENERIC__||!_A29K__)
2210 @node Fill, Float, File, Pseudo Ops
2211 _fi__(_GENERIC__||!_A29K__)
2212 _if__(_A29K__&&!_GENERIC__)
2213 @node Fill, Float, Extern, Pseudo Ops
2214 _fi__(_A29K__&&!_GENERIC__)
2215 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
2216 @var{result}, @var{size} and @var{value} are absolute expressions.
2217 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2218 may be zero or more. @var{Size} may be zero or more, but if it is
2219 more than 8, then it is deemed to have the value 8, compatible with
2220 other people's assemblers. The contents of each @var{repeat} bytes
2221 is taken from an 8-byte number. The highest order 4 bytes are
2222 zero. The lowest order 4 bytes are @var{value} rendered in the
2223 byte-order of an integer on the computer @code{_AS__} is assembling for.
2224 Each @var{size} bytes in a repetition is taken from the lowest order
2225 @var{size} bytes of this number. Again, this bizarre behavior is
2226 compatible with other people's assemblers.
2227
2228 @var{size} and @var{value} are optional.
2229 If the second comma and @var{value} are absent, @var{value} is
2230 assumed zero. If the first comma and following tokens are absent,
2231 @var{size} is assumed to be 1.
2232
2233 @node Float, Global, Fill, Pseudo Ops
2234 @section @code{.float @var{flonums}}
2235 This directive assembles zero or more flonums, separated by commas. It
2236 has the same effect as @code{.single}.
2237 _if__(_GENERIC__)
2238 The exact kind of floating point numbers emitted depends on how
2239 @code{_AS__} is configured.
2240 @xref{_MACH_DEP__}.
2241 _fi__(_GENERIC__)
2242 _if__((!_GENERIC__) && _IEEEFLOAT__)
2243 On the _HOST__ family, @code{.float} emits 32-bit floating point numbers
2244 in IEEE format.
2245 _fi__((!_GENERIC__) && _IEEEFLOAT__)
2246
2247 @node Global, hword, Float, Pseudo Ops
2248 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2249 @code{.global} makes the symbol visible to @code{_LD__}. If you define
2250 @var{symbol} in your partial program, its value is made available to
2251 other partial programs that are linked with it. Otherwise,
2252 @var{symbol} will take its attributes from a symbol of the same name
2253 from another partial program it is linked with.
2254
2255 _if__(!_I960__)
2256 @c FIXME BFD implications; this is different in COFF.
2257 This is done by setting the @code{N_EXT} bit of that symbol's type byte
2258 to 1. @xref{Symbol Attributes}.
2259 _fi__(!_I960__)
2260
2261 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
2262 compatibility with other assemblers.
2263
2264 _if__(_AOUT__||_BOUT__||_COFF__)
2265 @node hword, Ident, Global, Pseudo Ops
2266 _fi__(_AOUT__||_BOUT__||_COFF__)
2267 _if__(!(_AOUT__||_BOUT__||_COFF__))
2268 @node hword, If, Global, Pseudo Ops
2269 _fi__(!(_AOUT__||_BOUT__||_COFF__))
2270 @section @code{.hword @var{expressions}}
2271 This expects zero or more @var{expressions}, and emits
2272 a 16 bit number for each.
2273
2274 _if__(_GENERIC__)
2275 This directive is a synonym for @samp{.short}; depending on the target
2276 architecture, it may also be a synonym for @samp{.word}.
2277 _fi__(_GENERIC__)
2278 _if__( _W32__ && !_GENERIC__ )
2279 This directive is a synonym for @samp{.short}.
2280 _fi__( _W32__ && !_GENERIC__ )
2281 _if__(_W16__ && !_GENERIC__ )
2282 This directive is a synonym for both @samp{.short} and @samp{.word}.
2283 _fi__(_W16__ && !_GENERIC__ )
2284
2285 _if__(_AOUT__||_BOUT__||_COFF__)
2286 @node Ident, If, hword, Pseudo Ops
2287 @section @code{.ident}
2288 This directive is used by some assemblers to place tags in object files.
2289 @code{_AS__} simply accepts the directive for source-file
2290 compatibility with such assemblers, but does not actually emit anything
2291 for it.
2292 _fi__(_AOUT__||_BOUT__||_COFF__)
2293
2294 _if__(_AOUT__||_BOUT__||_COFF__)
2295 @node If, Include, Ident, Pseudo Ops
2296 _fi__(_AOUT__||_BOUT__||_COFF__)
2297 _if__(!(_AOUT__||_BOUT__||_COFF__))
2298 @node If, Include, hword, Pseudo Ops
2299 _fi__(!(_AOUT__||_BOUT__||_COFF__))
2300 @section @code{.if @var{absolute expression}}
2301 @code{.if} marks the beginning of a section of code which is only
2302 considered part of the source program being assembled if the argument
2303 (which must be an @var{absolute expression}) is non-zero. The end of
2304 the conditional section of code must be marked by @code{.endif}
2305 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
2306 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
2307
2308 The following variants of @code{.if} are also supported:
2309 @table @code
2310 @item ifdef @var{symbol}
2311 Assembles the following section of code if the specified @var{symbol}
2312 has been defined.
2313
2314 _if__(0)
2315 @item ifeqs
2316 Not yet implemented.
2317 _fi__(0)
2318
2319 @item ifndef @var{symbol}
2320 @itemx ifnotdef @var{symbol}
2321 Assembles the following section of code if the specified @var{symbol}
2322 has not been defined. Both spelling variants are equivalent.
2323
2324 _if__(0)
2325 @item ifnes
2326 Not yet implemented.
2327 _fi__(0)
2328 @end table
2329
2330 @node Include, Int, If, Pseudo Ops
2331 @section @code{.include "@var{file}"}
2332 This directive provides a way to include supporting files at specified
2333 points in your source program. The code from @var{file} is assembled as
2334 if it followed the point of the @code{.include}; when the end of the
2335 included file is reached, assembly of the original file continues. You
2336 can control the search paths used with the @samp{-I} command-line option
2337 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
2338 around @var{file}.
2339
2340 @node Int, Lcomm, Include, Pseudo Ops
2341 @section @code{.int @var{expressions}}
2342 Expect zero or more @var{expressions}, of any section, separated by
2343 commas. For each expression, emit a
2344 _if__(!_H8__)
2345 32-bit
2346 _fi__(!_H8__)
2347 _if__(_H8__)
2348 16-bit
2349 _fi__(_H8__)
2350 number that will, at run
2351 time, be the value of that expression. The byte order of the
2352 expression depends on what kind of computer will run the program.
2353
2354 _if__(_GENERIC__||(!_A29K__))
2355 @node Lcomm, Line, Int, Pseudo Ops
2356 _fi__(_GENERIC__||(!_A29K__))
2357 _if__((!_GENERIC__)&& _A29K__)
2358 @node Lcomm, Ln, Int, Pseudo Ops
2359 _fi__((!_GENERIC__)&& _A29K__)
2360 @section @code{.lcomm @var{symbol} , @var{length}}
2361 Reserve @var{length} (an absolute expression) bytes for a local common
2362 denoted by @var{symbol}. The section and value of @var{symbol} are
2363 those of the new local common. The addresses are allocated in the bss
2364 section, so at run-time the bytes will start off zeroed. @var{Symbol}
2365 is not declared global (@pxref{Global,,@code{.global}}), so is normally
2366 not visible to @code{_LD__}.
2367
2368 _if__(_GENERIC__ || !_A29K__)
2369 @node Line, Ln, Lcomm, Pseudo Ops
2370 @section @code{.line @var{line-number}}
2371 _fi__(_GENERIC__ || (!_A29K__))
2372 _if__(_A29K__ && (!_GENERIC__))
2373 @node Ln, List, Lcomm, Pseudo Ops
2374 @section @code{.ln @var{line-number}}
2375 _fi__(_A29K__ && (!_GENERIC__))
2376 _if__(_AOUT__||_BOUT__)
2377 Tell @code{_AS__} to change the logical line number. @var{line-number} must be
2378 an absolute expression. The next line will have that logical line
2379 number. So any other statements on the current line (after a statement
2380 separator
2381 _if__(_GENERIC__)
2382 character)
2383 _fi__(_GENERIC__)
2384 _if__(!_GENERIC__)
2385 _if__(! (_A29K__||_H8__) )
2386 character @code{;})
2387 _fi__(! (_A29K__||_H8__) )
2388 _if__(_A29K__)
2389 character @samp{@@})
2390 _fi__(_A29K__)
2391 _if__(_H8__)
2392 character @samp{$})
2393 _fi__(_H8__)
2394 _fi__(!_GENERIC__)
2395 will be reported as on logical line number
2396 @var{line-number} @minus{} 1.
2397 One day this directive will be unsupported: it is used only
2398 for compatibility with existing assembler programs. @refill
2399
2400 _if__(_GENERIC__ && _A29K__)
2401 @emph{Warning:} In the AMD29K configuration of _AS__, this command is
2402 only available with the name @code{.ln}, rather than as either
2403 @code{.line} or @code{.ln}.
2404 _fi__(_GENERIC__ && _A29K__)
2405 _fi__(_AOUT__||_BOUT__)
2406 _if__(_COFF__)
2407
2408 Even though this is a directive associated with the @code{a.out} or
2409 @code{b.out} object-code formats, @code{_AS__} will still recognize it
2410 when producing COFF output, and will treat @samp{.line} as though it
2411 were the COFF @samp{.ln} @emph{if} it is found outside a
2412 @code{.def}/@code{.endef} pair.
2413
2414 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
2415 used by compilers to generate auxiliary symbol information for
2416 debugging.
2417 _fi__(_COFF__)
2418
2419 _if__(_AOUT__&&(_GENERIC__||!_A29K__))
2420 @node Ln, List, Line, Pseudo Ops
2421 @section @code{.ln @var{line-number}}
2422 @samp{.ln} is a synonym for @samp{.line}.
2423 _fi__(_AOUT__&&(_GENERIC__||!_A29K__))
2424 _if__(_COFF__&&!_AOUT__)
2425 @node Ln, List, Line, Pseudo Ops
2426 @section @code{.ln @var{line-number}}
2427 Tell @code{_AS__} to change the logical line number. @var{line-number}
2428 must be an absolute expression. The next line will have that logical
2429 line number, so any other statements on the current line (after a
2430 statement separator character @code{;}) will be reported as on logical
2431 line number @var{line-number} @minus{} 1.
2432 _if__(_BOUT__)
2433
2434 This directive is accepted, but ignored, when @code{_AS__} is configured for
2435 @code{b.out}; its effect is only associated with COFF output format.
2436 _fi__(_BOUT__)
2437 _fi__(_COFF__&&!_AOUT__)
2438
2439 @node List, Long, Ln, Pseudo Ops
2440 @section @code{.list} and related directives
2441 @code{_AS__} ignores the directives @code{.list}, @code{.nolist},
2442 @code{.eject}, @code{.lflags}, @code{.title}, @code{.sbttl}; however,
2443 they're accepted for compatibility with assemblers that use them.
2444
2445 @node Long, Lsym, List, Pseudo Ops
2446 @section @code{.long @var{expressions}}
2447 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
2448
2449 @node Lsym, Octa, Long, Pseudo Ops
2450 @section @code{.lsym @var{symbol}, @var{expression}}
2451 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
2452 the hash table, ensuring it cannot be referenced by name during the
2453 rest of the assembly. This sets the attributes of the symbol to be
2454 the same as the expression value:
2455 @smallexample
2456 @var{other} = @var{descriptor} = 0
2457 @var{type} = @r{(section of @var{expression})}
2458 @var{value} = @var{expression}
2459 @end smallexample
2460 @noindent
2461 The new symbol is not flagged as external.
2462
2463 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
2464 @node Octa, Org, Lsym, Pseudo Ops
2465 @section @code{.octa @var{bignums}}
2466 This directive expects zero or more bignums, separated by commas. For each
2467 bignum, it emits a 16-byte integer.
2468
2469 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
2470 hence @emph{octa}-word for 16 bytes.
2471
2472 @node Org, Quad, Octa, Pseudo Ops
2473 @section @code{.org @var{new-lc} , @var{fill}}
2474
2475 @code{.org} will advance the location counter of the current section to
2476 @var{new-lc}. @var{new-lc} is either an absolute expression or an
2477 expression with the same section as the current subsection. That is,
2478 you can't use @code{.org} to cross sections: if @var{new-lc} has the
2479 wrong section, the @code{.org} directive is ignored. To be compatible
2480 with former assemblers, if the section of @var{new-lc} is absolute,
2481 @code{_AS__} will issue a warning, then pretend the section of @var{new-lc}
2482 is the same as the current subsection.
2483
2484 @code{.org} may only increase the location counter, or leave it
2485 unchanged; you cannot use @code{.org} to move the location counter
2486 backwards.
2487
2488 @c double negative used below "not undefined" because this is a specific
2489 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
2490 @c section. pesch@cygnus.com 18feb91
2491 Because @code{_AS__} tries to assemble programs in one pass @var{new-lc}
2492 may not be undefined. If you really detest this restriction we eagerly await
2493 a chance to share your improved assembler.
2494
2495 Beware that the origin is relative to the start of the section, not
2496 to the start of the subsection. This is compatible with other
2497 people's assemblers.
2498
2499 When the location counter (of the current subsection) is advanced, the
2500 intervening bytes are filled with @var{fill} which should be an
2501 absolute expression. If the comma and @var{fill} are omitted,
2502 @var{fill} defaults to zero.
2503
2504 _if__(_COFF__||_BOUT__)
2505 @node Quad, Scl, Org, Pseudo Ops
2506 _fi__(_COFF__||_BOUT__)
2507 _if__(!(_COFF__||_BOUT__))
2508 @node Quad, Set, Org, Pseudo Ops
2509 _fi__(!(_COFF__||_BOUT__))
2510 @section @code{.quad @var{bignums}}
2511 @code{.quad} expects zero or more bignums, separated by commas. For
2512 each bignum, it emits
2513 _if__(_GENERIC__||(!_I960__))
2514 an 8-byte integer. If the bignum won't fit in 8
2515 bytes, it prints a warning message; and just takes the lowest order 8
2516 bytes of the bignum.@refill
2517
2518 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
2519 hence @emph{quad}-word for 8 bytes.
2520 _fi__(_GENERIC__||(!_I960__))
2521 _if__(_I960__&&(!_GENERIC__))
2522 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
2523 warning message; and just takes the lowest order 16 bytes of the
2524 bignum.@refill
2525 _fi__(_I960__&&(!_GENERIC__))
2526
2527 _if__(_COFF__||_BOUT__)
2528 _if__(!_COFF__)
2529 @node Scl, Set, Quad, Pseudo Ops
2530 _fi__(!_COFF__)
2531 _if__(_COFF__)
2532 @node Scl, Section, Quad, Pseudo Ops
2533 _fi__(_COFF__)
2534 @section @code{.scl @var{class}}
2535 Set the storage-class value for a symbol. This directive may only be
2536 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
2537 whether a symbol is static or external, or it may record further
2538 symbolic debugging information.
2539 _if__(_BOUT__)
2540
2541 The @samp{.scl} directive is primarily associated with COFF output; when
2542 configured to generate @code{b.out} output format, @code{_AS__} will
2543 accept this directive but ignore it.
2544 _fi__(_BOUT__)
2545 _fi__(_COFF__||_BOUT__)
2546
2547 _if__(_COFF__)
2548 @node Section, Set, Scl, Pseudo Ops
2549 @section @code{.section} @var{name}
2550 Assemble the following code into the COFF section @var{name}.
2551 @samp{.section .text} is equivalent to the @code{.text} directive;
2552 @samp{.section .data} is equivalent to the @code{.data} directive.
2553
2554 @node Set, Short, Section, Pseudo Ops
2555 _fi__(_COFF__)
2556 _if__(_BOUT__)
2557 @node Set, Short, Scl, Pseudo Ops
2558 _fi__(_BOUT__)
2559 _if__(!(_COFF__||_BOUT__))
2560 @node Set, Short, Quad, Pseudo Ops
2561 _fi__(!(_COFF__||_BOUT__))
2562 @section @code{.set @var{symbol}, @var{expression}}
2563
2564 This directive sets the value of @var{symbol} to @var{expression}. This
2565 will change @var{symbol}'s value and type to conform to
2566 @var{expression}. If @var{symbol} was flagged as external, it remains
2567 flagged. (@xref{Symbol Attributes}.)
2568
2569 You may @code{.set} a symbol many times in the same assembly.
2570 If the expression's section is unknowable during pass 1, a second
2571 pass over the source program will be forced. The second pass is
2572 currently not implemented. @code{_AS__} will abort with an error
2573 message if one is required.
2574
2575 If you @code{.set} a global symbol, the value stored in the object
2576 file is the last value stored into it.
2577
2578 @node Short, Single, Set, Pseudo Ops
2579 @section @code{.short @var{expressions}}
2580 _if__(_GENERIC__ || _W16__)
2581 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
2582 _if__(_W32__)
2583 In some configurations, however, @code{.short} and @code{.word} generate
2584 numbers of different lengths; @pxref{_MACH_DEP__}.
2585 _fi__(_W32__)
2586 _fi__(_GENERIC__|| _W16__)
2587 _if__((!_GENERIC__) && _W32__)
2588 This expects zero or more @var{expressions}, and emits
2589 a 16 bit number for each.
2590 _fi__((!_GENERIC__) && _W32__)
2591 _if__(_COFF__||_BOUT__)
2592 @node Single, Size, Short, Pseudo Ops
2593 _fi__(_COFF__||_BOUT__)
2594 _if__(!(_COFF__||_BOUT__))
2595 @node Single, Space, Short, Pseudo Ops
2596 _fi__(!(_COFF__||_BOUT__))
2597 @section @code{.single @var{flonums}}
2598 This directive assembles zero or more flonums, separated by commas. It
2599 has the same effect as @code{.float}.
2600 _if__(_GENERIC__)
2601 The exact kind of floating point numbers emitted depends on how
2602 @code{_AS__} is configured. @xref{_MACH_DEP__}.
2603 _fi__(_GENERIC__)
2604 _if__((!_GENERIC__) && _IEEEFLOAT__)
2605 On the _HOST__ family, @code{.single} emits 32-bit floating point
2606 numbers in IEEE format.
2607 _fi__((!_GENERIC__) && _IEEEFLOAT__)
2608
2609 _if__(_COFF__||_BOUT__)
2610 @node Size, Space, Single, Pseudo Ops
2611 @section @code{.size}
2612 This directive is generated by compilers to include auxiliary debugging
2613 information in the symbol table. It is only permitted inside
2614 @code{.def}/@code{.endef} pairs.
2615 _if__(_BOUT__)
2616
2617 @samp{.size} is only meaningful when generating COFF format output; when
2618 @code{_AS__} is generating @code{b.out}, it accepts this directive but
2619 ignores it.
2620 _fi__(_BOUT__)
2621 _fi__(_COFF__||_BOUT__)
2622
2623 _if__(_H8__)
2624 @node Space, Tag, Size, Pseudo Ops
2625 _fi__(_H8__)
2626 _if__(!_H8__)
2627 _if__(_COFF__||_BOUT__)
2628 @node Space, Stab, Size, Pseudo Ops
2629 _fi__(_COFF__||_BOUT__)
2630 _if__(!(_COFF__||_BOUT__))
2631 @node Space, Stab, Single, Pseudo Ops
2632 _fi__(!(_COFF__||_BOUT__))
2633 _fi__(!_H8__)
2634 _if__(_GENERIC__ || !_A29K__)
2635 @section @code{.space @var{size} , @var{fill}}
2636 This directive emits @var{size} bytes, each of value @var{fill}. Both
2637 @var{size} and @var{fill} are absolute expressions. If the comma
2638 and @var{fill} are omitted, @var{fill} is assumed to be zero.
2639 _fi__(_GENERIC__ || !_A29K__)
2640
2641 _if__(_A29K__)
2642 @section @code{.space}
2643 On the AMD 29K, this directive is ignored; it is accepted for
2644 compatibility with other AMD 29K assemblers.
2645
2646 @quotation
2647 @emph{Warning:} In other versions of the GNU assembler, the directive
2648 @code{.space} has the effect of @code{.block} @xref{_MACH_DEP__}.
2649 @end quotation
2650 _fi__(_A29K__)
2651
2652 _if__(_GENERIC__||!_H8__)
2653 _if__(_AOUT__||_BOUT__||_COFF__)
2654 _if__(_COFF__||_BOUT__)
2655 @node Stab, Tag, Space, Pseudo Ops
2656 _fi__(_COFF__||_BOUT__)
2657 _if__(!(_COFF__||_BOUT__))
2658 @node Stab, Text, Space, Pseudo Ops
2659 _fi__(!(_COFF__||_BOUT__))
2660 @section @code{.stabd, .stabn, .stabs}
2661 There are three directives that begin @samp{.stab}.
2662 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
2663 The symbols are not entered in the @code{_AS__} hash table: they
2664 cannot be referenced elsewhere in the source file.
2665 Up to five fields are required:
2666 @table @var
2667 @item string
2668 This is the symbol's name. It may contain any character except @samp{\000},
2669 so is more general than ordinary symbol names. Some debuggers used to
2670 code arbitrarily complex structures into symbol names using this field.
2671 @item type
2672 An absolute expression. The symbol's type is set to the low 8
2673 bits of this expression.
2674 Any bit pattern is permitted, but @code{_LD__} and debuggers will choke on
2675 silly bit patterns.
2676 @item other
2677 An absolute expression.
2678 The symbol's ``other'' attribute is set to the low 8 bits of this expression.
2679 @item desc
2680 An absolute expression.
2681 The symbol's descriptor is set to the low 16 bits of this expression.
2682 @item value
2683 An absolute expression which becomes the symbol's value.
2684 @end table
2685
2686 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
2687 or @code{.stabs} statement, the symbol has probably already been created
2688 and you will get a half-formed symbol in your object file. This is
2689 compatible with earlier assemblers!
2690
2691 @table @code
2692 @item .stabd @var{type} , @var{other} , @var{desc}
2693
2694 The ``name'' of the symbol generated is not even an empty string.
2695 It is a null pointer, for compatibility. Older assemblers used a
2696 null pointer so they didn't waste space in object files with empty
2697 strings.
2698
2699 The symbol's value is set to the location counter,
2700 relocatably. When your program is linked, the value of this symbol
2701 will be where the location counter was when the @code{.stabd} was
2702 assembled.
2703
2704 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
2705
2706 The name of the symbol is set to the empty string @code{""}.
2707
2708 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
2709
2710 All five fields are specified.
2711 @end table
2712 _fi__(_AOUT__||_BOUT__||_COFF__)
2713 _fi__(_GENERIC__||!_H8__)
2714
2715 _if__(_COFF__||_BOUT__)
2716 _if__(!_H8__)
2717 @node Tag, Text, Stab, Pseudo Ops
2718 _fi__(!_H8__)
2719 _if__(_H8__)
2720 @node Tag, Text, Space, Pseudo Ops
2721 _fi__(_H8__)
2722 @section @code{.tag @var{structname}}
2723 This directive is generated by compilers to include auxiliary debugging
2724 information in the symbol table. It is only permitted inside
2725 @code{.def}/@code{.endef} pairs. Tags are used to link structure
2726 definitions in the symbol table with instances of those structures.
2727 _if__(_BOUT__)
2728
2729 @samp{.tag} is only used when generating COFF format output; when
2730 @code{_AS__} is generating @code{b.out}, it accepts this directive but
2731 ignores it.
2732 _fi__(_BOUT__)
2733 _fi__(_COFF__||_BOUT__)
2734
2735 _if__(_COFF__||_BOUT__)
2736 @node Text, Type, Tag, Pseudo Ops
2737 _fi__(_COFF__||_BOUT__)
2738 _if__(!(_COFF__||_BOUT__))
2739 @node Text, Word, Stab, Pseudo Ops
2740 _fi__(!(_COFF__||_BOUT__))
2741 @section @code{.text @var{subsection}}
2742 Tells @code{_AS__} to assemble the following statements onto the end of
2743 the text subsection numbered @var{subsection}, which is an absolute
2744 expression. If @var{subsection} is omitted, subsection number zero
2745 is used.
2746
2747 _if__(_COFF__||_BOUT__)
2748 @node Type, Val, Text, Pseudo Ops
2749 @section @code{.type @var{int}}
2750 This directive, permitted only within @code{.def}/@code{.endef} pairs,
2751 records the integer @var{int} as the type attribute of a symbol table entry.
2752 _if__(_BOUT__)
2753
2754 @samp{.type} is associated only with COFF format output; when
2755 @code{_AS__} is configured for @code{b.out} output, it accepts this
2756 directive but ignores it.
2757 _fi__(_BOUT__)
2758 _fi__(_COFF__||_BOUT__)
2759
2760 _if__(_COFF__||_BOUT__)
2761 @node Val, Word, Type, Pseudo Ops
2762 @section @code{.val @var{addr}}
2763 This directive, permitted only within @code{.def}/@code{.endef} pairs,
2764 records the address @var{addr} as the value attribute of a symbol table
2765 entry.
2766 _if__(_BOUT__)
2767
2768 @samp{.val} is used only for COFF output; when @code{_AS__} is
2769 configured for @code{b.out}, it accepts this directive but ignores it.
2770 _fi__(_BOUT__)
2771 _fi__(_COFF__||_BOUT__)
2772
2773 _if__(_COFF__||_BOUT__)
2774 @node Word, Deprecated, Val, Pseudo Ops
2775 _fi__(_COFF__||_BOUT__)
2776 _if__(!(_COFF__||_BOUT__))
2777 @node Word, Deprecated, Text, Pseudo Ops
2778 _fi__(!(_COFF__||_BOUT__))
2779 @section @code{.word @var{expressions}}
2780 This directive expects zero or more @var{expressions}, of any section,
2781 separated by commas.
2782 _if__((!_GENERIC__) && _W32__)
2783 For each expression, @code{_AS__} emits a 32-bit number.
2784 _fi__((!_GENERIC__) && _W32__)
2785 _if__((!_GENERIC__) && _W16__)
2786 For each expression, @code{_AS__} emits a 16-bit number.
2787 _fi__((!_GENERIC__) && _W16__)
2788
2789 _if__(_GENERIC__)
2790 The size of the number emitted, and its byte order,
2791 depends on what kind of computer will run the program.
2792 _fi__(_GENERIC__)
2793
2794 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
2795 @c happen---32-bit addressability, period; no long/short jumps.
2796 _if__(_GENERIC__ || _DIFFTABKLUG__)
2797 @quotation
2798 @emph{Warning: Special Treatment to support Compilers}
2799 @end quotation
2800
2801 _if__(_GENERIC__)
2802 Machines with a 32-bit address space, but that do less than 32-bit
2803 addressing, require the following special treatment. If the machine of
2804 interest to you does 32-bit addressing (or doesn't require it;
2805 @pxref{_MACH_DEP__}), you can ignore this issue.
2806
2807 _fi__(_GENERIC__)
2808 In order to assemble compiler output into something that will work,
2809 @code{_AS__} will occasionlly do strange things to @samp{.word} directives.
2810 Directives of the form @samp{.word sym1-sym2} are often emitted by
2811 compilers as part of jump tables. Therefore, when @code{_AS__} assembles a
2812 directive of the form @samp{.word sym1-sym2}, and the difference between
2813 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{_AS__} will
2814 create a @dfn{secondary jump table}, immediately before the next label.
2815 This secondary jump table will be preceded by a short-jump to the
2816 first byte after the secondary table. This short-jump prevents the flow
2817 of control from accidentally falling into the new table. Inside the
2818 table will be a long-jump to @code{sym2}. The original @samp{.word}
2819 will contain @code{sym1} minus the address of the long-jump to
2820 @code{sym2}.
2821
2822 If there were several occurrences of @samp{.word sym1-sym2} before the
2823 secondary jump table, all of them will be adjusted. If there was a
2824 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
2825 long-jump to @code{sym4} will be included in the secondary jump table,
2826 and the @code{.word} directives will be adjusted to contain @code{sym3}
2827 minus the address of the long-jump to @code{sym4}; and so on, for as many
2828 entries in the original jump table as necessary.
2829
2830 _if__(_INTERNALS__)
2831 @emph{This feature may be disabled by compiling @code{_AS__} with the
2832 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
2833 assembly language programmers.
2834 _fi__(_INTERNALS__)
2835 _fi__(_GENERIC__ || _DIFFTABKLUG__)
2836
2837 @node Deprecated, , Word, Pseudo Ops
2838 @section Deprecated Directives
2839 One day these directives won't work.
2840 They are included for compatibility with older assemblers.
2841 @table @t
2842 @item .abort
2843 @item .app-file
2844 @item .line
2845 @end table
2846
2847 @node _MACH_DEP__, Copying, Pseudo Ops, Top
2848 _if__(_GENERIC__)
2849 @chapter Machine Dependent Features
2850 @menu
2851 _if__(_VAX__)
2852 * Vax-Dependent:: VAX Dependent Features
2853 _fi__(_VAX__)
2854 _if__(_A29K__)
2855 * AMD29K-Dependent:: AMD 29K Dependent Features
2856 _fi__(_A29K__)
2857 _if__(_H8__)
2858 * H8-300-Dependent:: AMD 29K Dependent Features
2859 _fi__(_H8__)
2860 _if__(_I960__)
2861 * i960-Dependent:: Intel 80960 Dependent Features
2862 _fi__(_I960__)
2863 _if__(_M680X0__)
2864 * M68K-Dependent:: M680x0 Dependent Features
2865 _fi__(_M680X0__)
2866 _if__(_SPARC__)
2867 * Sparc-Dependent:: SPARC Dependent Features
2868 _fi__(_SPARC__)
2869 _if__(_I80386__)
2870 * i386-Dependent:: 80386 Dependent Features
2871 _fi__(_I80386__)
2872 @end menu
2873
2874 _fi__(_GENERIC__)
2875 _if__(_VAX__)
2876 _if__(_GENERIC__)
2877 @node Vax-Dependent, AMD29K-Dependent, Machine Dependent, Machine Dependent
2878 _fi__(_GENERIC__)
2879 _CHAPSEC__(0+_GENERIC__) VAX Dependent Features
2880 @menu
2881 * Vax-Opts:: VAX Command-Line Options
2882 * VAX-float:: VAX Floating Point
2883 * VAX-directives:: Vax Machine Directives
2884 * VAX-opcodes:: VAX Opcodes
2885 * VAX-branch:: VAX Branch Improvement
2886 * VAX-operands:: VAX Operands
2887 * VAX-no:: Not Supported on VAX
2888 @end menu
2889
2890 @node Vax-Opts, VAX-float, Vax-Dependent, Vax-Dependent
2891 _CHAPSEC__(1+_GENERIC__) VAX Command-Line Options
2892
2893 The Vax version of @code{_AS__} accepts any of the following options,
2894 gives a warning message that the option was ignored and proceeds.
2895 These options are for compatibility with scripts designed for other
2896 people's assemblers.
2897
2898 @table @asis
2899 @item @kbd{-D} (Debug)
2900 @itemx @kbd{-S} (Symbol Table)
2901 @itemx @kbd{-T} (Token Trace)
2902 These are obsolete options used to debug old assemblers.
2903
2904 @item @kbd{-d} (Displacement size for JUMPs)
2905 This option expects a number following the @kbd{-d}. Like options
2906 that expect filenames, the number may immediately follow the
2907 @kbd{-d} (old standard) or constitute the whole of the command line
2908 argument that follows @kbd{-d} (GNU standard).
2909
2910 @item @kbd{-V} (Virtualize Interpass Temporary File)
2911 Some other assemblers use a temporary file. This option
2912 commanded them to keep the information in active memory rather
2913 than in a disk file. @code{_AS__} always does this, so this
2914 option is redundant.
2915
2916 @item @kbd{-J} (JUMPify Longer Branches)
2917 Many 32-bit computers permit a variety of branch instructions
2918 to do the same job. Some of these instructions are short (and
2919 fast) but have a limited range; others are long (and slow) but
2920 can branch anywhere in virtual memory. Often there are 3
2921 flavors of branch: short, medium and long. Some other
2922 assemblers would emit short and medium branches, unless told by
2923 this option to emit short and long branches.
2924
2925 @item @kbd{-t} (Temporary File Directory)
2926 Some other assemblers may use a temporary file, and this option
2927 takes a filename being the directory to site the temporary
2928 file. @code{_AS__} does not use a temporary disk file, so this
2929 option makes no difference. @kbd{-t} needs exactly one
2930 filename.
2931 @end table
2932
2933 The Vax version of the assembler accepts two options when
2934 compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
2935 @kbd{-h} option prevents @code{_AS__} from modifying the
2936 symbol-table entries for symbols that contain lowercase
2937 characters (I think). The @kbd{-+} option causes @code{_AS__} to
2938 print warning messages if the FILENAME part of the object file,
2939 or any symbol name is larger than 31 characters. The @kbd{-+}
2940 option also insertes some code following the @samp{_main}
2941 symbol so that the object file will be compatible with Vax-11
2942 "C".
2943
2944 @node VAX-float, VAX-directives, Vax-Opts, Vax-Dependent
2945 _CHAPSEC__(1+_GENERIC__) VAX Floating Point
2946 Conversion of flonums to floating point is correct, and
2947 compatible with previous assemblers. Rounding is
2948 towards zero if the remainder is exactly half the least significant bit.
2949
2950 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
2951 are understood.
2952
2953 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
2954 are rendered correctly. Again, rounding is towards zero in the
2955 boundary case.
2956
2957 The @code{.float} directive produces @code{f} format numbers.
2958 The @code{.double} directive produces @code{d} format numbers.
2959
2960 @node VAX-directives, VAX-opcodes, VAX-float, Vax-Dependent
2961 _CHAPSEC__(1+_GENERIC__) Vax Machine Directives
2962 The Vax version of the assembler supports four directives for
2963 generating Vax floating point constants. They are described in the
2964 table below.
2965
2966 @table @code
2967 @item .dfloat
2968 This expects zero or more flonums, separated by commas, and
2969 assembles Vax @code{d} format 64-bit floating point constants.
2970
2971 @item .ffloat
2972 This expects zero or more flonums, separated by commas, and
2973 assembles Vax @code{f} format 32-bit floating point constants.
2974
2975 @item .gfloat
2976 This expects zero or more flonums, separated by commas, and
2977 assembles Vax @code{g} format 64-bit floating point constants.
2978
2979 @item .hfloat
2980 This expects zero or more flonums, separated by commas, and
2981 assembles Vax @code{h} format 128-bit floating point constants.
2982
2983 @end table
2984
2985 @node VAX-opcodes, VAX-branch, VAX-directives, Vax-Dependent
2986 _CHAPSEC__(1+_GENERIC__) VAX Opcodes
2987 All DEC mnemonics are supported. Beware that @code{case@dots{}}
2988 instructions have exactly 3 operands. The dispatch table that
2989 follows the @code{case@dots{}} instruction should be made with
2990 @code{.word} statements. This is compatible with all unix
2991 assemblers we know of.
2992
2993 @node VAX-branch, VAX-operands, VAX-opcodes, Vax-Dependent
2994 _CHAPSEC__(1+_GENERIC__) VAX Branch Improvement
2995 Certain pseudo opcodes are permitted. They are for branch
2996 instructions. They expand to the shortest branch instruction that
2997 will reach the target. Generally these mnemonics are made by
2998 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
2999 This feature is included both for compatibility and to help
3000 compilers. If you don't need this feature, don't use these
3001 opcodes. Here are the mnemonics, and the code they can expand into.
3002
3003 @table @code
3004 @item jbsb
3005 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
3006 @table @asis
3007 @item (byte displacement)
3008 @kbd{bsbb @dots{}}
3009 @item (word displacement)
3010 @kbd{bsbw @dots{}}
3011 @item (long displacement)
3012 @kbd{jsb @dots{}}
3013 @end table
3014 @item jbr
3015 @itemx jr
3016 Unconditional branch.
3017 @table @asis
3018 @item (byte displacement)
3019 @kbd{brb @dots{}}
3020 @item (word displacement)
3021 @kbd{brw @dots{}}
3022 @item (long displacement)
3023 @kbd{jmp @dots{}}
3024 @end table
3025 @item j@var{COND}
3026 @var{COND} may be any one of the conditional branches
3027 @code{neq nequ eql eqlu gtr geq lss gtru lequ vc vs gequ cc lssu cs}.
3028 @var{COND} may also be one of the bit tests
3029 @code{bs bc bss bcs bsc bcc bssi bcci lbs lbc}.
3030 @var{NOTCOND} is the opposite condition to @var{COND}.
3031 @table @asis
3032 @item (byte displacement)
3033 @kbd{b@var{COND} @dots{}}
3034 @item (word displacement)
3035 @kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
3036 @item (long displacement)
3037 @kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
3038 @end table
3039 @item jacb@var{X}
3040 @var{X} may be one of @code{b d f g h l w}.
3041 @table @asis
3042 @item (word displacement)
3043 @kbd{@var{OPCODE} @dots{}}
3044 @item (long displacement)
3045 @example
3046 @var{OPCODE} @dots{}, foo ;
3047 brb bar ;
3048 foo: jmp @dots{} ;
3049 bar:
3050 @end example
3051 @end table
3052 @item jaob@var{YYY}
3053 @var{YYY} may be one of @code{lss leq}.
3054 @item jsob@var{ZZZ}
3055 @var{ZZZ} may be one of @code{geq gtr}.
3056 @table @asis
3057 @item (byte displacement)
3058 @kbd{@var{OPCODE} @dots{}}
3059 @item (word displacement)
3060 @example
3061 @var{OPCODE} @dots{}, foo ;
3062 brb bar ;
3063 foo: brw @var{destination} ;
3064 bar:
3065 @end example
3066 @item (long displacement)
3067 @example
3068 @var{OPCODE} @dots{}, foo ;
3069 brb bar ;
3070 foo: jmp @var{destination} ;
3071 bar:
3072 @end example
3073 @end table
3074 @item aobleq
3075 @itemx aoblss
3076 @itemx sobgeq
3077 @itemx sobgtr
3078 @table @asis
3079 @item (byte displacement)
3080 @kbd{@var{OPCODE} @dots{}}
3081 @item (word displacement)
3082 @example
3083 @var{OPCODE} @dots{}, foo ;
3084 brb bar ;
3085 foo: brw @var{destination} ;
3086 bar:
3087 @end example
3088 @item (long displacement)
3089 @example
3090 @var{OPCODE} @dots{}, foo ;
3091 brb bar ;
3092 foo: jmp @var{destination} ;
3093 bar:
3094 @end example
3095 @end table
3096 @end table
3097
3098 @node VAX-operands, VAX-no, VAX-branch, Vax-Dependent
3099 _CHAPSEC__(1+_GENERIC__) VAX Operands
3100 The immediate character is @samp{$} for Unix compatibility, not
3101 @samp{#} as DEC writes it.
3102
3103 The indirect character is @samp{*} for Unix compatibility, not
3104 @samp{@@} as DEC writes it.
3105
3106 The displacement sizing character is @samp{`} (an accent grave) for
3107 Unix compatibility, not @samp{^} as DEC writes it. The letter
3108 preceding @samp{`} may have either case. @samp{G} is not
3109 understood, but all other letters (@code{b i l s w}) are understood.
3110
3111 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
3112 pc}. Any case of letters will do.
3113
3114 For instance
3115 @smallexample
3116 tstb *w`$4(r5)
3117 @end smallexample
3118
3119 Any expression is permitted in an operand. Operands are comma
3120 separated.
3121
3122 @c There is some bug to do with recognizing expressions
3123 @c in operands, but I forget what it is. It is
3124 @c a syntax clash because () is used as an address mode
3125 @c and to encapsulate sub-expressions.
3126
3127 @node VAX-no, , VAX-operands, Vax-Dependent
3128 _CHAPSEC__(1+_GENERIC__) Not Supported on VAX
3129 Vax bit fields can not be assembled with @code{_AS__}. Someone
3130 can add the required code if they really need it.
3131
3132 _fi__(_VAX__)
3133 _if__(_A29K__)
3134 _if__(_GENERIC__)
3135 @node AMD29K-Dependent, H8-300-Dependent, Vax-Dependent, Machine Dependent
3136 _fi__(_GENERIC__)
3137 _CHAPSEC__(0+_GENERIC__) AMD 29K Dependent Features
3138 @menu
3139 * AMD29K Options:: Options
3140 * AMD29K Syntax:: Syntax
3141 * AMD29K Floating Point:: Floating Point
3142 * AMD29K Directives:: AMD 29K Machine Directives
3143 * AMD29K Opcodes:: Opcodes
3144 @end menu
3145
3146 @node AMD29K Options, AMD29K Syntax, AMD29K-Dependent, AMD29K-Dependent
3147 _CHAPSEC__(1+_GENERIC__) Options
3148 @code{_AS__} has no additional command-line options for the AMD
3149 29K family.
3150
3151 @node AMD29K Syntax, AMD29K Floating Point, AMD29K Options, AMD29K-Dependent
3152 _CHAPSEC__(1+_GENERIC__) Syntax
3153 @menu
3154 * AMD29K-Chars:: Special Characters
3155 * AMD29K-Regs:: Register Names
3156 @end menu
3157
3158 @node AMD29K-Chars, AMD29K-Regs, AMD29K Syntax, AMD29K Syntax
3159 _CHAPSEC__(2+_GENERIC__) Special Characters
3160 @samp{;} is the line comment character.
3161
3162 @samp{@@} can be used instead of a newline to separate statements.
3163
3164 The character @samp{?} is permitted in identifiers (but may not begin
3165 an identifier).
3166
3167 @node AMD29K-Regs, , AMD29K-Chars, AMD29K Syntax
3168 _CHAPSEC__(2+_GENERIC__) Register Names
3169 General-purpose registers are represented by predefined symbols of the
3170 form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
3171 (for local registers), where @var{nnn} represents a number between
3172 @code{0} and @code{127}, written with no leading zeros. The leading
3173 letters may be in either upper or lower case; for example, @samp{gr13}
3174 and @samp{LR7} are both valid register names.
3175
3176 You may also refer to general-purpose registers by specifying the
3177 register number as the result of an expression (prefixed with @samp{%%}
3178 to flag the expression as a register number):
3179 @smallexample
3180 %%@var{expression}
3181 @end smallexample
3182 @noindent
3183 ---where @var{expression} must be an absolute expression evaluating to a
3184 number between @code{0} and @code{255}. The range [0, 127] refers to
3185 global registers, and the range [128, 255] to local registers.
3186
3187 In addition, @code{_AS__} understands the following protected
3188 special-purpose register names for the AMD 29K family:
3189
3190 @smallexample
3191 vab chd pc0
3192 ops chc pc1
3193 cps rbp pc2
3194 cfg tmc mmu
3195 cha tmr lru
3196 @end smallexample
3197
3198 These unprotected special-purpose register names are also recognized:
3199 @smallexample
3200 ipc alu fpe
3201 ipa bp inte
3202 ipb fc fps
3203 q cr exop
3204 @end smallexample
3205
3206 @node AMD29K Floating Point, AMD29K Directives, AMD29K Syntax, AMD29K-Dependent
3207 _CHAPSEC__(1+_GENERIC__) Floating Point
3208 The AMD 29K family uses IEEE floating-point numbers.
3209
3210 @node AMD29K Directives, AMD29K Opcodes, AMD29K Floating Point, AMD29K-Dependent
3211 _CHAPSEC__(1+_GENERIC__) AMD 29K Machine Directives
3212
3213 @table @code
3214 @item .block @var{size} , @var{fill}
3215 This directive emits @var{size} bytes, each of value @var{fill}. Both
3216 @var{size} and @var{fill} are absolute expressions. If the comma
3217 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3218
3219 In other versions of the GNU assembler, this directive is called
3220 @samp{.space}.
3221 @end table
3222
3223 @table @code
3224 @item .cputype
3225 This directive is ignored; it is accepted for compatibility with other
3226 AMD 29K assemblers.
3227
3228 @item .file
3229 This directive is ignored; it is accepted for compatibility with other
3230 AMD 29K assemblers.
3231
3232 @quotation
3233 @emph{Warning:} in other versions of the GNU assembler, @code{.file} is
3234 used for the directive called @code{.app-file} in the AMD 29K support.
3235 @end quotation
3236
3237 @item .line
3238 This directive is ignored; it is accepted for compatibility with other
3239 AMD 29K assemblers.
3240
3241 @item .reg @var{symbol}, @var{expression}
3242 @code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
3243
3244 @item .sect
3245 This directive is ignored; it is accepted for compatibility with other
3246 AMD 29K assemblers.
3247
3248 @item .use @var{section name}
3249 Establishes the section and subsection for the following code;
3250 @var{section name} may be one of @code{.text}, @code{.data},
3251 @code{.data1}, or @code{.lit}. With one of the first three @var{section
3252 name} options, @samp{.use} is equivalent to the machine directive
3253 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
3254 @samp{.data 200}.
3255 @end table
3256
3257 @node AMD29K Opcodes, , AMD29K Directives, AMD29K-Dependent
3258 _CHAPSEC__(1+_GENERIC__) Opcodes
3259 @code{_AS__} implements all the standard AMD 29K opcodes. No
3260 additional pseudo-instructions are needed on this family.
3261
3262 For information on the 29K machine instruction set, see @cite{Am29000
3263 User's Manual}, Advanced Micro Devices, Inc.
3264
3265 _fi__(_A29K__)
3266 _if__(_H8__)
3267 _if__(_GENERIC__)
3268 @node H8-300-Dependent, i960-Dependent, H8-300-Dependent, Machine Dependent
3269 _fi__(_GENERIC__)
3270 _CHAPSEC__(0+_GENERIC__) H8/300 Dependent Features
3271 @menu
3272 * H8-300 Options:: Options
3273 * H8-300 Syntax:: Syntax
3274 * H8-300 Floating Point:: Floating Point
3275 * H8-300 Directives:: H8/300 Machine Directives
3276 * H8-300 Opcodes:: Opcodes
3277 @end menu
3278
3279 @node H8-300 Options, H8-300 Syntax, H8-300-Dependent, H8-300-Dependent
3280 _CHAPSEC__(1+_GENERIC__) Options
3281 @code{_AS__} has no additional command-line options for the Hitachi
3282 H8/300 family.
3283
3284 @node H8-300 Syntax, H8-300 Floating Point, H8-300 Options, H8-300-Dependent
3285 _CHAPSEC__(1+_GENERIC__) Syntax
3286 @menu
3287 * H8-300-Chars:: Special Characters
3288 * H8-300-Regs:: Register Names
3289 * H8-300-Addressing:: Addressing Modes
3290 @end menu
3291
3292 @node H8-300-Chars, H8-300-Regs, H8-300 Syntax, H8-300 Syntax
3293 _CHAPSEC__(2+_GENERIC__) Special Characters
3294 @samp{;} is the line comment character.
3295
3296 @samp{$} can be used instead of a newline to separate statements.
3297 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
3298
3299 @node H8-300-Regs, H8-300-Addressing, H8-300-Chars, H8-300 Syntax
3300 _CHAPSEC__(2+_GENERIC__) Register Names
3301 You can use predefined symbols of the form @samp{r@var{n}h} and
3302 @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
3303 general-purpose registers. @var{n} is a digit from @samp{0} to
3304 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
3305 register names.
3306
3307 You can also use the eight predefined symbols @samp{r@var{n}} to refer
3308 to the H8/300 registers as 16-bit registers (you must use this form for
3309 addressing).
3310
3311 The two control registers are called @code{pc} (program counter; a
3312 16-bit register) and @code{ccr} (condition code register; an 8-bit
3313 register). @code{r7} is used as the stack pointer, and can also be
3314 called @code{sp}.
3315
3316 @node H8-300-Addressing, , H8-300-Regs, H8-300 Syntax
3317 _AS__ understands the following addressing modes for the H8/300:
3318 @table @code
3319 @c FIXME! verify metavars, descriptions in H8/300 addressing table
3320
3321 @item r@var{n}
3322 Register direct
3323
3324 @item @@r@var{n}
3325 @c MISSING METAVAR ABOVE??
3326 Register indirect
3327
3328 @item @@(@var{d}:16, r@var{n})
3329 Register indirect: 16-bit displacement @var{d} from register @var{n}.
3330 @code{_AS__} understands this notation but does not require it; if you don't
3331 specify the displacement size, @code{_AS__} supplies it from context.
3332
3333 @item @@r@var{n}+
3334 @c MISSING METAVAR ABOVE??
3335 Register indirect with post-increment
3336
3337 @item @@-r@var{n}
3338 @c MISSING METAVAR ABOVE??
3339 Register indirect with pre-decrement
3340
3341 @item @code{@@}@var{aa}
3342 @itemx @code{@@}@var{aa}:8
3343 @itemx @code{@@}@var{aa}:16
3344 Absolute address @code{aa}. @code{_AS__} understands the @samp{:8} or
3345 @samp{:16} notation (specifying 8-bit or 16-bit addresses) but does not
3346 require it; if you don't specify the address size, @code{_AS__}
3347 supplies it from context.
3348
3349 @item #@var{xx}
3350 @itemx #@var{xx}:8
3351 @itemx #@var{xx}:16
3352 Immediate data @var{xx}. @code{_AS__} understands the @samp{:8} or
3353 @samp{:16} notation (specifying 8-bit or 16-bit data) but does not
3354 require it; if you don't specify the data size, @code{_AS__}
3355 supplies it from context.
3356
3357 @item @code{@@}@code{@@}@var{aa}
3358 @itemx @code{@@}@code{@@}@var{aa}:8
3359 Memory indirect.
3360
3361 @c FIXME are these just examples of an H8/300 addressing language?
3362 @c ...what about:
3363 @c @(d:8,Rn) 8-bit reg indirect?
3364 @c @(d:16, PC) 16-bit pc-rel?
3365 @c @#xx:8 immediate indirect?
3366 @end table
3367
3368 @node H8-300 Floating Point, H8-300 Directives, H8-300 Syntax, H8-300-Dependent
3369 _CHAPSEC__(1+_GENERIC__) Floating Point
3370 The H8/300 family uses IEEE floating-point numbers.
3371
3372 @node H8-300 Directives, H8-300 Opcodes, H8-300 Floating Point, H8-300-Dependent
3373 _CHAPSEC__(1+_GENERIC__) H8/300 Machine Directives
3374 @code{_AS__} has no machine-dependent directives for the H8/300.
3375
3376 @node H8-300 Opcodes, , H8-300 Directives, H8-300-Dependent
3377 _CHAPSEC__(1+_GENERIC__) Opcodes
3378 @code{_AS__} implements all the standard H8/300 opcodes. No
3379 additional pseudo-instructions are needed on this family.
3380
3381 For information on the H8/300 machine instruction set, see @cite{H8/300
3382 Series Programming Manual} (Hitachi ADE--602--025).
3383
3384 _fi__(_H8__)
3385 _if__(_I960__)
3386 _if__(_GENERIC__)
3387 @node i960-Dependent, M68K-Dependent, H8-300-Dependent, Machine Dependent
3388 _fi__(_GENERIC__)
3389 _CHAPSEC__(0+_GENERIC__) Intel 80960 Dependent Features
3390 @menu
3391 * Options-i960:: i960 Command-line Options
3392 * Floating Point-i960:: Floating Point
3393 * Directives-i960:: i960 Machine Directives
3394 * Opcodes for i960:: i960 Opcodes
3395 @end menu
3396
3397 @c FIXME! Add Syntax sec with discussion of bitfields here, at least so
3398 @c long as they're not turned on for other machines than 960.
3399 @node Options-i960, Floating Point-i960, i960-Dependent, i960-Dependent
3400 _CHAPSEC__(1+_GENERIC__) i960 Command-line Options
3401 @table @code
3402
3403 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
3404 Select the 80960 architecture. Instructions or features not supported
3405 by the selected architecture cause fatal errors.
3406
3407 @samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
3408 @samp{-AMC}. Synonyms are provided for compatibility with other tools.
3409
3410 If none of these options is specified, @code{_AS__} will generate code for any
3411 instruction or feature that is supported by @emph{some} version of the
3412 960 (even if this means mixing architectures!). In principle,
3413 @code{_AS__} will attempt to deduce the minimal sufficient processor
3414 type if none is specified; depending on the object code format, the
3415 processor type may be recorded in the object file. If it is critical
3416 that the @code{_AS__} output match a specific architecture, specify that
3417 architecture explicitly.
3418
3419
3420 @item -b
3421 Add code to collect information about conditional branches taken, for
3422 later optimization using branch prediction bits. (The conditional branch
3423 instructions have branch prediction bits in the CA, CB, and CC
3424 architectures.) If @var{BR} represents a conditional branch instruction,
3425 the following represents the code generated by the assembler when
3426 @samp{-b} is specified:
3427
3428 @smallexample
3429 call @var{increment routine}
3430 .word 0 # pre-counter
3431 Label: @var{BR}
3432 call @var{increment routine}
3433 .word 0 # post-counter
3434 @end smallexample
3435
3436 The counter following a branch records the number of times that branch
3437 was @emph{not} taken; the differenc between the two counters is the
3438 number of times the branch @emph{was} taken.
3439
3440 A table of all such @code{Label}s is also generated, so that the
3441 external postprocessor @samp{gbr960} (supplied by Intel) can locate all
3442 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
3443 this is a local symbol to permit collecting statistics for many separate
3444 object files. The table is word aligned, and begins with a two-word
3445 header. The first word, initialized to 0, is used in maintaining linked
3446 lists of branch tables. The second word is a count of the number of
3447 entries in the table, which follow immediately: each is a word, pointing
3448 to one of the labels illustrated above.
3449
3450 @c TEXI2ROFF-KILL
3451 @ifinfo
3452 @c END TEXI2ROFF-KILL
3453 @example
3454 +------------+------------+------------+ ... +------------+
3455 | | | | | |
3456 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
3457 | | | | | |
3458 +------------+------------+------------+ ... +------------+
3459
3460 __BRANCH_TABLE__ layout
3461 @end example
3462 @c TEXI2ROFF-KILL
3463 @end ifinfo
3464 @tex
3465 \vskip 1pc
3466 \line{\leftskip=0pt\hskip\tableindent
3467 \boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
3468 *BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
3469 \centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
3470 @end tex
3471 @c END TEXI2ROFF-KILL
3472
3473 The first word of the header is used to locate multiple branch tables,
3474 since each object file may contain one. Normally the links are
3475 maintained with a call to an initialization routine, placed at the
3476 beginning of each function in the file. The GNU C compiler will
3477 generate these calls automatically when you give it a @samp{-b} option.
3478 For further details, see the documentation of @samp{gbr960}.
3479
3480 @item -norelax
3481 Normally, Compare-and-Branch instructions with targets that require
3482 displacements greater than 13 bits (or that have external targets) are
3483 replaced with the corresponding compare (or @samp{chkbit}) and branch
3484 instructions. You can use the @samp{-norelax} option to specify that
3485 @code{_AS__} should generate errors instead, if the target displacement
3486 is larger than 13 bits.
3487
3488 This option does not affect the Compare-and-Jump instructions; the code
3489 emitted for them is @emph{always} adjusted when necessary (depending on
3490 displacement size), regardless of whether you use @samp{-norelax}.
3491 @end table
3492
3493 @node Floating Point-i960, Directives-i960, Options-i960, i960-Dependent
3494 _CHAPSEC__(1+_GENERIC__) Floating Point
3495 @code{_AS__} generates IEEE floating-point numbers for the directives
3496 @samp{.float}, @samp{.double}, @samp{extended}, and @samp{.single}.
3497
3498 @node Directives-i960, Opcodes for i960, Floating Point-i960, i960-Dependent
3499 _CHAPSEC__(1+_GENERIC__) i960 Machine Directives
3500
3501 @table @code
3502 @item .bss @var{symbol}, @var{length}, @var{align}
3503 Reserve @var{length} bytes in the bss section for a local @var{symbol},
3504 aligned to the power of two specified by @var{align}. @var{length} and
3505 @var{align} must be positive absolute expressions. This directive
3506 differs from @samp{.lcomm} only in that it permits you to specify
3507 an alignment. @xref{Lcomm,,@code{.lcomm}}.
3508 @end table
3509
3510 @table @code
3511 @item .extended @var{flonums}
3512 @code{.extended} expects zero or more flonums, separated by commas; for
3513 each flonum, @samp{.extended} emits an IEEE extended-format (80-bit)
3514 floating-point number.
3515
3516 @item .leafproc @var{call-lab}, @var{bal-lab}
3517 You can use the @samp{.leafproc} directive in conjunction with the
3518 optimized @code{callj} instruction to enable faster calls of leaf
3519 procedures. If a procedure is known to call no other procedures, you
3520 may define an entry point that skips procedure prolog code (and that does
3521 not depend on system-supplied saved context), and declare it as the
3522 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
3523 entry point that goes through the normal prolog, you can specify that
3524 entry point as @var{call-lab}.
3525
3526 A @samp{.leafproc} declaration is meant for use in conjunction with the
3527 optimized call instruction @samp{callj}; the directive records the data
3528 needed later to choose between converting the @samp{callj} into a
3529 @code{bal} or a @code{call}.
3530
3531 @var{call-lab} is optional; if only one argument is present, or if the
3532 two arguments are identical, the single argument is assumed to be the
3533 @code{bal} entry point.
3534
3535 @item .sysproc @var{name}, @var{index}
3536 The @samp{.sysproc} directive defines a name for a system procedure.
3537 After you define it using @samp{.sysproc}, you can use @var{name} to
3538 refer to the system procedure identified by @var{index} when calling
3539 procedures with the optimized call instruction @samp{callj}.
3540
3541 Both arguments are required; @var{index} must be between 0 and 31
3542 (inclusive).
3543 @end table
3544
3545 @node Opcodes for i960, , Directives-i960, i960-Dependent
3546 _CHAPSEC__(1+_GENERIC__) i960 Opcodes
3547 All Intel 960 machine instructions are supported;
3548 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
3549 selecting the instruction subset for a particular 960
3550 architecture.@refill
3551
3552 Some opcodes are processed beyond simply emitting a single corresponding
3553 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
3554 instructions with target displacements larger than 13 bits.
3555
3556 @menu
3557 * callj-i960:: @code{callj}
3558 * Compare-and-branch-i960:: Compare-and-Branch
3559 @end menu
3560
3561 @node callj-i960, Compare-and-branch-i960, Opcodes for i960, Opcodes for i960
3562 _CHAPSEC__(2+_GENERIC__) @code{callj}
3563 You can write @code{callj} to have the assembler or the linker determine
3564 the most appropriate form of subroutine call: @samp{call},
3565 @samp{bal}, or @samp{calls}. If the assembly source contains
3566 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
3567 defining the operand---then @code{_AS__} will translate the
3568 @code{callj}; if not, it will simply emit the @code{callj}, leaving it
3569 for the linker to resolve.
3570
3571 @node Compare-and-branch-i960, , callj-i960, Opcodes for i960
3572 _CHAPSEC__(2+_GENERIC__) Compare-and-Branch
3573
3574 The 960 architectures provide combined Compare-and-Branch instructions
3575 that permit you to store the branch target in the lower 13 bits of the
3576 instruction word itself. However, if you specify a branch target far
3577 enough away that its address won't fit in 13 bits, the assembler can
3578 either issue an error, or convert your Compare-and-Branch instruction
3579 into separate instructions to do the compare and the branch.
3580
3581 Whether @code{_AS__} gives an error or expands the instruction depends
3582 on two choices you can make: whether you use the @samp{-norelax} option,
3583 and whether you use a ``Compare and Branch'' instruction or a ``Compare
3584 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
3585 expanded if necessary; the ``Branch'' instructions are expanded when
3586 necessary @emph{unless} you specify @code{-norelax}---in which case
3587 @code{_AS__} gives an error instead.
3588
3589 These are the Compare-and-Branch instructions, their ``Jump'' variants,
3590 and the instruction pairs they may expand into:
3591
3592 @c TEXI2ROFF-KILL
3593 @ifinfo
3594 @c END TEXI2ROFF-KILL
3595 @example
3596 Compare and
3597 Branch Jump Expanded to
3598 ------ ------ ------------
3599 bbc chkbit; bno
3600 bbs chkbit; bo
3601 cmpibe cmpije cmpi; be
3602 cmpibg cmpijg cmpi; bg
3603 cmpibge cmpijge cmpi; bge
3604 cmpibl cmpijl cmpi; bl
3605 cmpible cmpijle cmpi; ble
3606 cmpibno cmpijno cmpi; bno
3607 cmpibne cmpijne cmpi; bne
3608 cmpibo cmpijo cmpi; bo
3609 cmpobe cmpoje cmpo; be
3610 cmpobg cmpojg cmpo; bg
3611 cmpobge cmpojge cmpo; bge
3612 cmpobl cmpojl cmpo; bl
3613 cmpoble cmpojle cmpo; ble
3614 cmpobne cmpojne cmpo; bne
3615 @end example
3616 @c TEXI2ROFF-KILL
3617 @end ifinfo
3618 @tex
3619 \hskip\tableindent
3620 \halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
3621 \omit{\hfil\it Compare and\hfil}\span\omit&\cr
3622 {\it Branch}&{\it Jump}&{\it Expanded to}\cr
3623 bbc& & chkbit; bno\cr
3624 bbs& & chkbit; bo\cr
3625 cmpibe& cmpije& cmpi; be\cr
3626 cmpibg& cmpijg& cmpi; bg\cr
3627 cmpibge& cmpijge& cmpi; bge\cr
3628 cmpibl& cmpijl& cmpi; bl\cr
3629 cmpible& cmpijle& cmpi; ble\cr
3630 cmpibno& cmpijno& cmpi; bno\cr
3631 cmpibne& cmpijne& cmpi; bne\cr
3632 cmpibo& cmpijo& cmpi; bo\cr
3633 cmpobe& cmpoje& cmpo; be\cr
3634 cmpobg& cmpojg& cmpo; bg\cr
3635 cmpobge& cmpojge& cmpo; bge\cr
3636 cmpobl& cmpojl& cmpo; bl\cr
3637 cmpoble& cmpojle& cmpo; ble\cr
3638 cmpobne& cmpojne& cmpo; bne\cr}
3639 @end tex
3640 @c END TEXI2ROFF-KILL
3641 _fi__(_I960__)
3642
3643 _if__(_M680X0__)
3644 _if__(_GENERIC__)
3645 @c FIXME! node conds are only sufficient for m68k alone, all, and vintage
3646 _if__(_I960__)
3647 @node M68K-Dependent, Sparc-Dependent, i960-Dependent, Machine Dependent
3648 _fi__(_I960__)
3649 _if__(!_I960__)
3650 @node M68K-Dependent, Sparc-Dependent, Machine Dependent, Machine Dependent
3651 _fi__(!_I960__)
3652 _CHAPSEC__(0+_GENERIC__) M680x0 Dependent Features
3653 _fi__(_GENERIC__)
3654 @menu
3655 * M68K-Opts:: M680x0 Options
3656 * M68K-Syntax:: Syntax
3657 * M68K-Float:: Floating Point
3658 * M68K-Directives:: 680x0 Machine Directives
3659 * M68K-opcodes:: Opcodes
3660 @end menu
3661
3662 @node M68K-Opts, M68K-Syntax, M68K-Dependent, M68K-Dependent
3663 _CHAPSEC__(1+_GENERIC__) M680x0 Options
3664 The Motorola 680x0 version of @code{_AS__} has two machine dependent options.
3665 One shortens undefined references from 32 to 16 bits, while the
3666 other is used to tell @code{_AS__} what kind of machine it is
3667 assembling for.
3668
3669 You can use the @kbd{-l} option to shorten the size of references to
3670 undefined symbols. If the @kbd{-l} option is not given, references to
3671 undefined symbols will be a full long (32 bits) wide. (Since @code{_AS__}
3672 cannot know where these symbols will end up, @code{_AS__} can only allocate
3673 space for the linker to fill in later. Since @code{_AS__} doesn't know how
3674 far away these symbols will be, it allocates as much space as it can.)
3675 If this option is given, the references will only be one word wide (16
3676 bits). This may be useful if you want the object file to be as small as
3677 possible, and you know that the relevant symbols will be less than 17
3678 bits away.
3679
3680 The 680x0 version of @code{_AS__} is most frequently used to assemble
3681 programs for the Motorola MC68020 microprocessor. Occasionally it is
3682 used to assemble programs for the mostly similar, but slightly different
3683 MC68000 or MC68010 microprocessors. You can give @code{_AS__} the options
3684 @samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
3685 @samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
3686 target.
3687
3688 @node M68K-Syntax, M68K-Float, M68K-Opts, M68K-Dependent
3689 _CHAPSEC__(1+_GENERIC__) Syntax
3690
3691 The 680x0 version of @code{_AS__} uses syntax similar to the Sun assembler.
3692 Size modifiers are appended directly to the end of the opcode without an
3693 intervening period. For example, write @samp{movl} rather than
3694 @samp{move.l}.
3695
3696 _if__(_INTERNALS__)
3697 If @code{_AS__} is compiled with SUN_ASM_SYNTAX defined, it will also allow
3698 Sun-style local labels of the form @samp{1$} through @samp{$9}.
3699 _fi__(_INTERNALS__)
3700
3701 In the following table @dfn{apc} stands for any of the address
3702 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
3703 Program Counter (@samp{pc}), or the zero-address relative to the
3704 program counter (@samp{zpc}).
3705
3706 The following addressing modes are understood:
3707 @table @dfn
3708 @item Immediate
3709 @samp{#@var{digits}}
3710
3711 @item Data Register
3712 @samp{d0} through @samp{d7}
3713
3714 @item Address Register
3715 @samp{a0} through @samp{a7}
3716
3717 @item Address Register Indirect
3718 @samp{a0@@} through @samp{a7@@}
3719
3720 @item Address Register Postincrement
3721 @samp{a0@@+} through @samp{a7@@+}
3722
3723 @item Address Register Predecrement
3724 @samp{a0@@-} through @samp{a7@@-}
3725
3726 @item Indirect Plus Offset
3727 @samp{@var{apc}@@(@var{digits})}
3728
3729 @item Index
3730 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3731
3732 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
3733
3734 @item Postindex
3735 @samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3736
3737 or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
3738
3739 @item Preindex
3740 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3741
3742 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3743
3744 @item Memory Indirect
3745 @samp{@var{apc}@@(@var{digits})@@(@var{digits})}
3746
3747 @item Absolute
3748 @samp{@var{symbol}}, or @samp{@var{digits}}
3749 @ignore
3750 @c pesch@cygnus.com: gnu, rich concur the following needs careful
3751 @c research before documenting.
3752 , or either of the above followed
3753 by @samp{:b}, @samp{:w}, or @samp{:l}.
3754 @end ignore
3755 @end table
3756
3757 @node M68K-Float, M68K-Directives, M68K-Syntax, M68K-Dependent
3758 _CHAPSEC__(1+_GENERIC__) Floating Point
3759 The floating point code is not too well tested, and may have
3760 subtle bugs in it.
3761
3762 Packed decimal (P) format floating literals are not supported.
3763 Feel free to add the code!
3764
3765 The floating point formats generated by directives are these.
3766 @table @code
3767 @item .float
3768 @code{Single} precision floating point constants.
3769 @item .double
3770 @code{Double} precision floating point constants.
3771 @end table
3772
3773 There is no directive to produce regions of memory holding
3774 extended precision numbers, however they can be used as
3775 immediate operands to floating-point instructions. Adding a
3776 directive to create extended precision numbers would not be
3777 hard, but it has not yet seemed necessary.
3778
3779 @node M68K-Directives, M68K-opcodes, M68K-Float, M68K-Dependent
3780 _CHAPSEC__(1+_GENERIC__) 680x0 Machine Directives
3781 In order to be compatible with the Sun assembler the 680x0 assembler
3782 understands the following directives.
3783 @table @code
3784 @item .data1
3785 This directive is identical to a @code{.data 1} directive.
3786 @item .data2
3787 This directive is identical to a @code{.data 2} directive.
3788 @item .even
3789 This directive is identical to a @code{.align 1} directive.
3790 @c Is this true? does it work???
3791 @item .skip
3792 This directive is identical to a @code{.space} directive.
3793 @end table
3794
3795 @node M68K-opcodes, , M68K-Directives, M68K-Dependent
3796 _CHAPSEC__(1+_GENERIC__) Opcodes
3797 @c pesch@cygnus.com: I don't see any point in the following
3798 @c paragraph. Bugs are bugs; how does saying this
3799 @c help anyone?
3800 @ignore
3801 Danger: Several bugs have been found in the opcode table (and
3802 fixed). More bugs may exist. Be careful when using obscure
3803 instructions.
3804 @end ignore
3805
3806 @menu
3807 * M68K-Branch:: Branch Improvement
3808 * M68K-Chars:: Special Characters
3809 @end menu
3810
3811 @node M68K-Branch, M68K-Chars, M68K-opcodes, M68K-opcodes
3812 _CHAPSEC__(2+_GENERIC__) Branch Improvement
3813
3814 Certain pseudo opcodes are permitted for branch instructions.
3815 They expand to the shortest branch instruction that will reach the
3816 target. Generally these mnemonics are made by substituting @samp{j} for
3817 @samp{b} at the start of a Motorola mnemonic.
3818
3819 The following table summarizes the pseudo-operations. A @code{*} flags
3820 cases that are more fully described after the table:
3821
3822 @smallexample
3823 Displacement
3824 +---------------------------------------------------------
3825 | 68020 68000/10
3826 Pseudo-Op |BYTE WORD LONG LONG non-PC relative
3827 +---------------------------------------------------------
3828 jbsr |bsrs bsr bsrl jsr jsr
3829 jra |bras bra bral jmp jmp
3830 * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
3831 * dbXX |dbXX dbXX dbXX; bra; jmpl
3832 * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
3833
3834 XX: condition
3835 NX: negative of condition XX
3836
3837 @end smallexample
3838 @center @code{*}---see full description below
3839
3840 @table @code
3841 @item jbsr
3842 @itemx jra
3843 These are the simplest jump pseudo-operations; they always map to one
3844 particular machine instruction, depending on the displacement to the
3845 branch target.
3846
3847 @item j@var{XX}
3848 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
3849 where @var{XX} is a conditional branch or condition-code test. The full
3850 list of pseudo-ops in this family is:
3851 @smallexample
3852 jhi jls jcc jcs jne jeq jvc
3853 jvs jpl jmi jge jlt jgt jle
3854 @end smallexample
3855
3856 For the cases of non-PC relative displacements and long displacements on
3857 the 68000 or 68010, @code{_AS__} will issue a longer code fragment in terms of
3858 @var{NX}, the opposite condition to @var{XX}:
3859 @smallexample
3860 j@var{XX} foo
3861 @end smallexample
3862 gives
3863 @smallexample
3864 b@var{NX}s oof
3865 jmp foo
3866 oof:
3867 @end smallexample
3868
3869 @item db@var{XX}
3870 The full family of pseudo-operations covered here is
3871 @smallexample
3872 dbhi dbls dbcc dbcs dbne dbeq dbvc
3873 dbvs dbpl dbmi dbge dblt dbgt dble
3874 dbf dbra dbt
3875 @end smallexample
3876
3877 Other than for word and byte displacements, when the source reads
3878 @samp{db@var{XX} foo}, @code{_AS__} will emit
3879 @smallexample
3880 db@var{XX} oo1
3881 bra oo2
3882 oo1:jmpl foo
3883 oo2:
3884 @end smallexample
3885
3886 @item fj@var{XX}
3887 This family includes
3888 @smallexample
3889 fjne fjeq fjge fjlt fjgt fjle fjf
3890 fjt fjgl fjgle fjnge fjngl fjngle fjngt
3891 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
3892 fjor fjseq fjsf fjsne fjst fjueq fjuge
3893 fjugt fjule fjult fjun
3894 @end smallexample
3895
3896 For branch targets that are not PC relative, @code{_AS__} emits
3897 @smallexample
3898 fb@var{NX} oof
3899 jmp foo
3900 oof:
3901 @end smallexample
3902 when it encounters @samp{fj@var{XX} foo}.
3903
3904 @end table
3905
3906 @node M68K-Chars, , M68K-Branch, M68K-opcodes
3907 _CHAPSEC__(2+_GENERIC__) Special Characters
3908 The immediate character is @samp{#} for Sun compatibility. The
3909 line-comment character is @samp{|}. If a @samp{#} appears at the
3910 beginning of a line, it is treated as a comment unless it looks like
3911 @samp{# line file}, in which case it is treated normally.
3912
3913 _fi__(_M680X0__)
3914 _if__(0)
3915 @c pesch@cygnus.com: conditionalize on something other than 0 when filled in.
3916 @section 32x32
3917 @section Options
3918 The 32x32 version of @code{_AS__} accepts a @kbd{-m32032} option to
3919 specify thiat it is compiling for a 32032 processor, or a
3920 @kbd{-m32532} to specify that it is compiling for a 32532 option.
3921 The default (if neither is specified) is chosen when the assembler
3922 is compiled.
3923
3924 @subsection Syntax
3925 I don't know anything about the 32x32 syntax assembled by
3926 @code{_AS__}. Someone who undersands the processor (I've never seen
3927 one) and the possible syntaxes should write this section.
3928
3929 @subsection Floating Point
3930 The 32x32 uses IEEE floating point numbers, but @code{_AS__} will only
3931 create single or double precision values. I don't know if the 32x32
3932 understands extended precision numbers.
3933
3934 @subsection 32x32 Machine Directives
3935 The 32x32 has no machine dependent directives.
3936
3937 _fi__(0)
3938 _if__(_SPARC__)
3939 _if__(_GENERIC__)
3940 _if__(_I80386__&&_M680X0__)
3941 @node Sparc-Dependent, i386-Dependent, M68K-Dependent, Machine Dependent
3942 _fi__(_I80386__&&_M680X0__)
3943 _if__(_I80386__&&_I960__&&!_M680X0__)
3944 @node Sparc-Dependent, i386-Dependent, i960-Dependent, Machine Dependent
3945 _fi__(_I80386__&&_I960__&&!_M680X0__)
3946 _if__(_I80386__&&_A29K__&&(!_I960__)&&!_M680X0__)
3947 @node Sparc-Dependent, i386-Dependent, AMD29K-Dependent, Machine Dependent
3948 _fi__(_I80386__&&_A29K__&&(!_I960__)&&!_M680X0__)
3949 _if__(_I80386__&&_VAX__&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3950 @node Sparc-Dependent, i386-Dependent, Vax-Dependent, Machine Dependent
3951 _fi__(_I80386__&&_VAX__&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3952 _if__(_I80386__&&(!_VAX__)&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3953 @node Sparc-Dependent, i386-Dependent, Machine Dependent, Machine Dependent
3954 _fi__(_I80386__&&(!_VAX__)&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3955 _if__((!_I80386__)&&_M680X0__)
3956 @node Sparc-Dependent, , M68K-Dependent, Machine Dependent
3957 _fi__((!_I80386__)&&_M680X0__)
3958 _if__((!_I80386__)&&_I960__&&!_M680X0__)
3959 @node Sparc-Dependent, , i960-Dependent, Machine Dependent
3960 _fi__((!_I80386__)&&_I960__&&!_M680X0__)
3961 _if__((!_I80386__)&&_A29K__&&(!_I960__)&&!_M680X0__)
3962 @node Sparc-Dependent, , AMD29K-Dependent, Machine Dependent
3963 _fi__((!_I80386__)&&_A29K__&&(!_I960__)&&!_M680X0__)
3964 _if__((!_I80386__)&&_VAX__&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3965 @node Sparc-Dependent, , Vax-Dependent, Machine Dependent
3966 _fi__((!_I80386__)&&_VAX__&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3967 _if__((!_I80386__)&&(!_VAX__)&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3968 @node Sparc-Dependent, , Machine Dependent, Machine Dependent
3969 _fi__((!_I80386__)&&(!_VAX__)&&(!_A29K__)&&(!_I960__)&&!_M680X0__)
3970 _fi__(_GENERIC__)
3971 _CHAPSEC__(0+_GENERIC__) SPARC Dependent Features
3972 @menu
3973 * Sparc-Opts:: Options
3974 * Sparc-Float:: Floating Point
3975 * Sparc-Directives:: Sparc Machine Directives
3976 @end menu
3977
3978 @node Sparc-Opts, Sparc-Float, Sparc-Dependent, Sparc-Dependent
3979 _CHAPSEC__(1+_GENERIC__) Options
3980 The Sparc has no machine dependent options.
3981
3982 @ignore
3983 @c FIXME: (sparc) Fill in "syntax" section!
3984 @c subsection syntax
3985 I don't know anything about Sparc syntax. Someone who does
3986 will have to write this section.
3987 @end ignore
3988
3989 @node Sparc-Float, Sparc-Directives, Sparc-Opts, Sparc-Dependent
3990 _CHAPSEC__(1+_GENERIC__) Floating Point
3991 The Sparc uses @sc{ieee} floating-point numbers.
3992
3993 @node Sparc-Directives, , Sparc-Float, Sparc-Dependent
3994 _CHAPSEC__(1+_GENERIC__) Sparc Machine Directives
3995 The Sparc version of @code{_AS__} supports the following additional
3996 machine directives:
3997
3998 @table @code
3999 @item .common
4000 This must be followed by a symbol name, a positive number, and
4001 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
4002 syntax is different.
4003
4004 @item .global
4005 This is functionally identical to @code{.globl}.
4006 @c FIXME: is this still really SPARC specific? (vintage/devo)
4007
4008 @item .half
4009 This is functionally identical to @code{.short}.
4010
4011 @item .proc
4012 This directive is ignored. Any text following it on the same
4013 line is also ignored.
4014
4015 @item .reserve
4016 This must be followed by a symbol name, a positive number, and
4017 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
4018 syntax is different.
4019
4020 @item .seg
4021 This must be followed by @code{"text"}, @code{"data"}, or
4022 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
4023 @code{.data 1}.
4024
4025 @item .skip
4026 This is functionally identical to the @code{.space} directive.
4027
4028 @item .word
4029 On the Sparc, the .word directive produces 32 bit values,
4030 instead of the 16 bit values it produces on many other machines.
4031
4032 @end table
4033
4034 _fi__(_SPARC__)
4035 _if__(_I80386__)
4036 _if__(_GENERIC__)
4037 @c FIXME! Conditionalize for all combinations in this section
4038 @node i386-Dependent, , Sparc-Dependent, Machine Dependent
4039 _fi__(_GENERIC__)
4040 _CHAPSEC__(0+_GENERIC__) 80386 Dependent Features
4041
4042 @menu
4043 * i386-Options:: Options
4044 * i386-Syntax:: AT&T Syntax versus Intel Syntax
4045 * i386-Opcodes:: Opcode Naming
4046 * i386-Regs:: Register Naming
4047 * i386-prefixes:: Opcode Prefixes
4048 * i386-Memory:: Memory References
4049 * i386-jumps:: Handling of Jump Instructions
4050 * i386-Float:: Floating Point
4051 * i386-Notes:: Notes
4052 @end menu
4053
4054 @node i386-Options, i386-Syntax, i386-Dependent, i386-Dependent
4055 _CHAPSEC__(1+_GENERIC__) Options
4056 The 80386 has no machine dependent options.
4057
4058 @node i386-Syntax, i386-Opcodes, i386-Options, i386-Dependent
4059 _CHAPSEC__(1+_GENERIC__) AT&T Syntax versus Intel Syntax
4060 In order to maintain compatibility with the output of @code{_GCC__},
4061 @code{_AS__} supports AT&T System V/386 assembler syntax. This is quite
4062 different from Intel syntax. We mention these differences because
4063 almost all 80386 documents used only Intel syntax. Notable differences
4064 between the two syntaxes are:
4065 @itemize @bullet
4066 @item
4067 AT&T immediate operands are preceded by @samp{$}; Intel immediate
4068 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
4069 AT&T register operands are preceded by @samp{%}; Intel register operands
4070 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
4071 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
4072
4073 @item
4074 AT&T and Intel syntax use the opposite order for source and destination
4075 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
4076 @samp{source, dest} convention is maintained for compatibility with
4077 previous Unix assemblers.
4078
4079 @item
4080 In AT&T syntax the size of memory operands is determined from the last
4081 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
4082 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
4083 memory references. Intel syntax accomplishes this by prefixes memory
4084 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
4085 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
4086 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
4087
4088 @item
4089 Immediate form long jumps and calls are
4090 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
4091 Intel syntax is
4092 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
4093 instruction
4094 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
4095 @samp{ret far @var{stack-adjust}}.
4096
4097 @item
4098 The AT&T assembler does not provide support for multiple section
4099 programs. Unix style systems expect all programs to be single sections.
4100 @end itemize
4101
4102 @node i386-Opcodes, i386-Regs, i386-Syntax, i386-Dependent
4103 _CHAPSEC__(1+_GENERIC__) Opcode Naming
4104 Opcode names are suffixed with one character modifiers which specify the
4105 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
4106 byte, word, and long operands. If no suffix is specified by an
4107 instruction and it contains no memory operands then @code{_AS__} tries to
4108 fill in the missing suffix based on the destination register operand
4109 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
4110 to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
4111 @samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
4112 assembler which assumes that a missing opcode suffix implies long
4113 operand size. (This incompatibility does not affect compiler output
4114 since compilers always explicitly specify the opcode suffix.)
4115
4116 Almost all opcodes have the same names in AT&T and Intel format. There
4117 are a few exceptions. The sign extend and zero extend instructions need
4118 two sizes to specify them. They need a size to sign/zero extend
4119 @emph{from} and a size to zero extend @emph{to}. This is accomplished
4120 by using two opcode suffixes in AT&T syntax. Base names for sign extend
4121 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
4122 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
4123 suffixes are tacked on to this base name, the @emph{from} suffix before
4124 the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
4125 ``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
4126 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
4127 and @samp{wl} (from word to long).
4128
4129 The Intel syntax conversion instructions
4130 @itemize @bullet
4131 @item
4132 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
4133 @item
4134 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
4135 @item
4136 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
4137 @item
4138 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
4139 @end itemize
4140 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
4141 AT&T naming. @code{_AS__} accepts either naming for these instructions.
4142
4143 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
4144 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
4145 convention.
4146
4147 @node i386-Regs, i386-prefixes, i386-Opcodes, i386-Dependent
4148 _CHAPSEC__(1+_GENERIC__) Register Naming
4149 Register operands are always prefixes with @samp{%}. The 80386 registers
4150 consist of
4151 @itemize @bullet
4152 @item
4153 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
4154 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
4155 frame pointer), and @samp{%esp} (the stack pointer).
4156
4157 @item
4158 the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
4159 @samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
4160
4161 @item
4162 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
4163 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
4164 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
4165 @samp{%cx}, and @samp{%dx})
4166
4167 @item
4168 the 6 section registers @samp{%cs} (code section), @samp{%ds}
4169 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
4170 and @samp{%gs}.
4171
4172 @item
4173 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
4174 @samp{%cr3}.
4175
4176 @item
4177 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
4178 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
4179
4180 @item
4181 the 2 test registers @samp{%tr6} and @samp{%tr7}.
4182
4183 @item
4184 the 8 floating point register stack @samp{%st} or equivalently
4185 @samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
4186 @samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
4187 @end itemize
4188
4189 @node i386-prefixes, i386-Memory, i386-Regs, i386-Dependent
4190 _CHAPSEC__(1+_GENERIC__) Opcode Prefixes
4191 Opcode prefixes are used to modify the following opcode. They are used
4192 to repeat string instructions, to provide section overrides, to perform
4193 bus lock operations, and to give operand and address size (16-bit
4194 operands are specified in an instruction by prefixing what would
4195 normally be 32-bit operands with a ``operand size'' opcode prefix).
4196 Opcode prefixes are usually given as single-line instructions with no
4197 operands, and must directly precede the instruction they act upon. For
4198 example, the @samp{scas} (scan string) instruction is repeated with:
4199 @smallexample
4200 repne
4201 scas
4202 @end smallexample
4203
4204 Here is a list of opcode prefixes:
4205 @itemize @bullet
4206 @item
4207 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
4208 @samp{fs}, @samp{gs}. These are automatically added by specifying
4209 using the @var{section}:@var{memory-operand} form for memory references.
4210
4211 @item
4212 Operand/Address size prefixes @samp{data16} and @samp{addr16}
4213 change 32-bit operands/addresses into 16-bit operands/addresses. Note
4214 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
4215 are not supported (yet).
4216
4217 @item
4218 The bus lock prefix @samp{lock} inhibits interrupts during
4219 execution of the instruction it precedes. (This is only valid with
4220 certain instructions; see a 80386 manual for details).
4221
4222 @item
4223 The wait for coprocessor prefix @samp{wait} waits for the
4224 coprocessor to complete the current instruction. This should never be
4225 needed for the 80386/80387 combination.
4226
4227 @item
4228 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
4229 to string instructions to make them repeat @samp{%ecx} times.
4230 @end itemize
4231
4232 @node i386-Memory, i386-jumps, i386-prefixes, i386-Dependent
4233 _CHAPSEC__(1+_GENERIC__) Memory References
4234 An Intel syntax indirect memory reference of the form
4235 @smallexample
4236 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
4237 @end smallexample
4238 is translated into the AT&T syntax
4239 @smallexample
4240 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
4241 @end smallexample
4242 where @var{base} and @var{index} are the optional 32-bit base and
4243 index registers, @var{disp} is the optional displacement, and
4244 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
4245 to calculate the address of the operand. If no @var{scale} is
4246 specified, @var{scale} is taken to be 1. @var{section} specifies the
4247 optional section register for the memory operand, and may override the
4248 default section register (see a 80386 manual for section register
4249 defaults). Note that section overrides in AT&T syntax @emph{must} have
4250 be preceded by a @samp{%}. If you specify a section override which
4251 coincides with the default section register, @code{_AS__} will @emph{not}
4252 output any section register override prefixes to assemble the given
4253 instruction. Thus, section overrides can be specified to emphasize which
4254 section register is used for a given memory operand.
4255
4256 Here are some examples of Intel and AT&T style memory references:
4257 @table @asis
4258
4259 @item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
4260 @var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
4261 missing, and the default section is used (@samp{%ss} for addressing with
4262 @samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
4263
4264 @item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
4265 @var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
4266 @samp{foo}. All other fields are missing. The section register here
4267 defaults to @samp{%ds}.
4268
4269 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
4270 This uses the value pointed to by @samp{foo} as a memory operand.
4271 Note that @var{base} and @var{index} are both missing, but there is only
4272 @emph{one} @samp{,}. This is a syntactic exception.
4273
4274 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
4275 This selects the contents of the variable @samp{foo} with section
4276 register @var{section} being @samp{%gs}.
4277
4278 @end table
4279
4280 Absolute (as opposed to PC relative) call and jump operands must be
4281 prefixed with @samp{*}. If no @samp{*} is specified, @code{_AS__} will
4282 always choose PC relative addressing for jump/call labels.
4283
4284 Any instruction that has a memory operand @emph{must} specify its size (byte,
4285 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
4286 respectively).
4287
4288 @node i386-jumps, i386-Float, i386-Memory, i386-Dependent
4289 _CHAPSEC__(1+_GENERIC__) Handling of Jump Instructions
4290 Jump instructions are always optimized to use the smallest possible
4291 displacements. This is accomplished by using byte (8-bit) displacement
4292 jumps whenever the target is sufficiently close. If a byte displacement
4293 is insufficient a long (32-bit) displacement is used. We do not support
4294 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
4295 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
4296 @samp{%eip} to 16 bits after the word displacement is added.
4297
4298 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
4299 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
4300 byte displacements, so that it is possible that use of these
4301 instructions (@code{_GCC__} does not use them) will cause the assembler to
4302 print an error message (and generate incorrect code). The AT&T 80386
4303 assembler tries to get around this problem by expanding @samp{jcxz foo} to
4304 @smallexample
4305 jcxz cx_zero
4306 jmp cx_nonzero
4307 cx_zero: jmp foo
4308 cx_nonzero:
4309 @end smallexample
4310
4311 @node i386-Float, i386-Notes, i386-jumps, i386-Dependent
4312 _CHAPSEC__(1+_GENERIC__) Floating Point
4313 All 80387 floating point types except packed BCD are supported.
4314 (BCD support may be added without much difficulty). These data
4315 types are 16-, 32-, and 64- bit integers, and single (32-bit),
4316 double (64-bit), and extended (80-bit) precision floating point.
4317 Each supported type has an opcode suffix and a constructor
4318 associated with it. Opcode suffixes specify operand's data
4319 types. Constructors build these data types into memory.
4320
4321 @itemize @bullet
4322 @item
4323 Floating point constructors are @samp{.float} or @samp{.single},
4324 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
4325 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
4326 @samp{t} stands for temporary real, and that the 80387 only supports
4327 this format via the @samp{fldt} (load temporary real to stack top) and
4328 @samp{fstpt} (store temporary real and pop stack) instructions.
4329
4330 @item
4331 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
4332 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
4333 opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
4334 (quad). As with the temporary real format the 64-bit @samp{q} format is
4335 only present in the @samp{fildq} (load quad integer to stack top) and
4336 @samp{fistpq} (store quad integer and pop stack) instructions.
4337 @end itemize
4338
4339 Register to register operations do not require opcode suffixes,
4340 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
4341
4342 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
4343 instructions are almost never needed (this is not the case for the
4344 80286/80287 and 8086/8087 combinations). Therefore, @code{_AS__} suppresses
4345 the @samp{fwait} instruction whenever it is implicitly selected by one
4346 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
4347 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
4348 instructions are made equivalent to @samp{f@dots{}} instructions. If
4349 @samp{fwait} is desired it must be explicitly coded.
4350
4351 @node i386-Notes, , i386-Float, i386-Dependent
4352 _CHAPSEC__(1+_GENERIC__) Notes
4353 There is some trickery concerning the @samp{mul} and @samp{imul}
4354 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
4355 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
4356 for @samp{imul}) can be output only in the one operand form. Thus,
4357 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
4358 the expanding multiply would clobber the @samp{%edx} register, and this
4359 would confuse @code{_GCC__} output. Use @samp{imul %ebx} to get the
4360 64-bit product in @samp{%edx:%eax}.
4361
4362 We have added a two operand form of @samp{imul} when the first operand
4363 is an immediate mode expression and the second operand is a register.
4364 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
4365 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
4366 $69, %eax, %eax}.
4367
4368 _fi__(_I80386__)
4369 _if__(0)
4370 @c pesch@cygnus.com: we ignore the following chapters, since internals are
4371 @c changing rapidly. These may need to be moved to another
4372 @c book anyhow, if we adopt the model of user/modifier
4373 @c books.
4374 @node Maintenance, Retargeting, _MACH_DEP__, Top
4375 @chapter Maintaining the Assembler
4376 [[this chapter is still being built]]
4377
4378 @section Design
4379 We had these goals, in descending priority:
4380 @table @b
4381 @item Accuracy.
4382 For every program composed by a compiler, @code{_AS__} should emit
4383 ``correct'' code. This leaves some latitude in choosing addressing
4384 modes, order of @code{relocation_info} structures in the object
4385 file, @emph{etc}.
4386
4387 @item Speed, for usual case.
4388 By far the most common use of @code{_AS__} will be assembling compiler
4389 emissions.
4390
4391 @item Upward compatibility for existing assembler code.
4392 Well @dots{} we don't support Vax bit fields but everything else
4393 seems to be upward compatible.
4394
4395 @item Readability.
4396 The code should be maintainable with few surprises. (JF: ha!)
4397
4398 @end table
4399
4400 We assumed that disk I/O was slow and expensive while memory was
4401 fast and access to memory was cheap. We expect the in-memory data
4402 structures to be less than 10 times the size of the emitted object
4403 file. (Contrast this with the C compiler where in-memory structures
4404 might be 100 times object file size!)
4405 This suggests:
4406 @itemize @bullet
4407 @item
4408 Try to read the source file from disk only one time. For other
4409 reasons, we keep large chunks of the source file in memory during
4410 assembly so this is not a problem. Also the assembly algorithm
4411 should only scan the source text once if the compiler composed the
4412 text according to a few simple rules.
4413 @item
4414 Emit the object code bytes only once. Don't store values and then
4415 backpatch later.
4416 @item
4417 Build the object file in memory and do direct writes to disk of
4418 large buffers.
4419 @end itemize
4420
4421 RMS suggested a one-pass algorithm which seems to work well. By not
4422 parsing text during a second pass considerable time is saved on
4423 large programs (@emph{e.g.} the sort of C program @code{yacc} would
4424 emit).
4425
4426 It happened that the data structures needed to emit relocation
4427 information to the object file were neatly subsumed into the data
4428 structures that do backpatching of addresses after pass 1.
4429
4430 Many of the functions began life as re-usable modules, loosely
4431 connected. RMS changed this to gain speed. For example, input
4432 parsing routines which used to work on pre-sanitized strings now
4433 must parse raw data. Hence they have to import knowledge of the
4434 assemblers' comment conventions @emph{etc}.
4435
4436 @section Deprecated Feature(?)s
4437 We have stopped supporting some features:
4438 @itemize @bullet
4439 @item
4440 @code{.org} statements must have @b{defined} expressions.
4441 @item
4442 Vax Bit fields (@kbd{:} operator) are entirely unsupported.
4443 @end itemize
4444
4445 It might be a good idea to not support these features in a future release:
4446 @itemize @bullet
4447 @item
4448 @kbd{#} should begin a comment, even in column 1.
4449 @item
4450 Why support the logical line & file concept any more?
4451 @item
4452 Subsections are a good candidate for flushing.
4453 Depends on which compilers need them I guess.
4454 @end itemize
4455
4456 @section Bugs, Ideas, Further Work
4457 Clearly the major improvement is DON'T USE A TEXT-READING
4458 ASSEMBLER for the back end of a compiler. It is much faster to
4459 interpret binary gobbledygook from a compiler's tables than to
4460 ask the compiler to write out human-readable code just so the
4461 assembler can parse it back to binary.
4462
4463 Assuming you use @code{_AS__} for human written programs: here are
4464 some ideas:
4465 @itemize @bullet
4466 @item
4467 Document (here) @code{APP}.
4468 @item
4469 Take advantage of knowing no spaces except after opcode
4470 to speed up @code{_AS__}. (Modify @code{app.c} to flush useless spaces:
4471 only keep space/tabs at begin of line or between 2
4472 symbols.)
4473 @item
4474 Put pointers in this documentation to @file{a.out} documentation.
4475 @item
4476 Split the assembler into parts so it can gobble direct binary
4477 from @emph{e.g.} @code{cc}. It is silly for@code{cc} to compose text
4478 just so @code{_AS__} can parse it back to binary.
4479 @item
4480 Rewrite hash functions: I want a more modular, faster library.
4481 @item
4482 Clean up LOTS of code.
4483 @item
4484 Include all the non-@file{.c} files in the maintenance chapter.
4485 @item
4486 Document flonums.
4487 @item
4488 Implement flonum short literals.
4489 @item
4490 Change all talk of expression operands to expression quantities,
4491 or perhaps to expression arguments.
4492 @item
4493 Implement pass 2.
4494 @item
4495 Whenever a @code{.text} or @code{.data} statement is seen, we close
4496 of the current frag with an imaginary @code{.fill 0}. This is
4497 because we only have one obstack for frags, and we can't grow new
4498 frags for a new subsection, then go back to the old subsection and
4499 append bytes to the old frag. All this nonsense goes away if we
4500 give each subsection its own obstack. It makes code simpler in
4501 about 10 places, but nobody has bothered to do it because C compiler
4502 output rarely changes subsections (compared to ending frags with
4503 relaxable addresses, which is common).
4504 @end itemize
4505
4506 @section Sources
4507 @c The following files in the @file{_AS__} directory
4508 @c are symbolic links to other files, of
4509 @c the same name, in a different directory.
4510 @c @itemize @bullet
4511 @c @item
4512 @c @file{atof_generic.c}
4513 @c @item
4514 @c @file{atof_vax.c}
4515 @c @item
4516 @c @file{flonum_const.c}
4517 @c @item
4518 @c @file{flonum_copy.c}
4519 @c @item
4520 @c @file{flonum_get.c}
4521 @c @item
4522 @c @file{flonum_multip.c}
4523 @c @item
4524 @c @file{flonum_normal.c}
4525 @c @item
4526 @c @file{flonum_print.c}
4527 @c @end itemize
4528
4529 Here is a list of the source files in the @file{_AS__} directory.
4530
4531 @table @file
4532 @item app.c
4533 This contains the pre-processing phase, which deletes comments,
4534 handles whitespace, etc. This was recently re-written, since app
4535 used to be a separate program, but RMS wanted it to be inline.
4536
4537 @item append.c
4538 This is a subroutine to append a string to another string returning a
4539 pointer just after the last @code{char} appended. (JF: All these
4540 little routines should probably all be put in one file.)
4541
4542 @item as.c
4543 Here you will find the main program of the assembler @code{_AS__}.
4544
4545 @item expr.c
4546 This is a branch office of @file{read.c}. This understands
4547 expressions, arguments. Inside @code{_AS__}, arguments are called
4548 (expression) @emph{operands}. This is confusing, because we also talk
4549 (elsewhere) about instruction @emph{operands}. Also, expression
4550 operands are called @emph{quantities} explicitly to avoid confusion
4551 with instruction operands. What a mess.
4552
4553 @item frags.c
4554 This implements the @b{frag} concept. Without frags, finding the
4555 right size for branch instructions would be a lot harder.
4556
4557 @item hash.c
4558 This contains the symbol table, opcode table @emph{etc.} hashing
4559 functions.
4560
4561 @item hex_value.c
4562 This is a table of values of digits, for use in atoi() type
4563 functions. Could probably be flushed by using calls to strtol(), or
4564 something similar.
4565
4566 @item input-file.c
4567 This contains Operating system dependent source file reading
4568 routines. Since error messages often say where we are in reading
4569 the source file, they live here too. Since @code{_AS__} is intended to
4570 run under GNU and Unix only, this might be worth flushing. Anyway,
4571 almost all C compilers support stdio.
4572
4573 @item input-scrub.c
4574 This deals with calling the pre-processor (if needed) and feeding the
4575 chunks back to the rest of the assembler the right way.
4576
4577 @item messages.c
4578 This contains operating system independent parts of fatal and
4579 warning message reporting. See @file{append.c} above.
4580
4581 @item output-file.c
4582 This contains operating system dependent functions that write an
4583 object file for @code{_AS__}. See @file{input-file.c} above.
4584
4585 @item read.c
4586 This implements all the directives of @code{_AS__}. This also deals
4587 with passing input lines to the machine dependent part of the
4588 assembler.
4589
4590 @item strstr.c
4591 This is a C library function that isn't in most C libraries yet.
4592 See @file{append.c} above.
4593
4594 @item subsegs.c
4595 This implements subsections.
4596
4597 @item symbols.c
4598 This implements symbols.
4599
4600 @item write.c
4601 This contains the code to perform relaxation, and to write out
4602 the object file. It is mostly operating system independent, but
4603 different OSes have different object file formats in any case.
4604
4605 @item xmalloc.c
4606 This implements @code{malloc()} or bust. See @file{append.c} above.
4607
4608 @item xrealloc.c
4609 This implements @code{realloc()} or bust. See @file{append.c} above.
4610
4611 @item atof-generic.c
4612 The following files were taken from a machine-independent subroutine
4613 library for manipulating floating point numbers and very large
4614 integers.
4615
4616 @file{atof-generic.c} turns a string into a flonum internal format
4617 floating-point number.
4618
4619 @item flonum-const.c
4620 This contains some potentially useful floating point numbers in
4621 flonum format.
4622
4623 @item flonum-copy.c
4624 This copies a flonum.
4625
4626 @item flonum-multip.c
4627 This multiplies two flonums together.
4628
4629 @item bignum-copy.c
4630 This copies a bignum.
4631
4632 @end table
4633
4634 Here is a table of all the machine-specific files (this includes
4635 both source and header files). Typically, there is a
4636 @var{machine}.c file, a @var{machine}-opcode.h file, and an
4637 atof-@var{machine}.c file. The @var{machine}-opcode.h file should
4638 be identical to the one used by GDB (which uses it for disassembly.)
4639
4640 @table @file
4641
4642 @item atof-ieee.c
4643 This contains code to turn a flonum into a ieee literal constant.
4644 This is used by tye 680x0, 32x32, sparc, and i386 versions of @code{_AS__}.
4645
4646 @item i386-opcode.h
4647 This is the opcode-table for the i386 version of the assembler.
4648
4649 @item i386.c
4650 This contains all the code for the i386 version of the assembler.
4651
4652 @item i386.h
4653 This defines constants and macros used by the i386 version of the assembler.
4654
4655 @item m-generic.h
4656 generic 68020 header file. To be linked to m68k.h on a
4657 non-sun3, non-hpux system.
4658
4659 @item m-sun2.h
4660 68010 header file for Sun2 workstations. Not well tested. To be linked
4661 to m68k.h on a sun2. (See also @samp{-DSUN_ASM_SYNTAX} in the
4662 @file{Makefile}.)
4663
4664 @item m-sun3.h
4665 68020 header file for Sun3 workstations. To be linked to m68k.h before
4666 compiling on a Sun3 system. (See also @samp{-DSUN_ASM_SYNTAX} in the
4667 @file{Makefile}.)
4668
4669 @item m-hpux.h
4670 68020 header file for a HPUX (system 5?) box. Which box, which
4671 version of HPUX, etc? I don't know.
4672
4673 @item m68k.h
4674 A hard- or symbolic- link to one of @file{m-generic.h},
4675 @file{m-hpux.h} or @file{m-sun3.h} depending on which kind of
4676 680x0 you are assembling for. (See also @samp{-DSUN_ASM_SYNTAX} in the
4677 @file{Makefile}.)
4678
4679 @item m68k-opcode.h
4680 Opcode table for 68020. This is now a link to the opcode table
4681 in the @code{GDB} source directory.
4682
4683 @item m68k.c
4684 All the mc680x0 code, in one huge, slow-to-compile file.
4685
4686 @item ns32k.c
4687 This contains the code for the ns32032/ns32532 version of the
4688 assembler.
4689
4690 @item ns32k-opcode.h
4691 This contains the opcode table for the ns32032/ns32532 version
4692 of the assembler.
4693
4694 @item vax-inst.h
4695 Vax specific file for describing Vax operands and other Vax-ish things.
4696
4697 @item vax-opcode.h
4698 Vax opcode table.
4699
4700 @item vax.c
4701 Vax specific parts of @code{_AS__}. Also includes the former files
4702 @file{vax-ins-parse.c}, @file{vax-reg-parse.c} and @file{vip-op.c}.
4703
4704 @item atof-vax.c
4705 Turns a flonum into a Vax constant.
4706
4707 @item vms.c
4708 This file contains the special code needed to put out a VMS
4709 style object file for the Vax.
4710
4711 @end table
4712
4713 Here is a list of the header files in the source directory.
4714 (Warning: This section may not be very accurate. I didn't
4715 write the header files; I just report them.) Also note that I
4716 think many of these header files could be cleaned up or
4717 eliminated.
4718
4719 @table @file
4720
4721 @item a.out.h
4722 This describes the structures used to create the binary header data
4723 inside the object file. Perhaps we should use the one in
4724 @file{/usr/include}?
4725
4726 @item as.h
4727 This defines all the globally useful things, and pulls in _0__<stdio.h>_1__
4728 and _0__<assert.h>_1__.
4729
4730 @item bignum.h
4731 This defines macros useful for dealing with bignums.
4732
4733 @item expr.h
4734 Structure and macros for dealing with expression()
4735
4736 @item flonum.h
4737 This defines the structure for dealing with floating point
4738 numbers. It #includes @file{bignum.h}.
4739
4740 @item frags.h
4741 This contains macro for appending a byte to the current frag.
4742
4743 @item hash.h
4744 Structures and function definitions for the hashing functions.
4745
4746 @item input-file.h
4747 Function headers for the input-file.c functions.
4748
4749 @item md.h
4750 structures and function headers for things defined in the
4751 machine dependent part of the assembler.
4752
4753 @item obstack.h
4754 This is the GNU systemwide include file for manipulating obstacks.
4755 Since nobody is running under real GNU yet, we include this file.
4756
4757 @item read.h
4758 Macros and function headers for reading in source files.
4759
4760 @item struct-symbol.h
4761 Structure definition and macros for dealing with the _AS__
4762 internal form of a symbol.
4763
4764 @item subsegs.h
4765 structure definition for dealing with the numbered subsections
4766 of the text and data sections.
4767
4768 @item symbols.h
4769 Macros and function headers for dealing with symbols.
4770
4771 @item write.h
4772 Structure for doing section fixups.
4773 @end table
4774
4775 @comment ~subsection Test Directory
4776 @comment (Note: The test directory seems to have disappeared somewhere
4777 @comment along the line. If you want it, you'll probably have to find a
4778 @comment REALLY OLD dump tape~dots{})
4779 @comment
4780 @comment The ~file{test/} directory is used for regression testing.
4781 @comment After you modify ~@code{_AS__}, you can get a quick go/nogo
4782 @comment confidence test by running the new ~@code{_AS__} over the source
4783 @comment files in this directory. You use a shell script ~file{test/do}.
4784 @comment
4785 @comment The tests in this suite are evolving. They are not comprehensive.
4786 @comment They have, however, caught hundreds of bugs early in the debugging
4787 @comment cycle of ~@code{_AS__}. Most test statements in this suite were naturally
4788 @comment selected: they were used to demonstrate actual ~@code{_AS__} bugs rather
4789 @comment than being written ~i{a prioi}.
4790 @comment
4791 @comment Another testing suggestion: over 30 bugs have been found simply by
4792 @comment running examples from this manual through ~@code{_AS__}.
4793 @comment Some examples in this manual are selected
4794 @comment to distinguish boundary conditions; they are good for testing ~@code{_AS__}.
4795 @comment
4796 @comment ~subsubsection Regression Testing
4797 @comment Each regression test involves assembling a file and comparing the
4798 @comment actual output of ~@code{_AS__} to ``known good'' output files. Both
4799 @comment the object file and the error/warning message file (stderr) are
4800 @comment inspected. Optionally the ~@code{_AS__} exit status may be checked.
4801 @comment Discrepencies are reported. Each discrepency means either that
4802 @comment you broke some part of ~@code{_AS__} or that the ``known good'' files
4803 @comment are now out of date and should be changed to reflect the new
4804 @comment definition of ``good''.
4805 @comment
4806 @comment Each regression test lives in its own directory, in a tree
4807 @comment rooted in the directory ~file{test/}. Each such directory
4808 @comment has a name ending in ~file{.ret}, where `ret' stands for
4809 @comment REgression Test. The ~file{.ret} ending allows ~code{find
4810 @comment (1)} to find all regression tests in the tree, without
4811 @comment needing to list them explicitly.
4812 @comment
4813 @comment Any ~file{.ret} directory must contain a file called
4814 @comment ~file{input} which is the source file to assemble. During
4815 @comment testing an object file ~file{output} is created, as well as
4816 @comment a file ~file{stdouterr} which contains the output to both
4817 @comment stderr and stderr. If there is a file ~file{output.good} in
4818 @comment the directory, and if ~file{output} contains exactly the
4819 @comment same data as ~file{output.good}, the file ~file{output} is
4820 @comment deleted. Likewise ~file{stdouterr} is removed if it exactly
4821 @comment matches a file ~file{stdouterr.good}. If file
4822 @comment ~file{status.good} is present, containing a decimal number
4823 @comment before a newline, the exit status of ~@code{_AS__} is compared
4824 @comment to this number. If the status numbers are not equal, a file
4825 @comment ~file{status} is written to the directory, containing the
4826 @comment actual status as a decimal number followed by newline.
4827 @comment
4828 @comment Should any of the ~file{*.good} files fail to match their corresponding
4829 @comment actual files, this is noted by a 1-line message on the screen during
4830 @comment the regression test, and you can use ~@code{find (1)} to find any
4831 @comment files named ~file{status}, ~file {output} or ~file{stdouterr}.
4832 @comment
4833 @node Retargeting, Copying, Maintenance, Top
4834 @chapter Teaching the Assembler about a New Machine
4835
4836 This chapter describes the steps required in order to make the
4837 assembler work with another machine's assembly language. This
4838 chapter is not complete, and only describes the steps in the
4839 broadest terms. You should look at the source for the
4840 currently supported machine in order to discover some of the
4841 details that aren't mentioned here.
4842
4843 You should create a new file called @file{@var{machine}.c}, and
4844 add the appropriate lines to the file @file{Makefile} so that
4845 you can compile your new version of the assembler. This should
4846 be straighforward; simply add lines similar to the ones there
4847 for the four current versions of the assembler.
4848
4849 If you want to be compatible with GDB, (and the current
4850 machine-dependent versions of the assembler), you should create
4851 a file called @file{@var{machine}-opcode.h} which should
4852 contain all the information about the names of the machine
4853 instructions, their opcodes, and what addressing modes they
4854 support. If you do this right, the assembler and GDB can share
4855 this file, and you'll only have to write it once. Note that
4856 while you're writing @code{_AS__}, you may want to use an
4857 independent program (if you have access to one), to make sure
4858 that @code{_AS__} is emitting the correct bytes. Since @code{_AS__}
4859 and @code{GDB} share the opcode table, an incorrect opcode
4860 table entry may make invalid bytes look OK when you disassemble
4861 them with @code{GDB}.
4862
4863 @section Functions You will Have to Write
4864
4865 Your file @file{@var{machine}.c} should contain definitions for
4866 the following functions and variables. It will need to include
4867 some header files in order to use some of the structures
4868 defined in the machine-independent part of the assembler. The
4869 needed header files are mentioned in the descriptions of the
4870 functions that will need them.
4871
4872 @table @code
4873
4874 @item long omagic;
4875 This long integer holds the value to place at the beginning of
4876 the @file{a.out} file. It is usually @samp{OMAGIC}, except on
4877 machines that store additional information in the magic-number.
4878
4879 @item char comment_chars[];
4880 This character array holds the values of the characters that
4881 start a comment anywhere in a line. Comments are stripped off
4882 automatically by the machine independent part of the
4883 assembler. Note that the @samp{/*} will always start a
4884 comment, and that only @samp{*/} will end a comment started by
4885 @samp{*/}.
4886
4887 @item char line_comment_chars[];
4888 This character array holds the values of the chars that start a
4889 comment only if they are the first (non-whitespace) character
4890 on a line. If the character @samp{#} does not appear in this
4891 list, you may get unexpected results. (Various
4892 machine-independent parts of the assembler treat the comments
4893 @samp{#APP} and @samp{#NO_APP} specially, and assume that lines
4894 that start with @samp{#} are comments.)
4895
4896 @item char EXP_CHARS[];
4897 This character array holds the letters that can separate the
4898 mantissa and the exponent of a floating point number. Typical
4899 values are @samp{e} and @samp{E}.
4900
4901 @item char FLT_CHARS[];
4902 This character array holds the letters that--when they appear
4903 immediately after a leading zero--indicate that a number is a
4904 floating-point number. (Sort of how 0x indicates that a
4905 hexadecimal number follows.)
4906
4907 @item pseudo_typeS md_pseudo_table[];
4908 (@var{pseudo_typeS} is defined in @file{md.h})
4909 This array contains a list of the machine_dependent directives
4910 the assembler must support. It contains the name of each
4911 pseudo op (Without the leading @samp{.}), a pointer to a
4912 function to be called when that directive is encountered, and
4913 an integer argument to be passed to that function.
4914
4915 @item void md_begin(void)
4916 This function is called as part of the assembler's
4917 initialization. It should do any initialization required by
4918 any of your other routines.
4919
4920 @item int md_parse_option(char **optionPTR, int *argcPTR, char ***argvPTR)
4921 This routine is called once for each option on the command line
4922 that the machine-independent part of @code{_AS__} does not
4923 understand. This function should return non-zero if the option
4924 pointed to by @var{optionPTR} is a valid option. If it is not
4925 a valid option, this routine should return zero. The variables
4926 @var{argcPTR} and @var{argvPTR} are provided in case the option
4927 requires a filename or something similar as an argument. If
4928 the option is multi-character, @var{optionPTR} should be
4929 advanced past the end of the option, otherwise every letter in
4930 the option will be treated as a separate single-character
4931 option.
4932
4933 @item void md_assemble(char *string)
4934 This routine is called for every machine-dependent
4935 non-directive line in the source file. It does all the real
4936 work involved in reading the opcode, parsing the operands,
4937 etc. @var{string} is a pointer to a null-terminated string,
4938 that comprises the input line, with all excess whitespace and
4939 comments removed.
4940
4941 @item void md_number_to_chars(char *outputPTR,long value,int nbytes)
4942 This routine is called to turn a C long int, short int, or char
4943 into the series of bytes that represents that number on the
4944 target machine. @var{outputPTR} points to an array where the
4945 result should be stored; @var{value} is the value to store; and
4946 @var{nbytes} is the number of bytes in 'value' that should be
4947 stored.
4948
4949 @item void md_number_to_imm(char *outputPTR,long value,int nbytes)
4950 This routine is called to turn a C long int, short int, or char
4951 into the series of bytes that represent an immediate value on
4952 the target machine. It is identical to the function @code{md_number_to_chars},
4953 except on NS32K machines.@refill
4954
4955 @item void md_number_to_disp(char *outputPTR,long value,int nbytes)
4956 This routine is called to turn a C long int, short int, or char
4957 into the series of bytes that represent an displacement value on
4958 the target machine. It is identical to the function @code{md_number_to_chars},
4959 except on NS32K machines.@refill
4960
4961 @item void md_number_to_field(char *outputPTR,long value,int nbytes)
4962 This routine is identical to @code{md_number_to_chars},
4963 except on NS32K machines.
4964
4965 @item void md_ri_to_chars(struct relocation_info *riPTR,ri)
4966 (@code{struct relocation_info} is defined in @file{a.out.h})
4967 This routine emits the relocation info in @var{ri}
4968 in the appropriate bit-pattern for the target machine.
4969 The result should be stored in the location pointed
4970 to by @var{riPTR}. This routine may be a no-op unless you are
4971 attempting to do cross-assembly.
4972
4973 @item char *md_atof(char type,char *outputPTR,int *sizePTR)
4974 This routine turns a series of digits into the appropriate
4975 internal representation for a floating-point number.
4976 @var{type} is a character from @var{FLT_CHARS[]} that describes
4977 what kind of floating point number is wanted; @var{outputPTR}
4978 is a pointer to an array that the result should be stored in;
4979 and @var{sizePTR} is a pointer to an integer where the size (in
4980 bytes) of the result should be stored. This routine should
4981 return an error message, or an empty string (not (char *)0) for
4982 success.
4983
4984 @item int md_short_jump_size;
4985 This variable holds the (maximum) size in bytes of a short (16
4986 bit or so) jump created by @code{md_create_short_jump()}. This
4987 variable is used as part of the broken-word feature, and isn't
4988 needed if the assembler is compiled with
4989 @samp{-DWORKING_DOT_WORD}.
4990
4991 @item int md_long_jump_size;
4992 This variable holds the (maximum) size in bytes of a long (32
4993 bit or so) jump created by @code{md_create_long_jump()}. This
4994 variable is used as part of the broken-word feature, and isn't
4995 needed if the assembler is compiled with
4996 @samp{-DWORKING_DOT_WORD}.
4997
4998 @item void md_create_short_jump(char *resultPTR,long from_addr,
4999 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
5000 This function emits a jump from @var{from_addr} to @var{to_addr} in
5001 the array of bytes pointed to by @var{resultPTR}. If this creates a
5002 type of jump that must be relocated, this function should call
5003 @code{fix_new()} with @var{frag} and @var{to_symbol}. The jump
5004 emitted by this function may be smaller than @var{md_short_jump_size},
5005 but it must never create a larger one.
5006 (If it creates a smaller jump, the extra bytes of memory will not be
5007 used.) This function is used as part of the broken-word feature,
5008 and isn't needed if the assembler is compiled with
5009 @samp{-DWORKING_DOT_WORD}.@refill
5010
5011 @item void md_create_long_jump(char *ptr,long from_addr,
5012 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
5013 This function is similar to the previous function,
5014 @code{md_create_short_jump()}, except that it creates a long
5015 jump instead of a short one. This function is used as part of
5016 the broken-word feature, and isn't needed if the assembler is
5017 compiled with @samp{-DWORKING_DOT_WORD}.
5018
5019 @item int md_estimate_size_before_relax(fragS *fragPTR,int segment_type)
5020 This function does the initial setting up for relaxation. This
5021 includes forcing references to still-undefined symbols to the
5022 appropriate addressing modes.
5023
5024 @item relax_typeS md_relax_table[];
5025 (relax_typeS is defined in md.h)
5026 This array describes the various machine dependent states a
5027 frag may be in before relaxation. You will need one group of
5028 entries for each type of addressing mode you intend to relax.
5029
5030 @item void md_convert_frag(fragS *fragPTR)
5031 (@var{fragS} is defined in @file{as.h})
5032 This routine does the required cleanup after relaxation.
5033 Relaxation has changed the type of the frag to a type that can
5034 reach its destination. This function should adjust the opcode
5035 of the frag to use the appropriate addressing mode.
5036 @var{fragPTR} points to the frag to clean up.
5037
5038 @item void md_end(void)
5039 This function is called just before the assembler exits. It
5040 need not free up memory unless the operating system doesn't do
5041 it automatically on exit. (In which case you'll also have to
5042 track down all the other places where the assembler allocates
5043 space but never frees it.)
5044
5045 @end table
5046
5047 @section External Variables You will Need to Use
5048
5049 You will need to refer to or change the following external variables
5050 from within the machine-dependent part of the assembler.
5051
5052 @table @code
5053 @item extern char flagseen[];
5054 This array holds non-zero values in locations corresponding to
5055 the options that were on the command line. Thus, if the
5056 assembler was called with @samp{-W}, @var{flagseen['W']} would
5057 be non-zero.
5058
5059 @item extern fragS *frag_now;
5060 This pointer points to the current frag--the frag that bytes
5061 are currently being added to. If nothing else, you will need
5062 to pass it as an argument to various machine-independent
5063 functions. It is maintained automatically by the
5064 frag-manipulating functions; you should never have to change it
5065 yourself.
5066
5067 @item extern LITTLENUM_TYPE generic_bignum[];
5068 (@var{LITTLENUM_TYPE} is defined in @file{bignum.h}.
5069 This is where @dfn{bignums}--numbers larger than 32 bits--are
5070 returned when they are encountered in an expression. You will
5071 need to use this if you need to implement directives (or
5072 anything else) that must deal with these large numbers.
5073 @code{Bignums} are of @code{segT} @code{SEG_BIG} (defined in
5074 @file{as.h}, and have a positive @code{X_add_number}. The
5075 @code{X_add_number} of a @code{bignum} is the number of
5076 @code{LITTLENUMS} in @var{generic_bignum} that the number takes
5077 up.
5078
5079 @item extern FLONUM_TYPE generic_floating_point_number;
5080 (@var{FLONUM_TYPE} is defined in @file{flonum.h}.
5081 The is where @dfn{flonums}--floating-point numbers within
5082 expressions--are returned. @code{Flonums} are of @code{segT}
5083 @code{SEG_BIG}, and have a negative @code{X_add_number}.
5084 @code{Flonums} are returned in a generic format. You will have
5085 to write a routine to turn this generic format into the
5086 appropriate floating-point format for your machine.
5087
5088 @item extern int need_pass_2;
5089 If this variable is non-zero, the assembler has encountered an
5090 expression that cannot be assembled in a single pass. Since
5091 the second pass isn't implemented, this flag means that the
5092 assembler is punting, and is only looking for additional syntax
5093 errors. (Or something like that.)
5094
5095 @item extern segT now_seg;
5096 This variable holds the value of the section the assembler is
5097 currently assembling into.
5098
5099 @end table
5100
5101 @section External functions will you need
5102
5103 You will find the following external functions useful (or
5104 indispensable) when you're writing the machine-dependent part
5105 of the assembler.
5106
5107 @table @code
5108
5109 @item char *frag_more(int bytes)
5110 This function allocates @var{bytes} more bytes in the current
5111 frag (or starts a new frag, if it can't expand the current frag
5112 any more.) for you to store some object-file bytes in. It
5113 returns a pointer to the bytes, ready for you to store data in.
5114
5115 @item void fix_new(fragS *frag, int where, short size, symbolS *add_symbol, symbolS *sub_symbol, long offset, int pcrel)
5116 This function stores a relocation fixup to be acted on later.
5117 @var{frag} points to the frag the relocation belongs in;
5118 @var{where} is the location within the frag where the relocation begins;
5119 @var{size} is the size of the relocation, and is usually 1 (a single byte),
5120 2 (sixteen bits), or 4 (a longword).
5121 The value @var{add_symbol} @minus{} @var{sub_symbol} + @var{offset}, is added to the byte(s)
5122 at _0__@var{frag->literal[where]}_1__. If @var{pcrel} is non-zero, the address of the
5123 location is subtracted from the result. A relocation entry is also added
5124 to the @file{a.out} file. @var{add_symbol}, @var{sub_symbol}, and/or
5125 @var{offset} may be NULL.@refill
5126
5127 @item char *frag_var(relax_stateT type, int max_chars, int var,
5128 @code{relax_substateT subtype, symbolS *symbol, char *opcode)}
5129 This function creates a machine-dependent frag of type @var{type}
5130 (usually @code{rs_machine_dependent}).
5131 @var{max_chars} is the maximum size in bytes that the frag may grow by;
5132 @var{var} is the current size of the variable end of the frag;
5133 @var{subtype} is the sub-type of the frag. The sub-type is used to index into
5134 @var{md_relax_table[]} during @code{relaxation}.
5135 @var{symbol} is the symbol whose value should be used to when relax-ing this frag.
5136 @var{opcode} points into a byte whose value may have to be modified if the
5137 addressing mode used by this frag changes. It typically points into the
5138 @var{fr_literal[]} of the previous frag, and is used to point to a location
5139 that @code{md_convert_frag()}, may have to change.@refill
5140
5141 @item void frag_wane(fragS *fragPTR)
5142 This function is useful from within @code{md_convert_frag}. It
5143 changes a frag to type rs_fill, and sets the variable-sized
5144 piece of the frag to zero. The frag will never change in size
5145 again.
5146
5147 @item segT expression(expressionS *retval)
5148 (@var{segT} is defined in @file{as.h}; @var{expressionS} is defined in @file{expr.h})
5149 This function parses the string pointed to by the external char
5150 pointer @var{input_line_pointer}, and returns the section-type
5151 of the expression. It also stores the results in the
5152 @var{expressionS} pointed to by @var{retval}.
5153 @var{input_line_pointer} is advanced to point past the end of
5154 the expression. (@var{input_line_pointer} is used by other
5155 parts of the assembler. If you modify it, be sure to restore
5156 it to its original value.)
5157
5158 @item as_warn(char *message,@dots{})
5159 If warning messages are disabled, this function does nothing.
5160 Otherwise, it prints out the current file name, and the current
5161 line number, then uses @code{fprintf} to print the
5162 @var{message} and any arguments it was passed.
5163
5164 @item as_bad(char *message,@dots{})
5165 This function should be called when @code{_AS__} encounters
5166 conditions that are bad enough that @code{_AS__} should not
5167 produce an object file, but should continue reading input and
5168 printing warning and bad error messages.
5169
5170 @item as_fatal(char *message,@dots{})
5171 This function prints out the current file name and line number,
5172 prints the word @samp{FATAL:}, then uses @code{fprintf} to
5173 print the @var{message} and any arguments it was passed. Then
5174 the assembler exits. This function should only be used for
5175 serious, unrecoverable errors.
5176
5177 @item void float_const(int float_type)
5178 This function reads floating-point constants from the current
5179 input line, and calls @code{md_atof} to assemble them. It is
5180 useful as the function to call for the directives
5181 @samp{.single}, @samp{.double}, @samp{.float}, etc.
5182 @var{float_type} must be a character from @var{FLT_CHARS}.
5183
5184 @item void demand_empty_rest_of_line(void);
5185 This function can be used by machine-dependent directives to
5186 make sure the rest of the input line is empty. It prints a
5187 warning message if there are additional characters on the line.
5188
5189 @item long int get_absolute_expression(void)
5190 This function can be used by machine-dependent directives to
5191 read an absolute number from the current input line. It
5192 returns the result. If it isn't given an absolute expression,
5193 it prints a warning message and returns zero.
5194
5195 @end table
5196
5197
5198 @section The concept of Frags
5199
5200 This assembler works to optimize the size of certain addressing
5201 modes. (e.g. branch instructions) This means the size of many
5202 pieces of object code cannot be determined until after assembly
5203 is finished. (This means that the addresses of symbols cannot be
5204 determined until assembly is finished.) In order to do this,
5205 @code{_AS__} stores the output bytes as @dfn{frags}.
5206
5207 Here is the definition of a frag (from @file{as.h})
5208 @smallexample
5209 struct frag
5210 @{
5211 long int fr_fix;
5212 long int fr_var;
5213 relax_stateT fr_type;
5214 relax_substateT fr_substate;
5215 unsigned long fr_address;
5216 long int fr_offset;
5217 struct symbol *fr_symbol;
5218 char *fr_opcode;
5219 struct frag *fr_next;
5220 char fr_literal[];
5221 @}
5222 @end smallexample
5223
5224 @table @var
5225 @item fr_fix
5226 is the size of the fixed-size piece of the frag.
5227
5228 @item fr_var
5229 is the maximum (?) size of the variable-sized piece of the frag.
5230
5231 @item fr_type
5232 is the type of the frag.
5233 Current types are:
5234 rs_fill
5235 rs_align
5236 rs_org
5237 rs_machine_dependent
5238
5239 @item fr_substate
5240 This stores the type of machine-dependent frag this is. (what
5241 kind of addressing mode is being used, and what size is being
5242 tried/will fit/etc.
5243
5244 @item fr_address
5245 @var{fr_address} is only valid after relaxation is finished.
5246 Before relaxation, the only way to store an address is (pointer
5247 to frag containing the address) plus (offset into the frag).
5248
5249 @item fr_offset
5250 This contains a number, whose meaning depends on the type of
5251 the frag.
5252 for machine_dependent frags, this contains the offset from
5253 fr_symbol that the frag wants to go to. Thus, for branch
5254 instructions it is usually zero. (unless the instruction was
5255 @samp{jba foo+12} or something like that.)
5256
5257 @item fr_symbol
5258 for machine_dependent frags, this points to the symbol the frag
5259 needs to reach.
5260
5261 @item fr_opcode
5262 This points to the location in the frag (or in a previous frag)
5263 of the opcode for the instruction that caused this to be a frag.
5264 @var{fr_opcode} is needed if the actual opcode must be changed
5265 in order to use a different form of the addressing mode.
5266 (For example, if a conditional branch only comes in size tiny,
5267 a large-size branch could be implemented by reversing the sense
5268 of the test, and turning it into a tiny branch over a large jump.
5269 This would require changing the opcode.)
5270
5271 @var{fr_literal} is a variable-size array that contains the
5272 actual object bytes. A frag consists of a fixed size piece of
5273 object data, (which may be zero bytes long), followed by a
5274 piece of object data whose size may not have been determined
5275 yet. Other information includes the type of the frag (which
5276 controls how it is relaxed),
5277
5278 @item fr_next
5279 This is the next frag in the singly-linked list. This is
5280 usually only needed by the machine-independent part of
5281 @code{_AS__}.
5282
5283 @end table
5284 _fi__(0)
5285
5286 @node Copying, , Machine Dependent, Top
5287 @unnumbered GNU GENERAL PUBLIC LICENSE
5288 @center Version 2, June 1991
5289
5290 @display
5291 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
5292 675 Mass Ave, Cambridge, MA 02139, USA
5293
5294 Everyone is permitted to copy and distribute verbatim copies
5295 of this license document, but changing it is not allowed.
5296 @end display
5297
5298 @unnumberedsec Preamble
5299
5300 The licenses for most software are designed to take away your
5301 freedom to share and change it. By contrast, the GNU General Public
5302 License is intended to guarantee your freedom to share and change free
5303 software---to make sure the software is free for all its users. This
5304 General Public License applies to most of the Free Software
5305 Foundation's software and to any other program whose authors commit to
5306 using it. (Some other Free Software Foundation software is covered by
5307 the GNU Library General Public License instead.) You can apply it to
5308 your programs, too.
5309
5310 When we speak of free software, we are referring to freedom, not
5311 price. Our General Public Licenses are designed to make sure that you
5312 have the freedom to distribute copies of free software (and charge for
5313 this service if you wish), that you receive source code or can get it
5314 if you want it, that you can change the software or use pieces of it
5315 in new free programs; and that you know you can do these things.
5316
5317 To protect your rights, we need to make restrictions that forbid
5318 anyone to deny you these rights or to ask you to surrender the rights.
5319 These restrictions translate to certain responsibilities for you if you
5320 distribute copies of the software, or if you modify it.
5321
5322 For example, if you distribute copies of such a program, whether
5323 gratis or for a fee, you must give the recipients all the rights that
5324 you have. You must make sure that they, too, receive or can get the
5325 source code. And you must show them these terms so they know their
5326 rights.
5327
5328 We protect your rights with two steps: (1) copyright the software, and
5329 (2) offer you this license which gives you legal permission to copy,
5330 distribute and/or modify the software.
5331
5332 Also, for each author's protection and ours, we want to make certain
5333 that everyone understands that there is no warranty for this free
5334 software. If the software is modified by someone else and passed on, we
5335 want its recipients to know that what they have is not the original, so
5336 that any problems introduced by others will not reflect on the original
5337 authors' reputations.
5338
5339 Finally, any free program is threatened constantly by software
5340 patents. We wish to avoid the danger that redistributors of a free
5341 program will individually obtain patent licenses, in effect making the
5342 program proprietary. To prevent this, we have made it clear that any
5343 patent must be licensed for everyone's free use or not licensed at all.
5344
5345 The precise terms and conditions for copying, distribution and
5346 modification follow.
5347
5348 @iftex
5349 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
5350 @end iftex
5351 @ifinfo
5352 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
5353 @end ifinfo
5354
5355 @enumerate
5356 @item
5357 This License applies to any program or other work which contains
5358 a notice placed by the copyright holder saying it may be distributed
5359 under the terms of this General Public License. The ``Program'', below,
5360 refers to any such program or work, and a ``work based on the Program''
5361 means either the Program or any derivative work under copyright law:
5362 that is to say, a work containing the Program or a portion of it,
5363 either verbatim or with modifications and/or translated into another
5364 language. (Hereinafter, translation is included without limitation in
5365 the term ``modification''.) Each licensee is addressed as ``you''.
5366
5367 Activities other than copying, distribution and modification are not
5368 covered by this License; they are outside its scope. The act of
5369 running the Program is not restricted, and the output from the Program
5370 is covered only if its contents constitute a work based on the
5371 Program (independent of having been made by running the Program).
5372 Whether that is true depends on what the Program does.
5373
5374 @item
5375 You may copy and distribute verbatim copies of the Program's
5376 source code as you receive it, in any medium, provided that you
5377 conspicuously and appropriately publish on each copy an appropriate
5378 copyright notice and disclaimer of warranty; keep intact all the
5379 notices that refer to this License and to the absence of any warranty;
5380 and give any other recipients of the Program a copy of this License
5381 along with the Program.
5382
5383 You may charge a fee for the physical act of transferring a copy, and
5384 you may at your option offer warranty protection in exchange for a fee.
5385
5386 @item
5387 You may modify your copy or copies of the Program or any portion
5388 of it, thus forming a work based on the Program, and copy and
5389 distribute such modifications or work under the terms of Section 1
5390 above, provided that you also meet all of these conditions:
5391
5392 @alphaenumerate
5393 @item
5394 You must cause the modified files to carry prominent notices
5395 stating that you changed the files and the date of any change.
5396
5397 @item
5398 You must cause any work that you distribute or publish, that in
5399 whole or in part contains or is derived from the Program or any
5400 part thereof, to be licensed as a whole at no charge to all third
5401 parties under the terms of this License.
5402
5403 @item
5404 If the modified program normally reads commands interactively
5405 when run, you must cause it, when started running for such
5406 interactive use in the most ordinary way, to print or display an
5407 announcement including an appropriate copyright notice and a
5408 notice that there is no warranty (or else, saying that you provide
5409 a warranty) and that users may redistribute the program under
5410 these conditions, and telling the user how to view a copy of this
5411 License. (Exception: if the Program itself is interactive but
5412 does not normally print such an announcement, your work based on
5413 the Program is not required to print an announcement.)
5414 @end alphaenumerate
5415
5416 These requirements apply to the modified work as a whole. If
5417 identifiable sections of that work are not derived from the Program,
5418 and can be reasonably considered independent and separate works in
5419 themselves, then this License, and its terms, do not apply to those
5420 sections when you distribute them as separate works. But when you
5421 distribute the same sections as part of a whole which is a work based
5422 on the Program, the distribution of the whole must be on the terms of
5423 this License, whose permissions for other licensees extend to the
5424 entire whole, and thus to each and every part regardless of who wrote it.
5425
5426 Thus, it is not the intent of this section to claim rights or contest
5427 your rights to work written entirely by you; rather, the intent is to
5428 exercise the right to control the distribution of derivative or
5429 collective works based on the Program.
5430
5431 In addition, mere aggregation of another work not based on the Program
5432 with the Program (or with a work based on the Program) on a volume of
5433 a storage or distribution medium does not bring the other work under
5434 the scope of this License.
5435
5436 @item
5437 You may copy and distribute the Program (or a work based on it,
5438 under Section 2) in object code or executable form under the terms of
5439 Sections 1 and 2 above provided that you also do one of the following:
5440
5441 @alphaenumerate
5442 @item
5443 Accompany it with the complete corresponding machine-readable
5444 source code, which must be distributed under the terms of Sections
5445 1 and 2 above on a medium customarily used for software interchange; or,
5446
5447 @item
5448 Accompany it with a written offer, valid for at least three
5449 years, to give any third party, for a charge no more than your
5450 cost of physically performing source distribution, a complete
5451 machine-readable copy of the corresponding source code, to be
5452 distributed under the terms of Sections 1 and 2 above on a medium
5453 customarily used for software interchange; or,
5454
5455 @item
5456 Accompany it with the information you received as to the offer
5457 to distribute corresponding source code. (This alternative is
5458 allowed only for noncommercial distribution and only if you
5459 received the program in object code or executable form with such
5460 an offer, in accord with Subsection b above.)
5461 @end alphaenumerate
5462
5463 The source code for a work means the preferred form of the work for
5464 making modifications to it. For an executable work, complete source
5465 code means all the source code for all modules it contains, plus any
5466 associated interface definition files, plus the scripts used to
5467 control compilation and installation of the executable. However, as a
5468 special exception, the source code distributed need not include
5469 anything that is normally distributed (in either source or binary
5470 form) with the major components (compiler, kernel, and so on) of the
5471 operating system on which the executable runs, unless that component
5472 itself accompanies the executable.
5473
5474 If distribution of executable or object code is made by offering
5475 access to copy from a designated place, then offering equivalent
5476 access to copy the source code from the same place counts as
5477 distribution of the source code, even though third parties are not
5478 compelled to copy the source along with the object code.
5479
5480 @item
5481 You may not copy, modify, sublicense, or distribute the Program
5482 except as expressly provided under this License. Any attempt
5483 otherwise to copy, modify, sublicense or distribute the Program is
5484 void, and will automatically terminate your rights under this License.
5485 However, parties who have received copies, or rights, from you under
5486 this License will not have their licenses terminated so long as such
5487 parties remain in full compliance.
5488
5489 @item
5490 You are not required to accept this License, since you have not
5491 signed it. However, nothing else grants you permission to modify or
5492 distribute the Program or its derivative works. These actions are
5493 prohibited by law if you do not accept this License. Therefore, by
5494 modifying or distributing the Program (or any work based on the
5495 Program), you indicate your acceptance of this License to do so, and
5496 all its terms and conditions for copying, distributing or modifying
5497 the Program or works based on it.
5498
5499 @item
5500 Each time you redistribute the Program (or any work based on the
5501 Program), the recipient automatically receives a license from the
5502 original licensor to copy, distribute or modify the Program subject to
5503 these terms and conditions. You may not impose any further
5504 restrictions on the recipients' exercise of the rights granted herein.
5505 You are not responsible for enforcing compliance by third parties to
5506 this License.
5507
5508 @item
5509 If, as a consequence of a court judgment or allegation of patent
5510 infringement or for any other reason (not limited to patent issues),
5511 conditions are imposed on you (whether by court order, agreement or
5512 otherwise) that contradict the conditions of this License, they do not
5513 excuse you from the conditions of this License. If you cannot
5514 distribute so as to satisfy simultaneously your obligations under this
5515 License and any other pertinent obligations, then as a consequence you
5516 may not distribute the Program at all. For example, if a patent
5517 license would not permit royalty-free redistribution of the Program by
5518 all those who receive copies directly or indirectly through you, then
5519 the only way you could satisfy both it and this License would be to
5520 refrain entirely from distribution of the Program.
5521
5522 If any portion of this section is held invalid or unenforceable under
5523 any particular circumstance, the balance of the section is intended to
5524 apply and the section as a whole is intended to apply in other
5525 circumstances.
5526
5527 It is not the purpose of this section to induce you to infringe any
5528 patents or other property right claims or to contest validity of any
5529 such claims; this section has the sole purpose of protecting the
5530 integrity of the free software distribution system, which is
5531 implemented by public license practices. Many people have made
5532 generous contributions to the wide range of software distributed
5533 through that system in reliance on consistent application of that
5534 system; it is up to the author/donor to decide if he or she is willing
5535 to distribute software through any other system and a licensee cannot
5536 impose that choice.
5537
5538 This section is intended to make thoroughly clear what is believed to
5539 be a consequence of the rest of this License.
5540
5541 @item
5542 If the distribution and/or use of the Program is restricted in
5543 certain countries either by patents or by copyrighted interfaces, the
5544 original copyright holder who places the Program under this License
5545 may add an explicit geographical distribution limitation excluding
5546 those countries, so that distribution is permitted only in or among
5547 countries not thus excluded. In such case, this License incorporates
5548 the limitation as if written in the body of this License.
5549
5550 @item
5551 The Free Software Foundation may publish revised and/or new versions
5552 of the General Public License from time to time. Such new versions will
5553 be similar in spirit to the present version, but may differ in detail to
5554 address new problems or concerns.
5555
5556 Each version is given a distinguishing version number. If the Program
5557 specifies a version number of this License which applies to it and ``any
5558 later version'', you have the option of following the terms and conditions
5559 either of that version or of any later version published by the Free
5560 Software Foundation. If the Program does not specify a version number of
5561 this License, you may choose any version ever published by the Free Software
5562 Foundation.
5563
5564 @item
5565 If you wish to incorporate parts of the Program into other free
5566 programs whose distribution conditions are different, write to the author
5567 to ask for permission. For software which is copyrighted by the Free
5568 Software Foundation, write to the Free Software Foundation; we sometimes
5569 make exceptions for this. Our decision will be guided by the two goals
5570 of preserving the free status of all derivatives of our free software and
5571 of promoting the sharing and reuse of software generally.
5572
5573 @iftex
5574 @heading NO WARRANTY
5575 @end iftex
5576 @ifinfo
5577 @center NO WARRANTY
5578 @end ifinfo
5579
5580 @item
5581 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
5582 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
5583 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
5584 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
5585 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5586 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
5587 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
5588 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
5589 REPAIR OR CORRECTION.
5590
5591 @item
5592 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
5593 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
5594 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
5595 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
5596 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
5597 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
5598 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
5599 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
5600 POSSIBILITY OF SUCH DAMAGES.
5601 @end enumerate
5602
5603 @iftex
5604 @heading END OF TERMS AND CONDITIONS
5605 @end iftex
5606 @ifinfo
5607 @center END OF TERMS AND CONDITIONS
5608 @end ifinfo
5609
5610 @page
5611 @unnumberedsec Applying These Terms to Your New Programs
5612
5613 If you develop a new program, and you want it to be of the greatest
5614 possible use to the public, the best way to achieve this is to make it
5615 free software which everyone can redistribute and change under these terms.
5616
5617 To do so, attach the following notices to the program. It is safest
5618 to attach them to the start of each source file to most effectively
5619 convey the exclusion of warranty; and each file should have at least
5620 the ``copyright'' line and a pointer to where the full notice is found.
5621
5622 @smallexample
5623 @var{one line to give the program's name and an idea of what it does.}
5624 Copyright (C) 19@var{yy} @var{name of author}
5625
5626 This program is free software; you can redistribute it and/or
5627 modify it under the terms of the GNU General Public License
5628 as published by the Free Software Foundation; either version 2
5629 of the License, or (at your option) any later version.
5630
5631 This program is distributed in the hope that it will be useful,
5632 but WITHOUT ANY WARRANTY; without even the implied warranty of
5633 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5634 GNU General Public License for more details.
5635
5636 You should have received a copy of the GNU General Public License
5637 along with this program; if not, write to the
5638 Free Software Foundation, Inc., 675 Mass Ave,
5639 Cambridge, MA 02139, USA.
5640 @end smallexample
5641
5642 Also add information on how to contact you by electronic and paper mail.
5643
5644 If the program is interactive, make it output a short notice like this
5645 when it starts in an interactive mode:
5646
5647 @smallexample
5648 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
5649 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
5650 type `show w'. This is free software, and you are welcome
5651 to redistribute it under certain conditions; type `show c'
5652 for details.
5653 @end smallexample
5654
5655 The hypothetical commands @samp{show w} and @samp{show c} should show
5656 the appropriate parts of the General Public License. Of course, the
5657 commands you use may be called something other than @samp{show w} and
5658 @samp{show c}; they could even be mouse-clicks or menu items---whatever
5659 suits your program.
5660
5661 You should also get your employer (if you work as a programmer) or your
5662 school, if any, to sign a ``copyright disclaimer'' for the program, if
5663 necessary. Here is a sample; alter the names:
5664
5665 @smallexample
5666 Yoyodyne, Inc., hereby disclaims all copyright interest in
5667 the program `Gnomovision' (which makes passes at compilers)
5668 written by James Hacker.
5669
5670 @var{signature of Ty Coon}, 1 April 1989
5671 Ty Coon, President of Vice
5672 @end smallexample
5673
5674 This General Public License does not permit incorporating your program into
5675 proprietary programs. If your program is a subroutine library, you may
5676 consider it more useful to permit linking proprietary applications with the
5677 library. If this is what you want to do, use the GNU Library General
5678 Public License instead of this License.
5679
5680 @summarycontents
5681 @contents
5682 @bye