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