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