1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright (c) 1991 1992 Free Software Foundation, Inc.
14 * As: (as). The GNU assembler.
24 This file documents the GNU Assembler "as".
26 Copyright (C) 1991 Free Software Foundation, Inc.
28 Permission is granted to make and distribute verbatim copies of
29 this manual provided the copyright notice and this permission notice
30 are preserved on all copies.
33 Permission is granted to process this file through Tex and print the
34 results, provided the printed document carries copying permission
35 notice identical to this one except for the removal of this paragraph
36 (this paragraph not being relevant to the printed manual).
39 Permission is granted to copy and distribute modified versions of this
40 manual under the conditions for verbatim copying, provided also that the
41 section entitled ``GNU General Public License'' is included exactly as
42 in the original, and provided that the entire resulting derived work is
43 distributed under the terms of a permission notice identical to this
46 Permission is granted to copy and distribute translations of this manual
47 into another language, under the above conditions for modified versions,
48 except that the section entitled ``GNU General Public License'' may be
49 included in a translation approved by the Free Software Foundation
50 instead of in the original English.
55 @subtitle The GNU Assembler
57 @subtitle January 1992
60 The Free Software Foundation Inc. thanks The Nice Computer
61 Company of Australia for loaning Dean Elsner to write the
62 first (Vax) version of @code{as} for Project GNU.
63 The proprietors, management and staff of TNCCA thank FSF for
64 distracting the boss while they got some work
67 @author Dean Elsner, Jay Fenlason & friends
71 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
72 \xdef\manvers{\$Revision$} % For use in headers, footers too
74 \hfill {\it Using {\tt as}} \manvers\par
75 \hfill \TeX{}info \texinfoversion\par
76 \hfill Edited by Roland Pesch for Cygnus Support\par
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
86 @vskip 0pt plus 1filll
87 Copyright @copyright{} 1991 Free Software Foundation, Inc.
89 Permission is granted to make and distribute verbatim copies of
90 this manual provided the copyright notice and this permission notice
91 are preserved on all copies.
93 Permission is granted to copy and distribute modified versions of this
94 manual under the conditions for verbatim copying, provided also that the
95 section entitled ``GNU General Public License'' is included exactly as
96 in the original, and provided that the entire resulting derived work is
97 distributed under the terms of a permission notice identical to this
100 Permission is granted to copy and distribute translations of this manual
101 into another language, under the above conditions for modified versions,
102 except that the section entitled ``GNU General Public License'' may be
103 included in a translation approved by the Free Software Foundation
104 instead of in the original English.
111 This file is a user guide to the GNU assembler @code{as}.
113 * Overview:: Overview
114 * Invoking:: Command-Line Options
116 * Sections:: Sections and Relocation
118 * Expressions:: Expressions
119 * Pseudo Ops:: Assembler Directives
120 * Machine Dependent:: Machine Dependent Features
121 * Copying:: GNU GENERAL PUBLIC LICENSE
129 This manual is a user guide to the GNU assembler @code{as}.
132 @cindex invocation summary
133 @cindex option summary
134 @cindex summary of options
135 Here is a brief summary of how to invoke @code{as}. For details,
136 @pxref{Invoking,,Comand-Line Options}.
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.
141 as [ -a | -al | -as ] [ -D ] [ -f ]
142 [ -I @var{path} ] [ -K ] [ -L ]
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
146 @c Z8000 has no machine-dependent assembler options
147 @c see md_parse_option in i960.c
148 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
150 [ -l ] [ -mc68000 | -mc68010 | -mc68020 ]
151 [ -- | @var{files} @dots{} ]
156 Turn on assembly listings; @samp{-al}, listing only, @samp{-as}, symbols
157 only, @samp{-a}, everything.
160 This option is accepted only for script compatibility with calls to
161 other assemblers; it has no effect on @code{as}.
164 ``fast''---skip preprocessing (assume source is compiler output)
167 Add @var{path} to the search list for @code{.include} directives
170 Issue warnings when difference tables altered for long displacements.
173 Keep (in symbol table) local symbols, starting with @samp{L}
175 @item -o @var{objfile}
176 Name the object-file output from @code{as}
179 Fold data section into text section
182 Announce @code{as} version
185 Suppress warning messages
187 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
188 (When configured for Intel 960).
189 Specify which variant of the 960 architecture is the target.
192 (When configured for Intel 960).
193 Add code to collect statistics about branches taken.
196 (When configured for Intel 960).
197 Do not alter compare-and-branch instructions for long displacements;
201 (When configured for Motorola 68000).
202 Shorten references to undefined symbols, to one word instead of two
204 @item -mc68000 | -mc68010 | -mc68020
205 (When configured for Motorola 68000).
206 Specify what processor in the 68000 family is the target (default 68020)
208 @item -- | @var{files} @dots{}
209 Standard input, or source files to assemble
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
223 @section Structure of this Manual
225 @cindex manual, structure and purpose
226 This 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
228 notation for symbols, constants, and expressions; the directives that
229 @code{as} understands; and of course how to invoke @code{as}.
231 This manual also describes some of the machine-dependent features of
232 various flavors of the assembler.
235 @cindex machine instructions (not covered)
236 On the other hand, this manual is @emph{not} intended as an introduction
237 to programming in assembly language---let alone programming in general!
238 In a similar vein, we make no attempt to introduce the machine
239 architecture; we do @emph{not} describe the instruction set, standard
240 mnemonics, registers or addressing modes that are standard to a
241 particular architecture.
242 You may want to consult the manufacturer's
243 machine architecture manual for this information.
248 Throughout this manual, we assume that you are running @dfn{GNU},
249 the portable operating system from the @dfn{Free Software
250 Foundation, Inc.}. This restricts our attention to certain kinds of
251 computer (in particular, the kinds of computers that GNU can run on);
252 once this assumption is granted examples and definitions need less
255 @code{as} is part of a team of programs that turn a high-level
256 human-readable series of instructions into a low-level
257 computer-readable series of instructions. Different versions of
258 @code{as} are used for different kinds of computer.
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
271 @section as, the GNU Assembler
273 GNU @code{as} is really a family of assemblers.
274 If you use (or have used) the GNU assembler on one architecture, you
275 should find a fairly similar environment when you use it on another
276 architecture. Each version has much in common with the others,
277 including object file formats, most assembler directives (often called
278 @dfn{pseudo-ops)} and assembler syntax.@refill
280 @cindex purpose of @sc{gnu} @code{as}
281 @code{as} is primarily intended to assemble the output of the GNU C
282 compiler @code{gcc} for use by the linker @code{ld}. Nevertheless,
283 we've tried to make @code{as} assemble correctly everything that the native
285 Any exceptions are documented explicitly (@pxref{Machine Dependent}).
286 This doesn't mean @code{as} always uses the same syntax as another
287 assembler for the same architecture; for example, we know of several
288 incompatible versions of 680x0 assembly language syntax.
290 Unlike older assemblers, @code{as} is designed to assemble a source
291 program in one pass of the source file. This has a subtle impact on the
292 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
295 @section Object File Formats
297 @cindex object file format
298 The GNU assembler can be configured to produce several alternative
299 object file formats. For the most part, this does not affect how you
300 write assembly language programs; but directives for debugging symbols
301 are typically different in different file formats. @xref{Symbol
302 Attributes,,Symbol Attributes}.
305 @section Command Line
307 @cindex command line conventions
308 After the program name @code{as}, the command line may contain
309 options and file names. Options may appear in any order, and may be
310 before, after, or between file names. The order of file names is
313 @cindex standard input, as input file
315 @file{--} (two hyphens) by itself names the standard input file
316 explicitly, as one of the files for @code{as} to assemble.
318 @cindex options, command line
319 Except for @samp{--} any command line argument that begins with a
320 hyphen (@samp{-}) is an option. Each option changes the behavior of
321 @code{as}. No option changes the way another option works. An
322 option is a @samp{-} followed by one or more letters; the case of
323 the letter is important. All options are optional.
325 Some options expect exactly one file name to follow them. The file
326 name may either immediately follow the option's letter (compatible
327 with older assemblers) or it may be the next command argument (GNU
328 standard). These two command lines are equivalent:
331 as -o my-object-file.o mumble.s
332 as -omy-object-file.o mumble.s
339 @cindex source program
341 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
342 describe the program input to one run of @code{as}. The program may
343 be in one or more files; how the source is partitioned into files
344 doesn't change the meaning of the source.
346 @c I added "con" prefix to "catenation" just to prove I can overcome my
348 The source program is a concatenation of the text in all the files, in the
351 Each time you run @code{as} it assembles exactly one source
352 program. The source program is made up of one or more files.
353 (The standard input is also a file.)
355 You give @code{as} a command line that has zero or more input file
356 names. The input files are read (from left file name to right). A
357 command line argument (in any position) that has no special meaning
358 is taken to be an input file name.
360 If you give @code{as} no file names it attempts to read one input file
361 from the @code{as} standard input, which is normally your terminal. You
362 may have to type @key{ctl-D} to tell @code{as} there is no more program
365 Use @samp{--} if you need to explicitly name the standard input file
366 in your command line.
368 If the source is empty, @code{as} will produce a small, empty object
371 @subheading Filenames and Line-numbers
373 @cindex input file linenumbers
374 @cindex line numbers, in input files
375 There are two ways of locating a line in the input file (or files) and
376 either may be used in reporting error messages. One way refers to a line
377 number in a physical file; the other refers to a line number in a
378 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
380 @dfn{Physical files} are those files named in the command line given
383 @dfn{Logical files} are simply names declared explicitly by assembler
384 directives; they bear no relation to physical files. Logical file names
385 help error messages reflect the original source file, when @code{as}
386 source is itself synthesized from other files.
387 @xref{App-File,,@code{.app-file}}.
390 @section Output (Object) File
396 Every time you run @code{as} it produces an output file, which is
397 your assembly language program translated into numbers. This file
398 is the object file, named @code{a.out} unless you tell @code{as} to
399 give it another name by using the @code{-o} option. Conventionally,
400 object file names end with @file{.o}. The default name of
401 @file{a.out} is used for historical reasons: older assemblers were
402 capable of assembling self-contained programs directly into a
404 @c This may still work, but hasn't been tested.
408 The object file is meant for input to the linker @code{ld}. It contains
409 assembled program code, information to help @code{ld} integrate
410 the assembled program into a runnable file, and (optionally) symbolic
411 information for the debugger.
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.
417 @section Error and Warning Messages
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
423 file (usually your terminal). This should not happen when a compiler
424 runs @code{as} automatically. Warnings report an assumption made so
425 that @code{as} could keep assembling a flawed program; errors report a
426 grave problem that stops the assembly.
428 @cindex format of warning messages
429 Warning messages have the format
432 file_name:@b{NNN}:Warning Message Text
436 @cindex line numbers, in warnings/errors
437 (where @b{NNN} is a line number). If a logical file name has
438 been given (@pxref{App-File,,@code{.app-file}}) it is used for the filename, otherwise the
439 name of the current input file is used. If a logical line number was
441 (@pxref{Ln,,@code{.ln}})
442 then it is used to calculate the number printed,
443 otherwise the actual line in the current source file is printed. The
444 message text is intended to be self explanatory (in the grand Unix
447 @cindex format of error messages
448 Error messages have the format
450 file_name:@b{NNN}:FATAL:Error Message Text
452 The file name and line number are derived as for warning
453 messages. The actual message text may be rather less explanatory
454 because many of them aren't supposed to happen.
457 @chapter Command-Line Options
459 @cindex options, all versions of @code{as}
460 This chapter describes command-line options available in @emph{all}
461 versions of the GNU assembler; @pxref{Machine Dependent}, for options specific
462 to particular machine architectures.
464 @section Enable Listings: @code{-a}, @code{-al}, @code{-as}
469 @cindex listings, enabling
470 @cindex assembly listings, enabling
471 These options enable listing output from the assembler. @samp{-a} by
472 itself requests all listing output; @samp{-al} requests only the
473 output-program listing, and @samp{-as} requests only a symbol table
476 Once you have specified one of these options, you can further control
477 listing output and its appearance using the directives @code{.list},
478 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
481 If you do not request listing output with one of the @samp{-a} options, the
482 listing-control directives have no effect.
487 This option has no effect whatsoever, but it is accepted to make it more
488 likely that scripts written for other assemblers will also work with
491 @section Work Faster: @code{-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
498 the input file(s) before assembling them. @xref{Pre-processing,
502 @emph{Warning:} if the files actually need to be pre-processed (if they
503 contain comments, for example), @code{as} will not work correctly if
507 @section @code{.include} search path: @code{-I} @var{path}
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
513 Use this option to add a @var{path} to the list of directories
514 @code{as} will search for files specified in @code{.include}
515 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
516 many times as necessary to include a variety of paths. The current
517 working directory is always searched first; after that, @code{as}
518 searches any @samp{-I} directories in the same order as they were
519 specified (left to right) on the command line.
521 @section Difference Tables: @code{-K}
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}}.
529 You can use the @samp{-K} option if you want a warning issued when this
532 @section Include Local Labels: @code{-L}
535 @cindex local labels, retaining in output
536 Labels beginning with @samp{L} (upper case only) are called @dfn{local
537 labels}. @xref{Symbol Names}. Normally you don't see such labels when
538 debugging, because they are intended for the use of programs (like
539 compilers) that compose assembler programs, not for your notice.
540 Normally both @code{as} and @code{ld} discard such labels, so you don't
541 normally debug with them.
543 This option tells @code{as} to retain those @samp{L@dots{}} symbols
544 in 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}.
547 @section Name the Object File: @code{-o}
550 @cindex naming object file
551 @cindex object file name
552 There is always one object file output when you run @code{as}. By
553 default it has the name @file{a.out}. You use this option (which
554 takes exactly one filename) to give the object file a different name.
556 Whatever the object file is called, @code{as} will overwrite any
557 existing file of the same name.
559 @section Join Data and Text Sections: @code{-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
567 data-section data lives in the text section. This is only done at
568 the very last moment: your binary data are the same, but data
569 section parts are relocated differently. The data section part of
570 your object file is zero bytes long because all it bytes are
571 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
573 When you specify @code{-R} it would be possible to generate shorter
574 address displacements (because we don't have to cross between text and
575 data section). We refrain from doing this simply for compatibility with
576 older versions of @code{as}. In future, @code{-R} may work this way.
578 When @code{as} is configured for COFF output,
579 this option is only useful if you use sections named @samp{.text} and
582 @section Announce Version: @code{-v}
586 @cindex @code{as} version
587 @cindex version of @code{as}
588 You can find out what version of as is running by including the
589 option @samp{-v} (which you can also spell as @samp{-version}) on the
592 @section Suppress Warnings: @code{-W}
595 @cindex suppressing warnings
596 @cindex warnings, suppressing
597 @code{as} should never give a warning or error message when
598 assembling compiler output. But programs written by people often
599 cause @code{as} to give a warning that a particular assumption was
600 made. All such warnings are directed to the standard error file.
601 If you use this option, no warnings are issued. This option only
602 affects the warning messages: it does not change any particular of how
603 @code{as} assembles your file. Errors, which stop the assembly, are
609 @cindex machine-independent syntax
610 @cindex syntax, machine-independent
611 This chapter describes the machine-independent syntax allowed in a
612 source file. @code{as} syntax is similar to what many other assemblers
613 use; it is inspired in BSD 4.2
614 assembler, except that @code{as} does not assemble Vax bit-fields.
617 * Pre-processing:: Pre-processing
618 * Whitespace:: Whitespace
619 * Comments:: Comments
620 * Symbol Intro:: Symbols
621 * Statements:: Statements
622 * Constants:: Constants
626 @section Pre-Processing
628 @cindex preprocessing
631 @cindex whitespace, removed by preprocessor
633 adjusts and removes extra whitespace. It leaves one space or tab before
634 the keywords on a line, and turns any other whitespace on the line into
637 @cindex comments, removed by preprocessor
639 removes all comments, replacing them with a single space, or an
640 appropriate number of newlines.
642 @cindex constants, converted by preprocessor
644 converts character constants into the appropriate numeric values.
647 Excess whitespace, comments, and character constants
648 cannot be used in the portions of the input text that are not
651 @cindex turning preprocessing on and off
652 @cindex preprocessing, turning on and off
655 If the first line of an input file is @code{#NO_APP} or the @samp{-f}
656 option is given, the input file will not be pre-processed. Within such
657 an input file, parts of the file can be pre-processed by putting a line
658 that says @code{#APP} before the text that should be pre-processed, and
659 putting a line that says @code{#NO_APP} after them. This feature is
660 mainly intend to support @code{asm} statements in compilers whose output
661 normally does not need to be pre-processed.
667 @dfn{Whitespace} is one or more blanks or tabs, in any order.
668 Whitespace is used to separate symbols, and to make programs neater for
669 people to read. Unless within character constants
670 (@pxref{Characters,,Character Constants}), any whitespace means the same
671 as exactly one space.
677 There are two ways of rendering comments to @code{as}. In both
678 cases the comment is equivalent to one space.
680 Anything from @samp{/*} through the next @samp{*/} is a comment.
681 This means you may not nest these comments.
685 The only way to include a newline ('\n') in a comment
686 is to use this sort of comment.
689 /* This sort of comment does not nest. */
692 @cindex line comment character
693 Anything from the @dfn{line comment} character to the next newline
694 is considered a comment and is ignored. The line comment character is
696 @samp{#} on the i960;
697 @samp{|} on the 680x0;
698 @samp{;} for the AMD 29K family;
699 @samp{;} for the machine specific family;
700 @samp{!} for the Z8000.
701 @pxref{Machine Dependent}. @refill
702 @c FIXME: fill in SPARC line comment char
704 On some machines there are two different line comment characters. One
705 will only begin a comment if it is the first non-whitespace character on
706 a line, while the other will always begin a comment.
709 @cindex lines starting with @code{#}
710 @cindex logical line numbers
711 To be compatible with past assemblers, a special interpretation is
712 given to lines that begin with @samp{#}. Following the @samp{#} an
713 absolute expression (@pxref{Expressions}) is expected: this will be
714 the logical line number of the @b{next} line. Then a string
715 (@xref{Strings}.) is allowed: if present it is a new logical file
716 name. The rest of the line, if any, should be whitespace.
718 If the first non-whitespace characters on the line are not numeric,
719 the line is ignored. (Just like a comment.)
721 # This is an ordinary comment.
722 # 42-6 "new_file_name" # New logical file name
723 # This is logical line # 36.
725 This feature is deprecated, and may disappear from future versions
731 @cindex characters used in symbols
732 A @dfn{symbol} is one or more characters chosen from the set of all
733 letters (both upper and lower case), digits and
734 the two characters @samp{_.}
735 On most machines, you can also use @code{$} in symbol names; exceptions
736 are noted in @ref{Machine Dependent}.
737 No symbol may begin with a digit. Case is significant.
738 There is no length limit: all characters are significant. Symbols are
739 delimited 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
741 not a possible symbol delimiter). @xref{Symbols}.
742 @cindex length of symbols
747 @cindex statements, structure of
748 @cindex line separator character
749 @cindex statement separator character
750 A @dfn{statement} ends at a newline character (@samp{\n}) or line
751 separator character. (The line separator is usually @samp{;}, unless
752 this conflicts with the comment character; @pxref{Machine Dependent}.) The
753 newline or separator character is considered part of the preceding
754 statement. Newlines and separators within character constants are an
755 exception: they don't end statements.
757 @cindex newline, required at file end
758 @cindex EOF, newline must precede
759 It is an error to end any statement with end-of-file: the last
760 character of any input file should be a newline.@refill
762 @cindex continuing statements
763 @cindex multi-line statements
764 @cindex statement on multiple lines
765 You may write a statement on more than one line if you put a
766 backslash (@kbd{\}) immediately in front of any newlines within the
767 statement. When @code{as} reads a backslashed newline both
768 characters are ignored. You can even put backslashed newlines in
769 the middle of symbol names without changing the meaning of your
772 An empty statement is allowed, and may include whitespace. It is ignored.
774 @cindex instructions and directives
775 @cindex directives and instructions
776 @c "key symbol" is not used elsewhere in the document; seems pedantic to
779 A statement begins with zero or more labels, optionally followed by a
780 key symbol which determines what kind of statement it is. The key
781 symbol determines the syntax of the rest of the statement. If the
782 symbol begins with a dot @samp{.} then the statement is an assembler
783 directive: typically valid for any computer. If the symbol begins with
784 a letter the statement is an assembly language @dfn{instruction}: it
785 will assemble into a machine language instruction.
786 Different versions of @code{as} for different computers will
787 recognize different instructions. In fact, the same symbol may
788 represent a different instruction in a different computer's assembly
791 @cindex @code{:} (label)
792 @cindex label (@code{:})
793 A label is a symbol immediately followed by a colon (@code{:}).
794 Whitespace before a label or after a colon is permitted, but you may not
795 have whitespace between a label's symbol and its colon. @xref{Labels}.
798 label: .directive followed by something
799 another_label: # This is an empty statement.
800 instruction operand_1, operand_2, @dots{}
807 A constant is a number, written so that its value is known by
808 inspection, without knowing any context. Like this:
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\
814 95028841971.693993751E-40 # - pi, a flonum.
818 * Characters:: Character Constants
819 * Numbers:: Number Constants
823 @subsection Character Constants
825 @cindex character constants
826 @cindex constants, character
827 There are two kinds of character constants. A @dfn{character} stands
828 for one character in one byte and its value may be used in
829 numeric expressions. String constants (properly called string
830 @emph{literals}) are potentially many bytes and their values may not be
831 used in arithmetic expressions.
839 @subsubsection Strings
841 @cindex string constants
842 @cindex constants, string
843 A @dfn{string} is written between double-quotes. It may contain
844 double-quotes or null characters. The way to get special characters
845 into a string is to @dfn{escape} these characters: precede them with
846 a backslash @samp{\} character. For example @samp{\\} represents
847 one 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
850 escape character). The complete list of escapes follows.
852 @cindex escape codes, character
853 @cindex character escape codes
856 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
859 @cindex @code{\b} (backspace character)
860 @cindex backspace (@code{\b})
861 Mnemonic for backspace; for ASCII this is octal code 010.
864 @c Mnemonic for EOText; for ASCII this is octal code 004.
867 @cindex @code{\f} (formfeed character)
868 @cindex formfeed (@code{\f})
869 Mnemonic for FormFeed; for ASCII this is octal code 014.
872 @cindex @code{\n} (newline character)
873 @cindex newline (@code{\n})
874 Mnemonic for newline; for ASCII this is octal code 012.
877 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
880 @cindex @code{\r} (carriage return character)
881 @cindex carriage return (@code{\r})
882 Mnemonic for carriage-Return; for ASCII this is octal code 015.
885 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
889 @cindex @code{\t} (tab)
890 @cindex tab (@code{\t})
891 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
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.
898 @item \ @var{digit} @var{digit} @var{digit}
899 @cindex @code{\@var{ddd}} (octal character code)
900 @cindex octal character code (@code{\@var{ddd}})
901 An octal character code. The numeric code is 3 octal digits.
902 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
903 for example, @code{\008} has the value 010, and @code{\009} the value 011.
906 @cindex @code{\\} (@samp{\} character)
907 @cindex backslash (@code{\\})
908 Represents one @samp{\} character.
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
917 @cindex @code{\"} (doublequote character)
918 @cindex doublequote (@code{\"})
919 Represents one @samp{"} character. Needed in strings to represent
920 this character, because an unescaped @samp{"} would end the string.
922 @item \ @var{anything-else}
923 Any other character when escaped by @kbd{\} will give a warning, but
924 assemble as if the @samp{\} was not present. The idea is that if
925 you used an escape sequence you clearly didn't want the literal
926 interpretation of the following character. However @code{as} has no
927 other interpretation, so @code{as} knows it is giving you the wrong
928 code and warns you of the fact.
931 Which characters are escapable, and what those escapes represent,
932 varies widely among assemblers. The current set is what we think
933 the BSD 4.2 assembler recognizes, and is a subset of what most C
934 compilers recognize. If you are in doubt, don't use an escape
938 @subsubsection Characters
940 @cindex single character constant
941 @cindex character, single
942 @cindex constant, single character
943 A single character may be written as a single quote immediately
944 followed by that character. The same escapes apply to characters as
945 to strings. So if you want to write the character backslash, you
946 must write @kbd{'\\} where the first @code{\} escapes the second
947 @code{\}. As you can see, the quote is an acute accent, not a
948 grave accent. A newline
949 immediately following an acute accent is taken as a literal character
950 and does not count as the end of a statement. The value of a character
951 constant in a numeric expression is the machine's byte-wide code for
952 that character. @code{as} assumes your character code is ASCII:
953 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
956 @subsection Number Constants
958 @cindex constants, number
959 @cindex number constants
960 @code{as} distinguishes three kinds of numbers according to how they
961 are stored in the target machine. @emph{Integers} are numbers that
962 would fit into an @code{int} in the C language. @emph{Bignums} are
963 integers, but they are stored in more than 32 bits. @emph{Flonums}
964 are floating point numbers, described below.
967 * Integers:: Integers
973 @subsubsection Integers
975 @cindex constants, integer
977 @cindex binary integers
978 @cindex integers, binary
979 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
980 the binary digits @samp{01}.
982 @cindex octal integers
983 @cindex integers, octal
984 An octal integer is @samp{0} followed by zero or more of the octal
985 digits (@samp{01234567}).
987 @cindex decimal integers
988 @cindex integers, decimal
989 A decimal integer starts with a non-zero digit followed by zero or
990 more digits (@samp{0123456789}).
992 @cindex hexadecimal integers
993 @cindex integers, hexadecimal
994 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
995 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
997 Integers have the usual values. To denote a negative integer, use
998 the prefix operator @samp{-} discussed under expressions
999 (@pxref{Prefix Ops,,Prefix Operators}).
1002 @subsubsection Bignums
1005 @cindex constants, bignum
1006 A @dfn{bignum} has the same syntax and semantics as an integer
1007 except that the number (or its negative) takes more than 32 bits to
1008 represent in binary. The distinction is made because in some places
1009 integers are permitted while bignums are not.
1012 @subsubsection Flonums
1014 @cindex floating point numbers
1015 @cindex constants, floating point
1017 @cindex precision, floating point
1018 A @dfn{flonum} represents a floating point number. The translation is
1019 indirect: a decimal floating point number from the text is converted by
1020 @code{as} to a generic binary floating point number of more than
1021 sufficient precision. This generic floating point number is converted
1022 to a particular computer's floating point format (or formats) by a
1023 portion of @code{as} specialized to that computer.
1025 A flonum is written by writing (in order)
1030 A letter, to tell @code{as} the rest of the number is a flonum.
1031 @kbd{e} is recommended. Case is not important.
1033 @c FIXME: verify if flonum syntax really this vague for most cases
1034 (Any otherwise illegal letter
1035 will work here, but that might be changed. Vax BSD 4.2 assembler seems
1036 to allow any of @samp{defghDEFGH}.)
1038 On the AMD 29K and H8/300 architectures, the letter must be:
1039 One of the letters @samp{DFPRSX} (in upper or lower case).
1040 On the Intel 960 architecture, the letter must be:
1041 One of the letters @samp{DFT} (in upper or lower case).
1043 An optional sign: either @samp{+} or @samp{-}.
1045 An optional @dfn{integer part}: zero or more decimal digits.
1047 An optional @dfn{fractional part}: @samp{.} followed by zero
1048 or more decimal digits.
1050 An optional exponent, consisting of:
1053 An @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.
1057 Optional sign: either @samp{+} or @samp{-}.
1059 One or more decimal digits.
1063 At least one of the integer part or the fractional part must be
1064 present. The floating point number has the usual base-10 value.
1066 @code{as} does all processing using integers. Flonums are computed
1067 independently of any floating point hardware in the computer running
1072 @chapter Sections and Relocation
1077 * Secs Background:: Background
1078 * ld Sections:: ld Sections
1079 * as Sections:: as Internal Sections
1080 * Sub-Sections:: Sub-Sections
1084 @node Secs Background
1087 Roughly, a section is a range of addresses, with no gaps; all data
1088 ``in'' those addresses is treated the same for some particular purpose.
1089 For example there may be a ``read only'' section.
1091 @cindex linker, and assembler
1092 @cindex assembler, and linker
1093 The linker @code{ld} reads many object files (partial programs) and
1094 combines their contents to form a runnable program. When @code{as}
1095 emits an object file, the partial program is assumed to start at address
1096 0. @code{ld} will assign the final addresses the partial program
1097 occupies, so that different partial programs don't overlap. This is
1098 actually an over-simplification, but it will suffice to explain how
1099 @code{as} uses sections.
1101 @code{ld} moves blocks of bytes of your program to their run-time
1102 addresses. These blocks slide to their run-time addresses as rigid
1103 units; their length does not change and neither does the order of bytes
1104 within them. Such a rigid unit is called a @emph{section}. Assigning
1105 run-time addresses to sections is called @dfn{relocation}. It includes
1106 the task of adjusting mentions of object-file addresses so they refer to
1107 the proper run-time addresses.
1108 For the H8/300, @code{as} pads sections if needed to ensure they end
1109 on a word (sixteen bit) boundary.
1111 @cindex standard @code{as} sections
1112 An object file written by @code{as} has at least three sections, any
1113 of which may be empty. These are named @dfn{text}, @dfn{data} and
1116 When it generates COFF output,
1117 @code{as} can also generate whatever other named sections you specify
1118 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1119 If you don't use any directives that place output in the @samp{.text}
1120 or @samp{.data} sections, these sections will still exist, but will be empty.
1122 Within the object file, the text section starts at address @code{0}, the
1123 data section follows, and the bss section follows the data section.
1125 To let @code{ld} know which data will change when the sections are
1126 relocated, and how to change that data, @code{as} also writes to the
1127 object file details of the relocation needed. To perform relocation
1128 @code{ld} must know, each time an address in the object
1132 Where in the object file is the beginning of this reference to
1135 How long (in bytes) is this reference?
1137 Which section does the address refer to? What is the numeric value of
1139 (@var{address}) @minus{} (@var{start-address of section})?
1142 Is the reference to an address ``Program-Counter relative''?
1145 @cindex addresses, format of
1146 @cindex section-relative addressing
1147 In fact, every address @code{as} ever uses is expressed as
1149 (@var{section}) + (@var{offset into section})
1152 Further, every expression @code{as} computes is of this section-relative
1153 nature. @dfn{Absolute expression} means an expression with section
1154 ``absolute'' (@pxref{ld Sections}). A @dfn{pass1 expression} means
1155 an expression with section ``pass1'' (@pxref{as Sections,,as
1156 Internal Sections}). In this manual we use the notation @{@var{secname}
1157 @var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1159 Apart from text, data and bss sections you need to know about the
1160 @dfn{absolute} section. When @code{ld} mixes partial programs,
1161 addresses in the absolute section remain unchanged. For example, address
1162 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{ld}.
1163 Although two partial programs' data sections will not overlap addresses
1164 after linking, @emph{by definition} their absolute sections will overlap.
1165 Address @code{@{absolute@ 239@}} in one partial program will always be the same
1166 address when the program is running as address @code{@{absolute@ 239@}} in any
1167 other partial program.
1169 The idea of sections is extended to the @dfn{undefined} section. Any
1170 address whose section is unknown at assembly time is by definition
1171 rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
1172 Since numbers are always defined, the only way to generate an undefined
1173 address is to mention an undefined symbol. A reference to a named
1174 common block would be such a symbol: its value is unknown at assembly
1175 time so it has section @emph{undefined}.
1177 By analogy the word @emph{section} is used to describe groups of sections in
1178 the linked program. @code{ld} puts all partial programs' text
1179 sections in contiguous addresses in the linked program. It is
1180 customary to refer to the @emph{text section} of a program, meaning all
1181 the addresses of all partial program's text sections. Likewise for
1182 data and bss sections.
1184 Some sections are manipulated by @code{ld}; others are invented for
1185 use of @code{as} and have no meaning except during assembly.
1188 @section ld Sections
1189 @code{ld} deals with just four kinds of sections, summarized below.
1193 @cindex named sections
1194 @cindex sections, named
1195 @item named sections
1196 @cindex text section
1197 @cindex data section
1200 These sections hold your program. @code{as} and @code{ld} treat them as
1201 separate but equal sections. Anything you can say of one section is
1203 When the program is running, however, it is
1204 customary for the text section to be unalterable. The
1205 text section is often shared among processes: it will contain
1206 instructions, constants and the like. The data section of a running
1207 program is usually alterable: for example, C variables would be stored
1208 in the data section.
1212 This section contains zeroed bytes when your program begins running. It
1213 is used to hold unitialized variables or common storage. The length of
1214 each partial program's bss section is important, but because it starts
1215 out containing zeroed bytes there is no need to store explicit zero
1216 bytes in the object file. The bss section was invented to eliminate
1217 those explicit zeros from object files.
1219 @cindex absolute section
1220 @item absolute section
1221 Address 0 of this section is always ``relocated'' to runtime address 0.
1222 This is useful if you want to refer to an address that @code{ld} must
1223 not change when relocating. In this sense we speak of absolute
1224 addresses being ``unrelocatable'': they don't change during relocation.
1226 @cindex undefined section
1227 @item undefined section
1228 This ``section'' is a catch-all for address references to objects not in
1229 the preceding sections.
1230 @c FIXME: ref to some other doc on obj-file formats could go here.
1233 @cindex relocation example
1234 An idealized example of three relocatable sections follows.
1235 The example uses the traditional section names @samp{.text} and @samp{.data}.
1236 Memory addresses are on the horizontal axis.
1240 @c END TEXI2ROFF-KILL
1243 partial program # 1: |ttttt|dddd|00|
1250 partial program # 2: |TTT|DDD|000|
1253 +--+---+-----+--+----+---+-----+~~
1254 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1255 +--+---+-----+--+----+---+-----+~~
1257 addresses: 0 @dots{}
1261 @c FIXME make sure no page breaks inside figure!!
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}
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}
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
1275 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1276 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1278 \line{\it addresses: \hfil}
1282 @c END TEXI2ROFF-KILL
1285 @section as Internal Sections
1287 @cindex internal @code{as} sections
1288 @cindex sections in messages, internal
1289 These sections are meant only for the internal use of @code{as}. They
1290 have no meaning at run-time. You don't really need to know about these
1291 sections for most purposes; but they can be mentioned in @code{as}
1292 warning messages, so it might be helpful to have an idea of their
1293 meanings to @code{as}. These sections are used to permit the
1294 value of every expression in your assembly language program to be a
1295 section-relative address.
1299 @cindex absent (internal section)
1300 An expression was expected and none was found.
1302 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1303 @cindex assembler internal logic error
1304 An internal assembler logic error has been found. This means there is a
1305 bug in the assembler.
1308 @cindex bignum/flonum (internal section)
1309 If a number can't be written as a C @code{int} constant (a bignum or a
1310 flonum, but not an integer), it is recorded as belonging to this
1311 ``section''. @code{as} has to remember that a flonum or a bignum
1312 does not fit into 32 bits, and cannot be an argument (@pxref{Arguments})
1313 in an expression: this is done by making a flonum or bignum be in a
1314 separate internal section. This is purely for internal @code{as}
1315 convenience; bignum/flonum section behaves similarly to absolute
1319 @cindex pass1 (internal section)
1320 The expression was impossible to evaluate in the first pass. The
1321 assembler will attempt a second pass (second reading of the source) to
1322 evaluate the expression. Your expression mentioned an undefined symbol
1323 in a way that defies the one-pass (section + offset in section) assembly
1324 process. No compiler need emit such an expression.
1327 @emph{Warning:} the second pass is currently not implemented. @code{as}
1328 will abort with an error message if one is required.
1331 @item difference section
1332 @cindex difference (internal section)
1333 As an assist to the C compiler, expressions of the forms
1335 (@var{undefined symbol}) @minus{} (@var{expression})
1336 @var{something} @minus{} (@var{undefined symbol})
1337 (@var{undefined symbol}) @minus{} (@var{undefined symbol})
1340 are permitted, and belong to the difference section. @code{as}
1341 re-evaluates such expressions after the source file has been read and
1342 the symbol table built. If by that time there are no undefined symbols
1343 in the expression then the expression assumes a new section. The
1344 intention is to permit statements like
1345 @samp{.word label - base_of_table}
1346 to be assembled in one pass where both @code{label} and
1347 @code{base_of_table} are undefined. This is useful for compiling C and
1348 Algol switch statements, Pascal case statements, FORTRAN computed goto
1349 statements and the like.
1351 @c FIXME item transfer[t] vector preload
1352 @c FIXME item transfer[t] vector postload
1353 @c FIXME item register
1357 @section Sub-Sections
1359 @cindex numbered subsections
1360 @cindex grouping data
1363 fall into two sections: text and data.
1364 You may have separate groups of
1365 data in named sections
1366 that you want to end up near to each other in the object
1367 file, even though they are not contiguous in the assembler source.
1368 @code{as} allows you to use @dfn{subsections} for this purpose.
1369 Within each section, there can be numbered subsections with
1370 values from 0 to 8192. Objects assembled into the same subsection will
1371 be grouped with other objects in the same subsection when they are all
1372 put into the object file. For example, a compiler might want to store
1373 constants in the text section, but might not want to have them
1374 interspersed with the program being assembled. In this case, the
1375 compiler could issue a @samp{.text 0} before each section of code being
1376 output, and a @samp{.text 1} before each group of constants being output.
1378 Subsections are optional. If you don't use subsections, everything
1379 will be stored in subsection number zero.
1381 Each subsection is zero-padded up to a multiple of four bytes.
1382 (Subsections may be padded a different amount on different flavors
1385 Subsections appear in your object file in numeric order, lowest numbered
1386 to highest. (All this to be compatible with other people's assemblers.)
1387 The object file contains no representation of subsections; @code{ld} and
1388 other programs that manipulate object files will see no trace of them.
1389 They just see all your text subsections as a text section, and all your
1390 data subsections as a data section.
1392 To specify which subsection you want subsequent statements assembled
1393 into, use a numeric argument to specify it, in a @samp{.text
1394 @var{expression}} or a @samp{.data @var{expression}} statement.
1395 When generating COFF output, you
1396 can also use an extra subsection
1397 argument with arbitrary named sections: @samp{.section @var{name},
1399 @var{Expression} should be an absolute expression.
1400 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
1401 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
1402 begins in @code{text 0}. For instance:
1404 .text 0 # The default subsection is text 0 anyway.
1405 .ascii "This lives in the first text subsection. *"
1407 .ascii "But this lives in the second text subsection."
1409 .ascii "This lives in the data section,"
1410 .ascii "in the first data subsection."
1412 .ascii "This lives in the first text section,"
1413 .ascii "immediately following the asterisk (*)."
1416 Each section has a @dfn{location counter} incremented by one for every
1417 byte assembled into that section. Because subsections are merely a
1418 convenience restricted to @code{as} there is no concept of a subsection
1419 location counter. There is no way to directly manipulate a location
1420 counter---but the @code{.align} directive will change it, and any label
1421 definition will capture its current value. The location counter of the
1422 section that statements are being assembled into is said to be the
1423 @dfn{active} location counter.
1426 @section bss Section
1429 @cindex common variable storage
1430 The bss section is used for local common variable storage.
1431 You may allocate address space in the bss section, but you may
1432 not dictate data to load into it before your program executes. When
1433 your program starts running, all the contents of the bss
1434 section are zeroed bytes.
1436 Addresses in the bss section are allocated with special directives; you
1437 may not assemble anything directly into the bss section. Hence there
1438 are no bss subsections. @xref{Comm,,@code{.comm}},
1439 @pxref{Lcomm,,@code{.lcomm}}.
1445 Symbols are a central concept: the programmer uses symbols to name
1446 things, the linker uses symbols to link, and the debugger uses symbols
1450 @cindex debuggers, and symbol order
1451 @emph{Warning:} @code{as} does not place symbols in the object file in
1452 the same order they were declared. This may break some debuggers.
1457 * Setting Symbols:: Giving Symbols Other Values
1458 * Symbol Names:: Symbol Names
1459 * Dot:: The Special Dot Symbol
1460 * Symbol Attributes:: Symbol Attributes
1467 A @dfn{label} is written as a symbol immediately followed by a colon
1468 @samp{:}. The symbol then represents the current value of the
1469 active location counter, and is, for example, a suitable instruction
1470 operand. You are warned if you use the same symbol to represent two
1471 different locations: the first definition overrides any other
1474 @node Setting Symbols
1475 @section Giving Symbols Other Values
1477 @cindex assigning values to symbols
1478 @cindex symbol values, assigning
1479 A symbol can be given an arbitrary value by writing a symbol, followed
1480 by an equals sign @samp{=}, followed by an expression
1481 (@pxref{Expressions}). This is equivalent to using the @code{.set}
1482 directive. @xref{Set,,@code{.set}}.
1485 @section Symbol Names
1487 @cindex symbol names
1488 @cindex names, symbol
1489 Symbol names begin with a letter or with one of
1491 (On most machines, you can also use @code{$} in symbol names; exceptions
1492 are noted in @ref{Machine Dependent}.)
1493 That character may be followed by any string of digits, letters,
1494 dollar signs (unless otherwise noted in @ref{Machine Dependent}),
1496 Case of letters is significant:
1497 @code{foo} is a different symbol name than @code{Foo}.
1499 For the AMD 29K family, @samp{?} is also allowed in the
1500 body of a symbol name, though not at its beginning.
1502 Each symbol has exactly one name. Each name in an assembly language
1503 program refers to exactly one symbol. You may use that symbol name any
1504 number of times in a program.
1506 @subheading Local Symbol Names
1508 @cindex local symbol names
1509 @cindex symbol names, local
1510 @cindex temporary symbol names
1511 @cindex symbol names, temporary
1512 Local symbols help compilers and programmers use names temporarily.
1513 There are ten local symbol names, which are re-used throughout the
1514 program. 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
1517 recent previous definition of that symbol write @samp{@b{N}b}, using the
1518 same digit as when you defined the label. To refer to the next
1519 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
1520 a choice of 10 forward references. The @samp{b} stands for
1521 ``backwards'' and the @samp{f} stands for ``forwards''.
1523 Local symbols are not emitted by the current GNU C compiler.
1525 There is no restriction on how you can use these labels, but
1526 remember that at any point in the assembly you can refer to at most
1527 10 prior local labels and to at most 10 forward local labels.
1529 Local symbol names are only a notation device. They are immediately
1530 transformed into more conventional symbol names before the assembler
1531 uses them. The symbol names stored in the symbol table, appearing in
1532 error messages and optionally emitted to the object file have these
1537 All local labels begin with @samp{L}. Normally both @code{as} and
1538 @code{ld} forget symbols that start with @samp{L}. These labels are
1539 used 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
1541 object file. If you also instruct @code{ld} to retain these symbols,
1542 you may use them in debugging.
1545 If the label is written @samp{0:} then the digit is @samp{0}.
1546 If the label is written @samp{1:} then the digit is @samp{1}.
1547 And so on up through @samp{9:}.
1550 This unusual character is included so you don't accidentally invent
1551 a symbol of the same name. The character has ASCII value
1554 @item @emph{ordinal number}
1555 This 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
1557 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
1561 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
1562 @code{3:} is named @code{L3@ctrl{A}44}.
1565 @section The Special Dot Symbol
1567 @cindex dot (symbol)
1568 @cindex @code{.} (symbol)
1569 @cindex current address
1570 @cindex location counter
1571 The 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.
1574 Assigning a value to @code{.} is treated the same as a @code{.org}
1575 directive. Thus, the expression @samp{.=.+4} is the same as saying
1578 @node Symbol Attributes
1579 @section Symbol Attributes
1581 @cindex symbol attributes
1582 @cindex attributes, symbol
1583 Every symbol has, as well as its name, the attributes ``Value'' and
1584 ``Type''. Depending on output format, symbols can also have auxiliary
1587 If you use a symbol without defining it, @code{as} assumes zero for
1588 all these attributes, and probably won't warn you. This makes the
1589 symbol an externally defined symbol, which is generally what you
1593 * Symbol Value:: Value
1594 * Symbol Type:: Type
1595 * a.out Symbols:: Symbol Attributes: @code{a.out}
1596 * COFF Symbols:: Symbol Attributes for COFF
1602 @cindex value of a symbol
1603 @cindex symbol value
1604 The value of a symbol is (usually) 32 bits. For a symbol which labels a
1605 location in the text, data, bss or absolute sections the value is the
1606 number of addresses from the start of that section to the label.
1607 Naturally for text, data and bss sections the value of a symbol changes
1608 as @code{ld} changes section base addresses during linking. Absolute
1609 symbols' values do not change during linking: that is why they are
1612 The value of an undefined symbol is treated in a special way. If it is
1613 0 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
1615 linked with. You make this kind of symbol simply by mentioning a symbol
1616 name without defining it. A non-zero value represents a @code{.comm}
1617 common declaration. The value is how much common storage to reserve, in
1618 bytes (addresses). The symbol refers to the first address of the
1624 @cindex type of a symbol
1626 The type attribute of a symbol contains relocation (section)
1627 information, any flag settings indicating that a symbol is external, and
1628 (optionally), other information for linkers and debuggers. The exact
1629 format depends on the object-code output format in use.
1632 @subsection Symbol Attributes: @code{a.out}
1634 @cindex @code{a.out} symbol attributes
1635 @cindex symbol attributes, @code{a.out}
1638 * Symbol Desc:: Descriptor
1639 * Symbol Other:: Other
1643 @subsubsection Descriptor
1645 @cindex descriptor, of @code{a.out} symbol
1646 This is an arbitrary 16-bit value. You may establish a symbol's
1647 descriptor value by using a @code{.desc} statement
1648 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
1652 @subsubsection Other
1654 @cindex other attribute, of @code{a.out} symbol
1655 This is an arbitrary 8-bit value. It means nothing to @code{as}.
1658 @subsection Symbol Attributes for COFF
1660 @cindex COFF symbol attributes
1661 @cindex symbol attributes, COFF
1663 The COFF format supports a multitude of auxiliary symbol attributes;
1664 like the primary symbol attributes, they are set between @code{.def} and
1665 @code{.endef} directives.
1667 @subsubsection Primary Attributes
1669 @cindex primary attributes, COFF symbols
1670 The symbol name is set with @code{.def}; the value and type,
1671 respectively, with @code{.val} and @code{.type}.
1673 @subsubsection Auxiliary Attributes
1675 @cindex auxiliary attributes, COFF symbols
1676 The @code{as} directives @code{.dim}, @code{.line}, @code{.scl},
1677 @code{.size}, and @code{.tag} can generate auxiliary symbol table
1678 information for COFF.
1681 @chapter Expressions
1685 @cindex numeric values
1686 An @dfn{expression} specifies an address or numeric value.
1687 Whitespace may precede and/or follow an expression.
1690 * Empty Exprs:: Empty Expressions
1691 * Integer Exprs:: Integer Expressions
1695 @section Empty Expressions
1697 @cindex empty expressions
1698 @cindex expressions, empty
1699 An empty expression has no value: it is just whitespace or null.
1700 Wherever an absolute expression is required, you may omit the
1701 expression and @code{as} will assume a value of (absolute) 0. This
1702 is compatible with other assemblers.
1705 @section Integer Expressions
1707 @cindex integer expressions
1708 @cindex expressions, integer
1709 An @dfn{integer expression} is one or more @emph{arguments} delimited
1710 by @emph{operators}.
1713 * Arguments:: Arguments
1714 * Operators:: Operators
1715 * Prefix Ops:: Prefix Operators
1716 * Infix Ops:: Infix Operators
1720 @subsection Arguments
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
1727 contexts arguments are sometimes called ``arithmetic operands''. In
1728 this manual, to avoid confusing them with the ``instruction operands'' of
1729 the machine language, we use the term ``argument'' to refer to parts of
1730 expressions only, reserving the word ``operand'' to refer only to machine
1731 instruction operands.
1733 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
1734 @var{section} is one of text, data, bss, absolute,
1735 or undefined. @var{NNN} is a signed, 2's complement 32 bit
1738 Numbers are usually integers.
1740 A number can be a flonum or bignum. In this case, you are warned
1741 that only the low order 32 bits are used, and @code{as} pretends
1742 these 32 bits are an integer. You may write integer-manipulating
1743 instructions that act on exotic constants, compatible with other
1746 @cindex subexpressions
1747 Subexpressions are a left parenthesis @samp{(} followed by an integer
1748 expression, followed by a right parenthesis @samp{)}; or a prefix
1749 operator followed by an argument.
1752 @subsection Operators
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
1758 operators are followed by an argument. Infix operators appear
1759 between their arguments. Operators may be preceded and/or followed by
1763 @subsection Prefix Operator
1765 @cindex prefix operators
1766 @code{as} has the following @dfn{prefix operators}. They each take
1767 one argument, which must be absolute.
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).
1773 \global\advance\leftskip by \itemindent
1778 @dfn{Negation}. Two's complement negation.
1780 @dfn{Complementation}. Bitwise not.
1784 \global\advance\leftskip by -\itemindent
1788 @subsection Infix Operators
1790 @cindex infix operators
1791 @cindex operators, permitted arguments
1792 @dfn{Infix operators} take two arguments, one on either side. Operators
1793 have precedence, but operations with equal precedence are performed left
1794 to right. Apart from @code{+} or @code{-}, both arguments must be
1795 absolute, and the result is absolute.
1798 @cindex operator precedence
1799 @cindex precedence of operators
1806 @dfn{Multiplication}.
1809 @dfn{Division}. Truncation is the same as the C operator @samp{/}
1816 @dfn{Shift Left}. Same as the C operator @samp{<<}
1820 @dfn{Shift Right}. Same as the C operator @samp{>>}
1824 Intermediate precedence
1829 @dfn{Bitwise Inclusive Or}.
1835 @dfn{Bitwise Exclusive Or}.
1838 @dfn{Bitwise Or Not}.
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
1850 has the section of the other argument.
1851 If either argument is pass1 or undefined, the result is pass1.
1852 Otherwise @code{+} is illegal.
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
1859 result has the section of the left argument.
1860 If either argument is pass1 the result is pass1.
1861 If either argument is undefined the result is difference section.
1862 If both arguments are in the same section, the result is absolute---provided
1863 that section is one of text, data or bss.
1864 Otherwise subtraction is illegal.
1868 The sense of the rule for addition is that it's only meaningful to add
1869 the @emph{offsets} in an address; you can only have a defined section in
1870 one of the two arguments.
1872 Similarly, you can't subtract quantities from two different sections.
1875 @chapter Assembler Directives
1877 @cindex directives, machine independent
1878 @cindex pseudo-ops, machine independent
1879 @cindex machine independent directives
1880 All assembler directives have names that begin with a period (@samp{.}).
1881 The rest of the name is letters, usually in lower case.
1883 This chapter discusses directives present regardless of the target
1884 machine configuration for the GNU assembler.
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}}
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}}
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
1945 @section @code{.abort}
1947 @cindex @code{abort} directive
1948 @cindex stopping the assembly
1949 This directive stops the assembly immediately. It is for
1950 compatibility with other assemblers. The original idea was that the
1951 assembly language source would be piped into the assembler. If the sender
1952 of the source quit, it could use this directive tells @code{as} to
1953 quit also. One day @code{.abort} will not be supported.
1956 @section @code{.ABORT}
1958 @cindex @code{ABORT} directive
1959 When producing COFF output, @code{as} accepts this directive as a
1960 synonym for @samp{.abort}.
1963 When producing @code{b.out} output, @code{as} accepts this directive,
1967 @section @code{.align @var{abs-expr} , @var{abs-expr}}
1969 @cindex padding the location counter
1970 @cindex @code{align} directive
1971 Pad the location counter (in the current subsection) to a particular
1972 storage boundary. The first expression (which must be absolute) is the
1973 number of low-order zero bits the location counter will have after
1974 advancement. For example @samp{.align 3} will advance the location
1975 counter until it a multiple of 8. If the location counter is already a
1976 multiple of 8, no change is needed.
1978 The second expression (also absolute) gives the value to be stored in
1979 the padding bytes. It (and the comma) may be omitted. If it is
1980 omitted, the padding bytes are zero.
1983 @section @code{.app-file @var{string}}
1985 @cindex logical file name
1986 @cindex file name, logical
1987 @cindex @code{app-file} directive
1989 tells @code{as} that we are about to start a new
1990 logical file. @var{string} is the new file name. In general, the
1991 filename is recognized whether or not it is surrounded by quotes @samp{"};
1992 but if you wish to specify an empty file name is permitted,
1993 you must give the quotes--@code{""}. This statement may go away in
1994 future: it is only recognized to be compatible with old @code{as}
1998 @section @code{.ascii "@var{string}"}@dots{}
2000 @cindex @code{ascii} directive
2001 @cindex string literals
2002 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2003 separated by commas. It assembles each string (with no automatic
2004 trailing zero byte) into consecutive addresses.
2007 @section @code{.asciz "@var{string}"}@dots{}
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
2013 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2016 @section @code{.byte @var{expressions}}
2018 @cindex @code{byte} directive
2019 @cindex integers, one byte
2020 @code{.byte} expects zero or more expressions, separated by commas.
2021 Each expression is assembled into the next byte.
2024 @section @code{.comm @var{symbol} , @var{length} }
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
2030 program 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}
2032 will allocate space for each @code{.comm} symbol that is at least as
2033 long as the longest @code{.comm} request in any of the partial programs
2034 linked. @var{length} is an absolute expression.
2037 @section @code{.data @var{subsection}}
2039 @cindex @code{data} directive
2040 @code{.data} tells @code{as} to assemble the following statements onto the
2041 end of the data subsection numbered @var{subsection} (which is an
2042 absolute expression). If @var{subsection} is omitted, it defaults
2046 @section @code{.def @var{name}}
2048 @cindex @code{def} directive
2049 @cindex COFF symbols, debugging
2050 @cindex debugging COFF symbols
2051 Begin defining debugging information for a symbol @var{name}; the
2052 definition extends until the @code{.endef} directive is encountered.
2054 This directive is only observed when @code{as} is configured for COFF
2055 format output; when producing @code{b.out}, @samp{.def} is recognized,
2059 @section @code{.desc @var{symbol}, @var{abs-expression}}
2061 @cindex @code{desc} directive
2062 @cindex COFF symbol descriptor
2063 @cindex symbol descriptor, COFF
2064 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2065 to the low 16 bits of an absolute expression.
2067 The @samp{.desc} directive is not available when @code{as} is
2068 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2069 object format. For the sake of compatibility, @code{as} will accept
2070 it, but produce no output, when configured for COFF.
2073 @section @code{.dim}
2075 @cindex @code{dim} directive
2076 @cindex COFF auxiliary symbol information
2077 @cindex auxiliary symbol information, COFF
2078 This directive is generated by compilers to include auxiliary debugging
2079 information in the symbol table. It is only permitted inside
2080 @code{.def}/@code{.endef} pairs.
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
2087 @section @code{.double @var{flonums}}
2089 @cindex @code{double} directive
2090 @cindex floating point numbers (double)
2091 @code{.double} expects zero or more flonums, separated by commas. It
2092 assembles floating point numbers.
2093 The exact kind of floating point numbers emitted depends on how
2094 @code{as} is configured. @xref{Machine Dependent}.
2097 @section @code{.eject}
2099 @cindex @code{eject} directive
2100 @cindex new page, in listings
2101 @cindex page, in listings
2102 @cindex listing control: new page
2103 Force a page break at this point, when generating assembly listings.
2106 @section @code{.else}
2108 @cindex @code{else} directive
2109 @code{.else} is part of the @code{as} support for conditional
2110 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2111 of code to be assembled if the condition for the preceding @code{.if}
2116 @section @code{.endef}
2118 @cindex @code{endef} directive
2119 This directive flags the end of a symbol definition begun with
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
2124 directive but ignores it.
2127 @section @code{.endif}
2129 @cindex @code{endif} directive
2130 @code{.endif} is part of the @code{as} support for conditional assembly;
2131 it marks the end of a block of code that is only assembled
2132 conditionally. @xref{If,,@code{.if}}.
2135 @section @code{.equ @var{symbol}, @var{expression}}
2137 @cindex @code{equ} directive
2138 @cindex assigning values to symbols
2139 @cindex symbols, assigning values to
2140 This directive sets the value of @var{symbol} to @var{expression}.
2141 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2144 @section @code{.extern}
2146 @cindex @code{extern} directive
2147 @code{.extern} is accepted in the source program---for compatibility
2148 with other assemblers---but it is ignored. @code{as} treats
2149 all undefined symbols as external.
2152 @section @code{.file @var{string}}
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
2160 recognized whether or not it is surrounded by quotes @samp{"}; but if
2161 you wish to specify an empty file name, you must give the
2162 quotes--@code{""}. This statement may go away in future: it is only
2163 recognized to be compatible with old @code{as} programs.
2164 In some configurations of @code{as}, @code{.file} has already been
2165 removed to avoid conflicts with other assemblers. @xref{Machine Dependent}.
2168 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
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.
2174 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2175 may be zero or more. @var{Size} may be zero or more, but if it is
2176 more than 8, then it is deemed to have the value 8, compatible with
2177 other people's assemblers. The contents of each @var{repeat} bytes
2178 is taken from an 8-byte number. The highest order 4 bytes are
2179 zero. The lowest order 4 bytes are @var{value} rendered in the
2180 byte-order of an integer on the computer @code{as} is assembling for.
2181 Each @var{size} bytes in a repetition is taken from the lowest order
2182 @var{size} bytes of this number. Again, this bizarre behavior is
2183 compatible with other people's assemblers.
2185 @var{size} and @var{value} are optional.
2186 If the second comma and @var{value} are absent, @var{value} is
2187 assumed zero. If the first comma and following tokens are absent,
2188 @var{size} is assumed to be 1.
2191 @section @code{.float @var{flonums}}
2193 @cindex floating point numbers (single)
2194 @cindex @code{float} directive
2195 This directive assembles zero or more flonums, separated by commas. It
2196 has the same effect as @code{.single}.
2197 The exact kind of floating point numbers emitted depends on how
2198 @code{as} is configured.
2199 @xref{Machine Dependent}.
2202 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
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
2208 other partial programs that are linked with it. Otherwise,
2209 @var{symbol} will take its attributes from a symbol of the same name
2210 from another partial program it is linked with.
2212 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
2213 compatibility with other assemblers.
2216 @section @code{.hword @var{expressions}}
2218 @cindex @code{hword} directive
2219 @cindex integers, 16-bit
2220 @cindex numbers, 16-bit
2221 @cindex sixteen bit integers
2222 This expects zero or more @var{expressions}, and emits
2223 a 16 bit number for each.
2225 This directive is a synonym for @samp{.short}; depending on the target
2226 architecture, it may also be a synonym for @samp{.word}.
2229 @section @code{.ident}
2231 @cindex @code{ident} directive
2232 This directive is used by some assemblers to place tags in object files.
2233 @code{as} simply accepts the directive for source-file
2234 compatibility with such assemblers, but does not actually emit anything
2238 @section @code{.if @var{absolute expression}}
2240 @cindex conditional assembly
2241 @cindex @code{if} directive
2242 @code{.if} marks the beginning of a section of code which is only
2243 considered part of the source program being assembled if the argument
2244 (which must be an @var{absolute expression}) is non-zero. The end of
2245 the conditional section of code must be marked by @code{.endif}
2246 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
2247 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
2249 The following variants of @code{.if} are also supported:
2251 @item .ifdef @var{symbol}
2252 @cindex @code{ifdef} directive
2253 Assembles the following section of code if the specified @var{symbol}
2257 @item .ifndef @var{symbol}
2258 @itemx ifnotdef @var{symbol}
2259 @cindex @code{ifndef} directive
2260 @cindex @code{ifnotdef} directive
2261 Assembles the following section of code if the specified @var{symbol}
2262 has not been defined. Both spelling variants are equivalent.
2267 @section @code{.include "@var{file}"}
2269 @cindex @code{include} directive
2270 @cindex supporting files, including
2271 @cindex files, including
2272 This directive provides a way to include supporting files at specified
2273 points in your source program. The code from @var{file} is assembled as
2274 if it followed the point of the @code{.include}; when the end of the
2275 included file is reached, assembly of the original file continues. You
2276 can control the search paths used with the @samp{-I} command-line option
2277 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
2281 @section @code{.int @var{expressions}}
2283 @cindex @code{int} directive
2284 @cindex integers, 32-bit
2285 Expect zero or more @var{expressions}, of any section, separated by
2286 commas. For each expression, emit a
2288 number that will, at run
2289 time, be the value of that expression. The byte order of the
2290 expression depends on what kind of computer will run the program.
2293 @section @code{.lcomm @var{symbol} , @var{length}}
2295 @cindex @code{lcomm} directive
2296 @cindex local common symbols
2297 @cindex symbols, local common
2298 Reserve @var{length} (an absolute expression) bytes for a local common
2299 denoted by @var{symbol}. The section and value of @var{symbol} are
2300 those of the new local common. The addresses are allocated in the bss
2301 section, so at run-time the bytes will start off zeroed. @var{Symbol}
2302 is not declared global (@pxref{Global,,@code{.global}}), so is normally
2303 not visible to @code{ld}.
2306 @section @code{.lflags}
2308 @cindex @code{lflags} directive (ignored)
2309 @code{as} accepts this directive, for compatibility with other
2310 assemblers, but ignores it.
2313 @section @code{.line @var{line-number}}
2315 @cindex @code{line} directive
2316 @cindex logical line number
2317 Tell @code{as} to change the logical line number. @var{line-number} must be
2318 an absolute expression. The next line will have that logical line
2319 number. So any other statements on the current line (after a statement
2322 will be reported as on logical line number
2323 @var{line-number} @minus{} 1.
2324 One day this directive will be unsupported: it is used only
2325 for compatibility with existing assembler programs. @refill
2327 @emph{Warning:} In the AMD29K configuration of as, this command is
2328 only available with the name @code{.ln}, rather than as either
2329 @code{.line} or @code{.ln}.
2332 @section @code{.ln @var{line-number}}
2334 @cindex @code{ln} directive
2335 @samp{.ln} is a synonym for @samp{.line}.
2338 @section @code{.list}
2340 @cindex @code{list} directive
2341 @cindex listing control, turning on
2342 Control (in conjunction with the @code{.nolist} directive) whether or
2343 not assembly listings are generated. These two directives maintain an
2344 internal counter (which is zero initially). @code{.list} increments the
2345 counter, and @code{.nolist} decrements it. Assembly listings are
2346 generated whenever the counter is greater than zero.
2348 By default, listings are disabled. When you enable them (with the
2349 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
2350 the initial value of the listing counter is one.
2353 @section @code{.long @var{expressions}}
2355 @cindex @code{long} directive
2356 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
2359 @c no one seems to know what this is for or whether this description is
2360 @c what it really ought to do
2362 @section @code{.lsym @var{symbol}, @var{expression}}
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
2367 the hash table, ensuring it cannot be referenced by name during the
2368 rest of the assembly. This sets the attributes of the symbol to be
2369 the same as the expression value:
2371 @var{other} = @var{descriptor} = 0
2372 @var{type} = @r{(section of @var{expression})}
2373 @var{value} = @var{expression}
2376 The new symbol is not flagged as external.
2380 @section @code{.nolist}
2382 @cindex @code{nolist} directive
2383 @cindex listing control, turning off
2384 Control (in conjunction with the @code{.list} directive) whether or
2385 not assembly listings are generated. These two directives maintain an
2386 internal counter (which is zero initially). @code{.list} increments the
2387 counter, and @code{.nolist} decrements it. Assembly listings are
2388 generated whenever the counter is greater than zero.
2391 @section @code{.octa @var{bignums}}
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
2397 This directive expects zero or more bignums, separated by commas. For each
2398 bignum, it emits a 16-byte integer.
2400 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
2401 hence @emph{octa}-word for 16 bytes.
2404 @section @code{.org @var{new-lc} , @var{fill}}
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
2412 expression with the same section as the current subsection. That is,
2413 you can't use @code{.org} to cross sections: if @var{new-lc} has the
2414 wrong section, the @code{.org} directive is ignored. To be compatible
2415 with 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}
2417 is the same as the current subsection.
2419 @code{.org} may only increase the location counter, or leave it
2420 unchanged; you cannot use @code{.org} to move the location counter
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)
2426 Because @code{as} tries to assemble programs in one pass @var{new-lc}
2427 may not be undefined. If you really detest this restriction we eagerly await
2428 a chance to share your improved assembler.
2430 Beware that the origin is relative to the start of the section, not
2431 to the start of the subsection. This is compatible with other
2432 people's assemblers.
2434 When the location counter (of the current subsection) is advanced, the
2435 intervening bytes are filled with @var{fill} which should be an
2436 absolute expression. If the comma and @var{fill} are omitted,
2437 @var{fill} defaults to zero.
2440 @section @code{.psize @var{lines} , @var{columns}}
2442 @cindex @code{psize} directive
2443 @cindex listing control: paper size
2444 @cindex paper size, for listings
2445 Use this directive to declare the number of lines---and, optionally, the
2446 number of columns---to use for each page, when generating listings.
2448 If you don't use @code{.psize}, listings will use a default line-count
2449 of 60. You may omit the comma and @var{columns} specification; the
2450 default width is 200 columns.
2452 @code{as} will generate formfeeds whenever the specified number of
2453 lines is exceeded (or whenever you explicitly request one, using
2456 If you specify @var{lines} as @code{0}, no formfeeds are generated save
2457 those explicitly specified with @code{.eject}.
2460 @section @code{.quad @var{bignums}}
2462 @cindex @code{quad} directive
2463 @code{.quad} expects zero or more bignums, separated by commas. For
2464 each bignum, it emits
2465 an 8-byte integer. If the bignum won't fit in 8
2466 bytes, it prints a warning message; and just takes the lowest order 8
2467 bytes of the bignum.@refill
2468 @cindex eight-byte integer
2469 @cindex integer, 8-byte
2471 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
2472 hence @emph{quad}-word for 8 bytes.
2475 @section @code{.sbttl "@var{subheading}"}
2477 @cindex @code{sbttl} directive
2478 @cindex subtitles for listings
2479 @cindex listing control: subtitle
2480 Use @var{subheading} as the title (third line, immediately after the
2481 title line) when generating assembly listings.
2483 This directive affects subsequent pages, as well as the current page if
2484 it appears within ten lines of the top of a page.
2487 @section @code{.scl @var{class}}
2489 @cindex @code{scl} directive
2490 @cindex symbol storage class (COFF)
2491 @cindex COFF symbol storage class
2492 Set the storage-class value for a symbol. This directive may only be
2493 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
2494 whether a symbol is static or external, or it may record further
2495 symbolic debugging information.
2497 The @samp{.scl} directive is primarily associated with COFF output; when
2498 configured to generate @code{b.out} output format, @code{as} will
2499 accept this directive but ignore it.
2502 @section @code{.section @var{name}, @var{subsection}}
2504 @cindex @code{section} directive
2505 @cindex named section (COFF)
2506 @cindex COFF named section
2507 Assemble 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.
2514 @section @code{.set @var{symbol}, @var{expression}}
2516 @cindex @code{set} directive
2517 @cindex symbol value, setting
2518 This directive sets the value of @var{symbol} to @var{expression}. This
2519 will change @var{symbol}'s value and type to conform to
2520 @var{expression}. If @var{symbol} was flagged as external, it remains
2521 flagged. (@xref{Symbol Attributes}.)
2523 You may @code{.set} a symbol many times in the same assembly.
2524 If the expression's section is unknowable during pass 1, a second
2525 pass over the source program will be forced. The second pass is
2526 currently not implemented. @code{as} will abort with an error
2527 message if one is required.
2529 If you @code{.set} a global symbol, the value stored in the object
2530 file is the last value stored into it.
2533 @section @code{.short @var{expressions}}
2535 @cindex @code{short} directive
2536 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
2539 @section @code{.single @var{flonums}}
2541 @cindex @code{single} directive
2542 @cindex floating point numbers (single)
2543 This directive assembles zero or more flonums, separated by commas. It
2544 has the same effect as @code{.float}.
2545 The exact kind of floating point numbers emitted depends on how
2546 @code{as} is configured. @xref{Machine Dependent}.
2549 @section @code{.size}
2551 @cindex @code{size} directive
2552 This directive is generated by compilers to include auxiliary debugging
2553 information in the symbol table. It is only permitted inside
2554 @code{.def}/@code{.endef} pairs.
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
2561 @section @code{.space @var{size} , @var{fill}}
2563 @cindex @code{space} directive
2564 @cindex filling memory
2565 This directive emits @var{size} bytes, each of value @var{fill}. Both
2566 @var{size} and @var{fill} are absolute expressions. If the comma
2567 and @var{fill} are omitted, @var{fill} is assumed to be zero.
2569 On the AMD 29K, this directive is ignored; it is accepted for
2570 compatibility with other AMD 29K assemblers.
2573 @emph{Warning:} In other versions of the GNU assembler, the directive
2574 @code{.space} has the effect of @code{.block} @xref{Machine Dependent}.
2578 @section @code{.stabd, .stabn, .stabs}
2580 @cindex symbolic debuggers, information for
2581 @cindex @code{stab@var{x}} directives
2582 There are three directives that begin @samp{.stab}.
2583 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
2584 The symbols are not entered in the @code{as} hash table: they
2585 cannot be referenced elsewhere in the source file.
2586 Up to five fields are required:
2589 This is the symbol's name. It may contain any character except @samp{\000},
2590 so is more general than ordinary symbol names. Some debuggers used to
2591 code arbitrarily complex structures into symbol names using this field.
2593 An absolute expression. The symbol's type is set to the low 8
2594 bits of this expression.
2595 Any bit pattern is permitted, but @code{ld} and debuggers will choke on
2598 An absolute expression.
2599 The symbol's ``other'' attribute is set to the low 8 bits of this expression.
2601 An absolute expression.
2602 The symbol's descriptor is set to the low 16 bits of this expression.
2604 An absolute expression which becomes the symbol's value.
2607 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
2608 or @code{.stabs} statement, the symbol has probably already been created
2609 and you will get a half-formed symbol in your object file. This is
2610 compatible with earlier assemblers!
2613 @cindex @code{stabd} directive
2614 @item .stabd @var{type} , @var{other} , @var{desc}
2616 The ``name'' of the symbol generated is not even an empty string.
2617 It is a null pointer, for compatibility. Older assemblers used a
2618 null pointer so they didn't waste space in object files with empty
2621 The symbol's value is set to the location counter,
2622 relocatably. When your program is linked, the value of this symbol
2623 will be where the location counter was when the @code{.stabd} was
2626 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
2627 @cindex @code{stabn} directive
2628 The name of the symbol is set to the empty string @code{""}.
2630 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
2631 @cindex @code{stabs} directive
2632 All five fields are specified.
2636 @section @code{.tag @var{structname}}
2638 @cindex COFF structure debugging
2639 @cindex structure debugging, COFF
2640 @cindex @code{tag} directive
2641 This directive is generated by compilers to include auxiliary debugging
2642 information in the symbol table. It is only permitted inside
2643 @code{.def}/@code{.endef} pairs. Tags are used to link structure
2644 definitions in the symbol table with instances of those structures.
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
2651 @section @code{.text @var{subsection}}
2653 @cindex @code{text} directive
2654 Tells @code{as} to assemble the following statements onto the end of
2655 the text subsection numbered @var{subsection}, which is an absolute
2656 expression. If @var{subsection} is omitted, subsection number zero
2660 @section @code{.title "@var{heading}"}
2662 @cindex @code{title} directive
2663 @cindex listing control: title line
2664 Use @var{heading} as the title (second line, immediately after the
2665 source file name and pagenumber) when generating assembly listings.
2667 This directive affects subsequent pages, as well as the current page if
2668 it appears within ten lines of the top of a page.
2671 @section @code{.type @var{int}}
2673 @cindex COFF symbol type
2674 @cindex symbol type, COFF
2675 @cindex @code{type} directive
2676 This directive, permitted only within @code{.def}/@code{.endef} pairs,
2677 records the integer @var{int} as the type attribute of a symbol table entry.
2679 @samp{.type} is associated only with COFF format output; when
2680 @code{as} is configured for @code{b.out} output, it accepts this
2681 directive but ignores it.
2684 @section @code{.val @var{addr}}
2686 @cindex @code{val} directive
2687 @cindex COFF value attribute
2688 @cindex value attribute, COFF
2689 This directive, permitted only within @code{.def}/@code{.endef} pairs,
2690 records the address @var{addr} as the value attribute of a symbol table
2693 @samp{.val} is used only for COFF output; when @code{as} is
2694 configured for @code{b.out}, it accepts this directive but ignores it.
2697 @section @code{.word @var{expressions}}
2699 @cindex @code{word} directive
2700 This directive expects zero or more @var{expressions}, of any section,
2701 separated by commas.
2703 The size of the number emitted, and its byte order,
2704 depends on what kind of computer will run the program.
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
2711 @emph{Warning: Special Treatment to support Compilers}
2714 Machines with a 32-bit address space, but that do less than 32-bit
2715 addressing, require the following special treatment. If the machine of
2716 interest to you does 32-bit addressing (or doesn't require it;
2717 @pxref{Machine Dependent}), you can ignore this issue.
2719 In order to assemble compiler output into something that will work,
2720 @code{as} will occasionlly do strange things to @samp{.word} directives.
2721 Directives of the form @samp{.word sym1-sym2} are often emitted by
2722 compilers as part of jump tables. Therefore, when @code{as} assembles a
2723 directive 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
2725 create a @dfn{secondary jump table}, immediately before the next label.
2726 This secondary jump table will be preceded by a short-jump to the
2727 first byte after the secondary table. This short-jump prevents the flow
2728 of control from accidentally falling into the new table. Inside the
2729 table will be a long-jump to @code{sym2}. The original @samp{.word}
2730 will contain @code{sym1} minus the address of the long-jump to
2733 If there were several occurrences of @samp{.word sym1-sym2} before the
2734 secondary 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
2736 long-jump to @code{sym4} will be included in the secondary jump table,
2737 and the @code{.word} directives will be adjusted to contain @code{sym3}
2738 minus the address of the long-jump to @code{sym4}; and so on, for as many
2739 entries in the original jump table as necessary.
2743 @section Deprecated Directives
2745 @cindex deprecated directives
2746 @cindex obsolescent directives
2747 One day these directives won't work.
2748 They are included for compatibility with older assemblers.
2755 @node Machine Dependent
2756 @chapter Machine Dependent Features
2758 @cindex machine dependencies
2759 The machine instruction sets are (almost by definition) different on
2760 each machine where @code{as} runs. Floating point representations
2761 vary as well, and @code{as} often supports a few additional
2762 directives or command-line options for compatibility with other
2763 assemblers on a particular platform. Finally, some versions of
2764 @code{as} support special pseudo-instructions for branch
2767 This chapter discusses most of these differences, though it does not
2768 include details on any machine's instruction set. For details on that
2769 subject, see the hardware manufacturer's manual.
2772 * Vax-Dependent:: VAX Dependent Features
2773 * AMD29K-Dependent:: AMD 29K Dependent Features
2774 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
2775 * i960-Dependent:: Intel 80960 Dependent Features
2776 * M68K-Dependent:: M680x0 Dependent Features
2777 * Sparc-Dependent:: SPARC Dependent Features
2778 * Z8000-Dependent:: Z8000 Dependent Features
2779 * i386-Dependent:: 80386 Dependent Features
2783 @section VAX Dependent Features
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
2797 @subsection VAX Command-Line Options
2799 @cindex command-line options ignored, VAX
2800 @cindex VAX command-line options ignored
2801 The Vax version of @code{as} accepts any of the following options,
2802 gives a warning message that the option was ignored and proceeds.
2803 These options are for compatibility with scripts designed for other
2804 people's assemblers.
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
2813 These are obsolete options used to debug old assemblers.
2815 @item @kbd{-d} (Displacement size for JUMPs)
2816 @cindex @code{-d}, VAX option
2817 This option expects a number following the @kbd{-d}. Like options
2818 that expect filenames, the number may immediately follow the
2819 @kbd{-d} (old standard) or constitute the whole of the command line
2820 argument that follows @kbd{-d} (GNU standard).
2822 @item @kbd{-V} (Virtualize Interpass Temporary File)
2823 @cindex @code{-V}, redundant on VAX
2824 Some other assemblers use a temporary file. This option
2825 commanded them to keep the information in active memory rather
2826 than in a disk file. @code{as} always does this, so this
2827 option is redundant.
2829 @item @kbd{-J} (JUMPify Longer Branches)
2830 @cindex @code{-J}, ignored on VAX
2831 Many 32-bit computers permit a variety of branch instructions
2832 to do the same job. Some of these instructions are short (and
2833 fast) but have a limited range; others are long (and slow) but
2834 can branch anywhere in virtual memory. Often there are 3
2835 flavors of branch: short, medium and long. Some other
2836 assemblers would emit short and medium branches, unless told by
2837 this option to emit short and long branches.
2839 @item @kbd{-t} (Temporary File Directory)
2840 @cindex @code{-t}, ignored on VAX
2841 Some other assemblers may use a temporary file, and this option
2842 takes a filename being the directory to site the temporary
2843 file. @code{as} does not use a temporary disk file, so this
2844 option makes no difference. @kbd{-t} needs exactly one
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.
2856 The Vax version of the assembler accepts two options when
2857 compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
2858 @kbd{-h} option prevents @code{as} from modifying the
2859 symbol-table entries for symbols that contain lowercase
2860 characters (I think). The @kbd{-+} option causes @code{as} to
2861 print warning messages if the FILENAME part of the object file,
2862 or any symbol name is larger than 31 characters. The @kbd{-+}
2863 option also insertes some code following the @samp{_main}
2864 symbol so that the object file will be compatible with Vax-11
2868 @subsection VAX Floating Point
2870 @cindex VAX floating point
2871 @cindex floating point, VAX
2872 Conversion of flonums to floating point is correct, and
2873 compatible with previous assemblers. Rounding is
2874 towards zero if the remainder is exactly half the least significant bit.
2876 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
2879 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
2880 are rendered correctly. Again, rounding is towards zero in the
2883 @cindex @code{float} directive, VAX
2884 @cindex @code{double} directive, VAX
2885 The @code{.float} directive produces @code{f} format numbers.
2886 The @code{.double} directive produces @code{d} format numbers.
2888 @node VAX-directives
2889 @subsection Vax Machine Directives
2891 @cindex machine directives, VAX
2892 @cindex VAX machine directives
2893 The Vax version of the assembler supports four directives for
2894 generating Vax floating point constants. They are described in the
2897 @cindex wide floating point directives, VAX
2900 @cindex @code{dfloat} directive, VAX
2901 This expects zero or more flonums, separated by commas, and
2902 assembles Vax @code{d} format 64-bit floating point constants.
2905 @cindex @code{ffloat} directive, VAX
2906 This expects zero or more flonums, separated by commas, and
2907 assembles Vax @code{f} format 32-bit floating point constants.
2910 @cindex @code{gfloat} directive, VAX
2911 This expects zero or more flonums, separated by commas, and
2912 assembles Vax @code{g} format 64-bit floating point constants.
2915 @cindex @code{hfloat} directive, VAX
2916 This expects zero or more flonums, separated by commas, and
2917 assembles Vax @code{h} format 128-bit floating point constants.
2922 @subsection VAX Opcodes
2924 @cindex VAX opcode mnemonics
2925 @cindex opcode mnemonics, VAX
2926 @cindex mnemonics for opcodes, VAX
2927 All DEC mnemonics are supported. Beware that @code{case@dots{}}
2928 instructions have exactly 3 operands. The dispatch table that
2929 follows the @code{case@dots{}} instruction should be made with
2930 @code{.word} statements. This is compatible with all unix
2931 assemblers we know of.
2934 @subsection VAX Branch Improvement
2936 @cindex VAX branch improvement
2937 @cindex branch improvement, VAX
2938 @cindex pseudo-ops for branch, VAX
2939 Certain pseudo opcodes are permitted. They are for branch
2940 instructions. They expand to the shortest branch instruction that
2941 will reach the target. Generally these mnemonics are made by
2942 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
2943 This feature is included both for compatibility and to help
2944 compilers. If you don't need this feature, don't use these
2945 opcodes. Here are the mnemonics, and the code they can expand into.
2949 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
2951 @item (byte displacement)
2953 @item (word displacement)
2955 @item (long displacement)
2960 Unconditional branch.
2962 @item (byte displacement)
2964 @item (word displacement)
2966 @item (long displacement)
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}.
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:}
2987 @var{X} may be one of @code{b d f g h l w}.
2989 @item (word displacement)
2990 @kbd{@var{OPCODE} @dots{}}
2991 @item (long displacement)
2993 @var{OPCODE} @dots{}, foo ;
3000 @var{YYY} may be one of @code{lss leq}.
3002 @var{ZZZ} may be one of @code{geq gtr}.
3004 @item (byte displacement)
3005 @kbd{@var{OPCODE} @dots{}}
3006 @item (word displacement)
3008 @var{OPCODE} @dots{}, foo ;
3010 foo: brw @var{destination} ;
3013 @item (long displacement)
3015 @var{OPCODE} @dots{}, foo ;
3017 foo: jmp @var{destination} ;
3026 @item (byte displacement)
3027 @kbd{@var{OPCODE} @dots{}}
3028 @item (word displacement)
3030 @var{OPCODE} @dots{}, foo ;
3032 foo: brw @var{destination} ;
3035 @item (long displacement)
3037 @var{OPCODE} @dots{}, foo ;
3039 foo: jmp @var{destination} ;
3046 @subsection VAX Operands
3048 @cindex VAX operand notation
3049 @cindex operand notation, VAX
3050 @cindex immediate character, VAX
3051 @cindex VAX immediate character
3052 The immediate character is @samp{$} for Unix compatibility, not
3053 @samp{#} as DEC writes it.
3055 @cindex indirect character, VAX
3056 @cindex VAX indirect character
3057 The indirect character is @samp{*} for Unix compatibility, not
3058 @samp{@@} as DEC writes it.
3060 @cindex displacement sizing character, VAX
3061 @cindex VAX displacement sizing character
3062 The displacement sizing character is @samp{`} (an accent grave) for
3063 Unix compatibility, not @samp{^} as DEC writes it. The letter
3064 preceding @samp{`} may have either case. @samp{G} is not
3065 understood, but all other letters (@code{b i l s w}) are understood.
3067 @cindex register names, VAX
3068 @cindex VAX register names
3069 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
3070 pc}. Any case of letters will do.
3077 Any expression is permitted in an operand. Operands are comma
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.
3086 @subsection Not Supported on VAX
3088 @cindex VAX bitfields not supported
3089 @cindex bitfields, not supported on VAX
3090 Vax bit fields can not be assembled with @code{as}. Someone
3091 can add the required code if they really need it.
3093 @node AMD29K-Dependent
3094 @section AMD 29K Dependent Features
3096 @cindex AMD 29K support
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
3106 @node AMD29K 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
3116 * AMD29K-Chars:: Special Characters
3117 * AMD29K-Regs:: Register Names
3121 @subsubsection Special Characters
3123 @cindex line comment character, AMD 29K
3124 @cindex AMD 29K line comment character
3125 @samp{;} is the line comment character.
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.
3133 @cindex identifiers, AMD 29K
3134 @cindex AMD 29K identifiers
3135 The character @samp{?} is permitted in identifiers (but may not begin
3139 @subsubsection Register Names
3141 @cindex AMD 29K register names
3142 @cindex register names, AMD 29K
3143 General-purpose registers are represented by predefined symbols of the
3144 form @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
3147 letters may be in either upper or lower case; for example, @samp{gr13}
3148 and @samp{LR7} are both valid register names.
3150 You may also refer to general-purpose registers by specifying the
3151 register number as the result of an expression (prefixed with @samp{%%}
3152 to flag the expression as a register number):
3157 ---where @var{expression} must be an absolute expression evaluating to a
3158 number between @code{0} and @code{255}. The range [0, 127] refers to
3159 global registers, and the range [128, 255] to local registers.
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
3165 In addition, @code{as} understands the following protected
3166 special-purpose register names for the AMD 29K family:
3176 These unprotected special-purpose register names are also recognized:
3184 @node AMD29K Floating Point
3185 @subsection Floating Point
3187 @cindex floating point, AMD 29K (@sc{ieee})
3188 @cindex AMD 29K floating point (@sc{ieee})
3189 The AMD 29K family uses @sc{ieee} floating-point numbers.
3191 @node AMD29K Directives
3192 @subsection AMD 29K Machine Directives
3194 @cindex machine directives, AMD 29K
3195 @cindex AMD 29K machine directives
3197 @item .block @var{size} , @var{fill}
3198 @cindex @code{block} directive, AMD 29K
3199 This directive emits @var{size} bytes, each of value @var{fill}. Both
3200 @var{size} and @var{fill} are absolute expressions. If the comma
3201 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3203 In other versions of the GNU assembler, this directive is called
3209 @cindex @code{cputype} directive, AMD 29K
3210 This directive is ignored; it is accepted for compatibility with other
3214 @cindex @code{file} directive, AMD 29K
3215 This directive is ignored; it is accepted for compatibility with other
3219 @emph{Warning:} in other versions of the GNU assembler, @code{.file} is
3220 used for the directive called @code{.app-file} in the AMD 29K support.
3224 @cindex @code{line} directive, AMD 29K
3225 This directive is ignored; it is accepted for compatibility with other
3229 @c since we're ignoring .lsym...
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}}.
3236 @cindex @code{sect} directive, AMD 29K
3237 This directive is ignored; it is accepted for compatibility with other
3240 @item .use @var{section name}
3241 @cindex @code{use} directive, AMD 29K
3242 Establishes 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
3245 name} options, @samp{.use} is equivalent to the machine directive
3246 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
3250 @node AMD29K Opcodes
3253 @cindex AMD 29K opcodes
3254 @cindex opcodes for AMD 29K
3255 @code{as} implements all the standard AMD 29K opcodes. No
3256 additional pseudo-instructions are needed on this family.
3258 For information on the 29K machine instruction set, see @cite{Am29000
3259 User's Manual}, Advanced Micro Devices, Inc.
3261 @node H8/300-Dependent
3262 @section H8/300 Dependent Features
3264 @cindex H8/300 support
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
3273 @node H8/300 Options
3276 @cindex H8/300 options (none)
3277 @cindex options, H8/300 (none)
3278 @code{as} has no additional command-line options for the Hitachi
3284 * H8/300-Chars:: Special Characters
3285 * H8/300-Regs:: Register Names
3286 * H8/300-Addressing:: Addressing Modes
3290 @subsubsection Special Characters
3292 @cindex line comment character, H8/300
3293 @cindex H8/300 line comment character
3294 @samp{;} is the line comment character.
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.
3300 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
3303 @subsubsection Register Names
3305 @cindex H8/300 registers
3306 @cindex registers, H8/300
3307 You 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
3309 general-purpose registers. @var{n} is a digit from @samp{0} to
3310 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
3313 You can also use the eight predefined symbols @samp{r@var{n}} to refer
3314 to the H8/300 registers as 16-bit registers (you must use this form for
3317 The two control registers are called @code{pc} (program counter; a
3318 16-bit register) and @code{ccr} (condition code register; an 8-bit
3319 register). @code{r7} is used as the stack pointer, and can also be
3322 @node H8/300-Addressing
3323 @subsubsection Addressing Modes
3325 @cindex addressing modes, H8/300
3326 @cindex H8/300 addressing modes
3327 as understands the following addressing modes for the H8/300:
3335 @item @@(@var{d}, r@var{n})
3336 @itemx @@(@var{d}:16, r@var{n})
3337 Register 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
3339 required and has no effect.)
3342 Register indirect with post-increment
3345 Register indirect with pre-decrement
3347 @item @code{@@}@var{aa}
3348 @itemx @code{@@}@var{aa}:8
3349 @itemx @code{@@}@var{aa}:16
3350 Absolute address @code{aa}. You may specify the @samp{:8} or @samp{:16}
3351 for clarity, if you wish; but @code{as} neither requires this nor
3352 uses it---the address size required is taken from context.
3357 Immediate data @var{xx}. You may specify the @samp{:8} or @samp{:16}
3358 for clarity, if you wish; but @code{as} neither requires this nor
3359 uses it---the data size required is taken from context.
3361 @item @code{@@}@code{@@}@var{aa}
3362 @itemx @code{@@}@code{@@}@var{aa}:8
3363 Memory indirect. You may specify the @samp{:8} for clarity, if you
3364 wish; but @code{as} neither requires this nor uses it.
3367 @node H8/300 Floating Point
3368 @subsection Floating Point
3370 @cindex floating point, H8/300 (@sc{ieee})
3371 @cindex H8/300 floating point (@sc{ieee})
3372 The H8/300 family uses @sc{ieee} floating-point numbers.
3374 @node H8/300 Directives
3375 @subsection H8/300 Machine Directives
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.
3382 However, on this platform the @samp{.int} and @samp{.word} directives
3383 generate 16-bit numbers.
3385 @node H8/300 Opcodes
3388 @cindex H8/300 opcode summary
3389 @cindex opcode summary, H8/300
3390 @cindex mnemonics, H8/300
3391 @cindex instruction summary, H8/300
3392 For detailed information on the H8/300 machine instruction set, see
3393 @cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025).
3395 @code{as} implements all the standard H8/300 opcodes. No additional
3396 pseudo-instructions are needed on this family.
3398 The following table summarizes the opcodes and their arguments:
3399 @c kluge due to lack of group outside example
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}}
3410 add.b Rs,Rd biand #x:3,Rd
3411 add.b #imm:8,Rd biand #x:3,@@Rd
3412 add.w Rs,Rd biand #x:3,@@aa:8
3413 adds #1,Rd bild #x:3,Rd
3414 adds #2,Rd bild #x:3,@@Rd
3415 addx #imm:8,Rd bild #x:3,@@aa:8
3416 addx Rs,Rd bior #x:3,Rd
3417 and #imm:8,Rd bior #x:3,@@Rd
3418 and Rs,Rd bior #x:3,@@aa:8
3419 andc #imm:8,ccr bist #x:3,Rd
3420 band #x:3,Rd bist #x:3,@@Rd
3421 band #x:3,@@Rd bist #x:3,@@aa:8
3422 bra d:8 bixor #x:3,Rd
3423 bt d:8 bixor #x:3,@@Rd
3424 brn d:8 bixor #x:3,@@aa:8
3426 bhi d:8 bld #x:3,@@Rd
3427 bls d:8 bld #x:3,@@aa:8
3428 bcc d:8 bnot #x:3,Rd
3429 bhs d:8 bnot #x:3,@@Rd
3430 bcs d:8 bnot #x:3,@@aa:8
3432 bne d:8 bnot Rs,@@Rd
3433 beq d:8 bnot Rs,@@aa:8
3435 bvs d:8 bor #x:3,@@Rd
3436 bpl d:8 bor #x:3,@@aa:8
3437 bmi d:8 bset #x:3,@@Rd
3438 bge d:8 bset #x:3,@@aa:8
3440 bgt d:8 bset Rs,@@Rd
3441 ble d:8 bset Rs,@@aa:8
3442 bclr #x:3,Rd bsr d:8
3443 bclr #x:3,@@Rd bst #x:3,Rd
3444 bclr #x:3,@@aa:8 bst #x:3,@@Rd
3445 bclr Rs,Rd bst #x:3,@@aa:8
3446 bclr Rs,@@Rd btst #x:3,Rd
3449 btst #x:3,@@Rd mov.w @@(d:16, Rs),Rd
3450 btst #x:3,@@aa:8 mov.w @@Rs+,Rd
3451 btst Rs,Rd mov.w @@aa:16,Rd
3452 btst Rs,@@Rd mov.w Rs,@@Rd
3453 btst Rs,@@aa:8 mov.w Rs,@@(d:16, Rd)
3454 bxor #x:3,Rd mov.w Rs,@@-Rd
3455 bxor #x:3,@@Rd mov.w Rs,@@aa:16
3456 bxor #x:3,@@aa:8 movfpe @@aa:16,Rd
3457 cmp.b #imm:8,Rd movtpe Rs,@@aa:16
3458 cmp.b Rs,Rd mulxu Rs,Rd
3463 divxu Rs,Rd or Rs,Rd
3464 eepmov orc #imm:8,ccr
3470 jsr @@aa:16 rotxr Rs
3475 mov.b #imm:8,Rd shll Rs
3476 mov.b @@Rs,Rd shlr Rs
3477 mov.b @@(d:16, Rs),Rd sleep
3478 mov.b @@Rs+,Rd stc ccr,Rd
3479 mov.b @@aa:16,Rd sub.b Rs,Rd
3480 mov.b @@aa:8,Rd sub.w Rs,Rd
3481 mov.b Rs,@@Rd subs #1,Rd
3482 mov.b Rs,@@(d:16, Rd) subs #2,Rd
3483 mov.b Rs,@@-Rd subx #imm:8,Rd
3484 mov.b Rs,@@aa:16 subx Rs,Rd
3485 mov.b Rs,@@aa:8 xor #imm:8,Rd
3486 mov.w Rs,Rd xor Rs,Rd
3487 mov.w #imm:16,Rd xorc #imm:8,ccr
3492 @cindex size suffixes, H8/300
3493 @cindex H8/300 size suffixes
3494 Four 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}
3497 supports these suffixes, but does not require them; since one of the
3498 operands is always a register, @code{as} can deduce the correct size.
3500 For example, since @code{r0} refers to a 16-bit register,
3503 @exdent is equivalent to
3507 If you use the size suffixes, @code{as} will issue a warning if
3508 there's a mismatch between the suffix and the register size.
3510 @node i960-Dependent
3511 @section Intel 80960 Dependent Features
3513 @cindex i960 support
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
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.
3526 @subsection i960 Command-line Options
3528 @cindex i960 options
3529 @cindex options, i960
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
3536 Select the 80960 architecture. Instructions or features not supported
3537 by the selected architecture cause fatal errors.
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.
3542 If none of these options is specified, @code{as} will generate code for any
3543 instruction or feature that is supported by @emph{some} version of the
3544 960 (even if this means mixing architectures!). In principle,
3545 @code{as} will attempt to deduce the minimal sufficient processor
3546 type if none is specified; depending on the object code format, the
3547 processor type may be recorded in the object file. If it is critical
3548 that the @code{as} output match a specific architecture, specify that
3549 architecture explicitly.
3552 @cindex @code{-b} option, i960
3553 @cindex branch recording, i960
3554 @cindex i960 branch recording
3555 Add code to collect information about conditional branches taken, for
3556 later optimization using branch prediction bits. (The conditional branch
3557 instructions have branch prediction bits in the CA, CB, and CC
3558 architectures.) If @var{BR} represents a conditional branch instruction,
3559 the following represents the code generated by the assembler when
3560 @samp{-b} is specified:
3563 call @var{increment routine}
3564 .word 0 # pre-counter
3566 call @var{increment routine}
3567 .word 0 # post-counter
3570 The counter following a branch records the number of times that branch
3571 was @emph{not} taken; the differenc between the two counters is the
3572 number of times the branch @emph{was} taken.
3574 @cindex @code{gbr960}, i960 postprocessor
3575 @cindex branch statistics table, i960
3576 A table of every such @code{Label} is also generated, so that the
3577 external postprocessor @code{gbr960} (supplied by Intel) can locate all
3578 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
3579 this is a local symbol to permit collecting statistics for many separate
3580 object files. The table is word aligned, and begins with a two-word
3581 header. The first word, initialized to 0, is used in maintaining linked
3582 lists of branch tables. The second word is a count of the number of
3583 entries in the table, which follow immediately: each is a word, pointing
3584 to one of the labels illustrated above.
3588 @c END TEXI2ROFF-KILL
3590 +------------+------------+------------+ ... +------------+
3592 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
3594 +------------+------------+------------+ ... +------------+
3596 __BRANCH_TABLE__ layout
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}
3607 @c END TEXI2ROFF-KILL
3609 The first word of the header is used to locate multiple branch tables,
3610 since each object file may contain one. Normally the links are
3611 maintained with a call to an initialization routine, placed at the
3612 beginning of each function in the file. The GNU C compiler will
3613 generate these calls automatically when you give it a @samp{-b} option.
3614 For further details, see the documentation of @samp{gbr960}.
3617 @cindex @code{-norelax} option, i960
3618 Normally, Compare-and-Branch instructions with targets that require
3619 displacements greater than 13 bits (or that have external targets) are
3620 replaced with the corresponding compare (or @samp{chkbit}) and branch
3621 instructions. You can use the @samp{-norelax} option to specify that
3622 @code{as} should generate errors instead, if the target displacement
3623 is larger than 13 bits.
3625 This option does not affect the Compare-and-Jump instructions; the code
3626 emitted for them is @emph{always} adjusted when necessary (depending on
3627 displacement size), regardless of whether you use @samp{-norelax}.
3630 @node Floating Point-i960
3631 @subsection Floating Point
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}.
3638 @node Directives-i960
3639 @subsection i960 Machine Directives
3641 @cindex machine directives, i960
3642 @cindex i960 machine directives
3645 @cindex @code{bss} directive, i960
3646 @item .bss @var{symbol}, @var{length}, @var{align}
3647 Reserve @var{length} bytes in the bss section for a local @var{symbol},
3648 aligned to the power of two specified by @var{align}. @var{length} and
3649 @var{align} must be positive absolute expressions. This directive
3650 differs from @samp{.lcomm} only in that it permits you to specify
3651 an alignment. @xref{Lcomm,,@code{.lcomm}}.
3655 @item .extended @var{flonums}
3656 @cindex @code{extended} directive, i960
3657 @code{.extended} expects zero or more flonums, separated by commas; for
3658 each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
3659 floating-point number.
3661 @item .leafproc @var{call-lab}, @var{bal-lab}
3662 @cindex @code{leafproc} directive, i960
3663 You can use the @samp{.leafproc} directive in conjunction with the
3664 optimized @code{callj} instruction to enable faster calls of leaf
3665 procedures. If a procedure is known to call no other procedures, you
3666 may define an entry point that skips procedure prolog code (and that does
3667 not depend on system-supplied saved context), and declare it as the
3668 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
3669 entry point that goes through the normal prolog, you can specify that
3670 entry point as @var{call-lab}.
3672 A @samp{.leafproc} declaration is meant for use in conjunction with the
3673 optimized call instruction @samp{callj}; the directive records the data
3674 needed later to choose between converting the @samp{callj} into a
3675 @code{bal} or a @code{call}.
3677 @var{call-lab} is optional; if only one argument is present, or if the
3678 two arguments are identical, the single argument is assumed to be the
3679 @code{bal} entry point.
3681 @item .sysproc @var{name}, @var{index}
3682 @cindex @code{sysproc} directive, i960
3683 The @samp{.sysproc} directive defines a name for a system procedure.
3684 After you define it using @samp{.sysproc}, you can use @var{name} to
3685 refer to the system procedure identified by @var{index} when calling
3686 procedures with the optimized call instruction @samp{callj}.
3688 Both arguments are required; @var{index} must be between 0 and 31
3692 @node Opcodes for i960
3693 @subsection i960 Opcodes
3695 @cindex opcodes, i960
3696 @cindex i960 opcodes
3697 All Intel 960 machine instructions are supported;
3698 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
3699 selecting the instruction subset for a particular 960
3700 architecture.@refill
3702 Some opcodes are processed beyond simply emitting a single corresponding
3703 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
3704 instructions with target displacements larger than 13 bits.
3707 * callj-i960:: @code{callj}
3708 * Compare-and-branch-i960:: Compare-and-Branch
3712 @subsubsection @code{callj}
3714 @cindex @code{callj}, i960 pseudo-opcode
3715 @cindex i960 @code{callj} pseudo-opcode
3716 You can write @code{callj} to have the assembler or the linker determine
3717 the most appropriate form of subroutine call: @samp{call},
3718 @samp{bal}, or @samp{calls}. If the assembly source contains
3719 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
3720 defining the operand---then @code{as} will translate the
3721 @code{callj}; if not, it will simply emit the @code{callj}, leaving it
3722 for the linker to resolve.
3724 @node Compare-and-branch-i960
3725 @subsubsection Compare-and-Branch
3727 @cindex i960 compare/branch instructions
3728 @cindex compare/branch instructions, i960
3729 The 960 architectures provide combined Compare-and-Branch instructions
3730 that permit you to store the branch target in the lower 13 bits of the
3731 instruction word itself. However, if you specify a branch target far
3732 enough away that its address won't fit in 13 bits, the assembler can
3733 either issue an error, or convert your Compare-and-Branch instruction
3734 into separate instructions to do the compare and the branch.
3736 @cindex compare and jump expansions, i960
3737 @cindex i960 compare and jump expansions
3738 Whether @code{as} gives an error or expands the instruction depends
3739 on two choices you can make: whether you use the @samp{-norelax} option,
3740 and whether you use a ``Compare and Branch'' instruction or a ``Compare
3741 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
3742 expanded if necessary; the ``Branch'' instructions are expanded when
3743 necessary @emph{unless} you specify @code{-norelax}---in which case
3744 @code{as} gives an error instead.
3746 These are the Compare-and-Branch instructions, their ``Jump'' variants,
3747 and the instruction pairs they may expand into:
3751 @c END TEXI2ROFF-KILL
3754 Branch Jump Expanded to
3755 ------ ------ ------------
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
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}
3797 @c END TEXI2ROFF-KILL
3799 @node M68K-Dependent
3800 @section M680x0 Dependent Features
3802 @cindex M680x0 support
3804 * M68K-Opts:: M680x0 Options
3805 * M68K-Syntax:: Syntax
3806 * M68K-Float:: Floating Point
3807 * M68K-Directives:: 680x0 Machine Directives
3808 * M68K-opcodes:: Opcodes
3812 @subsection M680x0 Options
3814 @cindex options, M680x0
3815 @cindex M680x0 options
3816 The Motorola 680x0 version of @code{as} has two machine dependent options.
3817 One shortens undefined references from 32 to 16 bits, while the
3818 other is used to tell @code{as} what kind of machine it is
3821 @cindex @code{-l} option, M680x0
3822 You can use the @kbd{-l} option to shorten the size of references to
3823 undefined symbols. If the @kbd{-l} option is not given, references to
3824 undefined symbols will be a full long (32 bits) wide. (Since @code{as}
3825 cannot know where these symbols will end up, @code{as} can only allocate
3826 space for the linker to fill in later. Since @code{as} doesn't know how
3827 far away these symbols will be, it allocates as much space as it can.)
3828 If this option is given, the references will only be one word wide (16
3829 bits). This may be useful if you want the object file to be as small as
3830 possible, and you know that the relevant symbols will be less than 17
3833 @cindex @code{-m68000} and related options
3834 @cindex architecture options, M680x0
3835 @cindex M680x0 architecture options
3836 The 680x0 version of @code{as} is most frequently used to assemble
3837 programs for the Motorola MC68020 microprocessor. Occasionally it is
3838 used to assemble programs for the mostly similar, but slightly different
3839 MC68000 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
3847 @cindex M680x0 syntax
3848 @cindex syntax, M680x0
3849 @cindex M680x0 size modifiers
3850 @cindex size modifiers, M680x0
3851 The 680x0 version of @code{as} uses syntax similar to the Sun assembler.
3852 Size modifiers are appended directly to the end of the opcode without an
3853 intervening period. For example, write @samp{movl} rather than
3857 In the following table @dfn{apc} stands for any of the address
3858 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
3859 Program Counter (@samp{pc}), or the zero-address relative to the
3860 program counter (@samp{zpc}).
3862 @cindex M680x0 addressing modes
3863 @cindex addressing modes, M680x0
3864 The following addressing modes are understood:
3867 @samp{#@var{digits}}
3870 @samp{d0} through @samp{d7}
3872 @item Address Register
3873 @samp{a0} through @samp{a7}
3875 @item Address Register Indirect
3876 @samp{a0@@} through @samp{a7@@}
3878 @item Address Register Postincrement
3879 @samp{a0@@+} through @samp{a7@@+}
3881 @item Address Register Predecrement
3882 @samp{a0@@-} through @samp{a7@@-}
3884 @item Indirect Plus Offset
3885 @samp{@var{apc}@@(@var{digits})}
3888 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3890 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
3893 @samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3895 or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
3898 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3900 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3902 @item Memory Indirect
3903 @samp{@var{apc}@@(@var{digits})@@(@var{digits})}
3906 @samp{@var{symbol}}, or @samp{@var{digits}}
3909 @c research before documenting.
3910 , or either of the above followed
3911 by @samp{:b}, @samp{:w}, or @samp{:l}.
3916 @subsection Floating Point
3918 @cindex floating point, M680x0
3919 @cindex M680x0 floating point
3920 @c FIXME is this "not too well tested" crud STILL true?
3921 The floating point code is not too well tested, and may have
3924 Packed decimal (P) format floating literals are not supported.
3925 Feel free to add the code!
3927 The floating point formats generated by directives are these.
3931 @cindex @code{float} directive, M680x0
3932 @code{Single} precision floating point constants.
3935 @cindex @code{double} directive, M680x0
3936 @code{Double} precision floating point constants.
3939 There is no directive to produce regions of memory holding
3940 extended precision numbers, however they can be used as
3941 immediate operands to floating-point instructions. Adding a
3942 directive to create extended precision numbers would not be
3943 hard, but it has not yet seemed necessary.
3945 @node M68K-Directives
3946 @subsection 680x0 Machine Directives
3948 @cindex M680x0 directives
3949 @cindex directives, M680x0
3950 In order to be compatible with the Sun assembler the 680x0 assembler
3951 understands the following directives.
3955 @cindex @code{data1} directive, M680x0
3956 This directive is identical to a @code{.data 1} directive.
3959 @cindex @code{data2} directive, M680x0
3960 This directive is identical to a @code{.data 2} directive.
3963 @cindex @code{even} directive, M680x0
3964 This directive is identical to a @code{.align 1} directive.
3965 @c Is this true? does it work???
3968 @cindex @code{skip} directive, M680x0
3969 This directive is identical to a @code{.space} directive.
3975 @cindex M680x0 opcodes
3976 @cindex opcodes, M680x0
3977 @cindex instruction set, M680x0
3979 @c paragraph. Bugs are bugs; how does saying this
3982 Danger: Several bugs have been found in the opcode table (and
3983 fixed). More bugs may exist. Be careful when using obscure
3988 * M68K-Branch:: Branch Improvement
3989 * M68K-Chars:: Special Characters
3993 @subsubsection Branch Improvement
3995 @cindex pseudo-opcodes, M680x0
3996 @cindex M680x0 pseudo-opcodes
3997 @cindex branch improvement, M680x0
3998 @cindex M680x0 branch improvement
3999 Certain pseudo opcodes are permitted for branch instructions.
4000 They expand to the shortest branch instruction that will reach the
4001 target. Generally these mnemonics are made by substituting @samp{j} for
4002 @samp{b} at the start of a Motorola mnemonic.
4004 The following table summarizes the pseudo-operations. A @code{*} flags
4005 cases that are more fully described after the table:
4009 +-------------------------------------------------
4011 Pseudo-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
4020 NX: negative of condition XX
4023 @center @code{*}---see full description below
4028 These are the simplest jump pseudo-operations; they always map to one
4029 particular machine instruction, depending on the displacement to the
4033 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
4034 where @var{XX} is a conditional branch or condition-code test. The full
4035 list of pseudo-ops in this family is:
4037 jhi jls jcc jcs jne jeq jvc
4038 jvs jpl jmi jge jlt jgt jle
4041 For the cases of non-PC relative displacements and long displacements on
4042 the 68000 or 68010, @code{as} will issue a longer code fragment in terms of
4043 @var{NX}, the opposite condition to @var{XX}. For example, for the
4044 non-PC relative case:
4056 The full family of pseudo-operations covered here is
4058 dbhi dbls dbcc dbcs dbne dbeq dbvc
4059 dbvs dbpl dbmi dbge dblt dbgt dble
4063 Other than for word and byte displacements, when the source reads
4064 @samp{db@var{XX} foo}, @code{as} will emit
4073 This family includes
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
4082 For branch targets that are not PC relative, @code{as} emits
4088 when it encounters @samp{fj@var{XX} foo}.
4093 @subsubsection Special Characters
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
4101 The immediate character is @samp{#} for Sun compatibility. The
4102 line-comment character is @samp{|}. If a @samp{#} appears at the
4103 beginning of a line, it is treated as a comment unless it looks like
4104 @samp{# line file}, in which case it is treated normally.
4106 @node Sparc-Dependent
4107 @section SPARC Dependent Features
4109 @cindex SPARC support
4111 * Sparc-Opts:: Options
4112 * Sparc-Float:: Floating Point
4113 * Sparc-Directives:: Sparc Machine Directives
4119 @cindex options for SPARC (none)
4120 @cindex SPARC options (none)
4121 The Sparc has no machine dependent options.
4124 @c FIXME: (sparc) Fill in "syntax" section!
4125 @c subsection syntax
4126 I don't know anything about Sparc syntax. Someone who does
4127 will have to write this section.
4131 @subsection Floating Point
4133 @cindex floating point, SPARC (@sc{ieee})
4134 @cindex SPARC floating point (@sc{ieee})
4135 The Sparc uses @sc{ieee} floating-point numbers.
4137 @node Sparc-Directives
4138 @subsection Sparc Machine Directives
4140 @cindex SPARC machine directives
4141 @cindex machine directives, SPARC
4142 The Sparc version of @code{as} supports the following additional
4147 @cindex @code{common} directive, SPARC
4148 This must be followed by a symbol name, a positive number, and
4149 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
4150 syntax is different.
4153 @cindex @code{half} directive, SPARC
4154 This is functionally identical to @code{.short}.
4157 @cindex @code{proc} directive, SPARC
4158 This directive is ignored. Any text following it on the same
4159 line is also ignored.
4162 @cindex @code{reserve} directive, SPARC
4163 This must be followed by a symbol name, a positive number, and
4164 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
4165 syntax is different.
4168 @cindex @code{seg} directive, SPARC
4169 This must be followed by @code{"text"}, @code{"data"}, or
4170 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
4174 @cindex @code{skip} directive, SPARC
4175 This is functionally identical to the @code{.space} directive.
4178 @cindex @code{word} directive, SPARC
4179 On the Sparc, the .word directive produces 32 bit values,
4180 instead of the 16 bit values it produces on many other machines.
4183 @node i386-Dependent
4184 @section 80386 Dependent Features
4186 @cindex i386 support
4187 @cindex i80306 support
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
4203 @cindex options for i386 (none)
4204 @cindex i386 options (none)
4205 The 80386 has no machine dependent options.
4208 @subsection AT&T Syntax versus Intel Syntax
4210 @cindex i386 syntax compatibility
4211 @cindex syntax compatibility, i386
4212 In order to maintain compatibility with the output of @code{gcc},
4213 @code{as} supports AT&T System V/386 assembler syntax. This is quite
4214 different from Intel syntax. We mention these differences because
4215 almost all 80386 documents used only Intel syntax. Notable differences
4216 between the two syntaxes are:
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
4227 AT&T immediate operands are preceded by @samp{$}; Intel immediate
4228 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
4229 AT&T register operands are preceded by @samp{%}; Intel register operands
4230 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
4231 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
4234 @cindex i386 source, destination operands
4235 @cindex source, destination operands; i386
4236 AT&T and Intel syntax use the opposite order for source and destination
4237 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
4238 @samp{source, dest} convention is maintained for compatibility with
4239 previous Unix assemblers.
4242 @cindex opcode suffixes, i386
4243 @cindex sizes operands, i386
4244 @cindex i386 size suffixes
4245 In AT&T syntax the size of memory operands is determined from the last
4246 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
4247 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
4248 memory references. Intel syntax accomplishes this by prefixes memory
4249 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
4250 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
4251 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
4254 @cindex return instructions, i386
4255 @cindex i386 jump, call, return
4256 Immediate form long jumps and calls are
4257 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
4259 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
4261 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
4262 @samp{ret far @var{stack-adjust}}.
4265 @cindex sections, i386
4266 @cindex i386 sections
4267 The AT&T assembler does not provide support for multiple section
4268 programs. Unix style systems expect all programs to be single sections.
4272 @subsection Opcode Naming
4274 @cindex i386 opcode naming
4275 @cindex opcode naming, i386
4276 Opcode names are suffixed with one character modifiers which specify the
4277 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
4278 byte, word, and long operands. If no suffix is specified by an
4279 instruction and it contains no memory operands then @code{as} tries to
4280 fill in the missing suffix based on the destination register operand
4281 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
4282 to @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
4284 assembler which assumes that a missing opcode suffix implies long
4285 operand size. (This incompatibility does not affect compiler output
4286 since compilers always explicitly specify the opcode suffix.)
4288 Almost all opcodes have the same names in AT&T and Intel format. There
4289 are a few exceptions. The sign extend and zero extend instructions need
4290 two 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
4292 by using two opcode suffixes in AT&T syntax. Base names for sign extend
4293 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
4294 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
4295 suffixes are tacked on to this base name, the @emph{from} suffix before
4296 the @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,
4298 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
4299 and @samp{wl} (from word to long).
4301 @cindex conversion instructions, i386
4302 @cindex i386 conversion instructions
4303 The Intel-syntax conversion instructions
4307 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
4310 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
4313 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
4316 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
4320 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
4321 AT&T naming. @code{as} accepts either naming for these instructions.
4323 @cindex jump instructions, i386
4324 @cindex call instructions, i386
4325 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
4326 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
4330 @subsection Register Naming
4332 @cindex i386 registers
4333 @cindex registers, i386
4334 Register operands are always prefixes with @samp{%}. The 80386 registers
4339 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
4340 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
4341 frame pointer), and @samp{%esp} (the stack pointer).
4344 the 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}.
4348 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
4349 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
4350 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
4351 @samp{%cx}, and @samp{%dx})
4354 the 6 section registers @samp{%cs} (code section), @samp{%ds}
4355 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
4359 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
4363 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
4364 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
4367 the 2 test registers @samp{%tr6} and @samp{%tr7}.
4370 the 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)}.
4376 @subsection Opcode Prefixes
4378 @cindex i386 opcode prefixes
4379 @cindex opcode prefixes, i386
4380 @cindex prefixes, i386
4381 Opcode prefixes are used to modify the following opcode. They are used
4382 to repeat string instructions, to provide section overrides, to perform
4383 bus lock operations, and to give operand and address size (16-bit
4384 operands are specified in an instruction by prefixing what would
4385 normally be 32-bit operands with a ``operand size'' opcode prefix).
4386 Opcode prefixes are usually given as single-line instructions with no
4387 operands, and must directly precede the instruction they act upon. For
4388 example, the @samp{scas} (scan string) instruction is repeated with:
4394 Here is a list of opcode prefixes:
4398 @cindex section override prefixes, i386
4399 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
4400 @samp{fs}, @samp{gs}. These are automatically added by specifying
4401 using the @var{section}:@var{memory-operand} form for memory references.
4404 @cindex size prefixes, i386
4405 Operand/Address size prefixes @samp{data16} and @samp{addr16}
4406 change 32-bit operands/addresses into 16-bit operands/addresses. Note
4407 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
4408 are not supported (yet).
4411 @cindex bus lock prefixes, i386
4412 @cindex inhibiting interrupts, i386
4413 The bus lock prefix @samp{lock} inhibits interrupts during
4414 execution of the instruction it precedes. (This is only valid with
4415 certain instructions; see a 80386 manual for details).
4418 @cindex coprocessor wait, i386
4419 The wait for coprocessor prefix @samp{wait} waits for the
4420 coprocessor to complete the current instruction. This should never be
4421 needed for the 80386/80387 combination.
4424 @cindex repeat prefixes, i386
4425 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
4426 to string instructions to make them repeat @samp{%ecx} times.
4430 @subsection Memory References
4432 @cindex i386 memory references
4433 @cindex memory references, i386
4434 An Intel syntax indirect memory reference of the form
4437 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
4441 is translated into the AT&T syntax
4444 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
4448 where @var{base} and @var{index} are the optional 32-bit base and
4449 index registers, @var{disp} is the optional displacement, and
4450 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
4451 to calculate the address of the operand. If no @var{scale} is
4452 specified, @var{scale} is taken to be 1. @var{section} specifies the
4453 optional section register for the memory operand, and may override the
4454 default section register (see a 80386 manual for section register
4455 defaults). Note that section overrides in AT&T syntax @emph{must} have
4456 be preceded by a @samp{%}. If you specify a section override which
4457 coincides with the default section register, @code{as} will @emph{not}
4458 output any section register override prefixes to assemble the given
4459 instruction. Thus, section overrides can be specified to emphasize which
4460 section register is used for a given memory operand.
4462 Here are some examples of Intel and AT&T style memory references:
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
4467 missing, 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.
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
4473 defaults to @samp{%ds}.
4475 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
4476 This uses the value pointed to by @samp{foo} as a memory operand.
4477 Note that @var{base} and @var{index} are both missing, but there is only
4478 @emph{one} @samp{,}. This is a syntactic exception.
4480 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
4481 This selects the contents of the variable @samp{foo} with section
4482 register @var{section} being @samp{%gs}.
4485 Absolute (as opposed to PC relative) call and jump operands must be
4486 prefixed with @samp{*}. If no @samp{*} is specified, @code{as} will
4487 always choose PC relative addressing for jump/call labels.
4489 Any instruction that has a memory operand @emph{must} specify its size (byte,
4490 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
4494 @subsection Handling of Jump Instructions
4496 @cindex jump optimization, i386
4497 @cindex i386 jump optimization
4498 Jump instructions are always optimized to use the smallest possible
4499 displacements. This is accomplished by using byte (8-bit) displacement
4500 jumps whenever the target is sufficiently close. If a byte displacement
4501 is insufficient a long (32-bit) displacement is used. We do not support
4502 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
4503 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
4504 @samp{%eip} to 16 bits after the word displacement is added.
4506 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
4507 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
4508 byte displacements, so that it is possible that use of these
4509 instructions (@code{gcc} does not use them) will cause the assembler to
4510 print an error message (and generate incorrect code). The AT&T 80386
4511 assembler tries to get around this problem by expanding @samp{jcxz foo} to
4520 @subsection Floating Point
4522 @cindex i386 floating point
4523 @cindex floating point, i386
4524 All 80387 floating point types except packed BCD are supported.
4525 (BCD support may be added without much difficulty). These data
4526 types are 16-, 32-, and 64- bit integers, and single (32-bit),
4527 double (64-bit), and extended (80-bit) precision floating point.
4528 Each supported type has an opcode suffix and a constructor
4529 associated with it. Opcode suffixes specify operand's data
4530 types. Constructors build these data types into memory.
4534 @cindex @code{float} directive, i386
4535 @cindex @code{single} directive, i386
4536 @cindex @code{double} directive, i386
4537 @cindex @code{tfloat} directive, i386
4538 Floating point constructors are @samp{.float} or @samp{.single},
4539 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
4540 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
4541 @samp{t} stands for temporary real, and that the 80387 only supports
4542 this format via the @samp{fldt} (load temporary real to stack top) and
4543 @samp{fstpt} (store temporary real and pop stack) instructions.
4546 @cindex @code{word} directive, i386
4547 @cindex @code{long} directive, i386
4548 @cindex @code{int} directive, i386
4549 @cindex @code{quad} directive, i386
4550 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
4551 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
4552 opcode 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
4554 only present in the @samp{fildq} (load quad integer to stack top) and
4555 @samp{fistpq} (store quad integer and pop stack) instructions.
4558 Register to register operations do not require opcode suffixes,
4559 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
4561 @cindex i386 @code{fwait} instruction
4562 @cindex @code{fwait instruction}, i386
4563 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
4564 instructions are almost never needed (this is not the case for the
4565 80286/80287 and 8086/8087 combinations). Therefore, @code{as} suppresses
4566 the @samp{fwait} instruction whenever it is implicitly selected by one
4567 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
4568 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
4569 instructions are made equivalent to @samp{f@dots{}} instructions. If
4570 @samp{fwait} is desired it must be explicitly coded.
4575 @cindex i386 @code{mul}, @code{imul} instructions
4576 @cindex @code{mul} instruction, i386
4577 @cindex @code{imul} instruction, i386
4578 There is some trickery concerning the @samp{mul} and @samp{imul}
4579 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
4580 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
4581 for @samp{imul}) can be output only in the one operand form. Thus,
4582 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
4583 the expanding multiply would clobber the @samp{%edx} register, and this
4584 would confuse @code{gcc} output. Use @samp{imul %ebx} to get the
4585 64-bit product in @samp{%edx:%eax}.
4587 We have added a two operand form of @samp{imul} when the first operand
4588 is an immediate mode expression and the second operand is a register.
4589 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
4590 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
4593 @node Z8000-Dependent
4594 @section Z8000 Dependent Features
4596 @cindex Z8000 support
4598 * Z8000 Options:: No special command-line options for Z8000
4599 * Z8000 Syntax:: Assembler Syntax for the Z8000
4600 * Z8000 Opcodes:: Opcodes
4606 @cindex Z8000 options
4607 @cindex options, Z8000
4608 @code{as} has no additional command-line options for the Zilog
4614 * Z8000-Chars:: Special Characters
4615 * Z8000-Regs:: Register Names
4616 * Z8000-Addressing:: Addressing Modes
4620 @subsubsection Special Characters
4622 @cindex line comment character, Z8000
4623 @cindex Z8000 line comment character
4624 @samp{!} is the line comment character.
4626 @cindex line separator, Z8000
4627 @cindex statement separator, Z8000
4628 @cindex Z8000 line separator
4629 @samp{;} can be used instead of a newline to separate statements.
4632 @subsubsection Register Names
4634 @cindex Z8000 registers
4635 @cindex registers, Z8000
4636 The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer to different
4637 sized groups of registers with the prefix @samp{r} for 16 bit registers, @samp{rr}
4638 for 32 bit registers and @samp{rq} for 64 bit registers. The first eight of the sixteen
4639 16 bit registers may also be accessed by bytes. They are named @samp{r@var{n}h} and @samp{r@var{n}l}.
4642 r0l r0h r1h r1l r2h r2l r3h r3l r4h r4l r5h r5l r6h r6l r7h r7l
4645 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
4648 rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14
4653 @node Z8000-Addressing
4654 @subsubsection Addressing Modes
4655 @cindex addressing modes, Z8000
4656 @cindex Z800 addressing modes
4657 as understands the following addressing modes for the Z8000:
4666 Direct: the 16/24 bit address of the operand is in the instruction.
4668 @item address(r@var{n})
4669 Indexed: the 16/24 bit address is added to the 16 bit register to produce
4670 the final address in memory of the operand.
4672 @item r@var{n}(#@var{imm})
4673 Base 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 @item r@var{n}(r@var{m})
4676 Base Index: the 16/24 bit register r@var{n} is added to the sign extended
4677 16 bit index register r@var{m} to produce the final address in memory of the operand.
4680 Immediate data @var{xx}.
4685 @cindex Z8000 opcode summary
4686 @cindex opcode summary, Z8000
4687 @cindex mnemonics, Z8000
4688 @cindex instruction summary, Z8000
4689 For detailed information on the Z8000 machine instruction set, see
4690 @cite{Z8000 Technical Manual}.
4692 @cindex Z8000 pseudo ops
4694 The Z8000 port of gas provides a superficial resemblance to YASM, and
4695 provides these YASM compatible pseudo ops:
4699 Generates code for the segmented Z8001.
4701 Generates code for the unsegmented Z8002.
4703 Synonym for @code{.file}
4705 Synonum for @code{.global}
4714 @code{sval} expects one string literal, delimited by single quotes. It assembles each byte of the string into consecutive addresses. Single quote
4715 and other non-representable characters may be descrbed by escaping them
4716 with a percent sign and their ascii value as a two digit hex number.
4719 char *a = "he said \"it's 50% off\"";
4721 0000 68652073 sval 'he said %22it%27s 50%25 off%22%00'
4730 synonym for @code{.section}
4732 synonym for @code{.space}
4734 synonym for @code{.align 1}
4737 The following table summarizes the opcodes and their arguments:
4738 @c kluge due to lack of group outside example
4743 rs @r{16 bit source register}
4744 rd @r{16 bit destination register}
4745 rbs @r{8 bit source register}
4746 rbd @r{8 bit destination register}
4747 rrs @r{32 bit source register}
4748 rrd @r{32 bit destination register}
4749 rqs @r{64 bit source register}
4750 rqd @r{64 bit destination register}
4751 addr @r{16/24 bit address}
4752 imm @r{immediate data}
4754 adc rd,rs clrb addr cpsir @@rd,@@rs,rr,cc
4755 adcb rbd,rbs clrb addr(rd) cpsirb @@rd,@@rs,rr,cc
4756 add rd,@@rs clrb rbd dab rbd
4757 add rd,addr com @@rd dbjnz rbd,disp7
4758 add rd,addr(rs) com addr dec @@rd,imm4m1
4759 add rd,imm16 com addr(rd) dec addr(rd),imm4m1
4760 add rd,rs com rd dec addr,imm4m1
4761 addb rbd,@@rs comb @@rd dec rd,imm4m1
4762 addb rbd,addr comb addr decb @@rd,imm4m1
4763 addb rbd,addr(rs) comb addr(rd) decb addr(rd),imm4m1
4764 addb rbd,imm8 comb rbd decb addr,imm4m1
4765 addb rbd,rbs comflg flags decb rbd,imm4m1
4766 addl rrd,@@rs cp @@rd,imm16 di i2
4767 addl rrd,addr cp addr(rd),imm16 div rrd,@@rs
4768 addl rrd,addr(rs) cp addr,imm16 div rrd,addr
4769 addl rrd,imm32 cp rd,@@rs div rrd,addr(rs)
4770 addl rrd,rrs cp rd,addr div rrd,imm16
4771 and rd,@@rs cp rd,addr(rs) div rrd,rs
4772 and rd,addr cp rd,imm16 divl rqd,@@rs
4773 and rd,addr(rs) cp rd,rs divl rqd,addr
4774 and rd,imm16 cpb @@rd,imm8 divl rqd,addr(rs)
4775 and rd,rs cpb addr(rd),imm8 divl rqd,imm32
4776 andb rbd,@@rs cpb addr,imm8 divl rqd,rrs
4777 andb rbd,addr cpb rbd,@@rs djnz rd,disp7
4778 andb rbd,addr(rs) cpb rbd,addr ei i2
4779 andb rbd,imm8 cpb rbd,addr(rs) ex rd,@@rs
4780 andb rbd,rbs cpb rbd,imm8 ex rd,addr
4781 bit @@rd,imm4 cpb rbd,rbs ex rd,addr(rs)
4782 bit addr(rd),imm4 cpd rd,@@rs,rr,cc ex rd,rs
4783 bit addr,imm4 cpdb rbd,@@rs,rr,cc exb rbd,@@rs
4784 bit rd,imm4 cpdr rd,@@rs,rr,cc exb rbd,addr
4785 bit rd,rs cpdrb rbd,@@rs,rr,cc exb rbd,addr(rs)
4786 bitb @@rd,imm4 cpi rd,@@rs,rr,cc exb rbd,rbs
4787 bitb addr(rd),imm4 cpib rbd,@@rs,rr,cc ext0e imm8
4788 bitb addr,imm4 cpir rd,@@rs,rr,cc ext0f imm8
4789 bitb rbd,imm4 cpirb rbd,@@rs,rr,cc ext8e imm8
4790 bitb rbd,rs cpl rrd,@@rs ext8f imm8
4791 bpt cpl rrd,addr exts rrd
4792 call @@rd cpl rrd,addr(rs) extsb rd
4793 call addr cpl rrd,imm32 extsl rqd
4794 call addr(rd) cpl rrd,rrs halt
4795 calr disp12 cpsd @@rd,@@rs,rr,cc in rd,@@rs
4796 clr @@rd cpsdb @@rd,@@rs,rr,cc in rd,imm16
4797 clr addr cpsdr @@rd,@@rs,rr,cc inb rbd,@@rs
4798 clr addr(rd) cpsdrb @@rd,@@rs,rr,cc inb rbd,imm16
4799 clr rd cpsi @@rd,@@rs,rr,cc inc @@rd,imm4m1
4800 clrb @@rd cpsib @@rd,@@rs,rr,cc inc addr(rd),imm4m1
4803 inc addr,imm4m1 ldb rbd,rs(rx) mult rrd,addr(rs)
4804 inc rd,imm4m1 ldb rd(imm16),rbs mult rrd,imm16
4805 incb @@rd,imm4m1 ldb rd(rx),rbs mult rrd,rs
4806 incb addr(rd),imm4m1 ldctl ctrl,rs multl rqd,@@rs
4807 incb addr,imm4m1 ldctl rd,ctrl multl rqd,addr
4808 incb rbd,imm4m1 ldd @@rs,@@rd,rr multl rqd,addr(rs)
4809 ind @@rd,@@rs,ra lddb @@rs,@@rd,rr multl rqd,imm32
4810 indb @@rd,@@rs,rba lddr @@rs,@@rd,rr multl rqd,rrs
4811 inib @@rd,@@rs,ra lddrb @@rs,@@rd,rr neg @@rd
4812 inibr @@rd,@@rs,ra ldi @@rd,@@rs,rr neg addr
4813 iret ldib @@rd,@@rs,rr neg addr(rd)
4814 jp cc,@@rd ldir @@rd,@@rs,rr neg rd
4815 jp cc,addr ldirb @@rd,@@rs,rr negb @@rd
4816 jp cc,addr(rd) ldk rd,imm4 negb addr
4817 jr cc,disp8 ldl @@rd,rrs negb addr(rd)
4818 ld @@rd,imm16 ldl addr(rd),rrs negb rbd
4819 ld @@rd,rs ldl addr,rrs nop
4820 ld addr(rd),imm16 ldl rd(imm16),rrs or rd,@@rs
4821 ld addr(rd),rs ldl rd(rx),rrs or rd,addr
4822 ld addr,imm16 ldl rrd,@@rs or rd,addr(rs)
4823 ld addr,rs ldl rrd,addr or rd,imm16
4824 ld rd(imm16),rs ldl rrd,addr(rs) or rd,rs
4825 ld rd(rx),rs ldl rrd,imm32 orb rbd,@@rs
4826 ld rd,@@rs ldl rrd,rrs orb rbd,addr
4827 ld rd,addr ldl rrd,rs(imm16) orb rbd,addr(rs)
4828 ld rd,addr(rs) ldl rrd,rs(rx) orb rbd,imm8
4829 ld rd,imm16 ldm @@rd,rs,n orb rbd,rbs
4830 ld rd,rs ldm addr(rd),rs,n out @@rd,rs
4831 ld rd,rs(imm16) ldm addr,rs,n out imm16,rs
4832 ld rd,rs(rx) ldm rd,@@rs,n outb @@rd,rbs
4833 lda rd,addr ldm rd,addr(rs),n outb imm16,rbs
4834 lda rd,addr(rs) ldm rd,addr,n outd @@rd,@@rs,ra
4835 lda rd,rs(imm16) ldps @@rs outdb @@rd,@@rs,rba
4836 lda rd,rs(rx) ldps addr outib @@rd,@@rs,ra
4837 ldar rd,disp16 ldps addr(rs) outibr @@rd,@@rs,ra
4838 ldb @@rd,imm8 ldr disp16,rs pop @@rd,@@rs
4839 ldb @@rd,rbs ldr rd,disp16 pop addr(rd),@@rs
4840 ldb addr(rd),imm8 ldrb disp16,rbs pop addr,@@rs
4841 ldb addr(rd),rbs ldrb rbd,disp16 pop rd,@@rs
4842 ldb addr,imm8 ldrl disp16,rrs popl @@rd,@@rs
4843 ldb addr,rbs ldrl rrd,disp16 popl addr(rd),@@rs
4844 ldb rbd,@@rs mbit popl addr,@@rs
4845 ldb rbd,addr mreq rd popl rrd,@@rs
4846 ldb rbd,addr(rs) mres push @@rd,@@rs
4847 ldb rbd,imm8 mset push @@rd,addr
4848 ldb rbd,rbs mult rrd,@@rs push @@rd,addr(rs)
4849 ldb rbd,rs(imm16) mult rrd,addr push @@rd,imm16
4852 push @@rd,rs set addr,imm4 subl rrd,imm32
4853 pushl @@rd,@@rs set rd,imm4 subl rrd,rrs
4854 pushl @@rd,addr set rd,rs tcc cc,rd
4855 pushl @@rd,addr(rs) setb @@rd,imm4 tccb cc,rbd
4856 pushl @@rd,rrs setb addr(rd),imm4 test @@rd
4857 res @@rd,imm4 setb addr,imm4 test addr
4858 res addr(rd),imm4 setb rbd,imm4 test addr(rd)
4859 res addr,imm4 setb rbd,rs test rd
4860 res rd,imm4 setflg imm4 testb @@rd
4861 res rd,rs sinb rbd,imm16 testb addr
4862 resb @@rd,imm4 sinb rd,imm16 testb addr(rd)
4863 resb addr(rd),imm4 sind @@rd,@@rs,ra testb rbd
4864 resb addr,imm4 sindb @@rd,@@rs,rba testl @@rd
4865 resb rbd,imm4 sinib @@rd,@@rs,ra testl addr
4866 resb rbd,rs sinibr @@rd,@@rs,ra testl addr(rd)
4867 resflg imm4 sla rd,imm8 testl rrd
4868 ret cc slab rbd,imm8 trdb @@rd,@@rs,rba
4869 rl rd,imm1or2 slal rrd,imm8 trdrb @@rd,@@rs,rba
4870 rlb rbd,imm1or2 sll rd,imm8 trib @@rd,@@rs,rbr
4871 rlc rd,imm1or2 sllb rbd,imm8 trirb @@rd,@@rs,rbr
4872 rlcb rbd,imm1or2 slll rrd,imm8 trtdrb @@ra,@@rb,rbr
4873 rldb rbb,rba sout imm16,rs trtib @@ra,@@rb,rr
4874 rr rd,imm1or2 soutb imm16,rbs trtirb @@ra,@@rb,rbr
4875 rrb rbd,imm1or2 soutd @@rd,@@rs,ra trtrb @@ra,@@rb,rbr
4876 rrc rd,imm1or2 soutdb @@rd,@@rs,rba tset @@rd
4877 rrcb rbd,imm1or2 soutib @@rd,@@rs,ra tset addr
4878 rrdb rbb,rba soutibr @@rd,@@rs,ra tset addr(rd)
4879 rsvd36 sra rd,imm8 tset rd
4880 rsvd38 srab rbd,imm8 tsetb @@rd
4881 rsvd78 sral rrd,imm8 tsetb addr
4882 rsvd7e srl rd,imm8 tsetb addr(rd)
4883 rsvd9d srlb rbd,imm8 tsetb rbd
4884 rsvd9f srll rrd,imm8 xor rd,@@rs
4885 rsvdb9 sub rd,@@rs xor rd,addr
4886 rsvdbf sub rd,addr xor rd,addr(rs)
4887 sbc rd,rs sub rd,addr(rs) xor rd,imm16
4888 sbcb rbd,rbs sub rd,imm16 xor rd,rs
4889 sc imm8 sub rd,rs xorb rbd,@@rs
4890 sda rd,rs subb rbd,@@rs xorb rbd,addr
4891 sdab rbd,rs subb rbd,addr xorb rbd,addr(rs)
4892 sdal rrd,rs subb rbd,addr(rs) xorb rbd,imm8
4893 sdl rd,rs subb rbd,imm8 xorb rbd,rbs
4894 sdlb rbd,rs subb rbd,rbs xorb rbd,rbs
4895 sdll rrd,rs subl rrd,@@rs
4896 set @@rd,imm4 subl rrd,addr
4897 set addr(rd),imm4 subl rrd,addr(rs)
4903 @unnumbered GNU GENERAL PUBLIC LICENSE
4907 @cindex copying @code{as}
4908 @center Version 2, June 1991
4911 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
4912 675 Mass Ave, Cambridge, MA 02139, USA
4914 Everyone is permitted to copy and distribute verbatim copies
4915 of this license document, but changing it is not allowed.
4918 @unnumberedsec Preamble
4920 The licenses for most software are designed to take away your
4921 freedom to share and change it. By contrast, the GNU General Public
4922 License is intended to guarantee your freedom to share and change free
4923 software---to make sure the software is free for all its users. This
4924 General Public License applies to most of the Free Software
4925 Foundation's software and to any other program whose authors commit to
4926 using it. (Some other Free Software Foundation software is covered by
4927 the GNU Library General Public License instead.) You can apply it to
4930 When we speak of free software, we are referring to freedom, not
4931 price. Our General Public Licenses are designed to make sure that you
4932 have the freedom to distribute copies of free software (and charge for
4933 this service if you wish), that you receive source code or can get it
4934 if you want it, that you can change the software or use pieces of it
4935 in new free programs; and that you know you can do these things.
4937 To protect your rights, we need to make restrictions that forbid
4938 anyone to deny you these rights or to ask you to surrender the rights.
4939 These restrictions translate to certain responsibilities for you if you
4940 distribute copies of the software, or if you modify it.
4942 For example, if you distribute copies of such a program, whether
4943 gratis or for a fee, you must give the recipients all the rights that
4944 you have. You must make sure that they, too, receive or can get the
4945 source code. And you must show them these terms so they know their
4948 We protect your rights with two steps: (1) copyright the software, and
4949 (2) offer you this license which gives you legal permission to copy,
4950 distribute and/or modify the software.
4952 Also, for each author's protection and ours, we want to make certain
4953 that everyone understands that there is no warranty for this free
4954 software. If the software is modified by someone else and passed on, we
4955 want its recipients to know that what they have is not the original, so
4956 that any problems introduced by others will not reflect on the original
4957 authors' reputations.
4959 Finally, any free program is threatened constantly by software
4960 patents. We wish to avoid the danger that redistributors of a free
4961 program will individually obtain patent licenses, in effect making the
4962 program proprietary. To prevent this, we have made it clear that any
4963 patent must be licensed for everyone's free use or not licensed at all.
4965 The precise terms and conditions for copying, distribution and
4966 modification follow.
4969 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4972 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4977 This License applies to any program or other work which contains
4978 a notice placed by the copyright holder saying it may be distributed
4979 under the terms of this General Public License. The ``Program'', below,
4980 refers to any such program or work, and a ``work based on the Program''
4981 means either the Program or any derivative work under copyright law:
4982 that is to say, a work containing the Program or a portion of it,
4983 either verbatim or with modifications and/or translated into another
4984 language. (Hereinafter, translation is included without limitation in
4985 the term ``modification''.) Each licensee is addressed as ``you''.
4987 Activities other than copying, distribution and modification are not
4988 covered by this License; they are outside its scope. The act of
4989 running the Program is not restricted, and the output from the Program
4990 is covered only if its contents constitute a work based on the
4991 Program (independent of having been made by running the Program).
4992 Whether that is true depends on what the Program does.
4995 You may copy and distribute verbatim copies of the Program's
4996 source code as you receive it, in any medium, provided that you
4997 conspicuously and appropriately publish on each copy an appropriate
4998 copyright notice and disclaimer of warranty; keep intact all the
4999 notices that refer to this License and to the absence of any warranty;
5000 and give any other recipients of the Program a copy of this License
5001 along with the Program.
5003 You may charge a fee for the physical act of transferring a copy, and
5004 you may at your option offer warranty protection in exchange for a fee.
5007 You may modify your copy or copies of the Program or any portion
5008 of it, thus forming a work based on the Program, and copy and
5009 distribute such modifications or work under the terms of Section 1
5010 above, provided that you also meet all of these conditions:
5014 You must cause the modified files to carry prominent notices
5015 stating that you changed the files and the date of any change.
5018 You must cause any work that you distribute or publish, that in
5019 whole or in part contains or is derived from the Program or any
5020 part thereof, to be licensed as a whole at no charge to all third
5021 parties under the terms of this License.
5024 If the modified program normally reads commands interactively
5025 when run, you must cause it, when started running for such
5026 interactive use in the most ordinary way, to print or display an
5027 announcement including an appropriate copyright notice and a
5028 notice that there is no warranty (or else, saying that you provide
5029 a warranty) and that users may redistribute the program under
5030 these conditions, and telling the user how to view a copy of this
5031 License. (Exception: if the Program itself is interactive but
5032 does not normally print such an announcement, your work based on
5033 the Program is not required to print an announcement.)
5036 These requirements apply to the modified work as a whole. If
5037 identifiable sections of that work are not derived from the Program,
5038 and can be reasonably considered independent and separate works in
5039 themselves, then this License, and its terms, do not apply to those
5040 sections when you distribute them as separate works. But when you
5041 distribute the same sections as part of a whole which is a work based
5042 on the Program, the distribution of the whole must be on the terms of
5043 this License, whose permissions for other licensees extend to the
5044 entire whole, and thus to each and every part regardless of who wrote it.
5046 Thus, it is not the intent of this section to claim rights or contest
5047 your rights to work written entirely by you; rather, the intent is to
5048 exercise the right to control the distribution of derivative or
5049 collective works based on the Program.
5051 In addition, mere aggregation of another work not based on the Program
5052 with the Program (or with a work based on the Program) on a volume of
5053 a storage or distribution medium does not bring the other work under
5054 the scope of this License.
5057 You may copy and distribute the Program (or a work based on it,
5058 under Section 2) in object code or executable form under the terms of
5059 Sections 1 and 2 above provided that you also do one of the following:
5063 Accompany it with the complete corresponding machine-readable
5064 source code, which must be distributed under the terms of Sections
5065 1 and 2 above on a medium customarily used for software interchange; or,
5068 Accompany it with a written offer, valid for at least three
5069 years, to give any third party, for a charge no more than your
5070 cost of physically performing source distribution, a complete
5071 machine-readable copy of the corresponding source code, to be
5072 distributed under the terms of Sections 1 and 2 above on a medium
5073 customarily used for software interchange; or,
5076 Accompany it with the information you received as to the offer
5077 to distribute corresponding source code. (This alternative is
5078 allowed only for noncommercial distribution and only if you
5079 received the program in object code or executable form with such
5080 an offer, in accord with Subsection b above.)
5083 The source code for a work means the preferred form of the work for
5084 making modifications to it. For an executable work, complete source
5085 code means all the source code for all modules it contains, plus any
5086 associated interface definition files, plus the scripts used to
5087 control compilation and installation of the executable. However, as a
5088 special exception, the source code distributed need not include
5089 anything that is normally distributed (in either source or binary
5090 form) with the major components (compiler, kernel, and so on) of the
5091 operating system on which the executable runs, unless that component
5092 itself accompanies the executable.
5094 If distribution of executable or object code is made by offering
5095 access to copy from a designated place, then offering equivalent
5096 access to copy the source code from the same place counts as
5097 distribution of the source code, even though third parties are not
5098 compelled to copy the source along with the object code.
5101 You may not copy, modify, sublicense, or distribute the Program
5102 except as expressly provided under this License. Any attempt
5103 otherwise to copy, modify, sublicense or distribute the Program is
5104 void, and will automatically terminate your rights under this License.
5105 However, parties who have received copies, or rights, from you under
5106 this License will not have their licenses terminated so long as such
5107 parties remain in full compliance.
5110 You are not required to accept this License, since you have not
5111 signed it. However, nothing else grants you permission to modify or
5112 distribute the Program or its derivative works. These actions are
5113 prohibited by law if you do not accept this License. Therefore, by
5114 modifying or distributing the Program (or any work based on the
5115 Program), you indicate your acceptance of this License to do so, and
5116 all its terms and conditions for copying, distributing or modifying
5117 the Program or works based on it.
5120 Each time you redistribute the Program (or any work based on the
5121 Program), the recipient automatically receives a license from the
5122 original licensor to copy, distribute or modify the Program subject to
5123 these terms and conditions. You may not impose any further
5124 restrictions on the recipients' exercise of the rights granted herein.
5125 You are not responsible for enforcing compliance by third parties to
5129 If, as a consequence of a court judgment or allegation of patent
5130 infringement or for any other reason (not limited to patent issues),
5131 conditions are imposed on you (whether by court order, agreement or
5132 otherwise) that contradict the conditions of this License, they do not
5133 excuse you from the conditions of this License. If you cannot
5134 distribute so as to satisfy simultaneously your obligations under this
5135 License and any other pertinent obligations, then as a consequence you
5136 may not distribute the Program at all. For example, if a patent
5137 license would not permit royalty-free redistribution of the Program by
5138 all those who receive copies directly or indirectly through you, then
5139 the only way you could satisfy both it and this License would be to
5140 refrain entirely from distribution of the Program.
5142 If any portion of this section is held invalid or unenforceable under
5143 any particular circumstance, the balance of the section is intended to
5144 apply and the section as a whole is intended to apply in other
5147 It is not the purpose of this section to induce you to infringe any
5148 patents or other property right claims or to contest validity of any
5149 such claims; this section has the sole purpose of protecting the
5150 integrity of the free software distribution system, which is
5151 implemented by public license practices. Many people have made
5152 generous contributions to the wide range of software distributed
5153 through that system in reliance on consistent application of that
5154 system; it is up to the author/donor to decide if he or she is willing
5155 to distribute software through any other system and a licensee cannot
5158 This section is intended to make thoroughly clear what is believed to
5159 be a consequence of the rest of this License.
5162 If the distribution and/or use of the Program is restricted in
5163 certain countries either by patents or by copyrighted interfaces, the
5164 original copyright holder who places the Program under this License
5165 may add an explicit geographical distribution limitation excluding
5166 those countries, so that distribution is permitted only in or among
5167 countries not thus excluded. In such case, this License incorporates
5168 the limitation as if written in the body of this License.
5171 The Free Software Foundation may publish revised and/or new versions
5172 of the General Public License from time to time. Such new versions will
5173 be similar in spirit to the present version, but may differ in detail to
5174 address new problems or concerns.
5176 Each version is given a distinguishing version number. If the Program
5177 specifies a version number of this License which applies to it and ``any
5178 later version'', you have the option of following the terms and conditions
5179 either of that version or of any later version published by the Free
5180 Software Foundation. If the Program does not specify a version number of
5181 this License, you may choose any version ever published by the Free Software
5185 If you wish to incorporate parts of the Program into other free
5186 programs whose distribution conditions are different, write to the author
5187 to ask for permission. For software which is copyrighted by the Free
5188 Software Foundation, write to the Free Software Foundation; we sometimes
5189 make exceptions for this. Our decision will be guided by the two goals
5190 of preserving the free status of all derivatives of our free software and
5191 of promoting the sharing and reuse of software generally.
5194 @heading NO WARRANTY
5201 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
5202 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
5203 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
5204 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
5205 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5206 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
5207 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
5208 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
5209 REPAIR OR CORRECTION.
5212 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
5213 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
5214 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
5215 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
5216 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
5217 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
5218 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
5219 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
5220 POSSIBILITY OF SUCH DAMAGES.
5224 @heading END OF TERMS AND CONDITIONS
5227 @center END OF TERMS AND CONDITIONS
5231 @unnumberedsec Applying These Terms to Your New Programs
5233 If you develop a new program, and you want it to be of the greatest
5234 possible use to the public, the best way to achieve this is to make it
5235 free software which everyone can redistribute and change under these terms.
5237 To do so, attach the following notices to the program. It is safest
5238 to attach them to the start of each source file to most effectively
5239 convey the exclusion of warranty; and each file should have at least
5240 the ``copyright'' line and a pointer to where the full notice is found.
5243 @var{one line to give the program's name and an idea of what it does.}
5244 Copyright (C) 19@var{yy} @var{name of author}
5246 This program is free software; you can redistribute it and/or
5247 modify it under the terms of the GNU General Public License
5248 as published by the Free Software Foundation; either version 2
5249 of the License, or (at your option) any later version.
5251 This program is distributed in the hope that it will be useful,
5252 but WITHOUT ANY WARRANTY; without even the implied warranty of
5253 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5254 GNU General Public License for more details.
5256 You should have received a copy of the GNU General Public License
5257 along with this program; if not, write to the
5258 Free Software Foundation, Inc., 675 Mass Ave,
5259 Cambridge, MA 02139, USA.
5262 Also add information on how to contact you by electronic and paper mail.
5264 If the program is interactive, make it output a short notice like this
5265 when it starts in an interactive mode:
5268 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
5269 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
5270 type `show w'. This is free software, and you are welcome
5271 to redistribute it under certain conditions; type `show c'
5275 The hypothetical commands @samp{show w} and @samp{show c} should show
5276 the appropriate parts of the General Public License. Of course, the
5277 commands you use may be called something other than @samp{show w} and
5278 @samp{show c}; they could even be mouse-clicks or menu items---whatever
5281 You should also get your employer (if you work as a programmer) or your
5282 school, if any, to sign a ``copyright disclaimer'' for the program, if
5283 necessary. Here is a sample; alter the names:
5286 Yoyodyne, Inc., hereby disclaims all copyright interest in
5287 the program `Gnomovision' (which makes passes at compilers)
5288 written by James Hacker.
5290 @var{signature of Ty Coon}, 1 April 1989
5291 Ty Coon, President of Vice
5294 This General Public License does not permit incorporating your program into
5295 proprietary programs. If your program is a subroutine library, you may
5296 consider it more useful to permit linking proprietary applications with the
5297 library. If this is what you want to do, use the GNU Library General
5298 Public License instead of this License.