1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright (c) 1991 1992 1993 Free Software Foundation, Inc.
6 @c defaults, config file may override:
9 @include asdoc-config.texi
11 @c common OR combinations of conditions
29 @settitle Using @value{AS}
32 @settitle Using @value{AS} (@value{TARGET})
34 @setchapternewpage odd
40 * As:: The GNU assembler.
49 This file documents the GNU Assembler "@value{AS}".
51 Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
53 Permission is granted to make and distribute verbatim copies of
54 this manual provided the copyright notice and this permission notice
55 are preserved on all copies.
58 Permission is granted to process this file through Tex and print the
59 results, provided the printed document carries copying permission
60 notice identical to this one except for the removal of this paragraph
61 (this paragraph not being relevant to the printed manual).
64 Permission is granted to copy and distribute modified versions of this
65 manual under the conditions for verbatim copying, provided also that the
66 section entitled ``GNU General Public License'' is included exactly as
67 in the original, and provided that the entire resulting derived work is
68 distributed under the terms of a permission notice identical to this
71 Permission is granted to copy and distribute translations of this manual
72 into another language, under the above conditions for modified versions,
73 except that the section entitled ``GNU General Public License'' may be
74 included in a translation approved by the Free Software Foundation
75 instead of in the original English.
79 @title Using @value{AS}
80 @subtitle The GNU Assembler
82 @subtitle for the @value{TARGET} family
88 The Free Software Foundation Inc. thanks The Nice Computer
89 Company of Australia for loaning Dean Elsner to write the
90 first (Vax) version of @code{as} for Project GNU.
91 The proprietors, management and staff of TNCCA thank FSF for
92 distracting the boss while they got some work
95 @author Dean Elsner, Jay Fenlason & friends
99 \hfill {\it Using {\tt @value{AS}}}\par
100 \hfill Edited by Roland Pesch for Cygnus Support\par
102 %"boxit" macro for figures:
103 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
104 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
105 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
106 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
107 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
110 @vskip 0pt plus 1filll
111 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
113 Permission is granted to make and distribute verbatim copies of
114 this manual provided the copyright notice and this permission notice
115 are preserved on all copies.
117 Permission is granted to copy and distribute modified versions of this
118 manual under the conditions for verbatim copying, provided also that the
119 section entitled ``GNU General Public License'' is included exactly as
120 in the original, and provided that the entire resulting derived work is
121 distributed under the terms of a permission notice identical to this
124 Permission is granted to copy and distribute translations of this manual
125 into another language, under the above conditions for modified versions,
126 except that the section entitled ``GNU General Public License'' may be
127 included in a translation approved by the Free Software Foundation
128 instead of in the original English.
133 @top Using @value{AS}
135 This file is a user guide to the GNU assembler @code{@value{AS}}.
137 This version of the file describes @code{@value{AS}} configured to generate
138 code for @value{TARGET} architectures.
141 * Overview:: Overview
142 * Invoking:: Command-Line Options
144 * Sections:: Sections and Relocation
146 * Expressions:: Expressions
147 * Pseudo Ops:: Assembler Directives
148 * Machine Dependencies:: Machine Dependent Features
150 * Copying:: GNU GENERAL PUBLIC LICENSE
160 This manual is a user guide to the GNU assembler @code{@value{AS}}.
162 This version of the manual describes @code{@value{AS}} configured to generate
163 code for @value{TARGET} architectures.
167 @cindex invocation summary
168 @cindex option summary
169 @cindex summary of options
170 Here is a brief summary of how to invoke @code{@value{AS}}. For details,
171 @pxref{Invoking,,Comand-Line Options}.
173 @c We don't use deffn and friends for the following because they seem
174 @c to be limited to one line for the header.
176 @value{AS} [ -a[dhlns] ] [ -D ] [ -f ]
177 [ -I @var{path} ] [ -K ] [ -L ]
178 [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ]
180 @c am29k has no machine-dependent assembler options
183 @c Hitachi family chips have no machine-dependent assembler options
186 [ -Av6 | -Av7 | -Av8 | -Asparclite | -bump ]
189 @c Z8000 has no machine-dependent assembler options
192 @c see md_parse_option in tc-i960.c
193 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
197 [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
200 [ -nocpp ] [ -EL ] [ -EB ] [ -G @var{num} ]
202 [ -- | @var{files} @dots{} ]
208 @samp{-ad}, omit debugging pseudo-ops from listing,
209 @samp{-ah}, include high-level source,
210 @samp{-al}, assembly listing,
211 @samp{-an}, no forms processing,
213 These options may be combined; @emph{e.g.}, @samp{-aln} for assembly
214 listing without forms processing. By itself, @samp{-a} defaults to
215 @samp{-ahls} --- that is, all listings turned on.
218 This option is accepted only for script compatibility with calls to
219 other assemblers; it has no effect on @code{@value{AS}}.
222 ``fast''---skip preprocessing (assume source is compiler output)
225 Add @var{path} to the search list for @code{.include} directives
228 @ifclear DIFF-TBL-KLUGE
229 This option is accepted but has no effect on the @value{TARGET} family.
231 @ifset DIFF-TBL-KLUGE
232 Issue warnings when difference tables altered for long displacements.
236 Keep (in symbol table) local symbols, starting with @samp{L}
238 @item -o @var{objfile}
239 Name the object-file output from @code{@value{AS}}
242 Fold data section into text section
245 Announce @code{as} version
248 Suppress warning messages
250 @item -- | @var{files} @dots{}
251 Standard input, or source files to assemble.
256 The following options are available when @value{AS} is configured for the
257 Intel 80960 processor.
260 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
261 Specify which variant of the 960 architecture is the target.
264 Add code to collect statistics about branches taken.
267 Do not alter compare-and-branch instructions for long displacements;
274 The following options are available when @value{AS} is configured for the
275 Motorola 68000 series.
280 Shorten references to undefined symbols, to one word instead of two.
282 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040
283 @itemx | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32
284 Specify what processor in the 68000 family is the target. The default
285 is normally the 68020, but this can be changed at configuration time.
287 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
288 The target machine does (or does not) have a floating-point coprocessor.
289 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
290 the basic 68000 is not compatible with the 68881, a combination of the
291 two can be specified, since it's possible to do emulation of the
292 coprocessor instructions with the main processor.
294 @item -m68851 | -mno-68851
295 The target machine does (or does not) have a memory-management
296 unit coprocessor. The default is to assume an MMU for 68020 and up.
302 The following options are available when @code{@value{AS}} is configured
303 for the SPARC architecture:
306 @item -Av6 | -Av7 | -Av8 | -Asparclite
307 Explicitly select a variant of the SPARC architecture.
310 Warn when the assembler switches to another architecture.
315 The following options are available when @value{AS} is configured for
316 the MIPS R2000/R3000 processors.
321 This option sets the largest size of an object that will be referenced
322 implicitly with the @code{gp} register. It is only accepted for targets
323 that use ECOFF format, such as a DECstation running Ultrix. The default
328 These options are ignored. They are accepted for compatibility with the
335 * Manual:: Structure of this Manual
336 * GNU Assembler:: @value{AS}, the GNU Assembler
337 * Object Formats:: Object File Formats
338 * Command Line:: Command Line
339 * Input Files:: Input Files
340 * Object:: Output (Object) File
341 * Errors:: Error and Warning Messages
345 @section Structure of this Manual
347 @cindex manual, structure and purpose
348 This manual is intended to describe what you need to know to use
349 @sc{gnu} @code{@value{AS}}. We cover the syntax expected in source files, including
350 notation for symbols, constants, and expressions; the directives that
351 @code{@value{AS}} understands; and of course how to invoke @code{@value{AS}}.
354 We also cover special features in the @value{TARGET}
355 configuration of @code{@value{AS}}, including assembler directives.
358 This manual also describes some of the machine-dependent features of
359 various flavors of the assembler.
362 This manual also describes how the assembler works internally, and
363 provides some information that may be useful to people attempting to
364 port the assembler to another machine.
368 @cindex machine instructions (not covered)
369 On the other hand, this manual is @emph{not} intended as an introduction
370 to programming in assembly language---let alone programming in general!
371 In a similar vein, we make no attempt to introduce the machine
372 architecture; we do @emph{not} describe the instruction set, standard
373 mnemonics, registers or addressing modes that are standard to a
374 particular architecture.
376 You may want to consult the manufacturer's
377 machine architecture manual for this information.
381 For information on the H8/300 machine instruction set, see @cite{H8/300
382 Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,
383 see @cite{H8/300H Series Programming Manual} (Hitachi).
386 For information on the H8/500 machine instruction set, see @cite{H8/500
387 Series Programming Manual} (Hitachi M21T001).
390 For information on the Hitachi SH machine instruction set, see
391 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
394 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
398 @c I think this is premature---pesch@cygnus.com, 17jan1991
400 Throughout this manual, we assume that you are running @dfn{GNU},
401 the portable operating system from the @dfn{Free Software
402 Foundation, Inc.}. This restricts our attention to certain kinds of
403 computer (in particular, the kinds of computers that GNU can run on);
404 once this assumption is granted examples and definitions need less
407 @code{@value{AS}} is part of a team of programs that turn a high-level
408 human-readable series of instructions into a low-level
409 computer-readable series of instructions. Different versions of
410 @code{@value{AS}} are used for different kinds of computer.
413 @c There used to be a section "Terminology" here, which defined
414 @c "contents", "byte", "word", and "long". Defining "word" to any
415 @c particular size is confusing when the .word directive may generate 16
416 @c bits on one machine and 32 bits on another; in general, for the user
417 @c version of this manual, none of these terms seem essential to define.
418 @c They were used very little even in the former draft of the manual;
419 @c this draft makes an effort to avoid them (except in names of
423 @section @value{AS}, the GNU Assembler
425 GNU @code{as} is really a family of assemblers.
427 This manual describes @code{@value{AS}}, a member of that family which is
428 configured for the @value{TARGET} architectures.
430 If you use (or have used) the GNU assembler on one architecture, you
431 should find a fairly similar environment when you use it on another
432 architecture. Each version has much in common with the others,
433 including object file formats, most assembler directives (often called
434 @dfn{pseudo-ops}) and assembler syntax.@refill
436 @cindex purpose of @sc{gnu} @code{@value{AS}}
437 @code{@value{AS}} is primarily intended to assemble the output of the
438 GNU C compiler @code{@value{GCC}} for use by the linker
439 @code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}
440 assemble correctly everything that other assemblers for the same
441 machine would assemble.
443 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
446 @c This remark should appear in generic version of manual; assumption
447 @c here is that generic version sets M680x0.
448 This doesn't mean @code{@value{AS}} always uses the same syntax as another
449 assembler for the same architecture; for example, we know of several
450 incompatible versions of 680x0 assembly language syntax.
453 Unlike older assemblers, @code{@value{AS}} is designed to assemble a source
454 program in one pass of the source file. This has a subtle impact on the
455 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
458 @section Object File Formats
460 @cindex object file format
461 The GNU assembler can be configured to produce several alternative
462 object file formats. For the most part, this does not affect how you
463 write assembly language programs; but directives for debugging symbols
464 are typically different in different file formats. @xref{Symbol
465 Attributes,,Symbol Attributes}.
468 On the @value{TARGET}, @code{@value{AS}} is configured to produce
469 @value{OBJ-NAME} format object files.
471 @c The following should exhaust all configs that set MULTI-OBJ, ideally
473 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
474 @code{a.out} or COFF format object files.
477 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
478 @code{b.out} or COFF format object files.
483 @section Command Line
485 @cindex command line conventions
486 After the program name @code{@value{AS}}, the command line may contain
487 options and file names. Options may appear in any order, and may be
488 before, after, or between file names. The order of file names is
491 @cindex standard input, as input file
493 @file{--} (two hyphens) by itself names the standard input file
494 explicitly, as one of the files for @code{@value{AS}} to assemble.
496 @cindex options, command line
497 Except for @samp{--} any command line argument that begins with a
498 hyphen (@samp{-}) is an option. Each option changes the behavior of
499 @code{@value{AS}}. No option changes the way another option works. An
500 option is a @samp{-} followed by one or more letters; the case of
501 the letter is important. All options are optional.
503 Some options expect exactly one file name to follow them. The file
504 name may either immediately follow the option's letter (compatible
505 with older assemblers) or it may be the next command argument (GNU
506 standard). These two command lines are equivalent:
509 @value{AS} -o my-object-file.o mumble.s
510 @value{AS} -omy-object-file.o mumble.s
517 @cindex source program
519 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
520 describe the program input to one run of @code{@value{AS}}. The program may
521 be in one or more files; how the source is partitioned into files
522 doesn't change the meaning of the source.
524 @c I added "con" prefix to "catenation" just to prove I can overcome my
525 @c APL training... pesch@cygnus.com
526 The source program is a concatenation of the text in all the files, in the
529 Each time you run @code{@value{AS}} it assembles exactly one source
530 program. The source program is made up of one or more files.
531 (The standard input is also a file.)
533 You give @code{@value{AS}} a command line that has zero or more input file
534 names. The input files are read (from left file name to right). A
535 command line argument (in any position) that has no special meaning
536 is taken to be an input file name.
538 If you give @code{@value{AS}} no file names it attempts to read one input file
539 from the @code{@value{AS}} standard input, which is normally your terminal. You
540 may have to type @key{ctl-D} to tell @code{@value{AS}} there is no more program
543 Use @samp{--} if you need to explicitly name the standard input file
544 in your command line.
546 If the source is empty, @code{@value{AS}} will produce a small, empty object
549 @subheading Filenames and Line-numbers
551 @cindex input file linenumbers
552 @cindex line numbers, in input files
553 There are two ways of locating a line in the input file (or files) and
554 either may be used in reporting error messages. One way refers to a line
555 number in a physical file; the other refers to a line number in a
556 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
558 @dfn{Physical files} are those files named in the command line given
559 to @code{@value{AS}}.
561 @dfn{Logical files} are simply names declared explicitly by assembler
562 directives; they bear no relation to physical files. Logical file names
563 help error messages reflect the original source file, when @code{@value{AS}}
564 source is itself synthesized from other files.
565 @xref{App-File,,@code{.app-file}}.
568 @section Output (Object) File
574 Every time you run @code{@value{AS}} it produces an output file, which is
575 your assembly language program translated into numbers. This file
576 is the object file, named
580 if @code{@value{AS}} is configured for the Intel 80960, or
586 unless you tell @code{@value{AS}} to
587 give it another name by using the @code{-o} option. Conventionally,
588 object file names end with @file{.o}. The default name of
589 @file{a.out} is used for historical reasons: older assemblers were
590 capable of assembling self-contained programs directly into a
592 (For some formats, this isn't currently possible, but it can be done for
593 @code{a.out} format.)
597 The object file is meant for input to the linker @code{@value{LD}}. It contains
598 assembled program code, information to help @code{@value{LD}} integrate
599 the assembled program into a runnable file, and (optionally) symbolic
600 information for the debugger.
602 @c link above to some info file(s) like the description of a.out.
603 @c don't forget to describe GNU info as well as Unix lossage.
606 @section Error and Warning Messages
608 @cindex error messsages
609 @cindex warning messages
610 @cindex messages from @code{@value{AS}}
611 @code{@value{AS}} may write warnings and error messages to the standard error
612 file (usually your terminal). This should not happen when a compiler
613 runs @code{@value{AS}} automatically. Warnings report an assumption made so
614 that @code{@value{AS}} could keep assembling a flawed program; errors report a
615 grave problem that stops the assembly.
617 @cindex format of warning messages
618 Warning messages have the format
621 file_name:@b{NNN}:Warning Message Text
625 @cindex line numbers, in warnings/errors
626 (where @b{NNN} is a line number). If a logical file name has been given
627 (@pxref{App-File,,@code{.app-file}}) it is used for the filename,
628 otherwise the name of the current input file is used. If a logical line
631 (@pxref{Line,,@code{.line}})
635 (@pxref{Line,,@code{.line}})
638 (@pxref{Ln,,@code{.ln}})
641 then it is used to calculate the number printed,
642 otherwise the actual line in the current source file is printed. The
643 message text is intended to be self explanatory (in the grand Unix
646 @cindex format of error messages
647 Error messages have the format
649 file_name:@b{NNN}:FATAL:Error Message Text
651 The file name and line number are derived as for warning
652 messages. The actual message text may be rather less explanatory
653 because many of them aren't supposed to happen.
656 @chapter Command-Line Options
658 @cindex options, all versions of @code{@value{AS}}
659 This chapter describes command-line options available in @emph{all}
660 versions of the GNU assembler; @pxref{Machine Dependencies}, for options specific
662 to the @value{TARGET}.
665 to particular machine architectures.
668 If you are invoking @code{@value{AS}} via the GNU C compiler (version 2), you
669 can use the @samp{-Wa} option to pass arguments through to the
670 assembler. The assembler arguments must be separated from each other
671 (and the @samp{-Wa}) by commas. For example:
674 gcc -c -g -O -Wa,-alh,-L file.c
677 will cause a listing to be emitted to standard output with high-level
680 Many compiler command-line options, such as @samp{-R} and many
681 machine-specific options, will be automatically be passed to the
682 assembler by the compiler, so usually you do not need to use this
683 @samp{-Wa} mechanism.
686 * a:: -a[dhlns] enable listings
687 * D:: -D for compatibility
688 * f:: -f to work faster
689 * I:: -I for .include search path
690 @ifclear DIFF-TBL-KLUGE
691 * K:: -K for compatibility
693 @ifset DIFF-TBL-KLUGE
694 * K:: -K for difference tables
697 * L:: -L to retain local labels
698 * o:: -o to name the object file
699 * R:: -R to join data and text sections
700 * v:: -v to announce version
701 * W:: -W to suppress warnings
705 @section Enable Listings: @code{-a[dhlns]}
713 @cindex listings, enabling
714 @cindex assembly listings, enabling
716 These options enable listing output from the assembler. By itself,
717 @samp{-a} requests high-level, assembly, and symbols listing.
718 Other letters may be used to select specific options for the list:
719 @samp{-ah} requests a high-level language listing,
720 @samp{-al} requests an output-program assembly listing, and
721 @samp{-as} requests a symbol table listing.
722 High-level listings require that a compiler debugging option like
723 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
726 The @samp{-ad} option may be used to omit debugging pseudo-ops from the
729 Once you have specified one of these options, you can further control
730 listing output and its appearance using the directives @code{.list},
731 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
733 The @samp{-an} option turns off all forms processing.
734 If you do not request listing output with one of the @samp{-a} options, the
735 listing-control directives have no effect.
737 The letters after @samp{-a} may be combined into one option,
738 @emph{e.g.}, @samp{-aln}.
744 This option has no effect whatsoever, but it is accepted to make it more
745 likely that scripts written for other assemblers will also work with
749 @section Work Faster: @code{-f}
752 @cindex trusted compiler
753 @cindex faster processing (@code{-f})
754 @samp{-f} should only be used when assembling programs written by a
755 (trusted) compiler. @samp{-f} stops the assembler from pre-processing
756 the input file(s) before assembling them. @xref{Pre-processing,
760 @emph{Warning:} if the files actually need to be pre-processed (if they
761 contain comments, for example), @code{@value{AS}} will not work correctly if
766 @section @code{.include} search path: @code{-I} @var{path}
768 @kindex -I @var{path}
769 @cindex paths for @code{.include}
770 @cindex search path for @code{.include}
771 @cindex @code{include} directive search path
772 Use this option to add a @var{path} to the list of directories
773 @code{@value{AS}} will search for files specified in @code{.include}
774 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
775 many times as necessary to include a variety of paths. The current
776 working directory is always searched first; after that, @code{@value{AS}}
777 searches any @samp{-I} directories in the same order as they were
778 specified (left to right) on the command line.
781 @section Difference Tables: @code{-K}
784 @ifclear DIFF-TBL-KLUGE
785 On the @value{TARGET} family, this option is allowed, but has no effect. It is
786 permitted for compatibility with the GNU assembler on other platforms,
787 where it can be used to warn when the assembler alters the machine code
788 generated for @samp{.word} directives in difference tables. The @value{TARGET}
789 family does not have the addressing limitations that sometimes lead to this
790 alteration on other platforms.
793 @ifset DIFF-TBL-KLUGE
794 @cindex difference tables, warning
795 @cindex warning for altered difference tables
796 @code{@value{AS}} sometimes alters the code emitted for directives of the form
797 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
798 You can use the @samp{-K} option if you want a warning issued when this
803 @section Include Local Labels: @code{-L}
806 @cindex local labels, retaining in output
807 Labels beginning with @samp{L} (upper case only) are called @dfn{local
808 labels}. @xref{Symbol Names}. Normally you don't see such labels when
809 debugging, because they are intended for the use of programs (like
810 compilers) that compose assembler programs, not for your notice.
811 Normally both @code{@value{AS}} and @code{@value{LD}} discard such labels, so you don't
812 normally debug with them.
814 This option tells @code{@value{AS}} to retain those @samp{L@dots{}} symbols
815 in the object file. Usually if you do this you also tell the linker
816 @code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
819 @section Name the Object File: @code{-o}
822 @cindex naming object file
823 @cindex object file name
824 There is always one object file output when you run @code{@value{AS}}. By
825 default it has the name
828 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
842 You use this option (which takes exactly one filename) to give the
843 object file a different name.
845 Whatever the object file is called, @code{@value{AS}} will overwrite any
846 existing file of the same name.
849 @section Join Data and Text Sections: @code{-R}
852 @cindex data and text sections, joining
853 @cindex text and data sections, joining
854 @cindex joining text and data sections
855 @cindex merging text and data sections
856 @code{-R} tells @code{@value{AS}} to write the object file as if all
857 data-section data lives in the text section. This is only done at
858 the very last moment: your binary data are the same, but data
859 section parts are relocated differently. The data section part of
860 your object file is zero bytes long because all its bytes are
861 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
863 When you specify @code{-R} it would be possible to generate shorter
864 address displacements (because we don't have to cross between text and
865 data section). We refrain from doing this simply for compatibility with
866 older versions of @code{@value{AS}}. In future, @code{-R} may work this way.
869 When @code{@value{AS}} is configured for COFF output,
870 this option is only useful if you use sections named @samp{.text} and
875 @section Announce Version: @code{-v}
879 @cindex @code{@value{AS}} version
880 @cindex version of @code{@value{AS}}
881 You can find out what version of as is running by including the
882 option @samp{-v} (which you can also spell as @samp{-version}) on the
886 @section Suppress Warnings: @code{-W}
889 @cindex suppressing warnings
890 @cindex warnings, suppressing
891 @code{@value{AS}} should never give a warning or error message when
892 assembling compiler output. But programs written by people often
893 cause @code{@value{AS}} to give a warning that a particular assumption was
894 made. All such warnings are directed to the standard error file.
895 If you use this option, no warnings are issued. This option only
896 affects the warning messages: it does not change any particular of how
897 @code{@value{AS}} assembles your file. Errors, which stop the assembly, are
903 @cindex machine-independent syntax
904 @cindex syntax, machine-independent
905 This chapter describes the machine-independent syntax allowed in a
906 source file. @code{@value{AS}} syntax is similar to what many other
907 assemblers use; it is inspired by the BSD 4.2
912 assembler, except that @code{@value{AS}} does not assemble Vax bit-fields.
916 * Pre-processing:: Pre-processing
917 * Whitespace:: Whitespace
918 * Comments:: Comments
919 * Symbol Intro:: Symbols
920 * Statements:: Statements
921 * Constants:: Constants
925 @section Pre-Processing
927 @cindex preprocessing
930 @cindex whitespace, removed by preprocessor
932 adjusts and removes extra whitespace. It leaves one space or tab before
933 the keywords on a line, and turns any other whitespace on the line into
936 @cindex comments, removed by preprocessor
938 removes all comments, replacing them with a single space, or an
939 appropriate number of newlines.
941 @cindex constants, converted by preprocessor
943 converts character constants into the appropriate numeric values.
946 Excess whitespace, comments, and character constants
947 cannot be used in the portions of the input text that are not
950 @cindex turning preprocessing on and off
951 @cindex preprocessing, turning on and off
954 If the first line of an input file is @code{#NO_APP} or the @samp{-f}
955 option is given, the input file will not be pre-processed. Within such
956 an input file, parts of the file can be pre-processed by putting a line
957 that says @code{#APP} before the text that should be pre-processed, and
958 putting a line that says @code{#NO_APP} after them. This feature is
959 mainly intend to support @code{asm} statements in compilers whose output
960 normally does not need to be pre-processed.
966 @dfn{Whitespace} is one or more blanks or tabs, in any order.
967 Whitespace is used to separate symbols, and to make programs neater for
968 people to read. Unless within character constants
969 (@pxref{Characters,,Character Constants}), any whitespace means the same
970 as exactly one space.
976 There are two ways of rendering comments to @code{@value{AS}}. In both
977 cases the comment is equivalent to one space.
979 Anything from @samp{/*} through the next @samp{*/} is a comment.
980 This means you may not nest these comments.
984 The only way to include a newline ('\n') in a comment
985 is to use this sort of comment.
988 /* This sort of comment does not nest. */
991 @cindex line comment character
992 Anything from the @dfn{line comment} character to the next newline
993 is considered a comment and is ignored. The line comment character is
998 @samp{#} on the i960;
1001 @samp{!} on the SPARC;
1004 @samp{|} on the 680x0;
1007 @samp{;} for the AMD 29K family;
1010 @samp{;} for the H8/300 family;
1013 @samp{!} for the H8/500 family;
1016 @samp{!} for the Hitachi SH;
1019 @samp{!} for the Z8000;
1021 see @ref{Machine Dependencies}. @refill
1022 @c FIXME What about i386, m88k, i860?
1025 On some machines there are two different line comment characters. One
1026 will only begin a comment if it is the first non-whitespace character on
1027 a line, while the other will always begin a comment.
1031 @cindex lines starting with @code{#}
1032 @cindex logical line numbers
1033 To be compatible with past assemblers, a special interpretation is
1034 given to lines that begin with @samp{#}. Following the @samp{#} an
1035 absolute expression (@pxref{Expressions}) is expected: this will be
1036 the logical line number of the @b{next} line. Then a string
1037 (@xref{Strings}.) is allowed: if present it is a new logical file
1038 name. The rest of the line, if any, should be whitespace.
1040 If the first non-whitespace characters on the line are not numeric,
1041 the line is ignored. (Just like a comment.)
1043 # This is an ordinary comment.
1044 # 42-6 "new_file_name" # New logical file name
1045 # This is logical line # 36.
1047 This feature is deprecated, and may disappear from future versions
1048 of @code{@value{AS}}.
1053 @cindex characters used in symbols
1054 @ifclear SPECIAL-SYMS
1055 A @dfn{symbol} is one or more characters chosen from the set of all
1056 letters (both upper and lower case), digits and the three characters
1062 A @dfn{symbol} is one or more characters chosen from the set of all
1063 letters (both upper and lower case), digits and the three characters
1064 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
1070 On most machines, you can also use @code{$} in symbol names; exceptions
1071 are noted in @ref{Machine Dependencies}.
1073 No symbol may begin with a digit. Case is significant.
1074 There is no length limit: all characters are significant. Symbols are
1075 delimited by characters not in that set, or by the beginning of a file
1076 (since the source program must end with a newline, the end of a file is
1077 not a possible symbol delimiter). @xref{Symbols}.
1078 @cindex length of symbols
1083 @cindex statements, structure of
1084 @cindex line separator character
1085 @cindex statement separator character
1087 @ifclear abnormal-separator
1088 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
1089 semicolon (@samp{;}). The newline or semicolon is considered part of
1090 the preceding statement. Newlines and semicolons within character
1091 constants are an exception: they don't end statements.
1093 @ifset abnormal-separator
1095 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
1096 sign (@samp{@@}). The newline or at sign is considered part of the
1097 preceding statement. Newlines and at signs within character constants
1098 are an exception: they don't end statements.
1101 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
1102 H8/300) a dollar sign (@samp{$}); or (for the
1105 (@samp{;}). The newline or separator character is considered part of
1106 the preceding statement. Newlines and separators within character
1107 constants are an exception: they don't end statements.
1112 A @dfn{statement} ends at a newline character (@samp{\n}) or line
1113 separator character. (The line separator is usually @samp{;}, unless
1114 this conflicts with the comment character; @pxref{Machine Dependencies}.) The
1115 newline or separator character is considered part of the preceding
1116 statement. Newlines and separators within character constants are an
1117 exception: they don't end statements.
1120 @cindex newline, required at file end
1121 @cindex EOF, newline must precede
1122 It is an error to end any statement with end-of-file: the last
1123 character of any input file should be a newline.@refill
1125 @cindex continuing statements
1126 @cindex multi-line statements
1127 @cindex statement on multiple lines
1128 You may write a statement on more than one line if you put a
1129 backslash (@kbd{\}) immediately in front of any newlines within the
1130 statement. When @code{@value{AS}} reads a backslashed newline both
1131 characters are ignored. You can even put backslashed newlines in
1132 the middle of symbol names without changing the meaning of your
1135 An empty statement is allowed, and may include whitespace. It is ignored.
1137 @cindex instructions and directives
1138 @cindex directives and instructions
1139 @c "key symbol" is not used elsewhere in the document; seems pedantic to
1140 @c @defn{} it in that case, as was done previously... pesch@cygnus.com,
1142 A statement begins with zero or more labels, optionally followed by a
1143 key symbol which determines what kind of statement it is. The key
1144 symbol determines the syntax of the rest of the statement. If the
1145 symbol begins with a dot @samp{.} then the statement is an assembler
1146 directive: typically valid for any computer. If the symbol begins with
1147 a letter the statement is an assembly language @dfn{instruction}: it
1148 will assemble into a machine language instruction.
1150 Different versions of @code{@value{AS}} for different computers will
1151 recognize different instructions. In fact, the same symbol may
1152 represent a different instruction in a different computer's assembly
1156 @cindex @code{:} (label)
1157 @cindex label (@code{:})
1158 A label is a symbol immediately followed by a colon (@code{:}).
1159 Whitespace before a label or after a colon is permitted, but you may not
1160 have whitespace between a label's symbol and its colon. @xref{Labels}.
1163 label: .directive followed by something
1164 another_label: # This is an empty statement.
1165 instruction operand_1, operand_2, @dots{}
1172 A constant is a number, written so that its value is known by
1173 inspection, without knowing any context. Like this:
1176 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
1177 .ascii "Ring the bell\7" # A string constant.
1178 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
1179 .float 0f-314159265358979323846264338327\
1180 95028841971.693993751E-40 # - pi, a flonum.
1185 * Characters:: Character Constants
1186 * Numbers:: Number Constants
1190 @subsection Character Constants
1192 @cindex character constants
1193 @cindex constants, character
1194 There are two kinds of character constants. A @dfn{character} stands
1195 for one character in one byte and its value may be used in
1196 numeric expressions. String constants (properly called string
1197 @emph{literals}) are potentially many bytes and their values may not be
1198 used in arithmetic expressions.
1202 * Chars:: Characters
1206 @subsubsection Strings
1208 @cindex string constants
1209 @cindex constants, string
1210 A @dfn{string} is written between double-quotes. It may contain
1211 double-quotes or null characters. The way to get special characters
1212 into a string is to @dfn{escape} these characters: precede them with
1213 a backslash @samp{\} character. For example @samp{\\} represents
1214 one backslash: the first @code{\} is an escape which tells
1215 @code{@value{AS}} to interpret the second character literally as a backslash
1216 (which prevents @code{@value{AS}} from recognizing the second @code{\} as an
1217 escape character). The complete list of escapes follows.
1219 @cindex escape codes, character
1220 @cindex character escape codes
1223 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
1226 @cindex @code{\b} (backspace character)
1227 @cindex backspace (@code{\b})
1228 Mnemonic for backspace; for ASCII this is octal code 010.
1231 @c Mnemonic for EOText; for ASCII this is octal code 004.
1234 @cindex @code{\f} (formfeed character)
1235 @cindex formfeed (@code{\f})
1236 Mnemonic for FormFeed; for ASCII this is octal code 014.
1239 @cindex @code{\n} (newline character)
1240 @cindex newline (@code{\n})
1241 Mnemonic for newline; for ASCII this is octal code 012.
1244 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
1247 @cindex @code{\r} (carriage return character)
1248 @cindex carriage return (@code{\r})
1249 Mnemonic for carriage-Return; for ASCII this is octal code 015.
1252 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
1253 @c other assemblers.
1256 @cindex @code{\t} (tab)
1257 @cindex tab (@code{\t})
1258 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
1261 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
1262 @c @item \x @var{digit} @var{digit} @var{digit}
1263 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
1265 @item \ @var{digit} @var{digit} @var{digit}
1266 @cindex @code{\@var{ddd}} (octal character code)
1267 @cindex octal character code (@code{\@var{ddd}})
1268 An octal character code. The numeric code is 3 octal digits.
1269 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
1270 for example, @code{\008} has the value 010, and @code{\009} the value 011.
1273 @cindex @code{\\} (@samp{\} character)
1274 @cindex backslash (@code{\\})
1275 Represents one @samp{\} character.
1278 @c Represents one @samp{'} (accent acute) character.
1279 @c This is needed in single character literals
1280 @c (@xref{Characters,,Character Constants}.) to represent
1284 @cindex @code{\"} (doublequote character)
1285 @cindex doublequote (@code{\"})
1286 Represents one @samp{"} character. Needed in strings to represent
1287 this character, because an unescaped @samp{"} would end the string.
1289 @item \ @var{anything-else}
1290 Any other character when escaped by @kbd{\} will give a warning, but
1291 assemble as if the @samp{\} was not present. The idea is that if
1292 you used an escape sequence you clearly didn't want the literal
1293 interpretation of the following character. However @code{@value{AS}} has no
1294 other interpretation, so @code{@value{AS}} knows it is giving you the wrong
1295 code and warns you of the fact.
1298 Which characters are escapable, and what those escapes represent,
1299 varies widely among assemblers. The current set is what we think
1300 the BSD 4.2 assembler recognizes, and is a subset of what most C
1301 compilers recognize. If you are in doubt, don't use an escape
1305 @subsubsection Characters
1307 @cindex single character constant
1308 @cindex character, single
1309 @cindex constant, single character
1310 A single character may be written as a single quote immediately
1311 followed by that character. The same escapes apply to characters as
1312 to strings. So if you want to write the character backslash, you
1313 must write @kbd{'\\} where the first @code{\} escapes the second
1314 @code{\}. As you can see, the quote is an acute accent, not a
1315 grave accent. A newline
1317 @ifclear abnormal-separator
1318 (or semicolon @samp{;})
1320 @ifset abnormal-separator
1322 (or at sign @samp{@@})
1325 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
1331 immediately following an acute accent is taken as a literal character
1332 and does not count as the end of a statement. The value of a character
1333 constant in a numeric expression is the machine's byte-wide code for
1334 that character. @code{@value{AS}} assumes your character code is ASCII:
1335 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
1338 @subsection Number Constants
1340 @cindex constants, number
1341 @cindex number constants
1342 @code{@value{AS}} distinguishes three kinds of numbers according to how they
1343 are stored in the target machine. @emph{Integers} are numbers that
1344 would fit into an @code{int} in the C language. @emph{Bignums} are
1345 integers, but they are stored in more than 32 bits. @emph{Flonums}
1346 are floating point numbers, described below.
1349 * Integers:: Integers
1354 * Bit Fields:: Bit Fields
1360 @subsubsection Integers
1362 @cindex constants, integer
1364 @cindex binary integers
1365 @cindex integers, binary
1366 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
1367 the binary digits @samp{01}.
1369 @cindex octal integers
1370 @cindex integers, octal
1371 An octal integer is @samp{0} followed by zero or more of the octal
1372 digits (@samp{01234567}).
1374 @cindex decimal integers
1375 @cindex integers, decimal
1376 A decimal integer starts with a non-zero digit followed by zero or
1377 more digits (@samp{0123456789}).
1379 @cindex hexadecimal integers
1380 @cindex integers, hexadecimal
1381 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1382 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
1384 Integers have the usual values. To denote a negative integer, use
1385 the prefix operator @samp{-} discussed under expressions
1386 (@pxref{Prefix Ops,,Prefix Operators}).
1389 @subsubsection Bignums
1392 @cindex constants, bignum
1393 A @dfn{bignum} has the same syntax and semantics as an integer
1394 except that the number (or its negative) takes more than 32 bits to
1395 represent in binary. The distinction is made because in some places
1396 integers are permitted while bignums are not.
1399 @subsubsection Flonums
1401 @cindex floating point numbers
1402 @cindex constants, floating point
1404 @cindex precision, floating point
1405 A @dfn{flonum} represents a floating point number. The translation is
1406 indirect: a decimal floating point number from the text is converted by
1407 @code{@value{AS}} to a generic binary floating point number of more than
1408 sufficient precision. This generic floating point number is converted
1409 to a particular computer's floating point format (or formats) by a
1410 portion of @code{@value{AS}} specialized to that computer.
1412 A flonum is written by writing (in order)
1418 A letter, to tell @code{@value{AS}} the rest of the number is a flonum.
1420 @kbd{e} is recommended. Case is not important.
1422 @c FIXME: verify if flonum syntax really this vague for most cases
1423 (Any otherwise illegal letter
1424 will work here, but that might be changed. Vax BSD 4.2 assembler seems
1425 to allow any of @samp{defghDEFGH}.)
1428 On the H8/300, H8/500,
1430 and AMD 29K architectures, the letter must be
1431 one of the letters @samp{DFPRSX} (in upper or lower case).
1433 On the Intel 960 architecture, the letter must be
1434 one of the letters @samp{DFT} (in upper or lower case).
1438 One of the letters @samp{DFPRSX} (in upper or lower case).
1441 One of the letters @samp{DFPRSX} (in upper or lower case).
1444 One of the letters @samp{DFT} (in upper or lower case).
1449 An optional sign: either @samp{+} or @samp{-}.
1452 An optional @dfn{integer part}: zero or more decimal digits.
1455 An optional @dfn{fractional part}: @samp{.} followed by zero
1456 or more decimal digits.
1459 An optional exponent, consisting of:
1463 An @samp{E} or @samp{e}.
1464 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1465 @c principle this can perfectly well be different on different targets.
1467 Optional sign: either @samp{+} or @samp{-}.
1469 One or more decimal digits.
1474 At least one of the integer part or the fractional part must be
1475 present. The floating point number has the usual base-10 value.
1477 @code{@value{AS}} does all processing using integers. Flonums are computed
1478 independently of any floating point hardware in the computer running
1483 @c Bit fields are written as a general facility but are also controlled
1484 @c by a conditional-compilation flag---which is as of now (21mar91)
1485 @c turned on only by the i960 config of GAS.
1487 @subsubsection Bit Fields
1490 @cindex constants, bit field
1491 You can also define numeric constants as @dfn{bit fields}.
1492 specify two numbers separated by a colon---
1494 @var{mask}:@var{value}
1497 the first will act as a mask; @code{@value{AS}} will bitwise-and it with the
1500 The resulting number is then packed
1502 @c this conditional paren in case bit fields turned on elsewhere than 960
1503 (in host-dependent byte order)
1505 into a field whose width depends on which assembler directive has the
1506 bit-field as its argument. Overflow (a result from the bitwise and
1507 requiring more binary digits to represent) is not an error; instead,
1508 more constants are generated, of the specified width, beginning with the
1509 least significant digits.@refill
1511 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1512 @code{.short}, and @code{.word} accept bit-field arguments.
1517 @chapter Sections and Relocation
1522 * Secs Background:: Background
1523 * Ld Sections:: @value{LD} Sections
1524 * As Sections:: @value{AS} Internal Sections
1525 * Sub-Sections:: Sub-Sections
1529 @node Secs Background
1532 Roughly, a section is a range of addresses, with no gaps; all data
1533 ``in'' those addresses is treated the same for some particular purpose.
1534 For example there may be a ``read only'' section.
1536 @cindex linker, and assembler
1537 @cindex assembler, and linker
1538 The linker @code{@value{LD}} reads many object files (partial programs) and
1539 combines their contents to form a runnable program. When @code{@value{AS}}
1540 emits an object file, the partial program is assumed to start at address
1541 0. @code{@value{LD}} will assign the final addresses the partial program
1542 occupies, so that different partial programs don't overlap. This is
1543 actually an over-simplification, but it will suffice to explain how
1544 @code{@value{AS}} uses sections.
1546 @code{@value{LD}} moves blocks of bytes of your program to their run-time
1547 addresses. These blocks slide to their run-time addresses as rigid
1548 units; their length does not change and neither does the order of bytes
1549 within them. Such a rigid unit is called a @emph{section}. Assigning
1550 run-time addresses to sections is called @dfn{relocation}. It includes
1551 the task of adjusting mentions of object-file addresses so they refer to
1552 the proper run-time addresses.
1554 For the H8/300 and H8/500,
1555 and for the Hitachi SH,
1556 @code{@value{AS}} pads sections if needed to
1557 ensure they end on a word (sixteen bit) boundary.
1560 @cindex standard @code{@value{AS}} sections
1561 An object file written by @code{@value{AS}} has at least three sections, any
1562 of which may be empty. These are named @dfn{text}, @dfn{data} and
1567 When it generates COFF output,
1569 @code{@value{AS}} can also generate whatever other named sections you specify
1570 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1571 If you don't use any directives that place output in the @samp{.text}
1572 or @samp{.data} sections, these sections will still exist, but will be empty.
1575 Within the object file, the text section starts at address @code{0}, the
1576 data section follows, and the bss section follows the data section.
1578 To let @code{@value{LD}} know which data will change when the sections are
1579 relocated, and how to change that data, @code{@value{AS}} also writes to the
1580 object file details of the relocation needed. To perform relocation
1581 @code{@value{LD}} must know, each time an address in the object
1585 Where in the object file is the beginning of this reference to
1588 How long (in bytes) is this reference?
1590 Which section does the address refer to? What is the numeric value of
1592 (@var{address}) @minus{} (@var{start-address of section})?
1595 Is the reference to an address ``Program-Counter relative''?
1598 @cindex addresses, format of
1599 @cindex section-relative addressing
1600 In fact, every address @code{@value{AS}} ever uses is expressed as
1602 (@var{section}) + (@var{offset into section})
1605 Further, every expression @code{@value{AS}} computes is of this section-relative
1606 nature. @dfn{Absolute expression} means an expression with section
1607 ``absolute'' (@pxref{Ld Sections}). A @dfn{pass1 expression} means
1608 an expression with section ``pass1'' (@pxref{As Sections,,@value{AS}
1609 Internal Sections}). In this manual we use the notation @{@var{secname}
1610 @var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1612 Apart from text, data and bss sections you need to know about the
1613 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
1614 addresses in the absolute section remain unchanged. For example, address
1615 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{@value{LD}}.
1616 Although two partial programs' data sections will not overlap addresses
1617 after linking, @emph{by definition} their absolute sections will overlap.
1618 Address @code{@{absolute@ 239@}} in one partial program will always be the same
1619 address when the program is running as address @code{@{absolute@ 239@}} in any
1620 other partial program.
1622 The idea of sections is extended to the @dfn{undefined} section. Any
1623 address whose section is unknown at assembly time is by definition
1624 rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
1625 Since numbers are always defined, the only way to generate an undefined
1626 address is to mention an undefined symbol. A reference to a named
1627 common block would be such a symbol: its value is unknown at assembly
1628 time so it has section @emph{undefined}.
1630 By analogy the word @emph{section} is used to describe groups of sections in
1631 the linked program. @code{@value{LD}} puts all partial programs' text
1632 sections in contiguous addresses in the linked program. It is
1633 customary to refer to the @emph{text section} of a program, meaning all
1634 the addresses of all partial program's text sections. Likewise for
1635 data and bss sections.
1637 Some sections are manipulated by @code{@value{LD}}; others are invented for
1638 use of @code{@value{AS}} and have no meaning except during assembly.
1641 @section @value{LD} Sections
1642 @code{@value{LD}} deals with just four kinds of sections, summarized below.
1647 @cindex named sections
1648 @cindex sections, named
1649 @item named sections
1652 @cindex text section
1653 @cindex data section
1657 These sections hold your program. @code{@value{AS}} and @code{@value{LD}} treat them as
1658 separate but equal sections. Anything you can say of one section is
1661 When the program is running, however, it is
1662 customary for the text section to be unalterable. The
1663 text section is often shared among processes: it will contain
1664 instructions, constants and the like. The data section of a running
1665 program is usually alterable: for example, C variables would be stored
1666 in the data section.
1671 This section contains zeroed bytes when your program begins running. It
1672 is used to hold unitialized variables or common storage. The length of
1673 each partial program's bss section is important, but because it starts
1674 out containing zeroed bytes there is no need to store explicit zero
1675 bytes in the object file. The bss section was invented to eliminate
1676 those explicit zeros from object files.
1678 @cindex absolute section
1679 @item absolute section
1680 Address 0 of this section is always ``relocated'' to runtime address 0.
1681 This is useful if you want to refer to an address that @code{@value{LD}} must
1682 not change when relocating. In this sense we speak of absolute
1683 addresses being ``unrelocatable'': they don't change during relocation.
1685 @cindex undefined section
1686 @item undefined section
1687 This ``section'' is a catch-all for address references to objects not in
1688 the preceding sections.
1689 @c FIXME: ref to some other doc on obj-file formats could go here.
1692 @cindex relocation example
1693 An idealized example of three relocatable sections follows.
1695 The example uses the traditional section names @samp{.text} and @samp{.data}.
1697 Memory addresses are on the horizontal axis.
1701 @c END TEXI2ROFF-KILL
1704 partial program # 1: |ttttt|dddd|00|
1711 partial program # 2: |TTT|DDD|000|
1714 +--+---+-----+--+----+---+-----+~~
1715 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1716 +--+---+-----+--+----+---+-----+~~
1718 addresses: 0 @dots{}
1722 @c FIXME make sure no page breaks inside figure!!
1725 \line{\it Partial program \#1: \hfil}
1726 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1727 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1729 \line{\it Partial program \#2: \hfil}
1730 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1731 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
1733 \line{\it linked program: \hfil}
1734 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
1735 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
1736 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1737 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1739 \line{\it addresses: \hfil}
1743 @c END TEXI2ROFF-KILL
1746 @section @value{AS} Internal Sections
1748 @cindex internal @code{@value{AS}} sections
1749 @cindex sections in messages, internal
1750 These sections are meant only for the internal use of @code{@value{AS}}. They
1751 have no meaning at run-time. You don't really need to know about these
1752 sections for most purposes; but they can be mentioned in @code{@value{AS}}
1753 warning messages, so it might be helpful to have an idea of their
1754 meanings to @code{@value{AS}}. These sections are used to permit the
1755 value of every expression in your assembly language program to be a
1756 section-relative address.
1760 @cindex absent (internal section)
1761 An expression was expected and none was found.
1763 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1764 @cindex assembler internal logic error
1765 An internal assembler logic error has been found. This means there is a
1766 bug in the assembler.
1769 @cindex bignum/flonum (internal section)
1770 If a number can't be written as a C @code{int} constant (a bignum or a
1771 flonum, but not an integer), it is recorded as belonging to this
1772 ``section''. @code{@value{AS}} has to remember that a flonum or a bignum
1773 does not fit into 32 bits, and cannot be an argument (@pxref{Arguments})
1774 in an expression: this is done by making a flonum or bignum be in a
1775 separate internal section. This is purely for internal @code{@value{AS}}
1776 convenience; bignum/flonum section behaves similarly to absolute
1780 @cindex pass1 (internal section)
1781 The expression was impossible to evaluate in the first pass. The
1782 assembler will attempt a second pass (second reading of the source) to
1783 evaluate the expression. Your expression mentioned an undefined symbol
1784 in a way that defies the one-pass (section + offset in section) assembly
1785 process. No compiler need emit such an expression.
1788 @emph{Warning:} the second pass is currently not implemented. @code{@value{AS}}
1789 will abort with an error message if one is required.
1792 @item difference section
1793 @cindex difference (internal section)
1794 As an assist to the C compiler, expressions of the forms
1796 (@var{undefined symbol}) @minus{} (@var{expression})
1797 @var{something} @minus{} (@var{undefined symbol})
1798 (@var{undefined symbol}) @minus{} (@var{undefined symbol})
1801 are permitted, and belong to the difference section. @code{@value{AS}}
1802 re-evaluates such expressions after the source file has been read and
1803 the symbol table built. If by that time there are no undefined symbols
1804 in the expression then the expression assumes a new section. The
1805 intention is to permit statements like
1806 @samp{.word label - base_of_table}
1807 to be assembled in one pass where both @code{label} and
1808 @code{base_of_table} are undefined. This is useful for compiling C and
1809 Algol switch statements, Pascal case statements, FORTRAN computed goto
1810 statements and the like.
1812 @c FIXME item transfer[t] vector preload
1813 @c FIXME item transfer[t] vector postload
1814 @c FIXME item register
1818 @section Sub-Sections
1820 @cindex numbered subsections
1821 @cindex grouping data
1827 fall into two sections: text and data.
1829 You may have separate groups of
1831 data in named sections
1835 data in named sections
1841 that you want to end up near to each other in the object file, even
1842 though they are not contiguous in the assembler source.
1843 @code{@value{AS}} allows you to use @dfn{subsections} for this purpose.
1844 Within each section, there can be numbered subsections with values from
1845 0 to 8192. Objects assembled into the same subsection will be grouped
1846 with other objects in the same subsection when they are all put into the
1847 object file. For example, a compiler might want to store constants in
1848 the text section, but might not want to have them interspersed with the
1849 program being assembled. In this case, the compiler could issue a
1850 @samp{.text 0} before each section of code being output, and a
1851 @samp{.text 1} before each group of constants being output.
1853 Subsections are optional. If you don't use subsections, everything
1854 will be stored in subsection number zero.
1857 Each subsection is zero-padded up to a multiple of four bytes.
1858 (Subsections may be padded a different amount on different flavors
1859 of @code{@value{AS}}.)
1863 On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
1864 boundary (two bytes).
1865 The same is true on the Hitachi SH.
1868 @c FIXME section padding (alignment)?
1869 @c Rich Pixley says padding here depends on target obj code format; that
1870 @c doesn't seem particularly useful to say without further elaboration,
1871 @c so for now I say nothing about it. If this is a generic BFD issue,
1872 @c these paragraphs might need to vanish from this manual, and be
1873 @c discussed in BFD chapter of binutils (or some such).
1876 On the AMD 29K family, no particular padding is added to section or
1877 subsection sizes; @value{AS} forces no alignment on this platform.
1881 Subsections appear in your object file in numeric order, lowest numbered
1882 to highest. (All this to be compatible with other people's assemblers.)
1883 The object file contains no representation of subsections; @code{@value{LD}} and
1884 other programs that manipulate object files will see no trace of them.
1885 They just see all your text subsections as a text section, and all your
1886 data subsections as a data section.
1888 To specify which subsection you want subsequent statements assembled
1889 into, use a numeric argument to specify it, in a @samp{.text
1890 @var{expression}} or a @samp{.data @var{expression}} statement.
1893 When generating COFF output, you
1898 can also use an extra subsection
1899 argument with arbitrary named sections: @samp{.section @var{name},
1902 @var{Expression} should be an absolute expression.
1903 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
1904 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
1905 begins in @code{text 0}. For instance:
1907 .text 0 # The default subsection is text 0 anyway.
1908 .ascii "This lives in the first text subsection. *"
1910 .ascii "But this lives in the second text subsection."
1912 .ascii "This lives in the data section,"
1913 .ascii "in the first data subsection."
1915 .ascii "This lives in the first text section,"
1916 .ascii "immediately following the asterisk (*)."
1919 Each section has a @dfn{location counter} incremented by one for every
1920 byte assembled into that section. Because subsections are merely a
1921 convenience restricted to @code{@value{AS}} there is no concept of a subsection
1922 location counter. There is no way to directly manipulate a location
1923 counter---but the @code{.align} directive will change it, and any label
1924 definition will capture its current value. The location counter of the
1925 section that statements are being assembled into is said to be the
1926 @dfn{active} location counter.
1929 @section bss Section
1932 @cindex common variable storage
1933 The bss section is used for local common variable storage.
1934 You may allocate address space in the bss section, but you may
1935 not dictate data to load into it before your program executes. When
1936 your program starts running, all the contents of the bss
1937 section are zeroed bytes.
1939 Addresses in the bss section are allocated with special directives; you
1940 may not assemble anything directly into the bss section. Hence there
1941 are no bss subsections. @xref{Comm,,@code{.comm}},
1942 @pxref{Lcomm,,@code{.lcomm}}.
1948 Symbols are a central concept: the programmer uses symbols to name
1949 things, the linker uses symbols to link, and the debugger uses symbols
1953 @cindex debuggers, and symbol order
1954 @emph{Warning:} @code{@value{AS}} does not place symbols in the object file in
1955 the same order they were declared. This may break some debuggers.
1960 * Setting Symbols:: Giving Symbols Other Values
1961 * Symbol Names:: Symbol Names
1962 * Dot:: The Special Dot Symbol
1963 * Symbol Attributes:: Symbol Attributes
1970 A @dfn{label} is written as a symbol immediately followed by a colon
1971 @samp{:}. The symbol then represents the current value of the
1972 active location counter, and is, for example, a suitable instruction
1973 operand. You are warned if you use the same symbol to represent two
1974 different locations: the first definition overrides any other
1977 @node Setting Symbols
1978 @section Giving Symbols Other Values
1980 @cindex assigning values to symbols
1981 @cindex symbol values, assigning
1982 A symbol can be given an arbitrary value by writing a symbol, followed
1983 by an equals sign @samp{=}, followed by an expression
1984 (@pxref{Expressions}). This is equivalent to using the @code{.set}
1985 directive. @xref{Set,,@code{.set}}.
1988 @section Symbol Names
1990 @cindex symbol names
1991 @cindex names, symbol
1992 @ifclear SPECIAL-SYMS
1993 Symbol names begin with a letter or with one of @samp{._}. On most
1994 machines, you can also use @code{$} in symbol names; exceptions are
1995 noted in @ref{Machine Dependencies}. That character may be followed by any
1996 string of digits, letters, dollar signs (unless otherwise noted in
1997 @ref{Machine Dependencies}), and underscores.
2000 For the AMD 29K family, @samp{?} is also allowed in the
2001 body of a symbol name, though not at its beginning.
2006 Symbol names begin with a letter or with one of @samp{._}. On the
2008 H8/500, you can also use @code{$} in symbol names. That character may
2009 be followed by any string of digits, letters, dollar signs (save on the
2010 H8/300), and underscores.
2014 Case of letters is significant: @code{foo} is a different symbol name
2017 Each symbol has exactly one name. Each name in an assembly language
2018 program refers to exactly one symbol. You may use that symbol name any
2019 number of times in a program.
2021 @subheading Local Symbol Names
2023 @cindex local symbol names
2024 @cindex symbol names, local
2025 @cindex temporary symbol names
2026 @cindex symbol names, temporary
2027 Local symbols help compilers and programmers use names temporarily.
2028 There are ten local symbol names, which are re-used throughout the
2029 program. You may refer to them using the names @samp{0} @samp{1}
2030 @dots{} @samp{9}. To define a local symbol, write a label of the form
2031 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
2032 recent previous definition of that symbol write @samp{@b{N}b}, using the
2033 same digit as when you defined the label. To refer to the next
2034 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
2035 a choice of 10 forward references. The @samp{b} stands for
2036 ``backwards'' and the @samp{f} stands for ``forwards''.
2038 Local symbols are not emitted by the current GNU C compiler.
2040 There is no restriction on how you can use these labels, but
2041 remember that at any point in the assembly you can refer to at most
2042 10 prior local labels and to at most 10 forward local labels.
2044 Local symbol names are only a notation device. They are immediately
2045 transformed into more conventional symbol names before the assembler
2046 uses them. The symbol names stored in the symbol table, appearing in
2047 error messages and optionally emitted to the object file have these
2052 All local labels begin with @samp{L}. Normally both @code{@value{AS}} and
2053 @code{@value{LD}} forget symbols that start with @samp{L}. These labels are
2054 used for symbols you are never intended to see. If you give the
2055 @samp{-L} option then @code{@value{AS}} will retain these symbols in the
2056 object file. If you also instruct @code{@value{LD}} to retain these symbols,
2057 you may use them in debugging.
2060 If the label is written @samp{0:} then the digit is @samp{0}.
2061 If the label is written @samp{1:} then the digit is @samp{1}.
2062 And so on up through @samp{9:}.
2065 This unusual character is included so you don't accidentally invent
2066 a symbol of the same name. The character has ASCII value
2069 @item @emph{ordinal number}
2070 This is a serial number to keep the labels distinct. The first
2071 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
2072 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
2076 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
2077 @code{3:} is named @code{L3@ctrl{A}44}.
2080 @section The Special Dot Symbol
2082 @cindex dot (symbol)
2083 @cindex @code{.} (symbol)
2084 @cindex current address
2085 @cindex location counter
2086 The special symbol @samp{.} refers to the current address that
2087 @code{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
2088 .long .} will cause @code{melvin} to contain its own address.
2089 Assigning a value to @code{.} is treated the same as a @code{.org}
2090 directive. Thus, the expression @samp{.=.+4} is the same as saying
2091 @ifclear no-space-dir
2100 @node Symbol Attributes
2101 @section Symbol Attributes
2103 @cindex symbol attributes
2104 @cindex attributes, symbol
2105 Every symbol has, as well as its name, the attributes ``Value'' and
2106 ``Type''. Depending on output format, symbols can also have auxiliary
2109 The detailed definitions are in @file{a.out.h}.
2112 If you use a symbol without defining it, @code{@value{AS}} assumes zero for
2113 all these attributes, and probably won't warn you. This makes the
2114 symbol an externally defined symbol, which is generally what you
2118 * Symbol Value:: Value
2119 * Symbol Type:: Type
2122 * a.out Symbols:: Symbol Attributes: @code{a.out}
2126 * a.out Symbols:: Symbol Attributes: @code{a.out}
2129 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
2134 * COFF Symbols:: Symbol Attributes for COFF
2141 @cindex value of a symbol
2142 @cindex symbol value
2143 The value of a symbol is (usually) 32 bits. For a symbol which labels a
2144 location in the text, data, bss or absolute sections the value is the
2145 number of addresses from the start of that section to the label.
2146 Naturally for text, data and bss sections the value of a symbol changes
2147 as @code{@value{LD}} changes section base addresses during linking. Absolute
2148 symbols' values do not change during linking: that is why they are
2151 The value of an undefined symbol is treated in a special way. If it is
2152 0 then the symbol is not defined in this assembler source program, and
2153 @code{@value{LD}} will try to determine its value from other programs it is
2154 linked with. You make this kind of symbol simply by mentioning a symbol
2155 name without defining it. A non-zero value represents a @code{.comm}
2156 common declaration. The value is how much common storage to reserve, in
2157 bytes (addresses). The symbol refers to the first address of the
2163 @cindex type of a symbol
2165 The type attribute of a symbol contains relocation (section)
2166 information, any flag settings indicating that a symbol is external, and
2167 (optionally), other information for linkers and debuggers. The exact
2168 format depends on the object-code output format in use.
2173 @c The following avoids a "widow" subsection title. @group would be
2174 @c better if it were available outside examples.
2177 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
2179 @cindex @code{b.out} symbol attributes
2180 @cindex symbol attributes, @code{b.out}
2181 These symbol attributes appear only when @code{@value{AS}} is configured for
2182 one of the Berkeley-descended object output formats---@code{a.out} or
2188 @subsection Symbol Attributes: @code{a.out}
2190 @cindex @code{a.out} symbol attributes
2191 @cindex symbol attributes, @code{a.out}
2197 @subsection Symbol Attributes: @code{a.out}
2199 @cindex @code{a.out} symbol attributes
2200 @cindex symbol attributes, @code{a.out}
2204 * Symbol Desc:: Descriptor
2205 * Symbol Other:: Other
2209 @subsubsection Descriptor
2211 @cindex descriptor, of @code{a.out} symbol
2212 This is an arbitrary 16-bit value. You may establish a symbol's
2213 descriptor value by using a @code{.desc} statement
2214 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
2218 @subsubsection Other
2220 @cindex other attribute, of @code{a.out} symbol
2221 This is an arbitrary 8-bit value. It means nothing to @code{@value{AS}}.
2226 @subsection Symbol Attributes for COFF
2228 @cindex COFF symbol attributes
2229 @cindex symbol attributes, COFF
2231 The COFF format supports a multitude of auxiliary symbol attributes;
2232 like the primary symbol attributes, they are set between @code{.def} and
2233 @code{.endef} directives.
2235 @subsubsection Primary Attributes
2237 @cindex primary attributes, COFF symbols
2238 The symbol name is set with @code{.def}; the value and type,
2239 respectively, with @code{.val} and @code{.type}.
2241 @subsubsection Auxiliary Attributes
2243 @cindex auxiliary attributes, COFF symbols
2244 The @code{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
2245 @code{.size}, and @code{.tag} can generate auxiliary symbol table
2246 information for COFF.
2250 @chapter Expressions
2254 @cindex numeric values
2255 An @dfn{expression} specifies an address or numeric value.
2256 Whitespace may precede and/or follow an expression.
2259 * Empty Exprs:: Empty Expressions
2260 * Integer Exprs:: Integer Expressions
2264 @section Empty Expressions
2266 @cindex empty expressions
2267 @cindex expressions, empty
2268 An empty expression has no value: it is just whitespace or null.
2269 Wherever an absolute expression is required, you may omit the
2270 expression and @code{@value{AS}} will assume a value of (absolute) 0. This
2271 is compatible with other assemblers.
2274 @section Integer Expressions
2276 @cindex integer expressions
2277 @cindex expressions, integer
2278 An @dfn{integer expression} is one or more @emph{arguments} delimited
2279 by @emph{operators}.
2282 * Arguments:: Arguments
2283 * Operators:: Operators
2284 * Prefix Ops:: Prefix Operators
2285 * Infix Ops:: Infix Operators
2289 @subsection Arguments
2291 @cindex expression arguments
2292 @cindex arguments in expressions
2293 @cindex operands in expressions
2294 @cindex arithmetic operands
2295 @dfn{Arguments} are symbols, numbers or subexpressions. In other
2296 contexts arguments are sometimes called ``arithmetic operands''. In
2297 this manual, to avoid confusing them with the ``instruction operands'' of
2298 the machine language, we use the term ``argument'' to refer to parts of
2299 expressions only, reserving the word ``operand'' to refer only to machine
2300 instruction operands.
2302 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
2303 @var{section} is one of text, data, bss, absolute,
2304 or undefined. @var{NNN} is a signed, 2's complement 32 bit
2307 Numbers are usually integers.
2309 A number can be a flonum or bignum. In this case, you are warned
2310 that only the low order 32 bits are used, and @code{@value{AS}} pretends
2311 these 32 bits are an integer. You may write integer-manipulating
2312 instructions that act on exotic constants, compatible with other
2315 @cindex subexpressions
2316 Subexpressions are a left parenthesis @samp{(} followed by an integer
2317 expression, followed by a right parenthesis @samp{)}; or a prefix
2318 operator followed by an argument.
2321 @subsection Operators
2323 @cindex operators, in expressions
2324 @cindex arithmetic functions
2325 @cindex functions, in expressions
2326 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
2327 operators are followed by an argument. Infix operators appear
2328 between their arguments. Operators may be preceded and/or followed by
2332 @subsection Prefix Operator
2334 @cindex prefix operators
2335 @code{@value{AS}} has the following @dfn{prefix operators}. They each take
2336 one argument, which must be absolute.
2338 @c the tex/end tex stuff surrounding this small table is meant to make
2339 @c it align, on the printed page, with the similar table in the next
2340 @c section (which is inside an enumerate).
2342 \global\advance\leftskip by \itemindent
2347 @dfn{Negation}. Two's complement negation.
2349 @dfn{Complementation}. Bitwise not.
2353 \global\advance\leftskip by -\itemindent
2357 @subsection Infix Operators
2359 @cindex infix operators
2360 @cindex operators, permitted arguments
2361 @dfn{Infix operators} take two arguments, one on either side. Operators
2362 have precedence, but operations with equal precedence are performed left
2363 to right. Apart from @code{+} or @code{-}, both arguments must be
2364 absolute, and the result is absolute.
2367 @cindex operator precedence
2368 @cindex precedence of operators
2375 @dfn{Multiplication}.
2378 @dfn{Division}. Truncation is the same as the C operator @samp{/}
2385 @dfn{Shift Left}. Same as the C operator @samp{<<}.
2389 @dfn{Shift Right}. Same as the C operator @samp{>>}.
2393 Intermediate precedence
2398 @dfn{Bitwise Inclusive Or}.
2404 @dfn{Bitwise Exclusive Or}.
2407 @dfn{Bitwise Or Not}.
2415 @cindex addition, permitted arguments
2416 @cindex plus, permitted arguments
2417 @cindex arguments for addition
2418 @dfn{Addition}. If either argument is absolute, the result
2419 has the section of the other argument.
2420 If either argument is pass1 or undefined, the result is pass1.
2421 Otherwise @code{+} is illegal.
2424 @cindex subtraction, permitted arguments
2425 @cindex minus, permitted arguments
2426 @cindex arguments for subtraction
2427 @dfn{Subtraction}. If the right argument is absolute, the
2428 result has the section of the left argument.
2429 If either argument is pass1 the result is pass1.
2430 If either argument is undefined the result is difference section.
2431 If both arguments are in the same section, the result is absolute---provided
2432 that section is one of text, data or bss.
2433 Otherwise subtraction is illegal.
2437 The sense of the rule for addition is that it's only meaningful to add
2438 the @emph{offsets} in an address; you can only have a defined section in
2439 one of the two arguments.
2441 Similarly, you can't subtract quantities from two different sections.
2444 @chapter Assembler Directives
2446 @cindex directives, machine independent
2447 @cindex pseudo-ops, machine independent
2448 @cindex machine independent directives
2449 All assembler directives have names that begin with a period (@samp{.}).
2450 The rest of the name is letters, usually in lower case.
2452 This chapter discusses directives that are available regardless of the
2453 target machine configuration for the GNU assembler.
2455 Some machine configurations provide additional directives.
2456 @xref{Machine Dependencies}.
2459 @ifset machine-directives
2460 @xref{Machine Dependencies} for additional directives.
2465 * Abort:: @code{.abort}
2467 * ABORT:: @code{.ABORT}
2470 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
2471 * App-File:: @code{.app-file @var{string}}
2472 * Ascii:: @code{.ascii "@var{string}"}@dots{}
2473 * Asciz:: @code{.asciz "@var{string}"}@dots{}
2474 * Byte:: @code{.byte @var{expressions}}
2475 * Comm:: @code{.comm @var{symbol} , @var{length} }
2476 * Data:: @code{.data @var{subsection}}
2478 * Def:: @code{.def @var{name}}
2481 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
2487 * Double:: @code{.double @var{flonums}}
2488 * Eject:: @code{.eject}
2489 * Else:: @code{.else}
2491 * Endef:: @code{.endef}
2494 * Endif:: @code{.endif}
2495 * Equ:: @code{.equ @var{symbol}, @var{expression}}
2496 * Extern:: @code{.extern}
2497 @ifclear no-file-dir
2498 * File:: @code{.file @var{string}}
2501 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
2502 * Float:: @code{.float @var{flonums}}
2503 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2504 * hword:: @code{.hword @var{expressions}}
2505 * Ident:: @code{.ident}
2506 * If:: @code{.if @var{absolute expression}}
2507 * Include:: @code{.include "@var{file}"}
2508 * Int:: @code{.int @var{expressions}}
2509 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
2510 * Lflags:: @code{.lflags}
2511 @ifclear no-line-dir
2512 * Line:: @code{.line @var{line-number}}
2515 * Ln:: @code{.ln @var{line-number}}
2516 * List:: @code{.list}
2517 * Long:: @code{.long @var{expressions}}
2519 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
2522 * Nolist:: @code{.nolist}
2523 * Octa:: @code{.octa @var{bignums}}
2524 * Org:: @code{.org @var{new-lc} , @var{fill}}
2525 * Psize:: @code{.psize @var{lines}, @var{columns}}
2526 * Quad:: @code{.quad @var{bignums}}
2527 * Sbttl:: @code{.sbttl "@var{subheading}"}
2529 * Scl:: @code{.scl @var{class}}
2532 * Section:: @code{.section @var{name}, @var{subsection}}
2535 * Set:: @code{.set @var{symbol}, @var{expression}}
2536 * Short:: @code{.short @var{expressions}}
2537 * Single:: @code{.single @var{flonums}}
2539 * Size:: @code{.size}
2542 * Space:: @code{.space @var{size} , @var{fill}}
2544 * Stab:: @code{.stabd, .stabn, .stabs}
2547 * Tag:: @code{.tag @var{structname}}
2550 * Text:: @code{.text @var{subsection}}
2551 * Title:: @code{.title "@var{heading}"}
2553 * Type:: @code{.type @var{int}}
2554 * Val:: @code{.val @var{addr}}
2557 * Word:: @code{.word @var{expressions}}
2558 * Deprecated:: Deprecated Directives
2562 @section @code{.abort}
2564 @cindex @code{abort} directive
2565 @cindex stopping the assembly
2566 This directive stops the assembly immediately. It is for
2567 compatibility with other assemblers. The original idea was that the
2568 assembly language source would be piped into the assembler. If the sender
2569 of the source quit, it could use this directive tells @code{@value{AS}} to
2570 quit also. One day @code{.abort} will not be supported.
2574 @section @code{.ABORT}
2576 @cindex @code{ABORT} directive
2577 When producing COFF output, @code{@value{AS}} accepts this directive as a
2578 synonym for @samp{.abort}.
2581 When producing @code{b.out} output, @code{@value{AS}} accepts this directive,
2587 @section @code{.align @var{abs-expr} , @var{abs-expr}}
2589 @cindex padding the location counter
2590 @cindex @code{align} directive
2591 Pad the location counter (in the current subsection) to a particular
2592 storage boundary. The first expression (which must be absolute) is the
2593 number of low-order zero bits the location counter will have after
2594 advancement. For example @samp{.align 3} will advance the location
2595 counter until it a multiple of 8. If the location counter is already a
2596 multiple of 8, no change is needed.
2598 The second expression (also absolute) gives the value to be stored in
2599 the padding bytes. It (and the comma) may be omitted. If it is
2600 omitted, the padding bytes are zero.
2603 @section @code{.app-file @var{string}}
2605 @cindex logical file name
2606 @cindex file name, logical
2607 @cindex @code{app-file} directive
2609 @ifclear no-file-dir
2610 (which may also be spelled @samp{.file})
2612 tells @code{@value{AS}} that we are about to start a new
2613 logical file. @var{string} is the new file name. In general, the
2614 filename is recognized whether or not it is surrounded by quotes @samp{"};
2615 but if you wish to specify an empty file name is permitted,
2616 you must give the quotes--@code{""}. This statement may go away in
2617 future: it is only recognized to be compatible with old @code{@value{AS}}
2621 @section @code{.ascii "@var{string}"}@dots{}
2623 @cindex @code{ascii} directive
2624 @cindex string literals
2625 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2626 separated by commas. It assembles each string (with no automatic
2627 trailing zero byte) into consecutive addresses.
2630 @section @code{.asciz "@var{string}"}@dots{}
2632 @cindex @code{asciz} directive
2633 @cindex zero-terminated strings
2634 @cindex null-terminated strings
2635 @code{.asciz} is just like @code{.ascii}, but each string is followed by
2636 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2639 @section @code{.byte @var{expressions}}
2641 @cindex @code{byte} directive
2642 @cindex integers, one byte
2643 @code{.byte} expects zero or more expressions, separated by commas.
2644 Each expression is assembled into the next byte.
2647 @section @code{.comm @var{symbol} , @var{length} }
2649 @cindex @code{comm} directive
2650 @cindex symbol, common
2651 @code{.comm} declares a named common area in the bss section. Normally
2652 @code{@value{LD}} reserves memory addresses for it during linking, so no partial
2653 program defines the location of the symbol. Use @code{.comm} to tell
2654 @code{@value{LD}} that it must be at least @var{length} bytes long. @code{@value{LD}}
2655 will allocate space for each @code{.comm} symbol that is at least as
2656 long as the longest @code{.comm} request in any of the partial programs
2657 linked. @var{length} is an absolute expression.
2660 @section @code{.data @var{subsection}}
2662 @cindex @code{data} directive
2663 @code{.data} tells @code{@value{AS}} to assemble the following statements onto the
2664 end of the data subsection numbered @var{subsection} (which is an
2665 absolute expression). If @var{subsection} is omitted, it defaults
2670 @section @code{.def @var{name}}
2672 @cindex @code{def} directive
2673 @cindex COFF symbols, debugging
2674 @cindex debugging COFF symbols
2675 Begin defining debugging information for a symbol @var{name}; the
2676 definition extends until the @code{.endef} directive is encountered.
2679 This directive is only observed when @code{@value{AS}} is configured for COFF
2680 format output; when producing @code{b.out}, @samp{.def} is recognized,
2687 @section @code{.desc @var{symbol}, @var{abs-expression}}
2689 @cindex @code{desc} directive
2690 @cindex COFF symbol descriptor
2691 @cindex symbol descriptor, COFF
2692 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2693 to the low 16 bits of an absolute expression.
2696 The @samp{.desc} directive is not available when @code{@value{AS}} is
2697 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2698 object format. For the sake of compatibility, @code{@value{AS}} will accept
2699 it, but produce no output, when configured for COFF.
2705 @section @code{.dim}
2707 @cindex @code{dim} directive
2708 @cindex COFF auxiliary symbol information
2709 @cindex auxiliary symbol information, COFF
2710 This directive is generated by compilers to include auxiliary debugging
2711 information in the symbol table. It is only permitted inside
2712 @code{.def}/@code{.endef} pairs.
2715 @samp{.dim} is only meaningful when generating COFF format output; when
2716 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
2722 @section @code{.double @var{flonums}}
2724 @cindex @code{double} directive
2725 @cindex floating point numbers (double)
2726 @code{.double} expects zero or more flonums, separated by commas. It
2727 assembles floating point numbers.
2729 The exact kind of floating point numbers emitted depends on how
2730 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
2734 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
2735 in @sc{ieee} format.
2740 @section @code{.eject}
2742 @cindex @code{eject} directive
2743 @cindex new page, in listings
2744 @cindex page, in listings
2745 @cindex listing control: new page
2746 Force a page break at this point, when generating assembly listings.
2749 @section @code{.else}
2751 @cindex @code{else} directive
2752 @code{.else} is part of the @code{@value{AS}} support for conditional
2753 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2754 of code to be assembled if the condition for the preceding @code{.if}
2758 @node End, Endef, Else, Pseudo Ops
2759 @section @code{.end}
2761 @cindex @code{end} directive
2762 This doesn't do anything---but isn't an s_ignore, so I suspect it's
2763 meant to do something eventually (which is why it isn't documented here
2764 as "for compatibility with blah").
2769 @section @code{.endef}
2771 @cindex @code{endef} directive
2772 This directive flags the end of a symbol definition begun with
2776 @samp{.endef} is only meaningful when generating COFF format output; if
2777 @code{@value{AS}} is configured to generate @code{b.out}, it accepts this
2778 directive but ignores it.
2783 @section @code{.endif}
2785 @cindex @code{endif} directive
2786 @code{.endif} is part of the @code{@value{AS}} support for conditional assembly;
2787 it marks the end of a block of code that is only assembled
2788 conditionally. @xref{If,,@code{.if}}.
2791 @section @code{.equ @var{symbol}, @var{expression}}
2793 @cindex @code{equ} directive
2794 @cindex assigning values to symbols
2795 @cindex symbols, assigning values to
2796 This directive sets the value of @var{symbol} to @var{expression}.
2797 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2800 @section @code{.extern}
2802 @cindex @code{extern} directive
2803 @code{.extern} is accepted in the source program---for compatibility
2804 with other assemblers---but it is ignored. @code{@value{AS}} treats
2805 all undefined symbols as external.
2807 @ifclear no-file-dir
2809 @section @code{.file @var{string}}
2811 @cindex @code{file} directive
2812 @cindex logical file name
2813 @cindex file name, logical
2814 @code{.file} (which may also be spelled @samp{.app-file}) tells
2815 @code{@value{AS}} that we are about to start a new logical file.
2816 @var{string} is the new file name. In general, the filename is
2817 recognized whether or not it is surrounded by quotes @samp{"}; but if
2818 you wish to specify an empty file name, you must give the
2819 quotes--@code{""}. This statement may go away in future: it is only
2820 recognized to be compatible with old @code{@value{AS}} programs.
2822 In some configurations of @code{@value{AS}}, @code{.file} has already been
2823 removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
2828 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
2830 @cindex @code{fill} directive
2831 @cindex writing patterns in memory
2832 @cindex patterns, writing in memory
2833 @var{result}, @var{size} and @var{value} are absolute expressions.
2834 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2835 may be zero or more. @var{Size} may be zero or more, but if it is
2836 more than 8, then it is deemed to have the value 8, compatible with
2837 other people's assemblers. The contents of each @var{repeat} bytes
2838 is taken from an 8-byte number. The highest order 4 bytes are
2839 zero. The lowest order 4 bytes are @var{value} rendered in the
2840 byte-order of an integer on the computer @code{@value{AS}} is assembling for.
2841 Each @var{size} bytes in a repetition is taken from the lowest order
2842 @var{size} bytes of this number. Again, this bizarre behavior is
2843 compatible with other people's assemblers.
2845 @var{size} and @var{value} are optional.
2846 If the second comma and @var{value} are absent, @var{value} is
2847 assumed zero. If the first comma and following tokens are absent,
2848 @var{size} is assumed to be 1.
2851 @section @code{.float @var{flonums}}
2853 @cindex floating point numbers (single)
2854 @cindex @code{float} directive
2855 This directive assembles zero or more flonums, separated by commas. It
2856 has the same effect as @code{.single}.
2858 The exact kind of floating point numbers emitted depends on how
2859 @code{@value{AS}} is configured.
2860 @xref{Machine Dependencies}.
2864 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
2865 in @sc{ieee} format.
2870 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2872 @cindex @code{global} directive
2873 @cindex symbol, making visible to linker
2874 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
2875 @var{symbol} in your partial program, its value is made available to
2876 other partial programs that are linked with it. Otherwise,
2877 @var{symbol} will take its attributes from a symbol of the same name
2878 from another partial program it is linked with.
2880 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
2881 compatibility with other assemblers.
2884 @section @code{.hword @var{expressions}}
2886 @cindex @code{hword} directive
2887 @cindex integers, 16-bit
2888 @cindex numbers, 16-bit
2889 @cindex sixteen bit integers
2890 This expects zero or more @var{expressions}, and emits
2891 a 16 bit number for each.
2894 This directive is a synonym for @samp{.short}; depending on the target
2895 architecture, it may also be a synonym for @samp{.word}.
2899 This directive is a synonym for @samp{.short}.
2902 This directive is a synonym for both @samp{.short} and @samp{.word}.
2907 @section @code{.ident}
2909 @cindex @code{ident} directive
2910 This directive is used by some assemblers to place tags in object files.
2911 @code{@value{AS}} simply accepts the directive for source-file
2912 compatibility with such assemblers, but does not actually emit anything
2916 @section @code{.if @var{absolute expression}}
2918 @cindex conditional assembly
2919 @cindex @code{if} directive
2920 @code{.if} marks the beginning of a section of code which is only
2921 considered part of the source program being assembled if the argument
2922 (which must be an @var{absolute expression}) is non-zero. The end of
2923 the conditional section of code must be marked by @code{.endif}
2924 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
2925 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
2927 The following variants of @code{.if} are also supported:
2929 @item .ifdef @var{symbol}
2930 @cindex @code{ifdef} directive
2931 Assembles the following section of code if the specified @var{symbol}
2936 @cindex @code{ifeqs} directive
2937 Not yet implemented.
2940 @item .ifndef @var{symbol}
2941 @itemx ifnotdef @var{symbol}
2942 @cindex @code{ifndef} directive
2943 @cindex @code{ifnotdef} directive
2944 Assembles the following section of code if the specified @var{symbol}
2945 has not been defined. Both spelling variants are equivalent.
2949 Not yet implemented.
2954 @section @code{.include "@var{file}"}
2956 @cindex @code{include} directive
2957 @cindex supporting files, including
2958 @cindex files, including
2959 This directive provides a way to include supporting files at specified
2960 points in your source program. The code from @var{file} is assembled as
2961 if it followed the point of the @code{.include}; when the end of the
2962 included file is reached, assembly of the original file continues. You
2963 can control the search paths used with the @samp{-I} command-line option
2964 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
2968 @section @code{.int @var{expressions}}
2970 @cindex @code{int} directive
2972 @cindex integers, 32-bit
2973 Expect zero or more @var{expressions}, of any section, separated by
2974 commas. For each expression, emit a 32-bit
2978 @cindex integers, 32-bit
2979 Expect zero or more @var{expressions}, of any section, separated by
2980 commas. For each expression, emit a 32-bit
2984 Expect zero or more @var{expressions}, of any section, separated by
2985 commas. For each expression, emit a
2988 number that will, at run time, be the value of that expression. The
2989 byte order of the expression depends on what kind of computer will run
2994 On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
2995 integers. On the H8/300H and the Hitachi SH, however, @code{.int} emits
3001 @section @code{.lcomm @var{symbol} , @var{length}}
3003 @cindex @code{lcomm} directive
3004 @cindex local common symbols
3005 @cindex symbols, local common
3006 Reserve @var{length} (an absolute expression) bytes for a local common
3007 denoted by @var{symbol}. The section and value of @var{symbol} are
3008 those of the new local common. The addresses are allocated in the bss
3009 section, so at run-time the bytes will start off zeroed. @var{Symbol}
3010 is not declared global (@pxref{Global,,@code{.global}}), so is normally
3011 not visible to @code{@value{LD}}.
3014 @section @code{.lflags}
3016 @cindex @code{lflags} directive (ignored)
3017 @code{@value{AS}} accepts this directive, for compatibility with other
3018 assemblers, but ignores it.
3020 @ifclear no-line-dir
3022 @section @code{.line @var{line-number}}
3024 @cindex @code{line} directive
3028 @section @code{.ln @var{line-number}}
3030 @cindex @code{ln} directive
3032 @cindex logical line number
3034 Tell @code{@value{AS}} to change the logical line number. @var{line-number} must be
3035 an absolute expression. The next line will have that logical line
3036 number. So any other statements on the current line (after a statement
3037 separator character)
3038 will be reported as on logical line number
3039 @var{line-number} @minus{} 1.
3040 One day this directive will be unsupported: it is used only
3041 for compatibility with existing assembler programs.
3045 @emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
3046 only available with the name @code{.ln}, rather than as either
3047 @code{.line} or @code{.ln}.
3052 @ifclear no-line-dir
3053 Even though this is a directive associated with the @code{a.out} or
3054 @code{b.out} object-code formats, @code{@value{AS}} will still recognize it
3055 when producing COFF output, and will treat @samp{.line} as though it
3056 were the COFF @samp{.ln} @emph{if} it is found outside a
3057 @code{.def}/@code{.endef} pair.
3059 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
3060 used by compilers to generate auxiliary symbol information for
3065 @section @code{.ln @var{line-number}}
3067 @cindex @code{ln} directive
3068 @ifclear no-line-dir
3069 @samp{.ln} is a synonym for @samp{.line}.
3072 Tell @code{@value{AS}} to change the logical line number. @var{line-number}
3073 must be an absolute expression. The next line will have that logical
3074 line number, so any other statements on the current line (after a
3075 statement separator character @code{;}) will be reported as on logical
3076 line number @var{line-number} @minus{} 1.
3079 This directive is accepted, but ignored, when @code{@value{AS}} is
3080 configured for @code{b.out}; its effect is only associated with COFF
3086 @section @code{.list}
3088 @cindex @code{list} directive
3089 @cindex listing control, turning on
3090 Control (in conjunction with the @code{.nolist} directive) whether or
3091 not assembly listings are generated. These two directives maintain an
3092 internal counter (which is zero initially). @code{.list} increments the
3093 counter, and @code{.nolist} decrements it. Assembly listings are
3094 generated whenever the counter is greater than zero.
3096 By default, listings are disabled. When you enable them (with the
3097 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
3098 the initial value of the listing counter is one.
3101 @section @code{.long @var{expressions}}
3103 @cindex @code{long} directive
3104 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
3107 @c no one seems to know what this is for or whether this description is
3108 @c what it really ought to do
3110 @section @code{.lsym @var{symbol}, @var{expression}}
3112 @cindex @code{lsym} directive
3113 @cindex symbol, not referenced in assembly
3114 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
3115 the hash table, ensuring it cannot be referenced by name during the
3116 rest of the assembly. This sets the attributes of the symbol to be
3117 the same as the expression value:
3119 @var{other} = @var{descriptor} = 0
3120 @var{type} = @r{(section of @var{expression})}
3121 @var{value} = @var{expression}
3124 The new symbol is not flagged as external.
3128 @section @code{.nolist}
3130 @cindex @code{nolist} directive
3131 @cindex listing control, turning off
3132 Control (in conjunction with the @code{.list} directive) whether or
3133 not assembly listings are generated. These two directives maintain an
3134 internal counter (which is zero initially). @code{.list} increments the
3135 counter, and @code{.nolist} decrements it. Assembly listings are
3136 generated whenever the counter is greater than zero.
3139 @section @code{.octa @var{bignums}}
3141 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
3142 @cindex @code{octa} directive
3143 @cindex integer, 16-byte
3144 @cindex sixteen byte integer
3145 This directive expects zero or more bignums, separated by commas. For each
3146 bignum, it emits a 16-byte integer.
3148 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
3149 hence @emph{octa}-word for 16 bytes.
3152 @section @code{.org @var{new-lc} , @var{fill}}
3154 @cindex @code{org} directive
3155 @cindex location counter, advancing
3156 @cindex advancing location counter
3157 @cindex current address, advancing
3158 @code{.org} will advance the location counter of the current section to
3159 @var{new-lc}. @var{new-lc} is either an absolute expression or an
3160 expression with the same section as the current subsection. That is,
3161 you can't use @code{.org} to cross sections: if @var{new-lc} has the
3162 wrong section, the @code{.org} directive is ignored. To be compatible
3163 with former assemblers, if the section of @var{new-lc} is absolute,
3164 @code{@value{AS}} will issue a warning, then pretend the section of @var{new-lc}
3165 is the same as the current subsection.
3167 @code{.org} may only increase the location counter, or leave it
3168 unchanged; you cannot use @code{.org} to move the location counter
3171 @c double negative used below "not undefined" because this is a specific
3172 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
3173 @c section. pesch@cygnus.com 18feb91
3174 Because @code{@value{AS}} tries to assemble programs in one pass @var{new-lc}
3175 may not be undefined. If you really detest this restriction we eagerly await
3176 a chance to share your improved assembler.
3178 Beware that the origin is relative to the start of the section, not
3179 to the start of the subsection. This is compatible with other
3180 people's assemblers.
3182 When the location counter (of the current subsection) is advanced, the
3183 intervening bytes are filled with @var{fill} which should be an
3184 absolute expression. If the comma and @var{fill} are omitted,
3185 @var{fill} defaults to zero.
3188 @section @code{.psize @var{lines} , @var{columns}}
3190 @cindex @code{psize} directive
3191 @cindex listing control: paper size
3192 @cindex paper size, for listings
3193 Use this directive to declare the number of lines---and, optionally, the
3194 number of columns---to use for each page, when generating listings.
3196 If you don't use @code{.psize}, listings will use a default line-count
3197 of 60. You may omit the comma and @var{columns} specification; the
3198 default width is 200 columns.
3200 @code{@value{AS}} will generate formfeeds whenever the specified number of
3201 lines is exceeded (or whenever you explicitly request one, using
3204 If you specify @var{lines} as @code{0}, no formfeeds are generated save
3205 those explicitly specified with @code{.eject}.
3208 @section @code{.quad @var{bignums}}
3210 @cindex @code{quad} directive
3211 @code{.quad} expects zero or more bignums, separated by commas. For
3212 each bignum, it emits
3214 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
3215 warning message; and just takes the lowest order 8 bytes of the bignum.
3216 @cindex eight-byte integer
3217 @cindex integer, 8-byte
3219 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
3220 hence @emph{quad}-word for 8 bytes.
3223 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
3224 warning message; and just takes the lowest order 16 bytes of the bignum.
3225 @cindex sixteen-byte integer
3226 @cindex integer, 16-byte
3230 @section @code{.sbttl "@var{subheading}"}
3232 @cindex @code{sbttl} directive
3233 @cindex subtitles for listings
3234 @cindex listing control: subtitle
3235 Use @var{subheading} as the title (third line, immediately after the
3236 title line) when generating assembly listings.
3238 This directive affects subsequent pages, as well as the current page if
3239 it appears within ten lines of the top of a page.
3243 @section @code{.scl @var{class}}
3245 @cindex @code{scl} directive
3246 @cindex symbol storage class (COFF)
3247 @cindex COFF symbol storage class
3248 Set the storage-class value for a symbol. This directive may only be
3249 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
3250 whether a symbol is static or external, or it may record further
3251 symbolic debugging information.
3254 The @samp{.scl} directive is primarily associated with COFF output; when
3255 configured to generate @code{b.out} output format, @code{@value{AS}} will
3256 accept this directive but ignore it.
3262 @section @code{.section @var{name}, @var{subsection}}
3264 @cindex @code{section} directive
3265 @cindex named section (COFF)
3266 @cindex COFF named section
3267 Assemble the following code into end of subsection numbered
3268 @var{subsection} in the COFF named section @var{name}. If you omit
3269 @var{subsection}, @code{@value{AS}} uses subsection number zero.
3270 @samp{.section .text} is equivalent to the @code{.text} directive;
3271 @samp{.section .data} is equivalent to the @code{.data} directive.
3275 @section @code{.set @var{symbol}, @var{expression}}
3277 @cindex @code{set} directive
3278 @cindex symbol value, setting
3279 This directive sets the value of @var{symbol} to @var{expression}. This
3280 will change @var{symbol}'s value and type to conform to
3281 @var{expression}. If @var{symbol} was flagged as external, it remains
3282 flagged. (@xref{Symbol Attributes}.)
3284 You may @code{.set} a symbol many times in the same assembly.
3285 If the expression's section is unknowable during pass 1, a second
3286 pass over the source program will be forced. The second pass is
3287 currently not implemented. @code{@value{AS}} will abort with an error
3288 message if one is required.
3290 If you @code{.set} a global symbol, the value stored in the object
3291 file is the last value stored into it.
3294 @section @code{.short @var{expressions}}
3296 @cindex @code{short} directive
3298 @code{.short} is normally the same as @samp{.word}.
3299 @xref{Word,,@code{.word}}.
3301 In some configurations, however, @code{.short} and @code{.word} generate
3302 numbers of different lengths; @pxref{Machine Dependencies}.
3306 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
3309 This expects zero or more @var{expressions}, and emits
3310 a 16 bit number for each.
3315 @section @code{.single @var{flonums}}
3317 @cindex @code{single} directive
3318 @cindex floating point numbers (single)
3319 This directive assembles zero or more flonums, separated by commas. It
3320 has the same effect as @code{.float}.
3322 The exact kind of floating point numbers emitted depends on how
3323 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3327 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
3328 numbers in @sc{ieee} format.
3334 @section @code{.size}
3336 @cindex @code{size} directive
3337 This directive is generated by compilers to include auxiliary debugging
3338 information in the symbol table. It is only permitted inside
3339 @code{.def}/@code{.endef} pairs.
3342 @samp{.size} is only meaningful when generating COFF format output; when
3343 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3348 @ifclear no-space-dir
3350 @section @code{.space @var{size} , @var{fill}}
3352 @cindex @code{space} directive
3353 @cindex filling memory
3354 This directive emits @var{size} bytes, each of value @var{fill}. Both
3355 @var{size} and @var{fill} are absolute expressions. If the comma
3356 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3362 @section @code{.space}
3363 @cindex @code{space} directive
3365 On the AMD 29K, this directive is ignored; it is accepted for
3366 compatibility with other AMD 29K assemblers.
3369 @emph{Warning:} In most versions of the GNU assembler, the directive
3370 @code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
3376 @section @code{.stabd, .stabn, .stabs}
3378 @cindex symbolic debuggers, information for
3379 @cindex @code{stab@var{x}} directives
3380 There are three directives that begin @samp{.stab}.
3381 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
3382 The symbols are not entered in the @code{@value{AS}} hash table: they
3383 cannot be referenced elsewhere in the source file.
3384 Up to five fields are required:
3388 This is the symbol's name. It may contain any character except
3389 @samp{\000}, so is more general than ordinary symbol names. Some
3390 debuggers used to code arbitrarily complex structures into symbol names
3394 An absolute expression. The symbol's type is set to the low 8 bits of
3395 this expression. Any bit pattern is permitted, but @code{@value{LD}}
3396 and debuggers will choke on silly bit patterns.
3399 An absolute expression. The symbol's ``other'' attribute is set to the
3400 low 8 bits of this expression.
3403 An absolute expression. The symbol's descriptor is set to the low 16
3404 bits of this expression.
3407 An absolute expression which becomes the symbol's value.
3410 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
3411 or @code{.stabs} statement, the symbol has probably already been created
3412 and you will get a half-formed symbol in your object file. This is
3413 compatible with earlier assemblers!
3416 @cindex @code{stabd} directive
3417 @item .stabd @var{type} , @var{other} , @var{desc}
3419 The ``name'' of the symbol generated is not even an empty string.
3420 It is a null pointer, for compatibility. Older assemblers used a
3421 null pointer so they didn't waste space in object files with empty
3424 The symbol's value is set to the location counter,
3425 relocatably. When your program is linked, the value of this symbol
3426 will be where the location counter was when the @code{.stabd} was
3429 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
3430 @cindex @code{stabn} directive
3431 The name of the symbol is set to the empty string @code{""}.
3433 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
3434 @cindex @code{stabs} directive
3435 All five fields are specified.
3442 @section @code{.tag @var{structname}}
3444 @cindex COFF structure debugging
3445 @cindex structure debugging, COFF
3446 @cindex @code{tag} directive
3447 This directive is generated by compilers to include auxiliary debugging
3448 information in the symbol table. It is only permitted inside
3449 @code{.def}/@code{.endef} pairs. Tags are used to link structure
3450 definitions in the symbol table with instances of those structures.
3453 @samp{.tag} is only used when generating COFF format output; when
3454 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3460 @section @code{.text @var{subsection}}
3462 @cindex @code{text} directive
3463 Tells @code{@value{AS}} to assemble the following statements onto the end of
3464 the text subsection numbered @var{subsection}, which is an absolute
3465 expression. If @var{subsection} is omitted, subsection number zero
3469 @section @code{.title "@var{heading}"}
3471 @cindex @code{title} directive
3472 @cindex listing control: title line
3473 Use @var{heading} as the title (second line, immediately after the
3474 source file name and pagenumber) when generating assembly listings.
3476 This directive affects subsequent pages, as well as the current page if
3477 it appears within ten lines of the top of a page.
3481 @section @code{.type @var{int}}
3483 @cindex COFF symbol type
3484 @cindex symbol type, COFF
3485 @cindex @code{type} directive
3486 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3487 records the integer @var{int} as the type attribute of a symbol table entry.
3490 @samp{.type} is associated only with COFF format output; when
3491 @code{@value{AS}} is configured for @code{b.out} output, it accepts this
3492 directive but ignores it.
3498 @section @code{.val @var{addr}}
3500 @cindex @code{val} directive
3501 @cindex COFF value attribute
3502 @cindex value attribute, COFF
3503 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3504 records the address @var{addr} as the value attribute of a symbol table
3508 @samp{.val} is used only for COFF output; when @code{@value{AS}} is
3509 configured for @code{b.out}, it accepts this directive but ignores it.
3514 @section @code{.word @var{expressions}}
3516 @cindex @code{word} directive
3517 This directive expects zero or more @var{expressions}, of any section,
3518 separated by commas.
3521 For each expression, @code{@value{AS}} emits a 32-bit number.
3524 For each expression, @code{@value{AS}} emits a 16-bit number.
3529 The size of the number emitted, and its byte order,
3530 depends on what kind of computer will run the program.
3533 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
3534 @c happen---32-bit addressability, period; no long/short jumps.
3535 @ifset DIFF-TBL-KLUGE
3536 @cindex difference tables altered
3537 @cindex altered difference tables
3539 @emph{Warning: Special Treatment to support Compilers}
3543 Machines with a 32-bit address space, but that do less than 32-bit
3544 addressing, require the following special treatment. If the machine of
3545 interest to you does 32-bit addressing (or doesn't require it;
3546 @pxref{Machine Dependencies}), you can ignore this issue.
3549 In order to assemble compiler output into something that will work,
3550 @code{@value{AS}} will occasionlly do strange things to @samp{.word} directives.
3551 Directives of the form @samp{.word sym1-sym2} are often emitted by
3552 compilers as part of jump tables. Therefore, when @code{@value{AS}} assembles a
3553 directive of the form @samp{.word sym1-sym2}, and the difference between
3554 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{@value{AS}} will
3555 create a @dfn{secondary jump table}, immediately before the next label.
3556 This secondary jump table will be preceded by a short-jump to the
3557 first byte after the secondary table. This short-jump prevents the flow
3558 of control from accidentally falling into the new table. Inside the
3559 table will be a long-jump to @code{sym2}. The original @samp{.word}
3560 will contain @code{sym1} minus the address of the long-jump to
3563 If there were several occurrences of @samp{.word sym1-sym2} before the
3564 secondary jump table, all of them will be adjusted. If there was a
3565 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
3566 long-jump to @code{sym4} will be included in the secondary jump table,
3567 and the @code{.word} directives will be adjusted to contain @code{sym3}
3568 minus the address of the long-jump to @code{sym4}; and so on, for as many
3569 entries in the original jump table as necessary.
3572 @emph{This feature may be disabled by compiling @code{@value{AS}} with the
3573 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
3574 assembly language programmers.
3577 @c end DIFF-TBL-KLUGE
3580 @section Deprecated Directives
3582 @cindex deprecated directives
3583 @cindex obsolescent directives
3584 One day these directives won't work.
3585 They are included for compatibility with older assemblers.
3593 @node Machine Dependencies
3594 @chapter Machine Dependent Features
3596 @cindex machine dependencies
3597 The machine instruction sets are (almost by definition) different on
3598 each machine where @code{@value{AS}} runs. Floating point representations
3599 vary as well, and @code{@value{AS}} often supports a few additional
3600 directives or command-line options for compatibility with other
3601 assemblers on a particular platform. Finally, some versions of
3602 @code{@value{AS}} support special pseudo-instructions for branch
3605 This chapter discusses most of these differences, though it does not
3606 include details on any machine's instruction set. For details on that
3607 subject, see the hardware manufacturer's manual.
3611 * Vax-Dependent:: VAX Dependent Features
3614 * AMD29K-Dependent:: AMD 29K Dependent Features
3617 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
3620 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
3623 * SH-Dependent:: Hitachi SH Dependent Features
3626 * i960-Dependent:: Intel 80960 Dependent Features
3629 * M68K-Dependent:: M680x0 Dependent Features
3632 * Sparc-Dependent:: SPARC Dependent Features
3635 * Z8000-Dependent:: Z8000 Dependent Features
3638 * i386-Dependent:: 80386 Dependent Features
3645 @c The following major nodes are *sections* in the GENERIC version, *chapters*
3646 @c in single-cpu versions. This is mainly achieved by @down. There is a
3647 @c peculiarity: to preserve cross-references, there must be a node called
3648 @c "Machine Dependencies". Hence the conditional nodenames in each
3649 @c major node below. Node defaulting in makeinfo requires adjacency of
3650 @c node and sectioning commands; hence the repetition of @chapter BLAH
3651 @c in both conditional blocks.
3656 @chapter VAX Dependent Features
3661 @node Machine Dependencies
3662 @chapter VAX Dependent Features
3668 * Vax-Opts:: VAX Command-Line Options
3669 * VAX-float:: VAX Floating Point
3670 * VAX-directives:: Vax Machine Directives
3671 * VAX-opcodes:: VAX Opcodes
3672 * VAX-branch:: VAX Branch Improvement
3673 * VAX-operands:: VAX Operands
3674 * VAX-no:: Not Supported on VAX
3679 @section VAX Command-Line Options
3681 @cindex command-line options ignored, VAX
3682 @cindex VAX command-line options ignored
3683 The Vax version of @code{@value{AS}} accepts any of the following options,
3684 gives a warning message that the option was ignored and proceeds.
3685 These options are for compatibility with scripts designed for other
3686 people's assemblers.
3689 @item @kbd{-D} (Debug)
3690 @itemx @kbd{-S} (Symbol Table)
3691 @itemx @kbd{-T} (Token Trace)
3692 @cindex @code{-D}, ignored on VAX
3693 @cindex @code{-S}, ignored on VAX
3694 @cindex @code{-T}, ignored on VAX
3695 These are obsolete options used to debug old assemblers.
3697 @item @kbd{-d} (Displacement size for JUMPs)
3698 @cindex @code{-d}, VAX option
3699 This option expects a number following the @kbd{-d}. Like options
3700 that expect filenames, the number may immediately follow the
3701 @kbd{-d} (old standard) or constitute the whole of the command line
3702 argument that follows @kbd{-d} (GNU standard).
3704 @item @kbd{-V} (Virtualize Interpass Temporary File)
3705 @cindex @code{-V}, redundant on VAX
3706 Some other assemblers use a temporary file. This option
3707 commanded them to keep the information in active memory rather
3708 than in a disk file. @code{@value{AS}} always does this, so this
3709 option is redundant.
3711 @item @kbd{-J} (JUMPify Longer Branches)
3712 @cindex @code{-J}, ignored on VAX
3713 Many 32-bit computers permit a variety of branch instructions
3714 to do the same job. Some of these instructions are short (and
3715 fast) but have a limited range; others are long (and slow) but
3716 can branch anywhere in virtual memory. Often there are 3
3717 flavors of branch: short, medium and long. Some other
3718 assemblers would emit short and medium branches, unless told by
3719 this option to emit short and long branches.
3721 @item @kbd{-t} (Temporary File Directory)
3722 @cindex @code{-t}, ignored on VAX
3723 Some other assemblers may use a temporary file, and this option
3724 takes a filename being the directory to site the temporary
3725 file. Since @code{@value{AS}} does not use a temporary disk file, this
3726 option makes no difference. @kbd{-t} needs exactly one
3730 @cindex VMS (VAX) options
3731 @cindex options for VAX/VMS
3732 @cindex VAX/VMS options
3733 @cindex @code{-h} option, VAX/VMS
3734 @cindex @code{-+} option, VAX/VMS
3735 @cindex Vax-11 C compatibility
3736 @cindex symbols with lowercase, VAX/VMS
3737 @c FIXME! look into "I think" below, correct if needed, delete.
3738 The Vax version of the assembler accepts two options when
3739 compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
3740 @kbd{-h} option prevents @code{@value{AS}} from modifying the
3741 symbol-table entries for symbols that contain lowercase
3742 characters (I think). The @kbd{-+} option causes @code{@value{AS}} to
3743 print warning messages if the FILENAME part of the object file,
3744 or any symbol name is larger than 31 characters. The @kbd{-+}
3745 option also insertes some code following the @samp{_main}
3746 symbol so that the object file will be compatible with Vax-11
3750 @section VAX Floating Point
3752 @cindex VAX floating point
3753 @cindex floating point, VAX
3754 Conversion of flonums to floating point is correct, and
3755 compatible with previous assemblers. Rounding is
3756 towards zero if the remainder is exactly half the least significant bit.
3758 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
3761 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
3762 are rendered correctly. Again, rounding is towards zero in the
3765 @cindex @code{float} directive, VAX
3766 @cindex @code{double} directive, VAX
3767 The @code{.float} directive produces @code{f} format numbers.
3768 The @code{.double} directive produces @code{d} format numbers.
3770 @node VAX-directives
3771 @section Vax Machine Directives
3773 @cindex machine directives, VAX
3774 @cindex VAX machine directives
3775 The Vax version of the assembler supports four directives for
3776 generating Vax floating point constants. They are described in the
3779 @cindex wide floating point directives, VAX
3782 @cindex @code{dfloat} directive, VAX
3783 This expects zero or more flonums, separated by commas, and
3784 assembles Vax @code{d} format 64-bit floating point constants.
3787 @cindex @code{ffloat} directive, VAX
3788 This expects zero or more flonums, separated by commas, and
3789 assembles Vax @code{f} format 32-bit floating point constants.
3792 @cindex @code{gfloat} directive, VAX
3793 This expects zero or more flonums, separated by commas, and
3794 assembles Vax @code{g} format 64-bit floating point constants.
3797 @cindex @code{hfloat} directive, VAX
3798 This expects zero or more flonums, separated by commas, and
3799 assembles Vax @code{h} format 128-bit floating point constants.
3804 @section VAX Opcodes
3806 @cindex VAX opcode mnemonics
3807 @cindex opcode mnemonics, VAX
3808 @cindex mnemonics for opcodes, VAX
3809 All DEC mnemonics are supported. Beware that @code{case@dots{}}
3810 instructions have exactly 3 operands. The dispatch table that
3811 follows the @code{case@dots{}} instruction should be made with
3812 @code{.word} statements. This is compatible with all unix
3813 assemblers we know of.
3816 @section VAX Branch Improvement
3818 @cindex VAX branch improvement
3819 @cindex branch improvement, VAX
3820 @cindex pseudo-ops for branch, VAX
3821 Certain pseudo opcodes are permitted. They are for branch
3822 instructions. They expand to the shortest branch instruction that
3823 will reach the target. Generally these mnemonics are made by
3824 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
3825 This feature is included both for compatibility and to help
3826 compilers. If you don't need this feature, don't use these
3827 opcodes. Here are the mnemonics, and the code they can expand into.
3831 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
3833 @item (byte displacement)
3835 @item (word displacement)
3837 @item (long displacement)
3842 Unconditional branch.
3844 @item (byte displacement)
3846 @item (word displacement)
3848 @item (long displacement)
3852 @var{COND} may be any one of the conditional branches
3853 @code{neq}, @code{nequ}, @code{eql}, @code{eqlu}, @code{gtr},
3854 @code{geq}, @code{lss}, @code{gtru}, @code{lequ}, @code{vc}, @code{vs},
3855 @code{gequ}, @code{cc}, @code{lssu}, @code{cs}.
3856 @var{COND} may also be one of the bit tests
3857 @code{bs}, @code{bc}, @code{bss}, @code{bcs}, @code{bsc}, @code{bcc},
3858 @code{bssi}, @code{bcci}, @code{lbs}, @code{lbc}.
3859 @var{NOTCOND} is the opposite condition to @var{COND}.
3861 @item (byte displacement)
3862 @kbd{b@var{COND} @dots{}}
3863 @item (word displacement)
3864 @kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
3865 @item (long displacement)
3866 @kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
3869 @var{X} may be one of @code{b d f g h l w}.
3871 @item (word displacement)
3872 @kbd{@var{OPCODE} @dots{}}
3873 @item (long displacement)
3875 @var{OPCODE} @dots{}, foo ;
3882 @var{YYY} may be one of @code{lss leq}.
3884 @var{ZZZ} may be one of @code{geq gtr}.
3886 @item (byte displacement)
3887 @kbd{@var{OPCODE} @dots{}}
3888 @item (word displacement)
3890 @var{OPCODE} @dots{}, foo ;
3892 foo: brw @var{destination} ;
3895 @item (long displacement)
3897 @var{OPCODE} @dots{}, foo ;
3899 foo: jmp @var{destination} ;
3908 @item (byte displacement)
3909 @kbd{@var{OPCODE} @dots{}}
3910 @item (word displacement)
3912 @var{OPCODE} @dots{}, foo ;
3914 foo: brw @var{destination} ;
3917 @item (long displacement)
3919 @var{OPCODE} @dots{}, foo ;
3921 foo: jmp @var{destination} ;
3928 @section VAX Operands
3930 @cindex VAX operand notation
3931 @cindex operand notation, VAX
3932 @cindex immediate character, VAX
3933 @cindex VAX immediate character
3934 The immediate character is @samp{$} for Unix compatibility, not
3935 @samp{#} as DEC writes it.
3937 @cindex indirect character, VAX
3938 @cindex VAX indirect character
3939 The indirect character is @samp{*} for Unix compatibility, not
3940 @samp{@@} as DEC writes it.
3942 @cindex displacement sizing character, VAX
3943 @cindex VAX displacement sizing character
3944 The displacement sizing character is @samp{`} (an accent grave) for
3945 Unix compatibility, not @samp{^} as DEC writes it. The letter
3946 preceding @samp{`} may have either case. @samp{G} is not
3947 understood, but all other letters (@code{b i l s w}) are understood.
3949 @cindex register names, VAX
3950 @cindex VAX register names
3951 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
3952 pc}. Any case of letters will do.
3959 Any expression is permitted in an operand. Operands are comma
3962 @c There is some bug to do with recognizing expressions
3963 @c in operands, but I forget what it is. It is
3964 @c a syntax clash because () is used as an address mode
3965 @c and to encapsulate sub-expressions.
3968 @section Not Supported on VAX
3970 @cindex VAX bitfields not supported
3971 @cindex bitfields, not supported on VAX
3972 Vax bit fields can not be assembled with @code{@value{AS}}. Someone
3973 can add the required code if they really need it.
3979 @node AMD29K-Dependent
3980 @chapter AMD 29K Dependent Features
3983 @node Machine Dependencies
3984 @chapter AMD 29K Dependent Features
3987 @cindex AMD 29K support
3990 * AMD29K Options:: Options
3991 * AMD29K Syntax:: Syntax
3992 * AMD29K Floating Point:: Floating Point
3993 * AMD29K Directives:: AMD 29K Machine Directives
3994 * AMD29K Opcodes:: Opcodes
3997 @node AMD29K Options
3999 @cindex AMD 29K options (none)
4000 @cindex options for AMD29K (none)
4001 @code{@value{AS}} has no additional command-line options for the AMD
4007 * AMD29K-Chars:: Special Characters
4008 * AMD29K-Regs:: Register Names
4012 @subsection Special Characters
4014 @cindex line comment character, AMD 29K
4015 @cindex AMD 29K line comment character
4016 @samp{;} is the line comment character.
4018 @cindex line separator, AMD 29K
4019 @cindex AMD 29K line separator
4020 @cindex statement separator, AMD 29K
4021 @cindex AMD 29K statement separator
4022 @samp{@@} can be used instead of a newline to separate statements.
4024 @cindex identifiers, AMD 29K
4025 @cindex AMD 29K identifiers
4026 The character @samp{?} is permitted in identifiers (but may not begin
4030 @subsection Register Names
4032 @cindex AMD 29K register names
4033 @cindex register names, AMD 29K
4034 General-purpose registers are represented by predefined symbols of the
4035 form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
4036 (for local registers), where @var{nnn} represents a number between
4037 @code{0} and @code{127}, written with no leading zeros. The leading
4038 letters may be in either upper or lower case; for example, @samp{gr13}
4039 and @samp{LR7} are both valid register names.
4041 You may also refer to general-purpose registers by specifying the
4042 register number as the result of an expression (prefixed with @samp{%%}
4043 to flag the expression as a register number):
4048 ---where @var{expression} must be an absolute expression evaluating to a
4049 number between @code{0} and @code{255}. The range [0, 127] refers to
4050 global registers, and the range [128, 255] to local registers.
4052 @cindex special purpose registers, AMD 29K
4053 @cindex AMD 29K special purpose registers
4054 @cindex protected registers, AMD 29K
4055 @cindex AMD 29K protected registers
4056 In addition, @code{@value{AS}} understands the following protected
4057 special-purpose register names for the AMD 29K family:
4067 These unprotected special-purpose register names are also recognized:
4075 @node AMD29K Floating Point
4076 @section Floating Point
4078 @cindex floating point, AMD 29K (@sc{ieee})
4079 @cindex AMD 29K floating point (@sc{ieee})
4080 The AMD 29K family uses @sc{ieee} floating-point numbers.
4082 @node AMD29K Directives
4083 @section AMD 29K Machine Directives
4085 @cindex machine directives, AMD 29K
4086 @cindex AMD 29K machine directives
4088 @item .block @var{size} , @var{fill}
4089 @cindex @code{block} directive, AMD 29K
4090 This directive emits @var{size} bytes, each of value @var{fill}. Both
4091 @var{size} and @var{fill} are absolute expressions. If the comma
4092 and @var{fill} are omitted, @var{fill} is assumed to be zero.
4094 In other versions of the GNU assembler, this directive is called
4100 @cindex @code{cputype} directive, AMD 29K
4101 This directive is ignored; it is accepted for compatibility with other
4105 @cindex @code{file} directive, AMD 29K
4106 This directive is ignored; it is accepted for compatibility with other
4110 @emph{Warning:} in other versions of the GNU assembler, @code{.file} is
4111 used for the directive called @code{.app-file} in the AMD 29K support.
4115 @cindex @code{line} directive, AMD 29K
4116 This directive is ignored; it is accepted for compatibility with other
4120 @c since we're ignoring .lsym...
4121 @item .reg @var{symbol}, @var{expression}
4122 @cindex @code{reg} directive, AMD 29K
4123 @code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
4127 @cindex @code{sect} directive, AMD 29K
4128 This directive is ignored; it is accepted for compatibility with other
4131 @item .use @var{section name}
4132 @cindex @code{use} directive, AMD 29K
4133 Establishes the section and subsection for the following code;
4134 @var{section name} may be one of @code{.text}, @code{.data},
4135 @code{.data1}, or @code{.lit}. With one of the first three @var{section
4136 name} options, @samp{.use} is equivalent to the machine directive
4137 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
4141 @node AMD29K Opcodes
4144 @cindex AMD 29K opcodes
4145 @cindex opcodes for AMD 29K
4146 @code{@value{AS}} implements all the standard AMD 29K opcodes. No
4147 additional pseudo-instructions are needed on this family.
4149 For information on the 29K machine instruction set, see @cite{Am29000
4150 User's Manual}, Advanced Micro Devices, Inc.
4155 @node Machine Dependencies
4156 @chapter Machine Dependent Features
4158 The machine instruction sets are different on each Hitachi chip family,
4159 and there are also some syntax differences among the families. This
4160 chapter describes the specific @code{@value{AS}} features for each
4164 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4165 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4166 * SH-Dependent:: Hitachi SH Dependent Features
4176 @node H8/300-Dependent
4177 @chapter H8/300 Dependent Features
4179 @cindex H8/300 support
4181 * H8/300 Options:: Options
4182 * H8/300 Syntax:: Syntax
4183 * H8/300 Floating Point:: Floating Point
4184 * H8/300 Directives:: H8/300 Machine Directives
4185 * H8/300 Opcodes:: Opcodes
4188 @node H8/300 Options
4191 @cindex H8/300 options (none)
4192 @cindex options, H8/300 (none)
4193 @code{@value{AS}} has no additional command-line options for the Hitachi
4199 * H8/300-Chars:: Special Characters
4200 * H8/300-Regs:: Register Names
4201 * H8/300-Addressing:: Addressing Modes
4205 @subsection Special Characters
4207 @cindex line comment character, H8/300
4208 @cindex H8/300 line comment character
4209 @samp{;} is the line comment character.
4211 @cindex line separator, H8/300
4212 @cindex statement separator, H8/300
4213 @cindex H8/300 line separator
4214 @samp{$} can be used instead of a newline to separate statements.
4215 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
4218 @subsection Register Names
4220 @cindex H8/300 registers
4221 @cindex register names, H8/300
4222 You can use predefined symbols of the form @samp{r@var{n}h} and
4223 @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
4224 general-purpose registers. @var{n} is a digit from @samp{0} to
4225 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
4228 You can also use the eight predefined symbols @samp{r@var{n}} to refer
4229 to the H8/300 registers as 16-bit registers (you must use this form for
4232 On the H8/300H, you can also use the eight predefined symbols
4233 @samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit
4234 general purpose registers.
4236 The two control registers are called @code{pc} (program counter; a
4237 16-bit register, except on the H8/300H where it is 24 bits) and
4238 @code{ccr} (condition code register; an 8-bit register). @code{r7} is
4239 used as the stack pointer, and can also be called @code{sp}.
4241 @node H8/300-Addressing
4242 @subsection Addressing Modes
4244 @cindex addressing modes, H8/300
4245 @cindex H8/300 addressing modes
4246 @value{AS} understands the following addressing modes for the H8/300:
4254 @item @@(@var{d}, r@var{n})
4255 @itemx @@(@var{d}:16, r@var{n})
4256 @itemx @@(@var{d}:24, r@var{n})
4257 Register indirect: 16-bit or 24-bit displacement @var{d} from register
4258 @var{n}. (24-bit displacements are only meaningful on the H8/300H.)
4261 Register indirect with post-increment
4264 Register indirect with pre-decrement
4266 @item @code{@@}@var{aa}
4267 @itemx @code{@@}@var{aa}:8
4268 @itemx @code{@@}@var{aa}:16
4269 @itemx @code{@@}@var{aa}:24
4270 Absolute address @code{aa}. (The address size @samp{:24} only makes
4271 sense on the H8/300H.)
4277 Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or
4278 @samp{:32} for clarity, if you wish; but @code{@value{AS}} neither
4279 requires this nor uses it---the data size required is taken from
4282 @item @code{@@}@code{@@}@var{aa}
4283 @itemx @code{@@}@code{@@}@var{aa}:8
4284 Memory indirect. You may specify the @samp{:8} for clarity, if you
4285 wish; but @code{@value{AS}} neither requires this nor uses it.
4288 @node H8/300 Floating Point
4289 @section Floating Point
4291 @cindex floating point, H8/300 (@sc{ieee})
4292 @cindex H8/300 floating point (@sc{ieee})
4293 The H8/300 family has no hardware floating point, but the @code{.float}
4294 directive generates @sc{ieee} floating-point numbers for compatibility
4295 with other development tools.
4298 @node H8/300 Directives
4299 @section H8/300 Machine Directives
4301 @cindex H8/300 machine directives (none)
4302 @cindex machine directives, H8/300 (none)
4303 @cindex @code{word} directive, H8/300
4304 @cindex @code{int} directive, H8/300
4305 @code{@value{AS}} has only one machine-dependent directive for the
4310 @cindex H8/300H, assembling for
4311 Recognize and emit additional instructions for the H8/300H variant, and
4312 also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
4313 for the H8/300 family.
4316 On the H8/300 family (including the H8/300H) @samp{.word} directives
4317 generate 16-bit numbers.
4319 @node H8/300 Opcodes
4322 @cindex H8/300 opcode summary
4323 @cindex opcode summary, H8/300
4324 @cindex mnemonics, H8/300
4325 @cindex instruction summary, H8/300
4326 For detailed information on the H8/300 machine instruction set, see
4327 @cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025). For
4328 information specific to the H8/300H, see @cite{H8/300H Series
4329 Programming Manual} (Hitachi).
4331 @code{@value{AS}} implements all the standard H8/300 opcodes. No additional
4332 pseudo-instructions are needed on this family.
4334 The following table summarizes the H8/300 opcodes, and their arguments.
4335 Entries marked @samp{*} are opcodes used only on the H8/300H.
4338 @c Using @group seems to use the normal baselineskip, not the smallexample
4339 @c baselineskip; looks approx doublespaced.
4341 Rs @r{source register}
4342 Rd @r{destination register}
4343 abs @r{absolute address}
4344 imm @r{immediate data}
4345 disp:N @r{N-bit displacement from a register}
4346 pcrel:N @r{N-bit displacement relative to program counter}
4348 add.b #imm,rd * andc #imm,ccr
4349 add.b rs,rd band #imm,rd
4350 add.w rs,rd band #imm,@@rd
4351 * add.w #imm,rd band #imm,@@abs:8
4352 * add.l rs,rd bra pcrel:8
4353 * add.l #imm,rd * bra pcrel:16
4354 adds #imm,rd bt pcrel:8
4355 addx #imm,rd * bt pcrel:16
4356 addx rs,rd brn pcrel:8
4357 and.b #imm,rd * brn pcrel:16
4358 and.b rs,rd bf pcrel:8
4359 * and.w rs,rd * bf pcrel:16
4360 * and.w #imm,rd bhi pcrel:8
4361 * and.l #imm,rd * bhi pcrel:16
4362 * and.l rs,rd bls pcrel:8
4364 * bls pcrel:16 bld #imm,rd
4365 bcc pcrel:8 bld #imm,@@rd
4366 * bcc pcrel:16 bld #imm,@@abs:8
4367 bhs pcrel:8 bnot #imm,rd
4368 * bhs pcrel:16 bnot #imm,@@rd
4369 bcs pcrel:8 bnot #imm,@@abs:8
4370 * bcs pcrel:16 bnot rs,rd
4371 blo pcrel:8 bnot rs,@@rd
4372 * blo pcrel:16 bnot rs,@@abs:8
4373 bne pcrel:8 bor #imm,rd
4374 * bne pcrel:16 bor #imm,@@rd
4375 beq pcrel:8 bor #imm,@@abs:8
4376 * beq pcrel:16 bset #imm,rd
4377 bvc pcrel:8 bset #imm,@@rd
4378 * bvc pcrel:16 bset #imm,@@abs:8
4379 bvs pcrel:8 bset rs,rd
4380 * bvs pcrel:16 bset rs,@@rd
4381 bpl pcrel:8 bset rs,@@abs:8
4382 * bpl pcrel:16 bsr pcrel:8
4383 bmi pcrel:8 bsr pcrel:16
4384 * bmi pcrel:16 bst #imm,rd
4385 bge pcrel:8 bst #imm,@@rd
4386 * bge pcrel:16 bst #imm,@@abs:8
4387 blt pcrel:8 btst #imm,rd
4388 * blt pcrel:16 btst #imm,@@rd
4389 bgt pcrel:8 btst #imm,@@abs:8
4390 * bgt pcrel:16 btst rs,rd
4391 ble pcrel:8 btst rs,@@rd
4392 * ble pcrel:16 btst rs,@@abs:8
4393 bclr #imm,rd bxor #imm,rd
4394 bclr #imm,@@rd bxor #imm,@@rd
4395 bclr #imm,@@abs:8 bxor #imm,@@abs:8
4396 bclr rs,rd cmp.b #imm,rd
4397 bclr rs,@@rd cmp.b rs,rd
4398 bclr rs,@@abs:8 cmp.w rs,rd
4399 biand #imm,rd cmp.w rs,rd
4400 biand #imm,@@rd * cmp.w #imm,rd
4401 biand #imm,@@abs:8 * cmp.l #imm,rd
4402 bild #imm,rd * cmp.l rs,rd
4403 bild #imm,@@rd daa rs
4404 bild #imm,@@abs:8 das rs
4405 bior #imm,rd dec.b rs
4406 bior #imm,@@rd * dec.w #imm,rd
4407 bior #imm,@@abs:8 * dec.l #imm,rd
4408 bist #imm,rd divxu.b rs,rd
4409 bist #imm,@@rd * divxu.w rs,rd
4410 bist #imm,@@abs:8 * divxs.b rs,rd
4411 bixor #imm,rd * divxs.w rs,rd
4412 bixor #imm,@@rd eepmov
4413 bixor #imm,@@abs:8 * eepmovw
4415 * exts.w rd mov.w rs,@@abs:16
4416 * exts.l rd * mov.l #imm,rd
4417 * extu.w rd * mov.l rs,rd
4418 * extu.l rd * mov.l @@rs,rd
4419 inc rs * mov.l @@(disp:16,rs),rd
4420 * inc.w #imm,rd * mov.l @@(disp:24,rs),rd
4421 * inc.l #imm,rd * mov.l @@rs+,rd
4422 jmp @@rs * mov.l @@abs:16,rd
4423 jmp abs * mov.l @@abs:24,rd
4424 jmp @@@@abs:8 * mov.l rs,@@rd
4425 jsr @@rs * mov.l rs,@@(disp:16,rd)
4426 jsr abs * mov.l rs,@@(disp:24,rd)
4427 jsr @@@@abs:8 * mov.l rs,@@-rd
4428 ldc #imm,ccr * mov.l rs,@@abs:16
4429 ldc rs,ccr * mov.l rs,@@abs:24
4430 * ldc @@abs:16,ccr movfpe @@abs:16,rd
4431 * ldc @@abs:24,ccr movtpe rs,@@abs:16
4432 * ldc @@(disp:16,rs),ccr mulxu.b rs,rd
4433 * ldc @@(disp:24,rs),ccr * mulxu.w rs,rd
4434 * ldc @@rs+,ccr * mulxs.b rs,rd
4435 * ldc @@rs,ccr * mulxs.w rs,rd
4436 * mov.b @@(disp:24,rs),rd neg.b rs
4437 * mov.b rs,@@(disp:24,rd) * neg.w rs
4438 mov.b @@abs:16,rd * neg.l rs
4440 mov.b @@abs:8,rd not.b rs
4441 mov.b rs,@@abs:8 * not.w rs
4442 mov.b rs,rd * not.l rs
4443 mov.b #imm,rd or.b #imm,rd
4444 mov.b @@rs,rd or.b rs,rd
4445 mov.b @@(disp:16,rs),rd * or.w #imm,rd
4446 mov.b @@rs+,rd * or.w rs,rd
4447 mov.b @@abs:8,rd * or.l #imm,rd
4448 mov.b rs,@@rd * or.l rs,rd
4449 mov.b rs,@@(disp:16,rd) orc #imm,ccr
4450 mov.b rs,@@-rd pop.w rs
4451 mov.b rs,@@abs:8 * pop.l rs
4452 mov.w rs,@@rd push.w rs
4453 * mov.w @@(disp:24,rs),rd * push.l rs
4454 * mov.w rs,@@(disp:24,rd) rotl.b rs
4455 * mov.w @@abs:24,rd * rotl.w rs
4456 * mov.w rs,@@abs:24 * rotl.l rs
4457 mov.w rs,rd rotr.b rs
4458 mov.w #imm,rd * rotr.w rs
4459 mov.w @@rs,rd * rotr.l rs
4460 mov.w @@(disp:16,rs),rd rotxl.b rs
4461 mov.w @@rs+,rd * rotxl.w rs
4462 mov.w @@abs:16,rd * rotxl.l rs
4463 mov.w rs,@@(disp:16,rd) rotxr.b rs
4464 mov.w rs,@@-rd * rotxr.w rs
4466 * rotxr.l rs * stc ccr,@@(disp:24,rd)
4468 rte * stc ccr,@@abs:16
4469 rts * stc ccr,@@abs:24
4470 shal.b rs sub.b rs,rd
4471 * shal.w rs sub.w rs,rd
4472 * shal.l rs * sub.w #imm,rd
4473 shar.b rs * sub.l rs,rd
4474 * shar.w rs * sub.l #imm,rd
4475 * shar.l rs subs #imm,rd
4476 shll.b rs subx #imm,rd
4477 * shll.w rs subx rs,rd
4478 * shll.l rs * trapa #imm
4479 shlr.b rs xor #imm,rd
4480 * shlr.w rs xor rs,rd
4481 * shlr.l rs * xor.w #imm,rd
4483 stc ccr,rd * xor.l #imm,rd
4484 * stc ccr,@@rs * xor.l rs,rd
4485 * stc ccr,@@(disp:16,rd) xorc #imm,ccr
4488 @cindex size suffixes, H8/300
4489 @cindex H8/300 size suffixes
4490 Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
4491 @code{sub}) are defined with variants using the suffixes @samp{.b},
4492 @samp{.w}, and @samp{.l} to specify the size of a memory operand.
4493 @code{@value{AS}} supports these suffixes, but does not require them;
4494 since one of the operands is always a register, @code{@value{AS}} can
4495 deduce the correct size.
4497 For example, since @code{r0} refers to a 16-bit register,
4500 @exdent is equivalent to
4504 If you use the size suffixes, @code{@value{AS}} issues a warning when
4505 the suffix and the register size do not match.
4510 @node H8/500-Dependent
4511 @chapter H8/500 Dependent Features
4513 @cindex H8/500 support
4515 * H8/500 Options:: Options
4516 * H8/500 Syntax:: Syntax
4517 * H8/500 Floating Point:: Floating Point
4518 * H8/500 Directives:: H8/500 Machine Directives
4519 * H8/500 Opcodes:: Opcodes
4522 @node H8/500 Options
4525 @cindex H8/500 options (none)
4526 @cindex options, H8/500 (none)
4527 @code{@value{AS}} has no additional command-line options for the Hitachi
4534 * H8/500-Chars:: Special Characters
4535 * H8/500-Regs:: Register Names
4536 * H8/500-Addressing:: Addressing Modes
4540 @subsection Special Characters
4542 @cindex line comment character, H8/500
4543 @cindex H8/500 line comment character
4544 @samp{!} is the line comment character.
4546 @cindex line separator, H8/500
4547 @cindex statement separator, H8/500
4548 @cindex H8/500 line separator
4549 @samp{;} can be used instead of a newline to separate statements.
4551 @cindex symbol names, @samp{$} in
4552 @cindex @code{$} in symbol names
4553 Since @samp{$} has no special meaning, you may use it in symbol names.
4556 @subsection Register Names
4558 @cindex H8/500 registers
4559 @cindex registers, H8/500
4560 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
4561 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, and @samp{r7} to refer to
4562 the H8/500 registers.
4564 The H8/500 also has these control registers:
4586 condition code register
4589 All registers are 16 bits long. To represent 32 bit numbers, use two
4590 adjacent registers; for distant memory addresses, use one of the segment
4591 pointers (@code{cp} for the program counter; @code{dp} for
4592 @code{r0}--@code{r3}; @code{ep} for @code{r4} and @code{r5}; and
4593 @code{tp} for @code{r6} and @code{r7}.
4595 @node H8/500-Addressing
4596 @subsection Addressing Modes
4598 @cindex addressing modes, H8/500
4599 @cindex H8/500 addressing modes
4600 @value{AS} understands the following addressing modes for the H8/500:
4608 @item @@(d:8, R@var{n})
4609 Register indirect with 8 bit signed displacement
4611 @item @@(d:16, R@var{n})
4612 Register indirect with 16 bit signed displacement
4615 Register indirect with pre-decrement
4618 Register indirect with post-increment
4621 8 bit absolute address
4624 16 bit absolute address
4633 @node H8/500 Floating Point
4634 @section Floating Point
4636 @cindex floating point, H8/500 (@sc{ieee})
4637 @cindex H8/500 floating point (@sc{ieee})
4638 The H8/500 family uses @sc{ieee} floating-point numbers.
4640 @node H8/500 Directives
4641 @section H8/500 Machine Directives
4643 @cindex H8/500 machine directives (none)
4644 @cindex machine directives, H8/500 (none)
4645 @cindex @code{word} directive, H8/500
4646 @cindex @code{int} directive, H8/500
4647 @code{@value{AS}} has no machine-dependent directives for the H8/500.
4648 However, on this platform the @samp{.int} and @samp{.word} directives
4649 generate 16-bit numbers.
4651 @node H8/500 Opcodes
4654 @cindex H8/500 opcode summary
4655 @cindex opcode summary, H8/500
4656 @cindex mnemonics, H8/500
4657 @cindex instruction summary, H8/500
4658 For detailed information on the H8/500 machine instruction set, see
4659 @cite{H8/500 Series Programming Manual} (Hitachi M21T001).
4661 @code{@value{AS}} implements all the standard H8/500 opcodes. No additional
4662 pseudo-instructions are needed on this family.
4664 The following table summarizes H8/500 opcodes and their operands:
4666 @c Use @group if it ever works, instead of @page
4670 abs8 @r{8-bit absolute address}
4671 abs16 @r{16-bit absolute address}
4672 abs24 @r{24-bit absolute address}
4673 crb @r{@code{ccr}, @code{br}, @code{ep}, @code{dp}, @code{tp}, @code{dp}}
4674 disp8 @r{8-bit displacement}
4675 ea @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4676 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16},}
4677 @r{@code{#xx:8}, @code{#xx:16}}
4678 ea_mem @r{@code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4679 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4680 ea_noimm @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4681 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4683 imm4 @r{4-bit immediate data}
4684 imm8 @r{8-bit immediate data}
4685 imm16 @r{16-bit immediate data}
4686 pcrel8 @r{8-bit offset from program counter}
4687 pcrel16 @r{16-bit offset from program counter}
4688 qim @r{@code{-2}, @code{-1}, @code{1}, @code{2}}
4690 rs @r{a register distinct from rd}
4691 rlist @r{comma-separated list of registers in parentheses;}
4692 @r{register ranges @code{rd-rs} are allowed}
4693 sp @r{stack pointer (@code{r7})}
4694 sr @r{status register}
4695 sz @r{size; @samp{.b} or @samp{.w}. If omitted, default @samp{.w}}
4697 ldc[.b] ea,crb bcc[.w] pcrel16
4698 ldc[.w] ea,sr bcc[.b] pcrel8
4699 add[:q] sz qim,ea_noimm bhs[.w] pcrel16
4700 add[:g] sz ea,rd bhs[.b] pcrel8
4701 adds sz ea,rd bcs[.w] pcrel16
4702 addx sz ea,rd bcs[.b] pcrel8
4703 and sz ea,rd blo[.w] pcrel16
4704 andc[.b] imm8,crb blo[.b] pcrel8
4705 andc[.w] imm16,sr bne[.w] pcrel16
4707 bra[.w] pcrel16 beq[.w] pcrel16
4708 bra[.b] pcrel8 beq[.b] pcrel8
4709 bt[.w] pcrel16 bvc[.w] pcrel16
4710 bt[.b] pcrel8 bvc[.b] pcrel8
4711 brn[.w] pcrel16 bvs[.w] pcrel16
4712 brn[.b] pcrel8 bvs[.b] pcrel8
4713 bf[.w] pcrel16 bpl[.w] pcrel16
4714 bf[.b] pcrel8 bpl[.b] pcrel8
4715 bhi[.w] pcrel16 bmi[.w] pcrel16
4716 bhi[.b] pcrel8 bmi[.b] pcrel8
4717 bls[.w] pcrel16 bge[.w] pcrel16
4718 bls[.b] pcrel8 bge[.b] pcrel8
4720 blt[.w] pcrel16 mov[:g][.b] imm8,ea_mem
4721 blt[.b] pcrel8 mov[:g][.w] imm16,ea_mem
4722 bgt[.w] pcrel16 movfpe[.b] ea,rd
4723 bgt[.b] pcrel8 movtpe[.b] rs,ea_noimm
4724 ble[.w] pcrel16 mulxu sz ea,rd
4725 ble[.b] pcrel8 neg sz ea
4726 bclr sz imm4,ea_noimm nop
4727 bclr sz rs,ea_noimm not sz ea
4728 bnot sz imm4,ea_noimm or sz ea,rd
4729 bnot sz rs,ea_noimm orc[.b] imm8,crb
4730 bset sz imm4,ea_noimm orc[.w] imm16,sr
4731 bset sz rs,ea_noimm pjmp abs24
4732 bsr[.b] pcrel8 pjmp @@rd
4733 bsr[.w] pcrel16 pjsr abs24
4734 btst sz imm4,ea_noimm pjsr @@rd
4735 btst sz rs,ea_noimm prtd imm8
4736 clr sz ea prtd imm16
4737 cmp[:e][.b] imm8,rd prts
4738 cmp[:i][.w] imm16,rd rotl sz ea
4739 cmp[:g].b imm8,ea_noimm rotr sz ea
4740 cmp[:g][.w] imm16,ea_noimm rotxl sz ea
4741 Cmp[:g] sz ea,rd rotxr sz ea
4743 divxu sz ea,rd rtd imm16
4745 exts[.b] rd scb/f rs,pcrel8
4746 extu[.b] rd scb/ne rs,pcrel8
4747 jmp @@rd scb/eq rs,pcrel8
4748 jmp @@(imm8,rd) shal sz ea
4749 jmp @@(imm16,rd) shar sz ea
4750 jmp abs16 shll sz ea
4752 jsr @@(imm8,rd) sleep
4753 jsr @@(imm16,rd) stc[.b] crb,ea_noimm
4754 jsr abs16 stc[.w] sr,ea_noimm
4755 ldm @@sp+,(rlist) stm (rlist),@@-sp
4756 link fp,imm8 sub sz ea,rd
4757 link fp,imm16 subs sz ea,rd
4758 mov[:e][.b] imm8,rd subx sz ea,rd
4759 mov[:i][.w] imm16,rd swap[.b] rd
4760 mov[:l][.w] abs8,rd tas[.b] ea
4761 mov[:l].b abs8,rd trapa imm4
4762 mov[:s][.w] rs,abs8 trap/vs
4763 mov[:s].b rs,abs8 tst sz ea
4764 mov[:f][.w] @@(disp8,fp),rd unlk fp
4765 mov[:f][.w] rs,@@(disp8,fp) xch[.w] rs,rd
4766 mov[:f].b @@(disp8,fp),rd xor sz ea,rd
4767 mov[:f].b rs,@@(disp8,fp) xorc.b imm8,crb
4768 mov[:g] sz rs,ea_mem xorc.w imm16,sr
4776 @chapter Hitachi SH Dependent Features
4780 * SH Options:: Options
4781 * SH Syntax:: Syntax
4782 * SH Floating Point:: Floating Point
4783 * SH Directives:: SH Machine Directives
4784 * SH Opcodes:: Opcodes
4790 @cindex SH options (none)
4791 @cindex options, SH (none)
4792 @code{@value{AS}} has no additional command-line options for the Hitachi
4799 * SH-Chars:: Special Characters
4800 * SH-Regs:: Register Names
4801 * SH-Addressing:: Addressing Modes
4805 @subsection Special Characters
4807 @cindex line comment character, SH
4808 @cindex SH line comment character
4809 @samp{!} is the line comment character.
4811 @cindex line separator, SH
4812 @cindex statement separator, SH
4813 @cindex SH line separator
4814 You can use @samp{;} instead of a newline to separate statements.
4816 @cindex symbol names, @samp{$} in
4817 @cindex @code{$} in symbol names
4818 Since @samp{$} has no special meaning, you may use it in symbol names.
4821 @subsection Register Names
4823 @cindex SH registers
4824 @cindex registers, SH
4825 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
4826 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
4827 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
4828 and @samp{r15} to refer to the SH registers.
4830 The SH also has these control registers:
4834 procedure register (holds return address)
4841 high and low multiply accumulator registers
4847 global base register
4850 vector base register (for interrupt vectors)
4854 @subsection Addressing Modes
4856 @cindex addressing modes, SH
4857 @cindex SH addressing modes
4858 @code{@value{AS}} understands the following addressing modes for the SH.
4859 @code{R@var{n}} in the following refers to any of the numbered
4860 registers, but @emph{not} the control registers.
4870 Register indirect with pre-decrement
4873 Register indirect with post-increment
4875 @item @@(@var{disp}, R@var{n})
4876 Register indirect with displacement
4878 @item @@(R0, R@var{n})
4881 @item @@(@var{disp}, GBR)
4888 @itemx @@(@var{disp}, PC)
4889 PC relative address (for branch or for addressing memory). The
4890 @code{@value{AS}} implementation allows you to use the simpler form
4891 @var{addr} anywhere a PC relative address is called for; the alternate
4892 form is supported for compatibility with other assemblers.
4898 @node SH Floating Point
4899 @section Floating Point
4901 @cindex floating point, SH (@sc{ieee})
4902 @cindex SH floating point (@sc{ieee})
4903 The SH family uses @sc{ieee} floating-point numbers.
4906 @section SH Machine Directives
4908 @cindex SH machine directives (none)
4909 @cindex machine directives, SH (none)
4910 @cindex @code{word} directive, SH
4911 @cindex @code{int} directive, SH
4912 @code{@value{AS}} has no machine-dependent directives for the SH.
4917 @cindex SH opcode summary
4918 @cindex opcode summary, SH
4919 @cindex mnemonics, SH
4920 @cindex instruction summary, SH
4921 For detailed information on the SH machine instruction set, see
4922 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
4924 @code{@value{AS}} implements all the standard SH opcodes. No additional
4925 pseudo-instructions are needed on this family. Note, however, that
4926 because @code{@value{AS}} supports a simpler form of PC-relative
4927 addressing, you may simply write (for example)
4934 where other assemblers might require an explicit displacement to
4935 @code{bar} from the program counter:
4938 mov.l @@(@var{disp}, PC)
4941 Here is a summary of SH opcodes:
4946 Rn @r{a numbered register}
4947 Rm @r{another numbered register}
4948 #imm @r{immediate data}
4949 disp @r{displacement}
4950 disp8 @r{8-bit displacement}
4951 disp12 @r{12-bit displacement}
4953 add #imm,Rn lds.l @@Rn+,PR
4954 add Rm,Rn mac.w @@Rm+,@@Rn+
4955 addc Rm,Rn mov #imm,Rn
4956 addv Rm,Rn mov Rm,Rn
4957 and #imm,R0 mov.b Rm,@@(R0,Rn)
4958 and Rm,Rn mov.b Rm,@@-Rn
4959 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
4960 bf disp8 mov.b @@(disp,Rm),R0
4961 bra disp12 mov.b @@(disp,GBR),R0
4962 bsr disp12 mov.b @@(R0,Rm),Rn
4963 bt disp8 mov.b @@Rm+,Rn
4965 clrt mov.b R0,@@(disp,Rm)
4966 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
4967 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
4968 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
4969 cmp/gt Rm,Rn mov.l Rm,@@-Rn
4970 cmp/hi Rm,Rn mov.l Rm,@@Rn
4971 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
4972 cmp/pl Rn mov.l @@(disp,GBR),R0
4973 cmp/pz Rn mov.l @@(disp,PC),Rn
4974 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
4975 div0s Rm,Rn mov.l @@Rm+,Rn
4977 div1 Rm,Rn mov.l R0,@@(disp,GBR)
4978 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
4979 exts.w Rm,Rn mov.w Rm,@@-Rn
4980 extu.b Rm,Rn mov.w Rm,@@Rn
4981 extu.w Rm,Rn mov.w @@(disp,Rm),R0
4982 jmp @@Rn mov.w @@(disp,GBR),R0
4983 jsr @@Rn mov.w @@(disp,PC),Rn
4984 ldc Rn,GBR mov.w @@(R0,Rm),Rn
4985 ldc Rn,SR mov.w @@Rm+,Rn
4986 ldc Rn,VBR mov.w @@Rm,Rn
4987 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
4988 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
4989 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
4991 lds Rn,MACL muls Rm,Rn
4992 lds Rn,PR mulu Rm,Rn
4993 lds.l @@Rn+,MACH neg Rm,Rn
4994 lds.l @@Rn+,MACL negc Rm,Rn
4997 not Rm,Rn stc.l GBR,@@-Rn
4998 or #imm,R0 stc.l SR,@@-Rn
4999 or Rm,Rn stc.l VBR,@@-Rn
5000 or.b #imm,@@(R0,GBR) sts MACH,Rn
5001 rotcl Rn sts MACL,Rn
5003 rotl Rn sts.l MACH,@@-Rn
5004 rotr Rn sts.l MACL,@@-Rn
5009 shar Rn swap.b Rm,Rn
5010 shll Rn swap.w Rm,Rn
5011 shll16 Rn tas.b @@Rn
5013 shll8 Rn tst #imm,R0
5015 shlr16 Rn tst.b #imm,@@(R0,GBR)
5016 shlr2 Rn xor #imm,R0
5018 sleep xor.b #imm,@@(R0,GBR)
5019 stc GBR,Rn xtrct Rm,Rn
5033 @node i960-Dependent
5034 @chapter Intel 80960 Dependent Features
5037 @node Machine Dependencies
5038 @chapter Intel 80960 Dependent Features
5041 @cindex i960 support
5043 * Options-i960:: i960 Command-line Options
5044 * Floating Point-i960:: Floating Point
5045 * Directives-i960:: i960 Machine Directives
5046 * Opcodes for i960:: i960 Opcodes
5049 @c FIXME! Add Syntax sec with discussion of bitfields here, at least so
5050 @c long as they're not turned on for other machines than 960.
5054 @section i960 Command-line Options
5056 @cindex i960 options
5057 @cindex options, i960
5060 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
5061 @cindex i960 architecture options
5062 @cindex architecture options, i960
5063 @cindex @code{-A} options, i960
5064 Select the 80960 architecture. Instructions or features not supported
5065 by the selected architecture cause fatal errors.
5067 @samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
5068 @samp{-AMC}. Synonyms are provided for compatibility with other tools.
5070 If none of these options is specified, @code{@value{AS}} will generate code for any
5071 instruction or feature that is supported by @emph{some} version of the
5072 960 (even if this means mixing architectures!). In principle,
5073 @code{@value{AS}} will attempt to deduce the minimal sufficient processor
5074 type if none is specified; depending on the object code format, the
5075 processor type may be recorded in the object file. If it is critical
5076 that the @code{@value{AS}} output match a specific architecture, specify that
5077 architecture explicitly.
5080 @cindex @code{-b} option, i960
5081 @cindex branch recording, i960
5082 @cindex i960 branch recording
5083 Add code to collect information about conditional branches taken, for
5084 later optimization using branch prediction bits. (The conditional branch
5085 instructions have branch prediction bits in the CA, CB, and CC
5086 architectures.) If @var{BR} represents a conditional branch instruction,
5087 the following represents the code generated by the assembler when
5088 @samp{-b} is specified:
5091 call @var{increment routine}
5092 .word 0 # pre-counter
5094 call @var{increment routine}
5095 .word 0 # post-counter
5098 The counter following a branch records the number of times that branch
5099 was @emph{not} taken; the differenc between the two counters is the
5100 number of times the branch @emph{was} taken.
5102 @cindex @code{gbr960}, i960 postprocessor
5103 @cindex branch statistics table, i960
5104 A table of every such @code{Label} is also generated, so that the
5105 external postprocessor @code{gbr960} (supplied by Intel) can locate all
5106 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
5107 this is a local symbol to permit collecting statistics for many separate
5108 object files. The table is word aligned, and begins with a two-word
5109 header. The first word, initialized to 0, is used in maintaining linked
5110 lists of branch tables. The second word is a count of the number of
5111 entries in the table, which follow immediately: each is a word, pointing
5112 to one of the labels illustrated above.
5116 @c END TEXI2ROFF-KILL
5118 +------------+------------+------------+ ... +------------+
5120 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
5122 +------------+------------+------------+ ... +------------+
5124 __BRANCH_TABLE__ layout
5130 \line{\leftskip=0pt\hskip\tableindent
5131 \boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
5132 *BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
5133 \centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
5135 @c END TEXI2ROFF-KILL
5137 The first word of the header is used to locate multiple branch tables,
5138 since each object file may contain one. Normally the links are
5139 maintained with a call to an initialization routine, placed at the
5140 beginning of each function in the file. The GNU C compiler will
5141 generate these calls automatically when you give it a @samp{-b} option.
5142 For further details, see the documentation of @samp{gbr960}.
5145 @cindex @code{-norelax} option, i960
5146 Normally, Compare-and-Branch instructions with targets that require
5147 displacements greater than 13 bits (or that have external targets) are
5148 replaced with the corresponding compare (or @samp{chkbit}) and branch
5149 instructions. You can use the @samp{-norelax} option to specify that
5150 @code{@value{AS}} should generate errors instead, if the target displacement
5151 is larger than 13 bits.
5153 This option does not affect the Compare-and-Jump instructions; the code
5154 emitted for them is @emph{always} adjusted when necessary (depending on
5155 displacement size), regardless of whether you use @samp{-norelax}.
5158 @node Floating Point-i960
5159 @section Floating Point
5161 @cindex floating point, i960 (@sc{ieee})
5162 @cindex i960 floating point (@sc{ieee})
5163 @code{@value{AS}} generates @sc{ieee} floating-point numbers for the directives
5164 @samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
5166 @node Directives-i960
5167 @section i960 Machine Directives
5169 @cindex machine directives, i960
5170 @cindex i960 machine directives
5173 @cindex @code{bss} directive, i960
5174 @item .bss @var{symbol}, @var{length}, @var{align}
5175 Reserve @var{length} bytes in the bss section for a local @var{symbol},
5176 aligned to the power of two specified by @var{align}. @var{length} and
5177 @var{align} must be positive absolute expressions. This directive
5178 differs from @samp{.lcomm} only in that it permits you to specify
5179 an alignment. @xref{Lcomm,,@code{.lcomm}}.
5183 @item .extended @var{flonums}
5184 @cindex @code{extended} directive, i960
5185 @code{.extended} expects zero or more flonums, separated by commas; for
5186 each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
5187 floating-point number.
5189 @item .leafproc @var{call-lab}, @var{bal-lab}
5190 @cindex @code{leafproc} directive, i960
5191 You can use the @samp{.leafproc} directive in conjunction with the
5192 optimized @code{callj} instruction to enable faster calls of leaf
5193 procedures. If a procedure is known to call no other procedures, you
5194 may define an entry point that skips procedure prolog code (and that does
5195 not depend on system-supplied saved context), and declare it as the
5196 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
5197 entry point that goes through the normal prolog, you can specify that
5198 entry point as @var{call-lab}.
5200 A @samp{.leafproc} declaration is meant for use in conjunction with the
5201 optimized call instruction @samp{callj}; the directive records the data
5202 needed later to choose between converting the @samp{callj} into a
5203 @code{bal} or a @code{call}.
5205 @var{call-lab} is optional; if only one argument is present, or if the
5206 two arguments are identical, the single argument is assumed to be the
5207 @code{bal} entry point.
5209 @item .sysproc @var{name}, @var{index}
5210 @cindex @code{sysproc} directive, i960
5211 The @samp{.sysproc} directive defines a name for a system procedure.
5212 After you define it using @samp{.sysproc}, you can use @var{name} to
5213 refer to the system procedure identified by @var{index} when calling
5214 procedures with the optimized call instruction @samp{callj}.
5216 Both arguments are required; @var{index} must be between 0 and 31
5220 @node Opcodes for i960
5221 @section i960 Opcodes
5223 @cindex opcodes, i960
5224 @cindex i960 opcodes
5225 All Intel 960 machine instructions are supported;
5226 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
5227 selecting the instruction subset for a particular 960
5228 architecture.@refill
5230 Some opcodes are processed beyond simply emitting a single corresponding
5231 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
5232 instructions with target displacements larger than 13 bits.
5235 * callj-i960:: @code{callj}
5236 * Compare-and-branch-i960:: Compare-and-Branch
5240 @subsection @code{callj}
5242 @cindex @code{callj}, i960 pseudo-opcode
5243 @cindex i960 @code{callj} pseudo-opcode
5244 You can write @code{callj} to have the assembler or the linker determine
5245 the most appropriate form of subroutine call: @samp{call},
5246 @samp{bal}, or @samp{calls}. If the assembly source contains
5247 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
5248 defining the operand---then @code{@value{AS}} will translate the
5249 @code{callj}; if not, it will simply emit the @code{callj}, leaving it
5250 for the linker to resolve.
5252 @node Compare-and-branch-i960
5253 @subsection Compare-and-Branch
5255 @cindex i960 compare/branch instructions
5256 @cindex compare/branch instructions, i960
5257 The 960 architectures provide combined Compare-and-Branch instructions
5258 that permit you to store the branch target in the lower 13 bits of the
5259 instruction word itself. However, if you specify a branch target far
5260 enough away that its address won't fit in 13 bits, the assembler can
5261 either issue an error, or convert your Compare-and-Branch instruction
5262 into separate instructions to do the compare and the branch.
5264 @cindex compare and jump expansions, i960
5265 @cindex i960 compare and jump expansions
5266 Whether @code{@value{AS}} gives an error or expands the instruction depends
5267 on two choices you can make: whether you use the @samp{-norelax} option,
5268 and whether you use a ``Compare and Branch'' instruction or a ``Compare
5269 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
5270 expanded if necessary; the ``Branch'' instructions are expanded when
5271 necessary @emph{unless} you specify @code{-norelax}---in which case
5272 @code{@value{AS}} gives an error instead.
5274 These are the Compare-and-Branch instructions, their ``Jump'' variants,
5275 and the instruction pairs they may expand into:
5279 @c END TEXI2ROFF-KILL
5282 Branch Jump Expanded to
5283 ------ ------ ------------
5286 cmpibe cmpije cmpi; be
5287 cmpibg cmpijg cmpi; bg
5288 cmpibge cmpijge cmpi; bge
5289 cmpibl cmpijl cmpi; bl
5290 cmpible cmpijle cmpi; ble
5291 cmpibno cmpijno cmpi; bno
5292 cmpibne cmpijne cmpi; bne
5293 cmpibo cmpijo cmpi; bo
5294 cmpobe cmpoje cmpo; be
5295 cmpobg cmpojg cmpo; bg
5296 cmpobge cmpojge cmpo; bge
5297 cmpobl cmpojl cmpo; bl
5298 cmpoble cmpojle cmpo; ble
5299 cmpobne cmpojne cmpo; bne
5305 \halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
5306 \omit{\hfil\it Compare and\hfil}\span\omit&\cr
5307 {\it Branch}&{\it Jump}&{\it Expanded to}\cr
5308 bbc& & chkbit; bno\cr
5309 bbs& & chkbit; bo\cr
5310 cmpibe& cmpije& cmpi; be\cr
5311 cmpibg& cmpijg& cmpi; bg\cr
5312 cmpibge& cmpijge& cmpi; bge\cr
5313 cmpibl& cmpijl& cmpi; bl\cr
5314 cmpible& cmpijle& cmpi; ble\cr
5315 cmpibno& cmpijno& cmpi; bno\cr
5316 cmpibne& cmpijne& cmpi; bne\cr
5317 cmpibo& cmpijo& cmpi; bo\cr
5318 cmpobe& cmpoje& cmpo; be\cr
5319 cmpobg& cmpojg& cmpo; bg\cr
5320 cmpobge& cmpojge& cmpo; bge\cr
5321 cmpobl& cmpojl& cmpo; bl\cr
5322 cmpoble& cmpojle& cmpo; ble\cr
5323 cmpobne& cmpojne& cmpo; bne\cr}
5325 @c END TEXI2ROFF-KILL
5331 @node M68K-Dependent
5332 @chapter M680x0 Dependent Features
5335 @node Machine Dependencies
5336 @chapter M680x0 Dependent Features
5339 @cindex M680x0 support
5341 * M68K-Opts:: M680x0 Options
5342 * M68K-Syntax:: Syntax
5343 * M68K-Float:: Floating Point
5344 * M68K-Directives:: 680x0 Machine Directives
5345 * M68K-opcodes:: Opcodes
5349 @section M680x0 Options
5351 @cindex options, M680x0
5352 @cindex M680x0 options
5353 The Motorola 680x0 version of @code{@value{AS}} has two machine dependent options.
5354 One shortens undefined references from 32 to 16 bits, while the
5355 other is used to tell @code{@value{AS}} what kind of machine it is
5358 @cindex @code{-l} option, M680x0
5359 You can use the @kbd{-l} option to shorten the size of references to
5360 undefined symbols. If the @kbd{-l} option is not given, references to
5361 undefined symbols will be a full long (32 bits) wide. (Since @code{@value{AS}}
5362 cannot know where these symbols will end up, @code{@value{AS}} can only allocate
5363 space for the linker to fill in later. Since @code{@value{AS}} doesn't know how
5364 far away these symbols will be, it allocates as much space as it can.)
5365 If this option is given, the references will only be one word wide (16
5366 bits). This may be useful if you want the object file to be as small as
5367 possible, and you know that the relevant symbols will be less than 17
5370 @cindex @code{-m68000} and related options
5371 @cindex architecture options, M680x0
5372 @cindex M680x0 architecture options
5373 The 680x0 version of @code{@value{AS}} is most frequently used to assemble
5374 programs for the Motorola MC68020 microprocessor. Occasionally it is
5375 used to assemble programs for the mostly similar, but slightly different
5376 MC68000 or MC68010 microprocessors. You can give @code{@value{AS}} the options
5377 @samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
5378 @samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
5384 @cindex M680x0 syntax
5385 @cindex syntax, M680x0
5386 @cindex M680x0 size modifiers
5387 @cindex size modifiers, M680x0
5388 The 680x0 version of @code{@value{AS}} uses syntax similar to the Sun assembler.
5389 Size modifiers are appended directly to the end of the opcode without an
5390 intervening period. For example, write @samp{movl} rather than
5394 If @code{@value{AS}} is compiled with SUN_ASM_SYNTAX defined, it will also allow
5395 Sun-style local labels of the form @samp{1$} through @samp{$9}.
5398 In the following table @dfn{apc} stands for any of the address
5399 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
5400 Program Counter (@samp{pc}), or the zero-address relative to the
5401 program counter (@samp{zpc}).
5403 @cindex M680x0 addressing modes
5404 @cindex addressing modes, M680x0
5405 The following addressing modes are understood:
5408 @samp{#@var{digits}}
5411 @samp{d0} through @samp{d7}
5413 @item Address Register
5414 @samp{a0} through @samp{a7}
5416 @item Address Register Indirect
5417 @samp{a0@@} through @samp{a7@@}
5419 @item Address Register Postincrement
5420 @samp{a0@@+} through @samp{a7@@+}
5422 @item Address Register Predecrement
5423 @samp{a0@@-} through @samp{a7@@-}
5425 @item Indirect Plus Offset
5426 @samp{@var{apc}@@(@var{digits})}
5429 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5431 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
5434 @samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5436 or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
5439 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5441 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5443 @item Memory Indirect
5444 @samp{@var{apc}@@(@var{digits})@@(@var{digits})}
5447 @samp{@var{symbol}}, or @samp{@var{digits}}
5449 @c pesch@cygnus.com: gnu, rich concur the following needs careful
5450 @c research before documenting.
5451 , or either of the above followed
5452 by @samp{:b}, @samp{:w}, or @samp{:l}.
5456 For some configurations, especially those where the compiler normally
5457 does not prepend an underscore to the names of user variables, the
5458 assembler requires a @samp{%} before any use of a register name. This
5459 is intended to let the assembler distinguish between user variables and
5460 registers named @samp{a0} through @samp{a7}, et cetera. The @samp{%} is
5461 always accepted, but is only required for some configurations, notably
5465 @section Floating Point
5467 @cindex floating point, M680x0
5468 @cindex M680x0 floating point
5469 @c FIXME is this "not too well tested" crud STILL true?
5470 The floating point code is not too well tested, and may have
5473 Packed decimal (P) format floating literals are not supported.
5474 Feel free to add the code!
5476 The floating point formats generated by directives are these.
5480 @cindex @code{float} directive, M680x0
5481 @code{Single} precision floating point constants.
5484 @cindex @code{double} directive, M680x0
5485 @code{Double} precision floating point constants.
5488 There is no directive to produce regions of memory holding
5489 extended precision numbers, however they can be used as
5490 immediate operands to floating-point instructions. Adding a
5491 directive to create extended precision numbers would not be
5492 hard, but it has not yet seemed necessary.
5494 @node M68K-Directives
5495 @section 680x0 Machine Directives
5497 @cindex M680x0 directives
5498 @cindex directives, M680x0
5499 In order to be compatible with the Sun assembler the 680x0 assembler
5500 understands the following directives.
5504 @cindex @code{data1} directive, M680x0
5505 This directive is identical to a @code{.data 1} directive.
5508 @cindex @code{data2} directive, M680x0
5509 This directive is identical to a @code{.data 2} directive.
5512 @cindex @code{even} directive, M680x0
5513 This directive is identical to a @code{.align 1} directive.
5514 @c Is this true? does it work???
5517 @cindex @code{skip} directive, M680x0
5518 This directive is identical to a @code{.space} directive.
5524 @cindex M680x0 opcodes
5525 @cindex opcodes, M680x0
5526 @cindex instruction set, M680x0
5527 @c pesch@cygnus.com: I don't see any point in the following
5528 @c paragraph. Bugs are bugs; how does saying this
5531 Danger: Several bugs have been found in the opcode table (and
5532 fixed). More bugs may exist. Be careful when using obscure
5537 * M68K-Branch:: Branch Improvement
5538 * M68K-Chars:: Special Characters
5542 @subsection Branch Improvement
5544 @cindex pseudo-opcodes, M680x0
5545 @cindex M680x0 pseudo-opcodes
5546 @cindex branch improvement, M680x0
5547 @cindex M680x0 branch improvement
5548 Certain pseudo opcodes are permitted for branch instructions.
5549 They expand to the shortest branch instruction that will reach the
5550 target. Generally these mnemonics are made by substituting @samp{j} for
5551 @samp{b} at the start of a Motorola mnemonic.
5553 The following table summarizes the pseudo-operations. A @code{*} flags
5554 cases that are more fully described after the table:
5558 +-------------------------------------------------
5560 Pseudo-Op |BYTE WORD LONG LONG non-PC relative
5561 +-------------------------------------------------
5562 jbsr |bsrs bsr bsrl jsr jsr
5563 jra |bras bra bral jmp jmp
5564 * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
5565 * dbXX |dbXX dbXX dbXX; bra; jmpl
5566 * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
5569 NX: negative of condition XX
5572 @center @code{*}---see full description below
5577 These are the simplest jump pseudo-operations; they always map to one
5578 particular machine instruction, depending on the displacement to the
5582 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
5583 where @var{XX} is a conditional branch or condition-code test. The full
5584 list of pseudo-ops in this family is:
5586 jhi jls jcc jcs jne jeq jvc
5587 jvs jpl jmi jge jlt jgt jle
5590 For the cases of non-PC relative displacements and long displacements on
5591 the 68000 or 68010, @code{@value{AS}} will issue a longer code fragment in terms of
5592 @var{NX}, the opposite condition to @var{XX}. For example, for the
5593 non-PC relative case:
5605 The full family of pseudo-operations covered here is
5607 dbhi dbls dbcc dbcs dbne dbeq dbvc
5608 dbvs dbpl dbmi dbge dblt dbgt dble
5612 Other than for word and byte displacements, when the source reads
5613 @samp{db@var{XX} foo}, @code{@value{AS}} will emit
5622 This family includes
5624 fjne fjeq fjge fjlt fjgt fjle fjf
5625 fjt fjgl fjgle fjnge fjngl fjngle fjngt
5626 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
5627 fjor fjseq fjsf fjsne fjst fjueq fjuge
5628 fjugt fjule fjult fjun
5631 For branch targets that are not PC relative, @code{@value{AS}} emits
5637 when it encounters @samp{fj@var{XX} foo}.
5642 @subsection Special Characters
5644 @cindex special characters, M680x0
5645 @cindex M680x0 immediate character
5646 @cindex immediate character, M680x0
5647 @cindex M680x0 line comment character
5648 @cindex line comment character, M680x0
5649 @cindex comments, M680x0
5650 The immediate character is @samp{#} for Sun compatibility. The
5651 line-comment character is @samp{|}. If a @samp{#} appears at the
5652 beginning of a line, it is treated as a comment unless it looks like
5653 @samp{# line file}, in which case it is treated normally.
5657 @c FIXME! Stop ignoring when filled in.
5662 The 32x32 version of @code{@value{AS}} accepts a @kbd{-m32032} option to
5663 specify thiat it is compiling for a 32032 processor, or a
5664 @kbd{-m32532} to specify that it is compiling for a 32532 option.
5665 The default (if neither is specified) is chosen when the assembler
5669 I don't know anything about the 32x32 syntax assembled by
5670 @code{@value{AS}}. Someone who undersands the processor (I've never seen
5671 one) and the possible syntaxes should write this section.
5673 @section Floating Point
5674 The 32x32 uses @sc{ieee} floating point numbers, but @code{@value{AS}}
5675 will only create single or double precision values. I don't know if the
5676 32x32 understands extended precision numbers.
5678 @section 32x32 Machine Directives
5679 The 32x32 has no machine dependent directives.
5685 @node Sparc-Dependent
5686 @chapter SPARC Dependent Features
5689 @node Machine Dependencies
5690 @chapter SPARC Dependent Features
5693 @cindex SPARC support
5695 * Sparc-Opts:: Options
5696 * Sparc-Float:: Floating Point
5697 * Sparc-Directives:: Sparc Machine Directives
5703 @cindex options for SPARC
5704 @cindex SPARC options
5705 @cindex architectures, SPARC
5706 @cindex SPARC architectures
5707 The SPARC chip family includes several successive levels (or other
5708 variants) of chip, using the same core instruction set, but including
5709 a few additional instructions at each level.
5711 By default, @code{@value{AS}} assumes the core instruction set (SPARC
5712 v6), but ``bumps'' the architecture level as needed: it switches to
5713 successively higher architectures as it encounters instructions that
5714 only exist in the higher levels.
5717 @item -Av6 | -Av7 | -Av8 | -Asparclite
5722 Use one of the @samp{-A} options to select one of the SPARC
5723 architectures explicitly. If you select an architecture explicitly,
5724 @code{@value{AS}} reports a fatal error if it encounters an instruction
5725 or feature requiring a higher level.
5728 Permit the assembler to ``bump'' the architecture level as required, but
5729 warn whenever it is necessary to switch to another level.
5733 @c FIXME: (sparc) Fill in "syntax" section!
5734 @c subsection syntax
5735 I don't know anything about Sparc syntax. Someone who does
5736 will have to write this section.
5740 @section Floating Point
5742 @cindex floating point, SPARC (@sc{ieee})
5743 @cindex SPARC floating point (@sc{ieee})
5744 The Sparc uses @sc{ieee} floating-point numbers.
5746 @node Sparc-Directives
5747 @section Sparc Machine Directives
5749 @cindex SPARC machine directives
5750 @cindex machine directives, SPARC
5751 The Sparc version of @code{@value{AS}} supports the following additional
5756 @cindex @code{common} directive, SPARC
5757 This must be followed by a symbol name, a positive number, and
5758 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
5759 syntax is different.
5762 @cindex @code{half} directive, SPARC
5763 This is functionally identical to @code{.short}.
5766 @cindex @code{proc} directive, SPARC
5767 This directive is ignored. Any text following it on the same
5768 line is also ignored.
5771 @cindex @code{reserve} directive, SPARC
5772 This must be followed by a symbol name, a positive number, and
5773 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
5774 syntax is different.
5777 @cindex @code{seg} directive, SPARC
5778 This must be followed by @code{"text"}, @code{"data"}, or
5779 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
5783 @cindex @code{skip} directive, SPARC
5784 This is functionally identical to the @code{.space} directive.
5787 @cindex @code{word} directive, SPARC
5788 On the Sparc, the .word directive produces 32 bit values,
5789 instead of the 16 bit values it produces on many other machines.
5796 @node i386-Dependent
5797 @chapter 80386 Dependent Features
5800 @node Machine Dependencies
5801 @chapter 80386 Dependent Features
5804 @cindex i386 support
5805 @cindex i80306 support
5807 * i386-Options:: Options
5808 * i386-Syntax:: AT&T Syntax versus Intel Syntax
5809 * i386-Opcodes:: Opcode Naming
5810 * i386-Regs:: Register Naming
5811 * i386-prefixes:: Opcode Prefixes
5812 * i386-Memory:: Memory References
5813 * i386-jumps:: Handling of Jump Instructions
5814 * i386-Float:: Floating Point
5815 * i386-Notes:: Notes
5821 @cindex options for i386 (none)
5822 @cindex i386 options (none)
5823 The 80386 has no machine dependent options.
5826 @section AT&T Syntax versus Intel Syntax
5828 @cindex i386 syntax compatibility
5829 @cindex syntax compatibility, i386
5830 In order to maintain compatibility with the output of @code{@value{GCC}},
5831 @code{@value{AS}} supports AT&T System V/386 assembler syntax. This is quite
5832 different from Intel syntax. We mention these differences because
5833 almost all 80386 documents used only Intel syntax. Notable differences
5834 between the two syntaxes are:
5838 @cindex immediate operands, i386
5839 @cindex i386 immediate operands
5840 @cindex register operands, i386
5841 @cindex i386 register operands
5842 @cindex jump/call operands, i386
5843 @cindex i386 jump/call operands
5844 @cindex operand delimiters, i386
5845 AT&T immediate operands are preceded by @samp{$}; Intel immediate
5846 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
5847 AT&T register operands are preceded by @samp{%}; Intel register operands
5848 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
5849 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
5852 @cindex i386 source, destination operands
5853 @cindex source, destination operands; i386
5854 AT&T and Intel syntax use the opposite order for source and destination
5855 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
5856 @samp{source, dest} convention is maintained for compatibility with
5857 previous Unix assemblers.
5860 @cindex opcode suffixes, i386
5861 @cindex sizes operands, i386
5862 @cindex i386 size suffixes
5863 In AT&T syntax the size of memory operands is determined from the last
5864 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
5865 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
5866 memory references. Intel syntax accomplishes this by prefixes memory
5867 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
5868 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
5869 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
5872 @cindex return instructions, i386
5873 @cindex i386 jump, call, return
5874 Immediate form long jumps and calls are
5875 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
5877 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
5879 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
5880 @samp{ret far @var{stack-adjust}}.
5883 @cindex sections, i386
5884 @cindex i386 sections
5885 The AT&T assembler does not provide support for multiple section
5886 programs. Unix style systems expect all programs to be single sections.
5890 @section Opcode Naming
5892 @cindex i386 opcode naming
5893 @cindex opcode naming, i386
5894 Opcode names are suffixed with one character modifiers which specify the
5895 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
5896 byte, word, and long operands. If no suffix is specified by an
5897 instruction and it contains no memory operands then @code{@value{AS}} tries to
5898 fill in the missing suffix based on the destination register operand
5899 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
5900 to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
5901 @samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
5902 assembler which assumes that a missing opcode suffix implies long
5903 operand size. (This incompatibility does not affect compiler output
5904 since compilers always explicitly specify the opcode suffix.)
5906 Almost all opcodes have the same names in AT&T and Intel format. There
5907 are a few exceptions. The sign extend and zero extend instructions need
5908 two sizes to specify them. They need a size to sign/zero extend
5909 @emph{from} and a size to zero extend @emph{to}. This is accomplished
5910 by using two opcode suffixes in AT&T syntax. Base names for sign extend
5911 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
5912 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
5913 suffixes are tacked on to this base name, the @emph{from} suffix before
5914 the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
5915 ``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
5916 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
5917 and @samp{wl} (from word to long).
5919 @cindex conversion instructions, i386
5920 @cindex i386 conversion instructions
5921 The Intel-syntax conversion instructions
5925 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
5928 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
5931 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
5934 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
5938 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
5939 AT&T naming. @code{@value{AS}} accepts either naming for these instructions.
5941 @cindex jump instructions, i386
5942 @cindex call instructions, i386
5943 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
5944 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
5948 @section Register Naming
5950 @cindex i386 registers
5951 @cindex registers, i386
5952 Register operands are always prefixes with @samp{%}. The 80386 registers
5957 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
5958 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
5959 frame pointer), and @samp{%esp} (the stack pointer).
5962 the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
5963 @samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
5966 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
5967 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
5968 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
5969 @samp{%cx}, and @samp{%dx})
5972 the 6 section registers @samp{%cs} (code section), @samp{%ds}
5973 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
5977 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
5981 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
5982 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
5985 the 2 test registers @samp{%tr6} and @samp{%tr7}.
5988 the 8 floating point register stack @samp{%st} or equivalently
5989 @samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
5990 @samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
5994 @section Opcode Prefixes
5996 @cindex i386 opcode prefixes
5997 @cindex opcode prefixes, i386
5998 @cindex prefixes, i386
5999 Opcode prefixes are used to modify the following opcode. They are used
6000 to repeat string instructions, to provide section overrides, to perform
6001 bus lock operations, and to give operand and address size (16-bit
6002 operands are specified in an instruction by prefixing what would
6003 normally be 32-bit operands with a ``operand size'' opcode prefix).
6004 Opcode prefixes are usually given as single-line instructions with no
6005 operands, and must directly precede the instruction they act upon. For
6006 example, the @samp{scas} (scan string) instruction is repeated with:
6012 Here is a list of opcode prefixes:
6016 @cindex section override prefixes, i386
6017 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
6018 @samp{fs}, @samp{gs}. These are automatically added by specifying
6019 using the @var{section}:@var{memory-operand} form for memory references.
6022 @cindex size prefixes, i386
6023 Operand/Address size prefixes @samp{data16} and @samp{addr16}
6024 change 32-bit operands/addresses into 16-bit operands/addresses. Note
6025 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
6026 are not supported (yet).
6029 @cindex bus lock prefixes, i386
6030 @cindex inhibiting interrupts, i386
6031 The bus lock prefix @samp{lock} inhibits interrupts during
6032 execution of the instruction it precedes. (This is only valid with
6033 certain instructions; see a 80386 manual for details).
6036 @cindex coprocessor wait, i386
6037 The wait for coprocessor prefix @samp{wait} waits for the
6038 coprocessor to complete the current instruction. This should never be
6039 needed for the 80386/80387 combination.
6042 @cindex repeat prefixes, i386
6043 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
6044 to string instructions to make them repeat @samp{%ecx} times.
6048 @section Memory References
6050 @cindex i386 memory references
6051 @cindex memory references, i386
6052 An Intel syntax indirect memory reference of the form
6055 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
6059 is translated into the AT&T syntax
6062 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
6066 where @var{base} and @var{index} are the optional 32-bit base and
6067 index registers, @var{disp} is the optional displacement, and
6068 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
6069 to calculate the address of the operand. If no @var{scale} is
6070 specified, @var{scale} is taken to be 1. @var{section} specifies the
6071 optional section register for the memory operand, and may override the
6072 default section register (see a 80386 manual for section register
6073 defaults). Note that section overrides in AT&T syntax @emph{must} have
6074 be preceded by a @samp{%}. If you specify a section override which
6075 coincides with the default section register, @code{@value{AS}} will @emph{not}
6076 output any section register override prefixes to assemble the given
6077 instruction. Thus, section overrides can be specified to emphasize which
6078 section register is used for a given memory operand.
6080 Here are some examples of Intel and AT&T style memory references:
6083 @item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
6084 @var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
6085 missing, and the default section is used (@samp{%ss} for addressing with
6086 @samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
6088 @item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
6089 @var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
6090 @samp{foo}. All other fields are missing. The section register here
6091 defaults to @samp{%ds}.
6093 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
6094 This uses the value pointed to by @samp{foo} as a memory operand.
6095 Note that @var{base} and @var{index} are both missing, but there is only
6096 @emph{one} @samp{,}. This is a syntactic exception.
6098 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
6099 This selects the contents of the variable @samp{foo} with section
6100 register @var{section} being @samp{%gs}.
6103 Absolute (as opposed to PC relative) call and jump operands must be
6104 prefixed with @samp{*}. If no @samp{*} is specified, @code{@value{AS}} will
6105 always choose PC relative addressing for jump/call labels.
6107 Any instruction that has a memory operand @emph{must} specify its size (byte,
6108 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
6112 @section Handling of Jump Instructions
6114 @cindex jump optimization, i386
6115 @cindex i386 jump optimization
6116 Jump instructions are always optimized to use the smallest possible
6117 displacements. This is accomplished by using byte (8-bit) displacement
6118 jumps whenever the target is sufficiently close. If a byte displacement
6119 is insufficient a long (32-bit) displacement is used. We do not support
6120 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
6121 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
6122 @samp{%eip} to 16 bits after the word displacement is added.
6124 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
6125 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
6126 byte displacements, so that it is possible that use of these
6127 instructions (@code{@value{GCC}} does not use them) will cause the assembler to
6128 print an error message (and generate incorrect code). The AT&T 80386
6129 assembler tries to get around this problem by expanding @samp{jcxz foo} to
6138 @section Floating Point
6140 @cindex i386 floating point
6141 @cindex floating point, i386
6142 All 80387 floating point types except packed BCD are supported.
6143 (BCD support may be added without much difficulty). These data
6144 types are 16-, 32-, and 64- bit integers, and single (32-bit),
6145 double (64-bit), and extended (80-bit) precision floating point.
6146 Each supported type has an opcode suffix and a constructor
6147 associated with it. Opcode suffixes specify operand's data
6148 types. Constructors build these data types into memory.
6152 @cindex @code{float} directive, i386
6153 @cindex @code{single} directive, i386
6154 @cindex @code{double} directive, i386
6155 @cindex @code{tfloat} directive, i386
6156 Floating point constructors are @samp{.float} or @samp{.single},
6157 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
6158 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
6159 @samp{t} stands for temporary real, and that the 80387 only supports
6160 this format via the @samp{fldt} (load temporary real to stack top) and
6161 @samp{fstpt} (store temporary real and pop stack) instructions.
6164 @cindex @code{word} directive, i386
6165 @cindex @code{long} directive, i386
6166 @cindex @code{int} directive, i386
6167 @cindex @code{quad} directive, i386
6168 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
6169 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
6170 opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
6171 (quad). As with the temporary real format the 64-bit @samp{q} format is
6172 only present in the @samp{fildq} (load quad integer to stack top) and
6173 @samp{fistpq} (store quad integer and pop stack) instructions.
6176 Register to register operations do not require opcode suffixes,
6177 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
6179 @cindex i386 @code{fwait} instruction
6180 @cindex @code{fwait instruction}, i386
6181 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
6182 instructions are almost never needed (this is not the case for the
6183 80286/80287 and 8086/8087 combinations). Therefore, @code{@value{AS}} suppresses
6184 the @samp{fwait} instruction whenever it is implicitly selected by one
6185 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
6186 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
6187 instructions are made equivalent to @samp{f@dots{}} instructions. If
6188 @samp{fwait} is desired it must be explicitly coded.
6193 @cindex i386 @code{mul}, @code{imul} instructions
6194 @cindex @code{mul} instruction, i386
6195 @cindex @code{imul} instruction, i386
6196 There is some trickery concerning the @samp{mul} and @samp{imul}
6197 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
6198 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
6199 for @samp{imul}) can be output only in the one operand form. Thus,
6200 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
6201 the expanding multiply would clobber the @samp{%edx} register, and this
6202 would confuse @code{@value{GCC}} output. Use @samp{imul %ebx} to get the
6203 64-bit product in @samp{%edx:%eax}.
6205 We have added a two operand form of @samp{imul} when the first operand
6206 is an immediate mode expression and the second operand is a register.
6207 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
6208 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
6215 @node Z8000-Dependent
6216 @chapter Z8000 Dependent Features
6219 @node Machine Dependencies
6220 @chapter Z8000 Dependent Features
6223 @cindex Z8000 support
6224 The Z8000 @value{AS} supports both members of the Z8000 family: the
6225 unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with
6228 When the assembler is in unsegmented mode (specified with the
6229 @code{unsegm} directive), an address will take up one word (16 bit)
6230 sized register. When the assembler is in segmented mode (specified with
6231 the @code{segm} directive), a 24-bit address takes up a long (32 bit)
6232 register. @xref{Z8000 Directives,,Assembler Directives for the Z8000},
6233 for a list of other Z8000 specific assembler directives.
6236 * Z8000 Options:: No special command-line options for Z8000
6237 * Z8000 Syntax:: Assembler syntax for the Z8000
6238 * Z8000 Directives:: Special directives for the Z8000
6239 * Z8000 Opcodes:: Opcodes
6245 @cindex Z8000 options
6246 @cindex options, Z8000
6247 @code{@value{AS}} has no additional command-line options for the Zilog
6253 * Z8000-Chars:: Special Characters
6254 * Z8000-Regs:: Register Names
6255 * Z8000-Addressing:: Addressing Modes
6259 @subsection Special Characters
6261 @cindex line comment character, Z8000
6262 @cindex Z8000 line comment character
6263 @samp{!} is the line comment character.
6265 @cindex line separator, Z8000
6266 @cindex statement separator, Z8000
6267 @cindex Z8000 line separator
6268 You can use @samp{;} instead of a newline to separate statements.
6271 @subsection Register Names
6273 @cindex Z8000 registers
6274 @cindex registers, Z8000
6275 The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer
6276 to different sized groups of registers by register number, with the
6277 prefix @samp{r} for 16 bit registers, @samp{rr} for 32 bit registers and
6278 @samp{rq} for 64 bit registers. You can also refer to the contents of
6279 the first eight (of the sixteen 16 bit registers) by bytes. They are
6280 named @samp{r@var{n}h} and @samp{r@var{n}l}.
6283 @exdent @emph{byte registers}
6284 r0l r0h r1h r1l r2h r2l r3h r3l
6285 r4h r4l r5h r5l r6h r6l r7h r7l
6287 @exdent @emph{word registers}
6288 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
6290 @exdent @emph{long word registers}
6291 rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14
6293 @exdent @emph{quad word registers}
6297 @node Z8000-Addressing
6298 @subsection Addressing Modes
6300 @cindex addressing modes, Z8000
6301 @cindex Z800 addressing modes
6302 @value{AS} understands the following addressing modes for the Z8000:
6312 Direct: the 16 bit or 24 bit address (depending on whether the assembler
6313 is in segmented or unsegmented mode) of the operand is in the instruction.
6315 @item address(r@var{n})
6316 Indexed: the 16 or 24 bit address is added to the 16 bit register to produce
6317 the final address in memory of the operand.
6319 @item r@var{n}(#@var{imm})
6320 Base Address: the 16 or 24 bit register is added to the 16 bit sign
6321 extended immediate displacement to produce the final address in memory
6324 @item r@var{n}(r@var{m})
6325 Base Index: the 16 or 24 bit register r@var{n} is added to the sign
6326 extended 16 bit index register r@var{m} to produce the final address in
6327 memory of the operand.
6330 Immediate data @var{xx}.
6333 @node Z8000 Directives
6334 @section Assembler Directives for the Z8000
6336 @cindex Z8000 directives
6337 @cindex directives, Z8000
6338 The Z8000 port of @value{AS} includes these additional assembler directives,
6339 for compatibility with other Z8000 assemblers. As shown, these do not
6340 begin with @samp{.} (unlike the ordinary @value{AS} directives).
6345 Generates code for the segmented Z8001.
6349 Generates code for the unsegmented Z8002.
6353 Synonym for @code{.file}
6357 Synonum for @code{.global}
6361 Synonym for @code{.word}
6365 Synonym for @code{.long}
6369 Synonym for @code{.byte}
6373 Assemble a string. @code{sval} expects one string literal, delimited by
6374 single quotes. It assembles each byte of the string into consecutive
6375 addresses. You can use the escape sequence @samp{%@var{xx}} (where
6376 @var{xx} represents a two-digit hexadecimal number) to represent the
6377 character whose @sc{ascii} value is @var{xx}. Use this feature to
6378 describe single quote and other characters that may not appear in string
6379 literals as themselves. For example, the C statement @w{@samp{char *a =
6380 "he said \"it's 50% off\"";}} is represented in Z8000 assembly language
6381 (shown with the assembler output in hex at the left) as
6385 @let@nonarrowing=@comment
6388 68652073 sval 'he said %22it%27s 50%25 off%22%00'
6401 synonym for @code{.section}
6405 synonym for @code{.space}
6409 synonym for @code{.align 1}
6415 @cindex Z8000 opcode summary
6416 @cindex opcode summary, Z8000
6417 @cindex mnemonics, Z8000
6418 @cindex instruction summary, Z8000
6419 For detailed information on the Z8000 machine instruction set, see
6420 @cite{Z8000 Technical Manual}.
6422 The following table summarizes the opcodes and their arguments:
6425 @let@nonarrowing=@comment
6429 rs @r{16 bit source register}
6430 rd @r{16 bit destination register}
6431 rbs @r{8 bit source register}
6432 rbd @r{8 bit destination register}
6433 rrs @r{32 bit source register}
6434 rrd @r{32 bit destination register}
6435 rqs @r{64 bit source register}
6436 rqd @r{64 bit destination register}
6437 addr @r{16/24 bit address}
6438 imm @r{immediate data}
6440 adc rd,rs clrb addr cpsir @@rd,@@rs,rr,cc
6441 adcb rbd,rbs clrb addr(rd) cpsirb @@rd,@@rs,rr,cc
6442 add rd,@@rs clrb rbd dab rbd
6443 add rd,addr com @@rd dbjnz rbd,disp7
6444 add rd,addr(rs) com addr dec @@rd,imm4m1
6445 add rd,imm16 com addr(rd) dec addr(rd),imm4m1
6446 add rd,rs com rd dec addr,imm4m1
6447 addb rbd,@@rs comb @@rd dec rd,imm4m1
6448 addb rbd,addr comb addr decb @@rd,imm4m1
6449 addb rbd,addr(rs) comb addr(rd) decb addr(rd),imm4m1
6450 addb rbd,imm8 comb rbd decb addr,imm4m1
6451 addb rbd,rbs comflg flags decb rbd,imm4m1
6452 addl rrd,@@rs cp @@rd,imm16 di i2
6453 addl rrd,addr cp addr(rd),imm16 div rrd,@@rs
6454 addl rrd,addr(rs) cp addr,imm16 div rrd,addr
6455 addl rrd,imm32 cp rd,@@rs div rrd,addr(rs)
6456 addl rrd,rrs cp rd,addr div rrd,imm16
6457 and rd,@@rs cp rd,addr(rs) div rrd,rs
6458 and rd,addr cp rd,imm16 divl rqd,@@rs
6459 and rd,addr(rs) cp rd,rs divl rqd,addr
6460 and rd,imm16 cpb @@rd,imm8 divl rqd,addr(rs)
6461 and rd,rs cpb addr(rd),imm8 divl rqd,imm32
6462 andb rbd,@@rs cpb addr,imm8 divl rqd,rrs
6463 andb rbd,addr cpb rbd,@@rs djnz rd,disp7
6464 andb rbd,addr(rs) cpb rbd,addr ei i2
6465 andb rbd,imm8 cpb rbd,addr(rs) ex rd,@@rs
6466 andb rbd,rbs cpb rbd,imm8 ex rd,addr
6467 bit @@rd,imm4 cpb rbd,rbs ex rd,addr(rs)
6468 bit addr(rd),imm4 cpd rd,@@rs,rr,cc ex rd,rs
6469 bit addr,imm4 cpdb rbd,@@rs,rr,cc exb rbd,@@rs
6470 bit rd,imm4 cpdr rd,@@rs,rr,cc exb rbd,addr
6471 bit rd,rs cpdrb rbd,@@rs,rr,cc exb rbd,addr(rs)
6472 bitb @@rd,imm4 cpi rd,@@rs,rr,cc exb rbd,rbs
6473 bitb addr(rd),imm4 cpib rbd,@@rs,rr,cc ext0e imm8
6474 bitb addr,imm4 cpir rd,@@rs,rr,cc ext0f imm8
6475 bitb rbd,imm4 cpirb rbd,@@rs,rr,cc ext8e imm8
6476 bitb rbd,rs cpl rrd,@@rs ext8f imm8
6477 bpt cpl rrd,addr exts rrd
6478 call @@rd cpl rrd,addr(rs) extsb rd
6479 call addr cpl rrd,imm32 extsl rqd
6480 call addr(rd) cpl rrd,rrs halt
6481 calr disp12 cpsd @@rd,@@rs,rr,cc in rd,@@rs
6482 clr @@rd cpsdb @@rd,@@rs,rr,cc in rd,imm16
6483 clr addr cpsdr @@rd,@@rs,rr,cc inb rbd,@@rs
6484 clr addr(rd) cpsdrb @@rd,@@rs,rr,cc inb rbd,imm16
6485 clr rd cpsi @@rd,@@rs,rr,cc inc @@rd,imm4m1
6486 clrb @@rd cpsib @@rd,@@rs,rr,cc inc addr(rd),imm4m1
6487 inc addr,imm4m1 ldb rbd,rs(rx) mult rrd,addr(rs)
6488 inc rd,imm4m1 ldb rd(imm16),rbs mult rrd,imm16
6489 incb @@rd,imm4m1 ldb rd(rx),rbs mult rrd,rs
6490 incb addr(rd),imm4m1 ldctl ctrl,rs multl rqd,@@rs
6491 incb addr,imm4m1 ldctl rd,ctrl multl rqd,addr
6492 incb rbd,imm4m1 ldd @@rs,@@rd,rr multl rqd,addr(rs)
6493 ind @@rd,@@rs,ra lddb @@rs,@@rd,rr multl rqd,imm32
6494 indb @@rd,@@rs,rba lddr @@rs,@@rd,rr multl rqd,rrs
6495 inib @@rd,@@rs,ra lddrb @@rs,@@rd,rr neg @@rd
6496 inibr @@rd,@@rs,ra ldi @@rd,@@rs,rr neg addr
6497 iret ldib @@rd,@@rs,rr neg addr(rd)
6498 jp cc,@@rd ldir @@rd,@@rs,rr neg rd
6499 jp cc,addr ldirb @@rd,@@rs,rr negb @@rd
6500 jp cc,addr(rd) ldk rd,imm4 negb addr
6501 jr cc,disp8 ldl @@rd,rrs negb addr(rd)
6502 ld @@rd,imm16 ldl addr(rd),rrs negb rbd
6503 ld @@rd,rs ldl addr,rrs nop
6504 ld addr(rd),imm16 ldl rd(imm16),rrs or rd,@@rs
6505 ld addr(rd),rs ldl rd(rx),rrs or rd,addr
6506 ld addr,imm16 ldl rrd,@@rs or rd,addr(rs)
6507 ld addr,rs ldl rrd,addr or rd,imm16
6508 ld rd(imm16),rs ldl rrd,addr(rs) or rd,rs
6509 ld rd(rx),rs ldl rrd,imm32 orb rbd,@@rs
6510 ld rd,@@rs ldl rrd,rrs orb rbd,addr
6511 ld rd,addr ldl rrd,rs(imm16) orb rbd,addr(rs)
6512 ld rd,addr(rs) ldl rrd,rs(rx) orb rbd,imm8
6513 ld rd,imm16 ldm @@rd,rs,n orb rbd,rbs
6514 ld rd,rs ldm addr(rd),rs,n out @@rd,rs
6515 ld rd,rs(imm16) ldm addr,rs,n out imm16,rs
6516 ld rd,rs(rx) ldm rd,@@rs,n outb @@rd,rbs
6517 lda rd,addr ldm rd,addr(rs),n outb imm16,rbs
6518 lda rd,addr(rs) ldm rd,addr,n outd @@rd,@@rs,ra
6519 lda rd,rs(imm16) ldps @@rs outdb @@rd,@@rs,rba
6520 lda rd,rs(rx) ldps addr outib @@rd,@@rs,ra
6521 ldar rd,disp16 ldps addr(rs) outibr @@rd,@@rs,ra
6522 ldb @@rd,imm8 ldr disp16,rs pop @@rd,@@rs
6523 ldb @@rd,rbs ldr rd,disp16 pop addr(rd),@@rs
6524 ldb addr(rd),imm8 ldrb disp16,rbs pop addr,@@rs
6525 ldb addr(rd),rbs ldrb rbd,disp16 pop rd,@@rs
6526 ldb addr,imm8 ldrl disp16,rrs popl @@rd,@@rs
6527 ldb addr,rbs ldrl rrd,disp16 popl addr(rd),@@rs
6528 ldb rbd,@@rs mbit popl addr,@@rs
6529 ldb rbd,addr mreq rd popl rrd,@@rs
6530 ldb rbd,addr(rs) mres push @@rd,@@rs
6531 ldb rbd,imm8 mset push @@rd,addr
6532 ldb rbd,rbs mult rrd,@@rs push @@rd,addr(rs)
6533 ldb rbd,rs(imm16) mult rrd,addr push @@rd,imm16
6534 push @@rd,rs set addr,imm4 subl rrd,imm32
6535 pushl @@rd,@@rs set rd,imm4 subl rrd,rrs
6536 pushl @@rd,addr set rd,rs tcc cc,rd
6537 pushl @@rd,addr(rs) setb @@rd,imm4 tccb cc,rbd
6538 pushl @@rd,rrs setb addr(rd),imm4 test @@rd
6539 res @@rd,imm4 setb addr,imm4 test addr
6540 res addr(rd),imm4 setb rbd,imm4 test addr(rd)
6541 res addr,imm4 setb rbd,rs test rd
6542 res rd,imm4 setflg imm4 testb @@rd
6543 res rd,rs sinb rbd,imm16 testb addr
6544 resb @@rd,imm4 sinb rd,imm16 testb addr(rd)
6545 resb addr(rd),imm4 sind @@rd,@@rs,ra testb rbd
6546 resb addr,imm4 sindb @@rd,@@rs,rba testl @@rd
6547 resb rbd,imm4 sinib @@rd,@@rs,ra testl addr
6548 resb rbd,rs sinibr @@rd,@@rs,ra testl addr(rd)
6549 resflg imm4 sla rd,imm8 testl rrd
6550 ret cc slab rbd,imm8 trdb @@rd,@@rs,rba
6551 rl rd,imm1or2 slal rrd,imm8 trdrb @@rd,@@rs,rba
6552 rlb rbd,imm1or2 sll rd,imm8 trib @@rd,@@rs,rbr
6553 rlc rd,imm1or2 sllb rbd,imm8 trirb @@rd,@@rs,rbr
6554 rlcb rbd,imm1or2 slll rrd,imm8 trtdrb @@ra,@@rb,rbr
6555 rldb rbb,rba sout imm16,rs trtib @@ra,@@rb,rr
6556 rr rd,imm1or2 soutb imm16,rbs trtirb @@ra,@@rb,rbr
6557 rrb rbd,imm1or2 soutd @@rd,@@rs,ra trtrb @@ra,@@rb,rbr
6558 rrc rd,imm1or2 soutdb @@rd,@@rs,rba tset @@rd
6559 rrcb rbd,imm1or2 soutib @@rd,@@rs,ra tset addr
6560 rrdb rbb,rba soutibr @@rd,@@rs,ra tset addr(rd)
6561 rsvd36 sra rd,imm8 tset rd
6562 rsvd38 srab rbd,imm8 tsetb @@rd
6563 rsvd78 sral rrd,imm8 tsetb addr
6564 rsvd7e srl rd,imm8 tsetb addr(rd)
6565 rsvd9d srlb rbd,imm8 tsetb rbd
6566 rsvd9f srll rrd,imm8 xor rd,@@rs
6567 rsvdb9 sub rd,@@rs xor rd,addr
6568 rsvdbf sub rd,addr xor rd,addr(rs)
6569 sbc rd,rs sub rd,addr(rs) xor rd,imm16
6570 sbcb rbd,rbs sub rd,imm16 xor rd,rs
6571 sc imm8 sub rd,rs xorb rbd,@@rs
6572 sda rd,rs subb rbd,@@rs xorb rbd,addr
6573 sdab rbd,rs subb rbd,addr xorb rbd,addr(rs)
6574 sdal rrd,rs subb rbd,addr(rs) xorb rbd,imm8
6575 sdl rd,rs subb rbd,imm8 xorb rbd,rbs
6576 sdlb rbd,rs subb rbd,rbs xorb rbd,rbs
6577 sdll rrd,rs subl rrd,@@rs
6578 set @@rd,imm4 subl rrd,addr
6579 set addr(rd),imm4 subl rrd,addr(rs)
6590 @node MIPS-Dependent
6591 @chapter MIPS Dependent Features
6594 @node Machine Dependencies
6595 @chapter MIPS Dependent Features
6597 The MIPS @value{AS} supports the MIPS R2000 and R3000 processors.
6599 It ignores the @kbd{-nocpp}, @kbd{-EL}, and @kbd{-EB} options.
6601 Not all traditional MIPS macro instructions are currently supported.
6602 Specifically, @code{li.d} and @code{li.s} are not currently supported.
6604 When using @code{@value{GCC}} with MIPS @value{AS}, @code{@value{GCC}}
6605 must be configured using the -with-gnu-as switch (this is the case for
6606 Cygnus distributions) or @code{@value{GCC}} must be invoked with the
6609 Assembling for a MIPS ECOFF target supports some additional sections
6610 besides the usual @code{.text}, @code{.data} and @code{.bss}. The
6611 additional sections are @code{.rdata}, used for readonly data,
6612 @code{.sdata}, used for small data, and @code{.sbss}, used for small
6615 When assembling for ECOFF, the assembler will automatically use the $gp
6616 ($28) register when forming the address of a small object. Any object
6617 in the .sdata or .sbss sections is considered to be small. For external
6618 objects or objects in the @code{.bss} section, the -G switch may be used
6619 to control the size of objects for which the $gp register will be used;
6620 the default value is 8, meaning that a reference to any object eight
6621 bytes or smaller will use $gp. Passing -G 0 to @value{AS} will prevent
6622 it from using the $gp register. The size of an object in the
6623 @code{.bss} section is set by the @code{.comm} or @code{.lcomm}
6624 pseudo-op that defines it. The size of an external object may be set
6625 using the @code{.extern} pseudo-op. For example, @samp{.extern sym,4}
6626 declares that the object at @code{sym} is 4 bytes in length, whie
6627 leaving @code{sym} otherwise undefined.
6629 Using small ECOFF objects requires linker support, and assumes that the
6630 $gp register has been correctly initialized (normally done automatically
6631 by the startup code). MIPS ECOFF assembly code must avoid modifying the
6634 MIPS ECOFF @value{AS} supports several pseudo-ops used for generating
6635 debugging information which are not support by traditional MIPS
6636 assemblers. These are @code{.def}, @code{.endef}, @code{.dim},
6637 @code{.file}, @code{.scl}, @code{.size}, @code{.tag}, @code{.type},
6638 @code{.val}, @code{.stabd}, @code{.stabn}, and @code{.stabs}. The
6639 debugging information generated by the three @code{.stab} pseudo-ops can
6640 only be read by GDB, not by traditional MIPS debuggers (this enhancement
6641 is required to fully support C++ debugging). These psuedo-ops are
6642 primarily used by compilers, not assembly language programmers, and are
6643 described elsewhere in the manual.
6648 @c reverse effect of @down at top of generic Machine-Dep chapter
6653 @c pesch@cygnus.com: we ignore the following chapters, since internals are
6654 @c changing rapidly. These may need to be moved to another
6655 @c book anyhow, if we adopt the model of user/modifier
6658 @chapter Maintaining the Assembler
6659 [[this chapter is still being built]]
6662 We had these goals, in descending priority:
6665 For every program composed by a compiler, @code{@value{AS}} should emit
6666 ``correct'' code. This leaves some latitude in choosing addressing
6667 modes, order of @code{relocation_info} structures in the object
6670 @item Speed, for usual case.
6671 By far the most common use of @code{@value{AS}} will be assembling compiler
6674 @item Upward compatibility for existing assembler code.
6675 Well @dots{} we don't support Vax bit fields but everything else
6676 seems to be upward compatible.
6679 The code should be maintainable with few surprises. (JF: ha!)
6683 We assumed that disk I/O was slow and expensive while memory was
6684 fast and access to memory was cheap. We expect the in-memory data
6685 structures to be less than 10 times the size of the emitted object
6686 file. (Contrast this with the C compiler where in-memory structures
6687 might be 100 times object file size!)
6691 Try to read the source file from disk only one time. For other
6692 reasons, we keep large chunks of the source file in memory during
6693 assembly so this is not a problem. Also the assembly algorithm
6694 should only scan the source text once if the compiler composed the
6695 text according to a few simple rules.
6697 Emit the object code bytes only once. Don't store values and then
6700 Build the object file in memory and do direct writes to disk of
6704 RMS suggested a one-pass algorithm which seems to work well. By not
6705 parsing text during a second pass considerable time is saved on
6706 large programs (@emph{e.g.} the sort of C program @code{yacc} would
6709 It happened that the data structures needed to emit relocation
6710 information to the object file were neatly subsumed into the data
6711 structures that do backpatching of addresses after pass 1.
6713 Many of the functions began life as re-usable modules, loosely
6714 connected. RMS changed this to gain speed. For example, input
6715 parsing routines which used to work on pre-sanitized strings now
6716 must parse raw data. Hence they have to import knowledge of the
6717 assemblers' comment conventions @emph{etc}.
6719 @section Deprecated Feature(?)s
6720 We have stopped supporting some features:
6723 @code{.org} statements must have @b{defined} expressions.
6725 Vax Bit fields (@kbd{:} operator) are entirely unsupported.
6728 It might be a good idea to not support these features in a future release:
6731 @kbd{#} should begin a comment, even in column 1.
6733 Why support the logical line & file concept any more?
6735 Subsections are a good candidate for flushing.
6736 Depends on which compilers need them I guess.
6739 @section Bugs, Ideas, Further Work
6740 Clearly the major improvement is DON'T USE A TEXT-READING
6741 ASSEMBLER for the back end of a compiler. It is much faster to
6742 interpret binary gobbledygook from a compiler's tables than to
6743 ask the compiler to write out human-readable code just so the
6744 assembler can parse it back to binary.
6746 Assuming you use @code{@value{AS}} for human written programs: here are
6750 Document (here) @code{APP}.
6752 Take advantage of knowing no spaces except after opcode
6753 to speed up @code{@value{AS}}. (Modify @code{app.c} to flush useless spaces:
6754 only keep space/tabs at begin of line or between 2
6757 Put pointers in this documentation to @file{a.out} documentation.
6759 Split the assembler into parts so it can gobble direct binary
6760 from @emph{e.g.} @code{cc}. It is silly for@code{cc} to compose text
6761 just so @code{@value{AS}} can parse it back to binary.
6763 Rewrite hash functions: I want a more modular, faster library.
6765 Clean up LOTS of code.
6767 Include all the non-@file{.c} files in the maintenance chapter.
6771 Implement flonum short literals.
6773 Change all talk of expression operands to expression quantities,
6774 or perhaps to expression arguments.
6778 Whenever a @code{.text} or @code{.data} statement is seen, we close
6779 of the current frag with an imaginary @code{.fill 0}. This is
6780 because we only have one obstack for frags, and we can't grow new
6781 frags for a new subsection, then go back to the old subsection and
6782 append bytes to the old frag. All this nonsense goes away if we
6783 give each subsection its own obstack. It makes code simpler in
6784 about 10 places, but nobody has bothered to do it because C compiler
6785 output rarely changes subsections (compared to ending frags with
6786 relaxable addresses, which is common).
6790 @c The following files in the @file{@value{AS}} directory
6791 @c are symbolic links to other files, of
6792 @c the same name, in a different directory.
6795 @c @file{atof_generic.c}
6797 @c @file{atof_vax.c}
6799 @c @file{flonum_const.c}
6801 @c @file{flonum_copy.c}
6803 @c @file{flonum_get.c}
6805 @c @file{flonum_multip.c}
6807 @c @file{flonum_normal.c}
6809 @c @file{flonum_print.c}
6812 Here is a list of the source files in the @file{@value{AS}} directory.
6816 This contains the pre-processing phase, which deletes comments,
6817 handles whitespace, etc. This was recently re-written, since app
6818 used to be a separate program, but RMS wanted it to be inline.
6821 This is a subroutine to append a string to another string returning a
6822 pointer just after the last @code{char} appended. (JF: All these
6823 little routines should probably all be put in one file.)
6826 Here you will find the main program of the assembler @code{@value{AS}}.
6829 This is a branch office of @file{read.c}. This understands
6830 expressions, arguments. Inside @code{@value{AS}}, arguments are called
6831 (expression) @emph{operands}. This is confusing, because we also talk
6832 (elsewhere) about instruction @emph{operands}. Also, expression
6833 operands are called @emph{quantities} explicitly to avoid confusion
6834 with instruction operands. What a mess.
6837 This implements the @b{frag} concept. Without frags, finding the
6838 right size for branch instructions would be a lot harder.
6841 This contains the symbol table, opcode table @emph{etc.} hashing
6845 This is a table of values of digits, for use in atoi() type
6846 functions. Could probably be flushed by using calls to strtol(), or
6850 This contains Operating system dependent source file reading
6851 routines. Since error messages often say where we are in reading
6852 the source file, they live here too. Since @code{@value{AS}} is intended to
6853 run under GNU and Unix only, this might be worth flushing. Anyway,
6854 almost all C compilers support stdio.
6857 This deals with calling the pre-processor (if needed) and feeding the
6858 chunks back to the rest of the assembler the right way.
6861 This contains operating system independent parts of fatal and
6862 warning message reporting. See @file{append.c} above.
6865 This contains operating system dependent functions that write an
6866 object file for @code{@value{AS}}. See @file{input-file.c} above.
6869 This implements all the directives of @code{@value{AS}}. This also deals
6870 with passing input lines to the machine dependent part of the
6874 This is a C library function that isn't in most C libraries yet.
6875 See @file{append.c} above.
6878 This implements subsections.
6881 This implements symbols.
6884 This contains the code to perform relaxation, and to write out
6885 the object file. It is mostly operating system independent, but
6886 different OSes have different object file formats in any case.
6889 This implements @code{malloc()} or bust. See @file{append.c} above.
6892 This implements @code{realloc()} or bust. See @file{append.c} above.
6894 @item atof-generic.c
6895 The following files were taken from a machine-independent subroutine
6896 library for manipulating floating point numbers and very large
6899 @file{atof-generic.c} turns a string into a flonum internal format
6900 floating-point number.
6902 @item flonum-const.c
6903 This contains some potentially useful floating point numbers in
6907 This copies a flonum.
6909 @item flonum-multip.c
6910 This multiplies two flonums together.
6913 This copies a bignum.
6917 Here is a table of all the machine-specific files (this includes
6918 both source and header files). Typically, there is a
6919 @var{machine}.c file, a @var{machine}-opcode.h file, and an
6920 atof-@var{machine}.c file. The @var{machine}-opcode.h file should
6921 be identical to the one used by GDB (which uses it for disassembly.)
6926 This contains code to turn a flonum into a ieee literal constant.
6927 This is used by tye 680x0, 32x32, sparc, and i386 versions of @code{@value{AS}}.
6930 This is the opcode-table for the i386 version of the assembler.
6933 This contains all the code for the i386 version of the assembler.
6936 This defines constants and macros used by the i386 version of the assembler.
6939 generic 68020 header file. To be linked to m68k.h on a
6940 non-sun3, non-hpux system.
6943 68010 header file for Sun2 workstations. Not well tested. To be linked
6944 to m68k.h on a sun2. (See also @samp{-DSUN_ASM_SYNTAX} in the
6948 68020 header file for Sun3 workstations. To be linked to m68k.h before
6949 compiling on a Sun3 system. (See also @samp{-DSUN_ASM_SYNTAX} in the
6953 68020 header file for a HPUX (system 5?) box. Which box, which
6954 version of HPUX, etc? I don't know.
6957 A hard- or symbolic- link to one of @file{m-generic.h},
6958 @file{m-hpux.h} or @file{m-sun3.h} depending on which kind of
6959 680x0 you are assembling for. (See also @samp{-DSUN_ASM_SYNTAX} in the
6963 Opcode table for 68020. This is now a link to the opcode table
6964 in the @code{GDB} source directory.
6967 All the mc680x0 code, in one huge, slow-to-compile file.
6970 This contains the code for the ns32032/ns32532 version of the
6973 @item ns32k-opcode.h
6974 This contains the opcode table for the ns32032/ns32532 version
6978 Vax specific file for describing Vax operands and other Vax-ish things.
6984 Vax specific parts of @code{@value{AS}}. Also includes the former files
6985 @file{vax-ins-parse.c}, @file{vax-reg-parse.c} and @file{vip-op.c}.
6988 Turns a flonum into a Vax constant.
6991 This file contains the special code needed to put out a VMS
6992 style object file for the Vax.
6996 Here is a list of the header files in the source directory.
6997 (Warning: This section may not be very accurate. I didn't
6998 write the header files; I just report them.) Also note that I
6999 think many of these header files could be cleaned up or
7005 This describes the structures used to create the binary header data
7006 inside the object file. Perhaps we should use the one in
7007 @file{/usr/include}?
7010 This defines all the globally useful things, and pulls in @file{stdio.h}
7011 and @file{assert.h}.
7014 This defines macros useful for dealing with bignums.
7017 Structure and macros for dealing with expression()
7020 This defines the structure for dealing with floating point
7021 numbers. It #includes @file{bignum.h}.
7024 This contains macro for appending a byte to the current frag.
7027 Structures and function definitions for the hashing functions.
7030 Function headers for the input-file.c functions.
7033 structures and function headers for things defined in the
7034 machine dependent part of the assembler.
7037 This is the GNU systemwide include file for manipulating obstacks.
7038 Since nobody is running under real GNU yet, we include this file.
7041 Macros and function headers for reading in source files.
7043 @item struct-symbol.h
7044 Structure definition and macros for dealing with the @value{AS}
7045 internal form of a symbol.
7048 structure definition for dealing with the numbered subsections
7049 of the text and data sections.
7052 Macros and function headers for dealing with symbols.
7055 Structure for doing section fixups.
7058 @c ~subsection Test Directory
7059 @c (Note: The test directory seems to have disappeared somewhere
7060 @c along the line. If you want it, you'll probably have to find a
7061 @c REALLY OLD dump tape~dots{})
7063 @c The ~file{test/} directory is used for regression testing.
7064 @c After you modify ~@code{@value{AS}}, you can get a quick go/nogo
7065 @c confidence test by running the new ~@code{@value{AS}} over the source
7066 @c files in this directory. You use a shell script ~file{test/do}.
7068 @c The tests in this suite are evolving. They are not comprehensive.
7069 @c They have, however, caught hundreds of bugs early in the debugging
7070 @c cycle of ~@code{@value{AS}}. Most test statements in this suite were naturally
7071 @c selected: they were used to demonstrate actual ~@code{@value{AS}} bugs rather
7072 @c than being written ~i{a prioi}.
7074 @c Another testing suggestion: over 30 bugs have been found simply by
7075 @c running examples from this manual through ~@code{@value{AS}}.
7076 @c Some examples in this manual are selected
7077 @c to distinguish boundary conditions; they are good for testing ~@code{@value{AS}}.
7079 @c ~subsubsection Regression Testing
7080 @c Each regression test involves assembling a file and comparing the
7081 @c actual output of ~@code{@value{AS}} to ``known good'' output files. Both
7082 @c the object file and the error/warning message file (stderr) are
7083 @c inspected. Optionally the ~@code{@value{AS}} exit status may be checked.
7084 @c Discrepencies are reported. Each discrepency means either that
7085 @c you broke some part of ~@code{@value{AS}} or that the ``known good'' files
7086 @c are now out of date and should be changed to reflect the new
7087 @c definition of ``good''.
7089 @c Each regression test lives in its own directory, in a tree
7090 @c rooted in the directory ~file{test/}. Each such directory
7091 @c has a name ending in ~file{.ret}, where `ret' stands for
7092 @c REgression Test. The ~file{.ret} ending allows ~code{find
7093 @c (1)} to find all regression tests in the tree, without
7094 @c needing to list them explicitly.
7096 @c Any ~file{.ret} directory must contain a file called
7097 @c ~file{input} which is the source file to assemble. During
7098 @c testing an object file ~file{output} is created, as well as
7099 @c a file ~file{stdouterr} which contains the output to both
7100 @c stderr and stderr. If there is a file ~file{output.good} in
7101 @c the directory, and if ~file{output} contains exactly the
7102 @c same data as ~file{output.good}, the file ~file{output} is
7103 @c deleted. Likewise ~file{stdouterr} is removed if it exactly
7104 @c matches a file ~file{stdouterr.good}. If file
7105 @c ~file{status.good} is present, containing a decimal number
7106 @c before a newline, the exit status of ~@code{@value{AS}} is compared
7107 @c to this number. If the status numbers are not equal, a file
7108 @c ~file{status} is written to the directory, containing the
7109 @c actual status as a decimal number followed by newline.
7111 @c Should any of the ~file{*.good} files fail to match their corresponding
7112 @c actual files, this is noted by a 1-line message on the screen during
7113 @c the regression test, and you can use ~@code{find (1)} to find any
7114 @c files named ~file{status}, ~file {output} or ~file{stdouterr}.
7118 @chapter Teaching the Assembler about a New Machine
7120 This chapter describes the steps required in order to make the
7121 assembler work with another machine's assembly language. This
7122 chapter is not complete, and only describes the steps in the
7123 broadest terms. You should look at the source for the
7124 currently supported machine in order to discover some of the
7125 details that aren't mentioned here.
7127 You should create a new file called @file{@var{machine}.c}, and
7128 add the appropriate lines to the file @file{Makefile} so that
7129 you can compile your new version of the assembler. This should
7130 be straighforward; simply add lines similar to the ones there
7131 for the four current versions of the assembler.
7133 If you want to be compatible with GDB, (and the current
7134 machine-dependent versions of the assembler), you should create
7135 a file called @file{@var{machine}-opcode.h} which should
7136 contain all the information about the names of the machine
7137 instructions, their opcodes, and what addressing modes they
7138 support. If you do this right, the assembler and GDB can share
7139 this file, and you'll only have to write it once. Note that
7140 while you're writing @code{@value{AS}}, you may want to use an
7141 independent program (if you have access to one), to make sure
7142 that @code{@value{AS}} is emitting the correct bytes. Since @code{@value{AS}}
7143 and @code{GDB} share the opcode table, an incorrect opcode
7144 table entry may make invalid bytes look OK when you disassemble
7145 them with @code{GDB}.
7147 @section Functions You will Have to Write
7149 Your file @file{@var{machine}.c} should contain definitions for
7150 the following functions and variables. It will need to include
7151 some header files in order to use some of the structures
7152 defined in the machine-independent part of the assembler. The
7153 needed header files are mentioned in the descriptions of the
7154 functions that will need them.
7159 This long integer holds the value to place at the beginning of
7160 the @file{a.out} file. It is usually @samp{OMAGIC}, except on
7161 machines that store additional information in the magic-number.
7163 @item char comment_chars[];
7164 This character array holds the values of the characters that
7165 start a comment anywhere in a line. Comments are stripped off
7166 automatically by the machine independent part of the
7167 assembler. Note that the @samp{/*} will always start a
7168 comment, and that only @samp{*/} will end a comment started by
7171 @item char line_comment_chars[];
7172 This character array holds the values of the chars that start a
7173 comment only if they are the first (non-whitespace) character
7174 on a line. If the character @samp{#} does not appear in this
7175 list, you may get unexpected results. (Various
7176 machine-independent parts of the assembler treat the comments
7177 @samp{#APP} and @samp{#NO_APP} specially, and assume that lines
7178 that start with @samp{#} are comments.)
7180 @item char EXP_CHARS[];
7181 This character array holds the letters that can separate the
7182 mantissa and the exponent of a floating point number. Typical
7183 values are @samp{e} and @samp{E}.
7185 @item char FLT_CHARS[];
7186 This character array holds the letters that--when they appear
7187 immediately after a leading zero--indicate that a number is a
7188 floating-point number. (Sort of how 0x indicates that a
7189 hexadecimal number follows.)
7191 @item pseudo_typeS md_pseudo_table[];
7192 (@var{pseudo_typeS} is defined in @file{md.h})
7193 This array contains a list of the machine_dependent directives
7194 the assembler must support. It contains the name of each
7195 pseudo op (Without the leading @samp{.}), a pointer to a
7196 function to be called when that directive is encountered, and
7197 an integer argument to be passed to that function.
7199 @item void md_begin(void)
7200 This function is called as part of the assembler's
7201 initialization. It should do any initialization required by
7202 any of your other routines.
7204 @item int md_parse_option(char **optionPTR, int *argcPTR, char ***argvPTR)
7205 This routine is called once for each option on the command line
7206 that the machine-independent part of @code{@value{AS}} does not
7207 understand. This function should return non-zero if the option
7208 pointed to by @var{optionPTR} is a valid option. If it is not
7209 a valid option, this routine should return zero. The variables
7210 @var{argcPTR} and @var{argvPTR} are provided in case the option
7211 requires a filename or something similar as an argument. If
7212 the option is multi-character, @var{optionPTR} should be
7213 advanced past the end of the option, otherwise every letter in
7214 the option will be treated as a separate single-character
7217 @item void md_assemble(char *string)
7218 This routine is called for every machine-dependent
7219 non-directive line in the source file. It does all the real
7220 work involved in reading the opcode, parsing the operands,
7221 etc. @var{string} is a pointer to a null-terminated string,
7222 that comprises the input line, with all excess whitespace and
7225 @item void md_number_to_chars(char *outputPTR,long value,int nbytes)
7226 This routine is called to turn a C long int, short int, or char
7227 into the series of bytes that represents that number on the
7228 target machine. @var{outputPTR} points to an array where the
7229 result should be stored; @var{value} is the value to store; and
7230 @var{nbytes} is the number of bytes in 'value' that should be
7233 @item void md_number_to_imm(char *outputPTR,long value,int nbytes)
7234 This routine is called to turn a C long int, short int, or char
7235 into the series of bytes that represent an immediate value on
7236 the target machine. It is identical to the function @code{md_number_to_chars},
7237 except on NS32K machines.@refill
7239 @item void md_number_to_disp(char *outputPTR,long value,int nbytes)
7240 This routine is called to turn a C long int, short int, or char
7241 into the series of bytes that represent an displacement value on
7242 the target machine. It is identical to the function @code{md_number_to_chars},
7243 except on NS32K machines.@refill
7245 @item void md_number_to_field(char *outputPTR,long value,int nbytes)
7246 This routine is identical to @code{md_number_to_chars},
7247 except on NS32K machines.
7249 @item void md_ri_to_chars(struct relocation_info *riPTR,ri)
7250 (@code{struct relocation_info} is defined in @file{a.out.h})
7251 This routine emits the relocation info in @var{ri}
7252 in the appropriate bit-pattern for the target machine.
7253 The result should be stored in the location pointed
7254 to by @var{riPTR}. This routine may be a no-op unless you are
7255 attempting to do cross-assembly.
7257 @item char *md_atof(char type,char *outputPTR,int *sizePTR)
7258 This routine turns a series of digits into the appropriate
7259 internal representation for a floating-point number.
7260 @var{type} is a character from @var{FLT_CHARS[]} that describes
7261 what kind of floating point number is wanted; @var{outputPTR}
7262 is a pointer to an array that the result should be stored in;
7263 and @var{sizePTR} is a pointer to an integer where the size (in
7264 bytes) of the result should be stored. This routine should
7265 return an error message, or an empty string (not (char *)0) for
7268 @item int md_short_jump_size;
7269 This variable holds the (maximum) size in bytes of a short (16
7270 bit or so) jump created by @code{md_create_short_jump()}. This
7271 variable is used as part of the broken-word feature, and isn't
7272 needed if the assembler is compiled with
7273 @samp{-DWORKING_DOT_WORD}.
7275 @item int md_long_jump_size;
7276 This variable holds the (maximum) size in bytes of a long (32
7277 bit or so) jump created by @code{md_create_long_jump()}. This
7278 variable is used as part of the broken-word feature, and isn't
7279 needed if the assembler is compiled with
7280 @samp{-DWORKING_DOT_WORD}.
7282 @item void md_create_short_jump(char *resultPTR,long from_addr,
7283 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
7284 This function emits a jump from @var{from_addr} to @var{to_addr} in
7285 the array of bytes pointed to by @var{resultPTR}. If this creates a
7286 type of jump that must be relocated, this function should call
7287 @code{fix_new()} with @var{frag} and @var{to_symbol}. The jump
7288 emitted by this function may be smaller than @var{md_short_jump_size},
7289 but it must never create a larger one.
7290 (If it creates a smaller jump, the extra bytes of memory will not be
7291 used.) This function is used as part of the broken-word feature,
7292 and isn't needed if the assembler is compiled with
7293 @samp{-DWORKING_DOT_WORD}.@refill
7295 @item void md_create_long_jump(char *ptr,long from_addr,
7296 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
7297 This function is similar to the previous function,
7298 @code{md_create_short_jump()}, except that it creates a long
7299 jump instead of a short one. This function is used as part of
7300 the broken-word feature, and isn't needed if the assembler is
7301 compiled with @samp{-DWORKING_DOT_WORD}.
7303 @item int md_estimate_size_before_relax(fragS *fragPTR,int segment_type)
7304 This function does the initial setting up for relaxation. This
7305 includes forcing references to still-undefined symbols to the
7306 appropriate addressing modes.
7308 @item relax_typeS md_relax_table[];
7309 (relax_typeS is defined in md.h)
7310 This array describes the various machine dependent states a
7311 frag may be in before relaxation. You will need one group of
7312 entries for each type of addressing mode you intend to relax.
7314 @item void md_convert_frag(fragS *fragPTR)
7315 (@var{fragS} is defined in @file{as.h})
7316 This routine does the required cleanup after relaxation.
7317 Relaxation has changed the type of the frag to a type that can
7318 reach its destination. This function should adjust the opcode
7319 of the frag to use the appropriate addressing mode.
7320 @var{fragPTR} points to the frag to clean up.
7322 @item void md_end(void)
7323 This function is called just before the assembler exits. It
7324 need not free up memory unless the operating system doesn't do
7325 it automatically on exit. (In which case you'll also have to
7326 track down all the other places where the assembler allocates
7327 space but never frees it.)
7331 @section External Variables You will Need to Use
7333 You will need to refer to or change the following external variables
7334 from within the machine-dependent part of the assembler.
7337 @item extern char flagseen[];
7338 This array holds non-zero values in locations corresponding to
7339 the options that were on the command line. Thus, if the
7340 assembler was called with @samp{-W}, @var{flagseen['W']} would
7343 @item extern fragS *frag_now;
7344 This pointer points to the current frag--the frag that bytes
7345 are currently being added to. If nothing else, you will need
7346 to pass it as an argument to various machine-independent
7347 functions. It is maintained automatically by the
7348 frag-manipulating functions; you should never have to change it
7351 @item extern LITTLENUM_TYPE generic_bignum[];
7352 (@var{LITTLENUM_TYPE} is defined in @file{bignum.h}.
7353 This is where @dfn{bignums}--numbers larger than 32 bits--are
7354 returned when they are encountered in an expression. You will
7355 need to use this if you need to implement directives (or
7356 anything else) that must deal with these large numbers.
7357 @code{Bignums} are of @code{segT} @code{SEG_BIG} (defined in
7358 @file{as.h}, and have a positive @code{X_add_number}. The
7359 @code{X_add_number} of a @code{bignum} is the number of
7360 @code{LITTLENUMS} in @var{generic_bignum} that the number takes
7363 @item extern FLONUM_TYPE generic_floating_point_number;
7364 (@var{FLONUM_TYPE} is defined in @file{flonum.h}.
7365 The is where @dfn{flonums}--floating-point numbers within
7366 expressions--are returned. @code{Flonums} are of @code{segT}
7367 @code{SEG_BIG}, and have a negative @code{X_add_number}.
7368 @code{Flonums} are returned in a generic format. You will have
7369 to write a routine to turn this generic format into the
7370 appropriate floating-point format for your machine.
7372 @item extern int need_pass_2;
7373 If this variable is non-zero, the assembler has encountered an
7374 expression that cannot be assembled in a single pass. Since
7375 the second pass isn't implemented, this flag means that the
7376 assembler is punting, and is only looking for additional syntax
7377 errors. (Or something like that.)
7379 @item extern segT now_seg;
7380 This variable holds the value of the section the assembler is
7381 currently assembling into.
7385 @section External functions will you need
7387 You will find the following external functions useful (or
7388 indispensable) when you're writing the machine-dependent part
7393 @item char *frag_more(int bytes)
7394 This function allocates @var{bytes} more bytes in the current
7395 frag (or starts a new frag, if it can't expand the current frag
7396 any more.) for you to store some object-file bytes in. It
7397 returns a pointer to the bytes, ready for you to store data in.
7399 @item void fix_new(fragS *frag, int where, short size, symbolS *add_symbol, symbolS *sub_symbol, long offset, int pcrel)
7400 This function stores a relocation fixup to be acted on later.
7401 @var{frag} points to the frag the relocation belongs in;
7402 @var{where} is the location within the frag where the relocation begins;
7403 @var{size} is the size of the relocation, and is usually 1 (a single byte),
7404 2 (sixteen bits), or 4 (a longword). The value @var{add_symbol}
7405 @minus{} @var{sub_symbol} + @var{offset}, is added to the byte(s) at
7406 @var{frag->literal[where]}. If @var{pcrel} is non-zero, the address of
7407 the location is subtracted from the result. A relocation entry is also
7408 added to the @file{a.out} file. @var{add_symbol}, @var{sub_symbol},
7409 and/or @var{offset} may be NULL.@refill
7411 @item char *frag_var(relax_stateT type, int max_chars, int var,
7412 @code{relax_substateT subtype, symbolS *symbol, char *opcode)}
7413 This function creates a machine-dependent frag of type @var{type}
7414 (usually @code{rs_machine_dependent}).
7415 @var{max_chars} is the maximum size in bytes that the frag may grow by;
7416 @var{var} is the current size of the variable end of the frag;
7417 @var{subtype} is the sub-type of the frag. The sub-type is used to index into
7418 @var{md_relax_table[]} during @code{relaxation}.
7419 @var{symbol} is the symbol whose value should be used to when relax-ing this frag.
7420 @var{opcode} points into a byte whose value may have to be modified if the
7421 addressing mode used by this frag changes. It typically points into the
7422 @var{fr_literal[]} of the previous frag, and is used to point to a location
7423 that @code{md_convert_frag()}, may have to change.@refill
7425 @item void frag_wane(fragS *fragPTR)
7426 This function is useful from within @code{md_convert_frag}. It
7427 changes a frag to type rs_fill, and sets the variable-sized
7428 piece of the frag to zero. The frag will never change in size
7431 @item segT expression(expressionS *retval)
7432 (@var{segT} is defined in @file{as.h}; @var{expressionS} is defined in @file{expr.h})
7433 This function parses the string pointed to by the external char
7434 pointer @var{input_line_pointer}, and returns the section-type
7435 of the expression. It also stores the results in the
7436 @var{expressionS} pointed to by @var{retval}.
7437 @var{input_line_pointer} is advanced to point past the end of
7438 the expression. (@var{input_line_pointer} is used by other
7439 parts of the assembler. If you modify it, be sure to restore
7440 it to its original value.)
7442 @item as_warn(char *message,@dots{})
7443 If warning messages are disabled, this function does nothing.
7444 Otherwise, it prints out the current file name, and the current
7445 line number, then uses @code{fprintf} to print the
7446 @var{message} and any arguments it was passed.
7448 @item as_bad(char *message,@dots{})
7449 This function should be called when @code{@value{AS}} encounters
7450 conditions that are bad enough that @code{@value{AS}} should not
7451 produce an object file, but should continue reading input and
7452 printing warning and bad error messages.
7454 @item as_fatal(char *message,@dots{})
7455 This function prints out the current file name and line number,
7456 prints the word @samp{FATAL:}, then uses @code{fprintf} to
7457 print the @var{message} and any arguments it was passed. Then
7458 the assembler exits. This function should only be used for
7459 serious, unrecoverable errors.
7461 @item void float_const(int float_type)
7462 This function reads floating-point constants from the current
7463 input line, and calls @code{md_atof} to assemble them. It is
7464 useful as the function to call for the directives
7465 @samp{.single}, @samp{.double}, @samp{.float}, etc.
7466 @var{float_type} must be a character from @var{FLT_CHARS}.
7468 @item void demand_empty_rest_of_line(void);
7469 This function can be used by machine-dependent directives to
7470 make sure the rest of the input line is empty. It prints a
7471 warning message if there are additional characters on the line.
7473 @item long int get_absolute_expression(void)
7474 This function can be used by machine-dependent directives to
7475 read an absolute number from the current input line. It
7476 returns the result. If it isn't given an absolute expression,
7477 it prints a warning message and returns zero.
7482 @section The concept of Frags
7484 This assembler works to optimize the size of certain addressing
7485 modes. (e.g. branch instructions) This means the size of many
7486 pieces of object code cannot be determined until after assembly
7487 is finished. (This means that the addresses of symbols cannot be
7488 determined until assembly is finished.) In order to do this,
7489 @code{@value{AS}} stores the output bytes as @dfn{frags}.
7491 Here is the definition of a frag (from @file{as.h})
7497 relax_stateT fr_type;
7498 relax_substateT fr_substate;
7499 unsigned long fr_address;
7501 struct symbol *fr_symbol;
7503 struct frag *fr_next;
7510 is the size of the fixed-size piece of the frag.
7513 is the maximum (?) size of the variable-sized piece of the frag.
7516 is the type of the frag.
7521 rs_machine_dependent
7524 This stores the type of machine-dependent frag this is. (what
7525 kind of addressing mode is being used, and what size is being
7529 @var{fr_address} is only valid after relaxation is finished.
7530 Before relaxation, the only way to store an address is (pointer
7531 to frag containing the address) plus (offset into the frag).
7534 This contains a number, whose meaning depends on the type of
7536 for machine_dependent frags, this contains the offset from
7537 fr_symbol that the frag wants to go to. Thus, for branch
7538 instructions it is usually zero. (unless the instruction was
7539 @samp{jba foo+12} or something like that.)
7542 for machine_dependent frags, this points to the symbol the frag
7546 This points to the location in the frag (or in a previous frag)
7547 of the opcode for the instruction that caused this to be a frag.
7548 @var{fr_opcode} is needed if the actual opcode must be changed
7549 in order to use a different form of the addressing mode.
7550 (For example, if a conditional branch only comes in size tiny,
7551 a large-size branch could be implemented by reversing the sense
7552 of the test, and turning it into a tiny branch over a large jump.
7553 This would require changing the opcode.)
7555 @var{fr_literal} is a variable-size array that contains the
7556 actual object bytes. A frag consists of a fixed size piece of
7557 object data, (which may be zero bytes long), followed by a
7558 piece of object data whose size may not have been determined
7559 yet. Other information includes the type of the frag (which
7560 controls how it is relaxed),
7563 This is the next frag in the singly-linked list. This is
7564 usually only needed by the machine-independent part of
7571 @include gpl.texinfo