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