1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright (c) 1991 1992 1993 1994 Free Software Foundation, Inc.
3 @c UPDATE!! On future updates--
4 @c (1) check for new machine-dep cmdline options in
5 @c md_parse_option definitions in config/tc-*.c
6 @c (2) for platform-specific directives, examine md_pseudo_op
8 @c (3) for object-format specific directives, examine obj_pseudo_op
10 @c (4) portable directives in potable[] in read.c
14 @c defaults, config file may override:
17 @include asconfig.texi
19 @c common OR combinations of conditions
36 @set abnormal-separator
40 @settitle Using @value{AS}
43 @settitle Using @value{AS} (@value{TARGET})
45 @setchapternewpage odd
50 @c WARE! Some of the machine-dependent sections contain tables of machine
51 @c instructions. Except in multi-column format, these tables look silly.
52 @c Unfortunately, Texinfo doesn't have a general-purpose multi-col format, so
53 @c the multi-col format is faked within @example sections.
55 @c Again unfortunately, the natural size that fits on a page, for these tables,
56 @c is different depending on whether or not smallbook is turned on.
57 @c This matters, because of order: text flow switches columns at each page
60 @c The format faked in this source works reasonably well for smallbook,
61 @c not well for the default large-page format. This manual expects that if you
62 @c turn on @smallbook, you will also uncomment the "@set SMALL" to enable the
63 @c tables in question. You can turn on one without the other at your
64 @c discretion, of course.
67 @c the insn tables look just as silly in info files regardless of smallbook,
68 @c might as well show 'em anyways.
74 * As: (as). The GNU assembler.
83 This file documents the GNU Assembler "@value{AS}".
85 Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
87 Permission is granted to make and distribute verbatim copies of
88 this manual provided the copyright notice and this permission notice
89 are preserved on all copies.
92 Permission is granted to process this file through Tex and print the
93 results, provided the printed document carries copying permission
94 notice identical to this one except for the removal of this paragraph
95 (this paragraph not being relevant to the printed manual).
98 Permission is granted to copy and distribute modified versions of this manual
99 under the conditions for verbatim copying, provided that the entire resulting
100 derived work is distributed under the terms of a permission notice identical to
103 Permission is granted to copy and distribute translations of this manual
104 into another language, under the above conditions for modified versions.
108 @title Using @value{AS}
109 @subtitle The GNU Assembler
111 @subtitle for the @value{TARGET} family
114 @subtitle January 1994
117 The Free Software Foundation Inc. thanks The Nice Computer
118 Company of Australia for loaning Dean Elsner to write the
119 first (Vax) version of @code{as} for Project GNU.
120 The proprietors, management and staff of TNCCA thank FSF for
121 distracting the boss while they got some work
124 @author Dean Elsner, Jay Fenlason & friends
128 \hfill {\it Using {\tt @value{AS}}}\par
129 \hfill Edited by Roland Pesch for Cygnus Support\par
131 %"boxit" macro for figures:
132 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
133 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
134 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
135 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
136 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
139 @vskip 0pt plus 1filll
140 Copyright @copyright{} 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
142 Permission is granted to make and distribute verbatim copies of
143 this manual provided the copyright notice and this permission notice
144 are preserved on all copies.
146 Permission is granted to copy and distribute modified versions of this manual
147 under the conditions for verbatim copying, provided that the entire resulting
148 derived work is distributed under the terms of a permission notice identical to
151 Permission is granted to copy and distribute translations of this manual
152 into another language, under the above conditions for modified versions.
157 @top Using @value{AS}
159 This file is a user guide to the @sc{gnu} assembler @code{@value{AS}}.
161 This version of the file describes @code{@value{AS}} configured to generate
162 code for @value{TARGET} architectures.
165 * Overview:: Overview
166 * Invoking:: Command-Line Options
168 * Sections:: Sections and Relocation
170 * Expressions:: Expressions
171 * Pseudo Ops:: Assembler Directives
172 * Machine Dependencies:: Machine Dependent Features
173 * Acknowledgements:: Who Did What
181 This manual is a user guide to the @sc{gnu} assembler @code{@value{AS}}.
183 This version of the manual describes @code{@value{AS}} configured to generate
184 code for @value{TARGET} architectures.
188 @cindex invocation summary
189 @cindex option summary
190 @cindex summary of options
191 Here is a brief summary of how to invoke @code{@value{AS}}. For details,
192 @pxref{Invoking,,Comand-Line Options}.
194 @c We don't use deffn and friends for the following because they seem
195 @c to be limited to one line for the header.
197 @value{AS} [ -a[dhlns] ] [ -D ] [ -f ] [ --help ]
198 [ -I @var{dir} ] [ -J ] [ -K ] [ -L ] [ -o @var{objfile} ]
199 [ -R ] [ --statistics ] [ -v ] [ -version ] [ --version ]
200 [ -W ] [ -w ] [ -x ] [ -Z ]
202 @c am29k has no machine-dependent assembler options
204 @c start-sanitize-arc
206 [ -mbig-endian | -mlittle-endian ]
210 @c Hitachi family chips have no machine-dependent assembler options
213 @c HPPA has no machine-dependent assembler options (yet).
216 [ -Av6 | -Av7 | -Av8 | -Av9 | -Asparclite | -bump ]
219 @c Z8000 has no machine-dependent assembler options
222 @c see md_parse_option in tc-i960.c
223 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
227 [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
230 [ -nocpp ] [ -EL ] [ -EB ] [ -G @var{num} ] [ -mcpu=@var{CPU} ]
231 [ -mips1 ] [ -mips2 ] [ -mips3 ] [ -m4650 ] [ -no-m4650 ]
232 [ --trap ] [ --break ]
233 [ --emulation=@var{name} ]
235 [ -- | @var{files} @dots{} ]
240 Turn on listings, in any of a variety of ways:
244 omit debugging directives
247 include high-level source
253 omit forms processing
259 You may combine these options; for example, use @samp{-aln} for assembly
260 listing without forms processing. By itself, @samp{-a} defaults to
261 @samp{-ahls}---that is, all listings turned on.
264 Ignored. This option is accepted for script compatibility with calls to
268 ``fast''---skip whitespace and comment preprocessing (assume source is
272 Print a summary of the command line options and exit.
275 Add directory @var{dir} to the search list for @code{.include} directives.
278 Don't warn about signed overflow.
281 @ifclear DIFF-TBL-KLUGE
282 This option is accepted but has no effect on the @value{TARGET} family.
284 @ifset DIFF-TBL-KLUGE
285 Issue warnings when difference tables altered for long displacements.
289 Keep (in the symbol table) local symbols, starting with @samp{L}.
291 @item -o @var{objfile}
292 Name the object-file output from @code{@value{AS}} @var{objfile}.
295 Fold the data section into the text section.
298 Print the maximum space (in bytes) and total time (in seconds) used by
303 Print the @code{as} version.
306 Print the @code{as} version and exit.
309 Suppress warning messages.
318 Generate an object file even after errors.
320 @item -- | @var{files} @dots{}
321 Standard input, or source files to assemble.
326 The following options are available when @value{AS} is configured for
331 @cindex ARC endianness
332 @cindex endianness, ARC
333 @cindex big endian output, ARC
335 Generate ``big endian'' format output.
337 @cindex little endian output, ARC
338 @item -mlittle-endian
339 Generate ``little endian'' format output.
345 The following options are available when @value{AS} is configured for the
346 Intel 80960 processor.
349 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
350 Specify which variant of the 960 architecture is the target.
353 Add code to collect statistics about branches taken.
356 Do not alter compare-and-branch instructions for long displacements;
363 The following options are available when @value{AS} is configured for the
364 Motorola 68000 series.
369 Shorten references to undefined symbols, to one word instead of two.
371 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040
372 @itemx | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32
373 Specify what processor in the 68000 family is the target. The default
374 is normally the 68020, but this can be changed at configuration time.
376 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
377 The target machine does (or does not) have a floating-point coprocessor.
378 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
379 the basic 68000 is not compatible with the 68881, a combination of the
380 two can be specified, since it's possible to do emulation of the
381 coprocessor instructions with the main processor.
383 @item -m68851 | -mno-68851
384 The target machine does (or does not) have a memory-management
385 unit coprocessor. The default is to assume an MMU for 68020 and up.
391 The following options are available when @code{@value{AS}} is configured
392 for the SPARC architecture:
395 @item -Av6 | -Av7 | -Av8 | -Av9 | -Asparclite
396 Explicitly select a variant of the SPARC architecture.
399 Warn when the assembler switches to another architecture.
404 The following options are available when @value{AS} is configured for
409 This option sets the largest size of an object that can be referenced
410 implicitly with the @code{gp} register. It is only accepted for targets that
411 use ECOFF format, such as a DECstation running Ultrix. The default value is 8.
413 @cindex MIPS endianness
414 @cindex endianness, MIPS
415 @cindex big endian output, MIPS
417 Generate ``big endian'' format output.
419 @cindex little endian output, MIPS
421 Generate ``little endian'' format output.
427 Generate code for a particular MIPS Instruction Set Architecture level.
428 @samp{-mips1} corresponds to the @sc{r2000} and @sc{r3000} processors,
429 @samp{-mips2} to the @sc{r6000} processor, and @samp{-mips3} to the @sc{r4000}
434 Generate code for the MIPS @sc{r4650} chip. This tells the assembler to accept
435 the @samp{mad} and @samp{madu} instruction, and to not schedule @samp{nop}
436 instructions around accesses to the @samp{HI} and @samp{LO} registers.
437 @samp{-no-m4650} turns off this option.
439 @item -mcpu=@var{CPU}
440 Generate code for a particular MIPS cpu. This has little effect on the
441 assembler, but it is passed by @code{@value{GCC}}.
444 @item --emulation=@var{name}
445 This option causes @code{@value{AS}} to emulated @code{@value{AS}} configured
446 for some other target, in all respects, including output format (choosing
447 between ELF and ECOFF only), handling of pseudo-opcodes which may generate
448 debugging information or store symbol table information, and default
449 endianness. The available configuration names are: @samp{mipsecoff},
450 @samp{mipself}, @samp{mipslecoff}, @samp{mipsbecoff}, @samp{mipslelf},
451 @samp{mipsbelf}. The first two do not alter the default endianness from that
452 of the primary target for which the assembler was configured; the others change
453 the default to little- or big-endian as indicated by the @samp{b} or @samp{l}
454 in the name. Using @samp{-EB} or @samp{-EL} will override the endianness
455 selection in any case.
457 This option is currently supported only when the primary target
458 @code{@value{AS}} is configured for is a MIPS ELF or ECOFF target.
459 Furthermore, the primary target or others specified with
460 @samp{--enable-targets=@dots{}} at configuration time must include support for
461 the other format, if both are to be available. For example, the Irix 5
462 configuration includes support for both.
464 Eventually, this option will support more configurations, with more
465 fine-grained control over the assembler's behavior, and will be supported for
469 @code{@value{AS}} ignores this option. It is accepted for compatibility with
476 Control how to deal with multiplication overflow and division by zero.
477 @samp{--trap} or @samp{--no-break} (which are synonyms) take a trap exception
478 (and only work for Instruction Set Architecture level 2 and higher);
479 @samp{--break} or @samp{--no-trap} (also synonyms, and the default) take a
485 * Manual:: Structure of this Manual
486 * GNU Assembler:: @value{AS}, the GNU Assembler
487 * Object Formats:: Object File Formats
488 * Command Line:: Command Line
489 * Input Files:: Input Files
490 * Object:: Output (Object) File
491 * Errors:: Error and Warning Messages
495 @section Structure of this Manual
497 @cindex manual, structure and purpose
498 This manual is intended to describe what you need to know to use
499 @sc{gnu} @code{@value{AS}}. We cover the syntax expected in source files, including
500 notation for symbols, constants, and expressions; the directives that
501 @code{@value{AS}} understands; and of course how to invoke @code{@value{AS}}.
504 We also cover special features in the @value{TARGET}
505 configuration of @code{@value{AS}}, including assembler directives.
508 This manual also describes some of the machine-dependent features of
509 various flavors of the assembler.
512 @cindex machine instructions (not covered)
513 On the other hand, this manual is @emph{not} intended as an introduction
514 to programming in assembly language---let alone programming in general!
515 In a similar vein, we make no attempt to introduce the machine
516 architecture; we do @emph{not} describe the instruction set, standard
517 mnemonics, registers or addressing modes that are standard to a
518 particular architecture.
520 You may want to consult the manufacturer's
521 machine architecture manual for this information.
525 For information on the H8/300 machine instruction set, see @cite{H8/300
526 Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,
527 see @cite{H8/300H Series Programming Manual} (Hitachi).
530 For information on the H8/500 machine instruction set, see @cite{H8/500
531 Series Programming Manual} (Hitachi M21T001).
534 For information on the Hitachi SH machine instruction set, see
535 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
538 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
542 @c I think this is premature---pesch@cygnus.com, 17jan1991
544 Throughout this manual, we assume that you are running @dfn{GNU},
545 the portable operating system from the @dfn{Free Software
546 Foundation, Inc.}. This restricts our attention to certain kinds of
547 computer (in particular, the kinds of computers that @sc{gnu} can run on);
548 once this assumption is granted examples and definitions need less
551 @code{@value{AS}} is part of a team of programs that turn a high-level
552 human-readable series of instructions into a low-level
553 computer-readable series of instructions. Different versions of
554 @code{@value{AS}} are used for different kinds of computer.
557 @c There used to be a section "Terminology" here, which defined
558 @c "contents", "byte", "word", and "long". Defining "word" to any
559 @c particular size is confusing when the .word directive may generate 16
560 @c bits on one machine and 32 bits on another; in general, for the user
561 @c version of this manual, none of these terms seem essential to define.
562 @c They were used very little even in the former draft of the manual;
563 @c this draft makes an effort to avoid them (except in names of
567 @section @value{AS}, the GNU Assembler
569 @sc{gnu} @code{as} is really a family of assemblers.
571 This manual describes @code{@value{AS}}, a member of that family which is
572 configured for the @value{TARGET} architectures.
574 If you use (or have used) the @sc{gnu} assembler on one architecture, you
575 should find a fairly similar environment when you use it on another
576 architecture. Each version has much in common with the others,
577 including object file formats, most assembler directives (often called
578 @dfn{pseudo-ops}) and assembler syntax.@refill
580 @cindex purpose of @sc{gnu} @code{@value{AS}}
581 @code{@value{AS}} is primarily intended to assemble the output of the
582 @sc{gnu} C compiler @code{@value{GCC}} for use by the linker
583 @code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}
584 assemble correctly everything that other assemblers for the same
585 machine would assemble.
587 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
590 @c This remark should appear in generic version of manual; assumption
591 @c here is that generic version sets M680x0.
592 This doesn't mean @code{@value{AS}} always uses the same syntax as another
593 assembler for the same architecture; for example, we know of several
594 incompatible versions of 680x0 assembly language syntax.
597 Unlike older assemblers, @code{@value{AS}} is designed to assemble a source
598 program in one pass of the source file. This has a subtle impact on the
599 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
602 @section Object File Formats
604 @cindex object file format
605 The @sc{gnu} assembler can be configured to produce several alternative
606 object file formats. For the most part, this does not affect how you
607 write assembly language programs; but directives for debugging symbols
608 are typically different in different file formats. @xref{Symbol
609 Attributes,,Symbol Attributes}.
612 On the @value{TARGET}, @code{@value{AS}} is configured to produce
613 @value{OBJ-NAME} format object files.
615 @c The following should exhaust all configs that set MULTI-OBJ, ideally
617 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
618 @code{a.out} or COFF format object files.
621 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
622 @code{b.out} or COFF format object files.
625 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
626 SOM or ELF format object files.
631 @section Command Line
633 @cindex command line conventions
634 After the program name @code{@value{AS}}, the command line may contain
635 options and file names. Options may appear in any order, and may be
636 before, after, or between file names. The order of file names is
639 @cindex standard input, as input file
641 @file{--} (two hyphens) by itself names the standard input file
642 explicitly, as one of the files for @code{@value{AS}} to assemble.
644 @cindex options, command line
645 Except for @samp{--} any command line argument that begins with a
646 hyphen (@samp{-}) is an option. Each option changes the behavior of
647 @code{@value{AS}}. No option changes the way another option works. An
648 option is a @samp{-} followed by one or more letters; the case of
649 the letter is important. All options are optional.
651 Some options expect exactly one file name to follow them. The file
652 name may either immediately follow the option's letter (compatible
653 with older assemblers) or it may be the next command argument (@sc{gnu}
654 standard). These two command lines are equivalent:
657 @value{AS} -o my-object-file.o mumble.s
658 @value{AS} -omy-object-file.o mumble.s
665 @cindex source program
667 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
668 describe the program input to one run of @code{@value{AS}}. The program may
669 be in one or more files; how the source is partitioned into files
670 doesn't change the meaning of the source.
672 @c I added "con" prefix to "catenation" just to prove I can overcome my
673 @c APL training... pesch@cygnus.com
674 The source program is a concatenation of the text in all the files, in the
677 Each time you run @code{@value{AS}} it assembles exactly one source
678 program. The source program is made up of one or more files.
679 (The standard input is also a file.)
681 You give @code{@value{AS}} a command line that has zero or more input file
682 names. The input files are read (from left file name to right). A
683 command line argument (in any position) that has no special meaning
684 is taken to be an input file name.
686 If you give @code{@value{AS}} no file names it attempts to read one input file
687 from the @code{@value{AS}} standard input, which is normally your terminal. You
688 may have to type @key{ctl-D} to tell @code{@value{AS}} there is no more program
691 Use @samp{--} if you need to explicitly name the standard input file
692 in your command line.
694 If the source is empty, @code{@value{AS}} produces a small, empty object
697 @subheading Filenames and Line-numbers
699 @cindex input file linenumbers
700 @cindex line numbers, in input files
701 There are two ways of locating a line in the input file (or files) and
702 either may be used in reporting error messages. One way refers to a line
703 number in a physical file; the other refers to a line number in a
704 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
706 @dfn{Physical files} are those files named in the command line given
707 to @code{@value{AS}}.
709 @dfn{Logical files} are simply names declared explicitly by assembler
710 directives; they bear no relation to physical files. Logical file names
711 help error messages reflect the original source file, when @code{@value{AS}}
712 source is itself synthesized from other files.
713 @xref{App-File,,@code{.app-file}}.
716 @section Output (Object) File
722 Every time you run @code{@value{AS}} it produces an output file, which is
723 your assembly language program translated into numbers. This file
724 is the object file. Its default name is
732 @code{b.out} when @code{@value{AS}} is configured for the Intel 80960.
734 You can give it another name by using the @code{-o} option. Conventionally,
735 object file names end with @file{.o}. The default name is used for historical
736 reasons: older assemblers were capable of assembling self-contained programs
737 directly into a runnable program. (For some formats, this isn't currently
738 possible, but it can be done for the @code{a.out} format.)
742 The object file is meant for input to the linker @code{@value{LD}}. It contains
743 assembled program code, information to help @code{@value{LD}} integrate
744 the assembled program into a runnable file, and (optionally) symbolic
745 information for the debugger.
747 @c link above to some info file(s) like the description of a.out.
748 @c don't forget to describe GNU info as well as Unix lossage.
751 @section Error and Warning Messages
753 @cindex error messsages
754 @cindex warning messages
755 @cindex messages from @code{@value{AS}}
756 @code{@value{AS}} may write warnings and error messages to the standard error
757 file (usually your terminal). This should not happen when a compiler
758 runs @code{@value{AS}} automatically. Warnings report an assumption made so
759 that @code{@value{AS}} could keep assembling a flawed program; errors report a
760 grave problem that stops the assembly.
762 @cindex format of warning messages
763 Warning messages have the format
766 file_name:@b{NNN}:Warning Message Text
770 @cindex line numbers, in warnings/errors
771 (where @b{NNN} is a line number). If a logical file name has been given
772 (@pxref{App-File,,@code{.app-file}}) it is used for the filename,
773 otherwise the name of the current input file is used. If a logical line
776 (@pxref{Line,,@code{.line}})
780 (@pxref{Line,,@code{.line}})
783 (@pxref{Ln,,@code{.ln}})
786 then it is used to calculate the number printed,
787 otherwise the actual line in the current source file is printed. The
788 message text is intended to be self explanatory (in the grand Unix
791 @cindex format of error messages
792 Error messages have the format
794 file_name:@b{NNN}:FATAL:Error Message Text
796 The file name and line number are derived as for warning
797 messages. The actual message text may be rather less explanatory
798 because many of them aren't supposed to happen.
801 @chapter Command-Line Options
803 @cindex options, all versions of @code{@value{AS}}
804 This chapter describes command-line options available in @emph{all}
805 versions of the @sc{gnu} assembler; @pxref{Machine Dependencies}, for options specific
807 to the @value{TARGET}.
810 to particular machine architectures.
813 If you are invoking @code{@value{AS}} via the @sc{gnu} C compiler (version 2), you
814 can use the @samp{-Wa} option to pass arguments through to the
815 assembler. The assembler arguments must be separated from each other
816 (and the @samp{-Wa}) by commas. For example:
819 gcc -c -g -O -Wa,-alh,-L file.c
823 emits a listing to standard output with high-level
826 Usually you do not need to use this @samp{-Wa} mechanism, since many compiler
827 command-line options are automatically passed to the assembler by the compiler.
828 (You can call the @sc{gnu} compiler driver with the @samp{-v} option to see
829 precisely what options it passes to each compilation pass, including the
833 * a:: -a[dhlns] enable listings
834 * D:: -D for compatibility
835 * f:: -f to work faster
836 * I:: -I for .include search path
837 @ifclear DIFF-TBL-KLUGE
838 * K:: -K for compatibility
840 @ifset DIFF-TBL-KLUGE
841 * K:: -K for difference tables
844 * L:: -L to retain local labels
845 * o:: -o to name the object file
846 * R:: -R to join data and text sections
847 * statistics:: --statistics to see statistics about assembly
848 * v:: -v to announce version
849 * W:: -W to suppress warnings
850 * Z:: -Z to make object file even after errors
854 @section Enable Listings: @code{-a[dhlns]}
862 @cindex listings, enabling
863 @cindex assembly listings, enabling
865 These options enable listing output from the assembler. By itself,
866 @samp{-a} requests high-level, assembly, and symbols listing.
867 You can use other letters to select specific options for the list:
868 @samp{-ah} requests a high-level language listing,
869 @samp{-al} requests an output-program assembly listing, and
870 @samp{-as} requests a symbol table listing.
871 High-level listings require that a compiler debugging option like
872 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
875 Use the @samp{-ad} option to omit debugging directives from the
878 Once you have specified one of these options, you can further control
879 listing output and its appearance using the directives @code{.list},
880 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
882 The @samp{-an} option turns off all forms processing.
883 If you do not request listing output with one of the @samp{-a} options, the
884 listing-control directives have no effect.
886 The letters after @samp{-a} may be combined into one option,
887 @emph{e.g.}, @samp{-aln}.
893 This option has no effect whatsoever, but it is accepted to make it more
894 likely that scripts written for other assemblers also work with
898 @section Work Faster: @code{-f}
901 @cindex trusted compiler
902 @cindex faster processing (@code{-f})
903 @samp{-f} should only be used when assembling programs written by a
904 (trusted) compiler. @samp{-f} stops the assembler from doing whitespace
905 and comment preprocessing on
906 the input file(s) before assembling them. @xref{Preprocessing,
910 @emph{Warning:} if you use @samp{-f} when the files actually need to be
911 preprocessed (if they contain comments, for example), @code{@value{AS}} does
916 @section @code{.include} search path: @code{-I} @var{path}
918 @kindex -I @var{path}
919 @cindex paths for @code{.include}
920 @cindex search path for @code{.include}
921 @cindex @code{include} directive search path
922 Use this option to add a @var{path} to the list of directories
923 @code{@value{AS}} searches for files specified in @code{.include}
924 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
925 many times as necessary to include a variety of paths. The current
926 working directory is always searched first; after that, @code{@value{AS}}
927 searches any @samp{-I} directories in the same order as they were
928 specified (left to right) on the command line.
931 @section Difference Tables: @code{-K}
934 @ifclear DIFF-TBL-KLUGE
935 On the @value{TARGET} family, this option is allowed, but has no effect. It is
936 permitted for compatibility with the @sc{gnu} assembler on other platforms,
937 where it can be used to warn when the assembler alters the machine code
938 generated for @samp{.word} directives in difference tables. The @value{TARGET}
939 family does not have the addressing limitations that sometimes lead to this
940 alteration on other platforms.
943 @ifset DIFF-TBL-KLUGE
944 @cindex difference tables, warning
945 @cindex warning for altered difference tables
946 @code{@value{AS}} sometimes alters the code emitted for directives of the form
947 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
948 You can use the @samp{-K} option if you want a warning issued when this
953 @section Include Local Labels: @code{-L}
956 @cindex local labels, retaining in output
957 Labels beginning with @samp{L} (upper case only) are called @dfn{local
958 labels}. @xref{Symbol Names}. Normally you do not see such labels when
959 debugging, because they are intended for the use of programs (like
960 compilers) that compose assembler programs, not for your notice.
961 Normally both @code{@value{AS}} and @code{@value{LD}} discard such labels, so you do not
962 normally debug with them.
964 This option tells @code{@value{AS}} to retain those @samp{L@dots{}} symbols
965 in the object file. Usually if you do this you also tell the linker
966 @code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
968 By default, a local label is any label beginning with @samp{L}, but each
969 target is allowed to redefine the local label prefix.
971 On the HPPA local labels begin with @samp{L$}.
973 @c start-sanitize-arc
975 On the ARC local labels begin with @samp{.L}.
980 @section Name the Object File: @code{-o}
983 @cindex naming object file
984 @cindex object file name
985 There is always one object file output when you run @code{@value{AS}}. By
986 default it has the name
989 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
1003 You use this option (which takes exactly one filename) to give the
1004 object file a different name.
1006 Whatever the object file is called, @code{@value{AS}} overwrites any
1007 existing file of the same name.
1010 @section Join Data and Text Sections: @code{-R}
1013 @cindex data and text sections, joining
1014 @cindex text and data sections, joining
1015 @cindex joining text and data sections
1016 @cindex merging text and data sections
1017 @code{-R} tells @code{@value{AS}} to write the object file as if all
1018 data-section data lives in the text section. This is only done at
1019 the very last moment: your binary data are the same, but data
1020 section parts are relocated differently. The data section part of
1021 your object file is zero bytes long because all its bytes are
1022 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
1024 When you specify @code{-R} it would be possible to generate shorter
1025 address displacements (because we do not have to cross between text and
1026 data section). We refrain from doing this simply for compatibility with
1027 older versions of @code{@value{AS}}. In future, @code{-R} may work this way.
1030 When @code{@value{AS}} is configured for COFF output,
1031 this option is only useful if you use sections named @samp{.text} and
1036 @code{-R} is not supported for any of the HPPA targets. Using
1037 @code{-R} generates a warning from @code{@value{AS}}.
1041 @section Display Assembly Statistics: @code{--statistics}
1043 @kindex --statistics
1044 @cindex statistics, about assembly
1045 @cindex time, total for assembly
1046 @cindex space used, maximum for assembly
1047 Use @samp{--statistics} to display two statistics about the resources used by
1048 @code{@value{AS}}: the maximum amount of space allocated during the assembly
1049 (in bytes), and the total execution time taken for the assembly (in @sc{cpu}
1053 @section Announce Version: @code{-v}
1057 @cindex @code{@value{AS}} version
1058 @cindex version of @code{@value{AS}}
1059 You can find out what version of as is running by including the
1060 option @samp{-v} (which you can also spell as @samp{-version}) on the
1064 @section Suppress Warnings: @code{-W}
1067 @cindex suppressing warnings
1068 @cindex warnings, suppressing
1069 @code{@value{AS}} should never give a warning or error message when
1070 assembling compiler output. But programs written by people often
1071 cause @code{@value{AS}} to give a warning that a particular assumption was
1072 made. All such warnings are directed to the standard error file.
1073 If you use this option, no warnings are issued. This option only
1074 affects the warning messages: it does not change any particular of how
1075 @code{@value{AS}} assembles your file. Errors, which stop the assembly, are
1079 @section Generate Object File in Spite of Errors: @code{-Z}
1080 @cindex object file, after errors
1081 @cindex errors, continuing after
1082 After an error message, @code{@value{AS}} normally produces no output. If for
1083 some reason you are interested in object file output even after
1084 @code{@value{AS}} gives an error message on your program, use the @samp{-Z}
1085 option. If there are any errors, @code{@value{AS}} continues anyways, and
1086 writes an object file after a final warning message of the form @samp{@var{n}
1087 errors, @var{m} warnings, generating bad object file.}
1092 @cindex machine-independent syntax
1093 @cindex syntax, machine-independent
1094 This chapter describes the machine-independent syntax allowed in a
1095 source file. @code{@value{AS}} syntax is similar to what many other
1096 assemblers use; it is inspired by the BSD 4.2
1101 assembler, except that @code{@value{AS}} does not assemble Vax bit-fields.
1105 * Preprocessing:: Preprocessing
1106 * Whitespace:: Whitespace
1107 * Comments:: Comments
1108 * Symbol Intro:: Symbols
1109 * Statements:: Statements
1110 * Constants:: Constants
1114 @section Preprocessing
1116 @cindex preprocessing
1117 The @code{@value{AS}} internal preprocessor:
1119 @cindex whitespace, removed by preprocessor
1121 adjusts and removes extra whitespace. It leaves one space or tab before
1122 the keywords on a line, and turns any other whitespace on the line into
1125 @cindex comments, removed by preprocessor
1127 removes all comments, replacing them with a single space, or an
1128 appropriate number of newlines.
1130 @cindex constants, converted by preprocessor
1132 converts character constants into the appropriate numeric values.
1135 It does not do macro processing, include file handling, or
1136 anything else you may get from your C compiler's preprocessor. You can
1137 do include file processing with the @code{.include} directive
1138 (@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
1139 to get other ``CPP'' style preprocessing, by giving the input file a
1140 @samp{.S} suffix. @xref{Overall Options,, Options Controlling the Kind of
1141 Output, gcc.info, Using GNU CC}.
1143 Excess whitespace, comments, and character constants
1144 cannot be used in the portions of the input text that are not
1147 @cindex turning preprocessing on and off
1148 @cindex preprocessing, turning on and off
1151 If the first line of an input file is @code{#NO_APP} or if you use the
1152 @samp{-f} option, whitespace and comments are not removed from the input file.
1153 Within an input file, you can ask for whitespace and comment removal in
1154 specific portions of the by putting a line that says @code{#APP} before the
1155 text that may contain whitespace or comments, and putting a line that says
1156 @code{#NO_APP} after this text. This feature is mainly intend to support
1157 @code{asm} statements in compilers whose output is otherwise free of comments
1164 @dfn{Whitespace} is one or more blanks or tabs, in any order.
1165 Whitespace is used to separate symbols, and to make programs neater for
1166 people to read. Unless within character constants
1167 (@pxref{Characters,,Character Constants}), any whitespace means the same
1168 as exactly one space.
1174 There are two ways of rendering comments to @code{@value{AS}}. In both
1175 cases the comment is equivalent to one space.
1177 Anything from @samp{/*} through the next @samp{*/} is a comment.
1178 This means you may not nest these comments.
1182 The only way to include a newline ('\n') in a comment
1183 is to use this sort of comment.
1186 /* This sort of comment does not nest. */
1189 @cindex line comment character
1190 Anything from the @dfn{line comment} character to the next newline
1191 is considered a comment and is ignored. The line comment character is
1192 @c start-sanitize-arc
1194 @samp{;} on the ARC;
1198 @samp{#} on the Vax;
1201 @samp{#} on the i960;
1204 @samp{!} on the SPARC;
1207 @samp{|} on the 680x0;
1210 @samp{;} for the AMD 29K family;
1213 @samp{;} for the H8/300 family;
1216 @samp{!} for the H8/500 family;
1219 @samp{;} for the HPPA;
1222 @samp{!} for the Hitachi SH;
1225 @samp{!} for the Z8000;
1227 see @ref{Machine Dependencies}. @refill
1228 @c FIXME What about i386, m88k, i860?
1231 On some machines there are two different line comment characters. One
1232 character only begins a comment if it is the first non-whitespace character on
1233 a line, while the other always begins a comment.
1237 @cindex lines starting with @code{#}
1238 @cindex logical line numbers
1239 To be compatible with past assemblers, lines that begin with @samp{#} have a
1240 special interpretation. Following the @samp{#} should be an absolute
1241 expression (@pxref{Expressions}): the logical line number of the @emph{next}
1242 line. Then a string (@pxref{Strings,, Strings}) is allowed: if present it is a
1243 new logical file name. The rest of the line, if any, should be whitespace.
1245 If the first non-whitespace characters on the line are not numeric,
1246 the line is ignored. (Just like a comment.)
1249 # This is an ordinary comment.
1250 # 42-6 "new_file_name" # New logical file name
1251 # This is logical line # 36.
1253 This feature is deprecated, and may disappear from future versions
1254 of @code{@value{AS}}.
1259 @cindex characters used in symbols
1260 @ifclear SPECIAL-SYMS
1261 A @dfn{symbol} is one or more characters chosen from the set of all
1262 letters (both upper and lower case), digits and the three characters
1268 A @dfn{symbol} is one or more characters chosen from the set of all
1269 letters (both upper and lower case), digits and the three characters
1270 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
1276 On most machines, you can also use @code{$} in symbol names; exceptions
1277 are noted in @ref{Machine Dependencies}.
1279 No symbol may begin with a digit. Case is significant.
1280 There is no length limit: all characters are significant. Symbols are
1281 delimited by characters not in that set, or by the beginning of a file
1282 (since the source program must end with a newline, the end of a file is
1283 not a possible symbol delimiter). @xref{Symbols}.
1284 @cindex length of symbols
1289 @cindex statements, structure of
1290 @cindex line separator character
1291 @cindex statement separator character
1293 @ifclear abnormal-separator
1294 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
1295 semicolon (@samp{;}). The newline or semicolon is considered part of
1296 the preceding statement. Newlines and semicolons within character
1297 constants are an exception: they do not end statements.
1299 @ifset abnormal-separator
1301 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
1302 sign (@samp{@@}). The newline or at sign is considered part of the
1303 preceding statement. Newlines and at signs within character constants
1304 are an exception: they do not end statements.
1307 A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
1308 point (@samp{!}). The newline or exclamation point is considered part of the
1309 preceding statement. Newlines and exclamation points within character
1310 constants are an exception: they do not end statements.
1313 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
1314 H8/300) a dollar sign (@samp{$}); or (for the
1317 (@samp{;}). The newline or separator character is considered part of
1318 the preceding statement. Newlines and separators within character
1319 constants are an exception: they do not end statements.
1324 A @dfn{statement} ends at a newline character (@samp{\n}) or line
1325 separator character. (The line separator is usually @samp{;}, unless
1326 this conflicts with the comment character; @pxref{Machine Dependencies}.) The
1327 newline or separator character is considered part of the preceding
1328 statement. Newlines and separators within character constants are an
1329 exception: they do not end statements.
1332 @cindex newline, required at file end
1333 @cindex EOF, newline must precede
1334 It is an error to end any statement with end-of-file: the last
1335 character of any input file should be a newline.@refill
1337 @cindex continuing statements
1338 @cindex multi-line statements
1339 @cindex statement on multiple lines
1340 You may write a statement on more than one line if you put a
1341 backslash (@kbd{\}) immediately in front of any newlines within the
1342 statement. When @code{@value{AS}} reads a backslashed newline both
1343 characters are ignored. You can even put backslashed newlines in
1344 the middle of symbol names without changing the meaning of your
1347 An empty statement is allowed, and may include whitespace. It is ignored.
1349 @cindex instructions and directives
1350 @cindex directives and instructions
1351 @c "key symbol" is not used elsewhere in the document; seems pedantic to
1352 @c @defn{} it in that case, as was done previously... pesch@cygnus.com,
1354 A statement begins with zero or more labels, optionally followed by a
1355 key symbol which determines what kind of statement it is. The key
1356 symbol determines the syntax of the rest of the statement. If the
1357 symbol begins with a dot @samp{.} then the statement is an assembler
1358 directive: typically valid for any computer. If the symbol begins with
1359 a letter the statement is an assembly language @dfn{instruction}: it
1360 assembles into a machine language instruction.
1362 Different versions of @code{@value{AS}} for different computers
1363 recognize different instructions. In fact, the same symbol may
1364 represent a different instruction in a different computer's assembly
1368 @cindex @code{:} (label)
1369 @cindex label (@code{:})
1370 A label is a symbol immediately followed by a colon (@code{:}).
1371 Whitespace before a label or after a colon is permitted, but you may not
1372 have whitespace between a label's symbol and its colon. @xref{Labels}.
1375 For HPPA targets, labels need not be immediately followed by a colon, but
1376 the definition of a label must begin in column zero. This also implies that
1377 only one label may be defined on each line.
1381 label: .directive followed by something
1382 another_label: # This is an empty statement.
1383 instruction operand_1, operand_2, @dots{}
1390 A constant is a number, written so that its value is known by
1391 inspection, without knowing any context. Like this:
1394 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
1395 .ascii "Ring the bell\7" # A string constant.
1396 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
1397 .float 0f-314159265358979323846264338327\
1398 95028841971.693993751E-40 # - pi, a flonum.
1403 * Characters:: Character Constants
1404 * Numbers:: Number Constants
1408 @subsection Character Constants
1410 @cindex character constants
1411 @cindex constants, character
1412 There are two kinds of character constants. A @dfn{character} stands
1413 for one character in one byte and its value may be used in
1414 numeric expressions. String constants (properly called string
1415 @emph{literals}) are potentially many bytes and their values may not be
1416 used in arithmetic expressions.
1420 * Chars:: Characters
1424 @subsubsection Strings
1426 @cindex string constants
1427 @cindex constants, string
1428 A @dfn{string} is written between double-quotes. It may contain
1429 double-quotes or null characters. The way to get special characters
1430 into a string is to @dfn{escape} these characters: precede them with
1431 a backslash @samp{\} character. For example @samp{\\} represents
1432 one backslash: the first @code{\} is an escape which tells
1433 @code{@value{AS}} to interpret the second character literally as a backslash
1434 (which prevents @code{@value{AS}} from recognizing the second @code{\} as an
1435 escape character). The complete list of escapes follows.
1437 @cindex escape codes, character
1438 @cindex character escape codes
1441 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
1444 @cindex @code{\b} (backspace character)
1445 @cindex backspace (@code{\b})
1446 Mnemonic for backspace; for ASCII this is octal code 010.
1449 @c Mnemonic for EOText; for ASCII this is octal code 004.
1452 @cindex @code{\f} (formfeed character)
1453 @cindex formfeed (@code{\f})
1454 Mnemonic for FormFeed; for ASCII this is octal code 014.
1457 @cindex @code{\n} (newline character)
1458 @cindex newline (@code{\n})
1459 Mnemonic for newline; for ASCII this is octal code 012.
1462 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
1465 @cindex @code{\r} (carriage return character)
1466 @cindex carriage return (@code{\r})
1467 Mnemonic for carriage-Return; for ASCII this is octal code 015.
1470 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
1471 @c other assemblers.
1474 @cindex @code{\t} (tab)
1475 @cindex tab (@code{\t})
1476 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
1479 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
1480 @c @item \x @var{digit} @var{digit} @var{digit}
1481 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
1483 @item \ @var{digit} @var{digit} @var{digit}
1484 @cindex @code{\@var{ddd}} (octal character code)
1485 @cindex octal character code (@code{\@var{ddd}})
1486 An octal character code. The numeric code is 3 octal digits.
1487 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
1488 for example, @code{\008} has the value 010, and @code{\009} the value 011.
1491 @item \@code{x} @var{hex-digit} @var{hex-digit}
1492 @cindex @code{\@var{xdd}} (hex character code)
1493 @cindex hex character code (@code{\@var{xdd}})
1494 A hex character code. The numeric code is 2 hexadecimal digits. Either
1495 upper or lower case @code{x} works.
1499 @cindex @code{\\} (@samp{\} character)
1500 @cindex backslash (@code{\\})
1501 Represents one @samp{\} character.
1504 @c Represents one @samp{'} (accent acute) character.
1505 @c This is needed in single character literals
1506 @c (@xref{Characters,,Character Constants}.) to represent
1510 @cindex @code{\"} (doublequote character)
1511 @cindex doublequote (@code{\"})
1512 Represents one @samp{"} character. Needed in strings to represent
1513 this character, because an unescaped @samp{"} would end the string.
1515 @item \ @var{anything-else}
1516 Any other character when escaped by @kbd{\} gives a warning, but
1517 assembles as if the @samp{\} was not present. The idea is that if
1518 you used an escape sequence you clearly didn't want the literal
1519 interpretation of the following character. However @code{@value{AS}} has no
1520 other interpretation, so @code{@value{AS}} knows it is giving you the wrong
1521 code and warns you of the fact.
1524 Which characters are escapable, and what those escapes represent,
1525 varies widely among assemblers. The current set is what we think
1526 the BSD 4.2 assembler recognizes, and is a subset of what most C
1527 compilers recognize. If you are in doubt, do not use an escape
1531 @subsubsection Characters
1533 @cindex single character constant
1534 @cindex character, single
1535 @cindex constant, single character
1536 A single character may be written as a single quote immediately
1537 followed by that character. The same escapes apply to characters as
1538 to strings. So if you want to write the character backslash, you
1539 must write @kbd{'\\} where the first @code{\} escapes the second
1540 @code{\}. As you can see, the quote is an acute accent, not a
1541 grave accent. A newline
1543 @ifclear abnormal-separator
1544 (or semicolon @samp{;})
1546 @ifset abnormal-separator
1548 (or at sign @samp{@@})
1551 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
1557 immediately following an acute accent is taken as a literal character
1558 and does not count as the end of a statement. The value of a character
1559 constant in a numeric expression is the machine's byte-wide code for
1560 that character. @code{@value{AS}} assumes your character code is ASCII:
1561 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
1564 @subsection Number Constants
1566 @cindex constants, number
1567 @cindex number constants
1568 @code{@value{AS}} distinguishes three kinds of numbers according to how they
1569 are stored in the target machine. @emph{Integers} are numbers that
1570 would fit into an @code{int} in the C language. @emph{Bignums} are
1571 integers, but they are stored in more than 32 bits. @emph{Flonums}
1572 are floating point numbers, described below.
1575 * Integers:: Integers
1580 * Bit Fields:: Bit Fields
1586 @subsubsection Integers
1588 @cindex constants, integer
1590 @cindex binary integers
1591 @cindex integers, binary
1592 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
1593 the binary digits @samp{01}.
1595 @cindex octal integers
1596 @cindex integers, octal
1597 An octal integer is @samp{0} followed by zero or more of the octal
1598 digits (@samp{01234567}).
1600 @cindex decimal integers
1601 @cindex integers, decimal
1602 A decimal integer starts with a non-zero digit followed by zero or
1603 more digits (@samp{0123456789}).
1605 @cindex hexadecimal integers
1606 @cindex integers, hexadecimal
1607 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1608 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
1610 Integers have the usual values. To denote a negative integer, use
1611 the prefix operator @samp{-} discussed under expressions
1612 (@pxref{Prefix Ops,,Prefix Operators}).
1615 @subsubsection Bignums
1618 @cindex constants, bignum
1619 A @dfn{bignum} has the same syntax and semantics as an integer
1620 except that the number (or its negative) takes more than 32 bits to
1621 represent in binary. The distinction is made because in some places
1622 integers are permitted while bignums are not.
1625 @subsubsection Flonums
1627 @cindex floating point numbers
1628 @cindex constants, floating point
1630 @cindex precision, floating point
1631 A @dfn{flonum} represents a floating point number. The translation is
1632 indirect: a decimal floating point number from the text is converted by
1633 @code{@value{AS}} to a generic binary floating point number of more than
1634 sufficient precision. This generic floating point number is converted
1635 to a particular computer's floating point format (or formats) by a
1636 portion of @code{@value{AS}} specialized to that computer.
1638 A flonum is written by writing (in order)
1643 (@samp{0} is optional on the HPPA.)
1647 A letter, to tell @code{@value{AS}} the rest of the number is a flonum.
1649 @kbd{e} is recommended. Case is not important.
1651 @c FIXME: verify if flonum syntax really this vague for most cases
1652 (Any otherwise illegal letter works here, but that might be changed. Vax BSD
1653 4.2 assembler seems to allow any of @samp{defghDEFGH}.)
1656 On the H8/300, H8/500,
1658 and AMD 29K architectures, the letter must be
1659 one of the letters @samp{DFPRSX} (in upper or lower case).
1661 @c start-sanitize-arc
1662 On the ARC, the letter one of the letters @samp{DFRS}
1663 (in upper or lower case).
1666 On the Intel 960 architecture, the letter must be
1667 one of the letters @samp{DFT} (in upper or lower case).
1669 On the HPPA architecture, the letter must be @samp{E} (upper case only).
1673 One of the letters @samp{DFPRSX} (in upper or lower case).
1675 @c start-sanitize-arc
1677 One of the letters @samp{DFRS} (in upper or lower case).
1681 One of the letters @samp{DFPRSX} (in upper or lower case).
1684 One of the letters @samp{DFT} (in upper or lower case).
1687 The letter @samp{E} (upper case only).
1692 An optional sign: either @samp{+} or @samp{-}.
1695 An optional @dfn{integer part}: zero or more decimal digits.
1698 An optional @dfn{fractional part}: @samp{.} followed by zero
1699 or more decimal digits.
1702 An optional exponent, consisting of:
1706 An @samp{E} or @samp{e}.
1707 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1708 @c principle this can perfectly well be different on different targets.
1710 Optional sign: either @samp{+} or @samp{-}.
1712 One or more decimal digits.
1717 At least one of the integer part or the fractional part must be
1718 present. The floating point number has the usual base-10 value.
1720 @code{@value{AS}} does all processing using integers. Flonums are computed
1721 independently of any floating point hardware in the computer running
1726 @c Bit fields are written as a general facility but are also controlled
1727 @c by a conditional-compilation flag---which is as of now (21mar91)
1728 @c turned on only by the i960 config of GAS.
1730 @subsubsection Bit Fields
1733 @cindex constants, bit field
1734 You can also define numeric constants as @dfn{bit fields}.
1735 specify two numbers separated by a colon---
1737 @var{mask}:@var{value}
1740 @code{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
1743 The resulting number is then packed
1745 @c this conditional paren in case bit fields turned on elsewhere than 960
1746 (in host-dependent byte order)
1748 into a field whose width depends on which assembler directive has the
1749 bit-field as its argument. Overflow (a result from the bitwise and
1750 requiring more binary digits to represent) is not an error; instead,
1751 more constants are generated, of the specified width, beginning with the
1752 least significant digits.@refill
1754 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1755 @code{.short}, and @code{.word} accept bit-field arguments.
1760 @chapter Sections and Relocation
1765 * Secs Background:: Background
1766 * Ld Sections:: @value{LD} Sections
1767 * As Sections:: @value{AS} Internal Sections
1768 * Sub-Sections:: Sub-Sections
1772 @node Secs Background
1775 Roughly, a section is a range of addresses, with no gaps; all data
1776 ``in'' those addresses is treated the same for some particular purpose.
1777 For example there may be a ``read only'' section.
1779 @cindex linker, and assembler
1780 @cindex assembler, and linker
1781 The linker @code{@value{LD}} reads many object files (partial programs) and
1782 combines their contents to form a runnable program. When @code{@value{AS}}
1783 emits an object file, the partial program is assumed to start at address 0.
1784 @code{@value{LD}} assigns the final addresses for the partial program, so that
1785 different partial programs do not overlap. This is actually an
1786 oversimplification, but it suffices to explain how @code{@value{AS}} uses
1789 @code{@value{LD}} moves blocks of bytes of your program to their run-time
1790 addresses. These blocks slide to their run-time addresses as rigid
1791 units; their length does not change and neither does the order of bytes
1792 within them. Such a rigid unit is called a @emph{section}. Assigning
1793 run-time addresses to sections is called @dfn{relocation}. It includes
1794 the task of adjusting mentions of object-file addresses so they refer to
1795 the proper run-time addresses.
1797 For the H8/300 and H8/500,
1798 and for the Hitachi SH,
1799 @code{@value{AS}} pads sections if needed to
1800 ensure they end on a word (sixteen bit) boundary.
1803 @cindex standard @code{@value{AS}} sections
1804 An object file written by @code{@value{AS}} has at least three sections, any
1805 of which may be empty. These are named @dfn{text}, @dfn{data} and
1810 When it generates COFF output,
1812 @code{@value{AS}} can also generate whatever other named sections you specify
1813 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1814 If you do not use any directives that place output in the @samp{.text}
1815 or @samp{.data} sections, these sections still exist, but are empty.
1820 When @code{@value{AS}} generates SOM or ELF output for the HPPA,
1822 @code{@value{AS}} can also generate whatever other named sections you
1823 specify using the @samp{.space} and @samp{.subspace} directives. See
1824 @cite{HP9000 Series 800 Assembly Language Reference Manual}
1825 (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
1826 assembler directives.
1829 Additionally, @code{@value{AS}} uses different names for the standard
1830 text, data, and bss sections when generating SOM output. Program text
1831 is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
1832 BSS into @samp{$BSS$}.
1836 Within the object file, the text section starts at address @code{0}, the
1837 data section follows, and the bss section follows the data section.
1840 When generating either SOM or ELF output files on the HPPA, the text
1841 section starts at address @code{0}, the data section at address
1842 @code{0x4000000}, and the bss section follows the data section.
1845 To let @code{@value{LD}} know which data changes when the sections are
1846 relocated, and how to change that data, @code{@value{AS}} also writes to the
1847 object file details of the relocation needed. To perform relocation
1848 @code{@value{LD}} must know, each time an address in the object
1852 Where in the object file is the beginning of this reference to
1855 How long (in bytes) is this reference?
1857 Which section does the address refer to? What is the numeric value of
1859 (@var{address}) @minus{} (@var{start-address of section})?
1862 Is the reference to an address ``Program-Counter relative''?
1865 @cindex addresses, format of
1866 @cindex section-relative addressing
1867 In fact, every address @code{@value{AS}} ever uses is expressed as
1869 (@var{section}) + (@var{offset into section})
1872 Further, most expressions @code{@value{AS}} computes have this section-relative
1875 (For some object formats, such as SOM for the HPPA, some expressions are
1876 symbol-relative instead.)
1879 In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset
1880 @var{N} into section @var{secname}.''
1882 Apart from text, data and bss sections you need to know about the
1883 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
1884 addresses in the absolute section remain unchanged. For example, address
1885 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by
1886 @code{@value{LD}}. Although the linker never arranges two partial programs'
1887 data sections with overlapping addresses after linking, @emph{by definition}
1888 their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one
1889 part of a program is always the same address when the program is running as
1890 address @code{@{absolute@ 239@}} in any other part of the program.
1892 The idea of sections is extended to the @dfn{undefined} section. Any
1893 address whose section is unknown at assembly time is by definition
1894 rendered @{undefined @var{U}@}---where @var{U} is filled in later.
1895 Since numbers are always defined, the only way to generate an undefined
1896 address is to mention an undefined symbol. A reference to a named
1897 common block would be such a symbol: its value is unknown at assembly
1898 time so it has section @emph{undefined}.
1900 By analogy the word @emph{section} is used to describe groups of sections in
1901 the linked program. @code{@value{LD}} puts all partial programs' text
1902 sections in contiguous addresses in the linked program. It is
1903 customary to refer to the @emph{text section} of a program, meaning all
1904 the addresses of all partial programs' text sections. Likewise for
1905 data and bss sections.
1907 Some sections are manipulated by @code{@value{LD}}; others are invented for
1908 use of @code{@value{AS}} and have no meaning except during assembly.
1911 @section @value{LD} Sections
1912 @code{@value{LD}} deals with just four kinds of sections, summarized below.
1917 @cindex named sections
1918 @cindex sections, named
1919 @item named sections
1922 @cindex text section
1923 @cindex data section
1927 These sections hold your program. @code{@value{AS}} and @code{@value{LD}} treat them as
1928 separate but equal sections. Anything you can say of one section is
1931 When the program is running, however, it is
1932 customary for the text section to be unalterable. The
1933 text section is often shared among processes: it contains
1934 instructions, constants and the like. The data section of a running
1935 program is usually alterable: for example, C variables would be stored
1936 in the data section.
1941 This section contains zeroed bytes when your program begins running. It
1942 is used to hold unitialized variables or common storage. The length of
1943 each partial program's bss section is important, but because it starts
1944 out containing zeroed bytes there is no need to store explicit zero
1945 bytes in the object file. The bss section was invented to eliminate
1946 those explicit zeros from object files.
1948 @cindex absolute section
1949 @item absolute section
1950 Address 0 of this section is always ``relocated'' to runtime address 0.
1951 This is useful if you want to refer to an address that @code{@value{LD}} must
1952 not change when relocating. In this sense we speak of absolute
1953 addresses being ``unrelocatable'': they do not change during relocation.
1955 @cindex undefined section
1956 @item undefined section
1957 This ``section'' is a catch-all for address references to objects not in
1958 the preceding sections.
1959 @c FIXME: ref to some other doc on obj-file formats could go here.
1962 @cindex relocation example
1963 An idealized example of three relocatable sections follows.
1965 The example uses the traditional section names @samp{.text} and @samp{.data}.
1967 Memory addresses are on the horizontal axis.
1971 @c END TEXI2ROFF-KILL
1974 partial program # 1: |ttttt|dddd|00|
1981 partial program # 2: |TTT|DDD|000|
1984 +--+---+-----+--+----+---+-----+~~
1985 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1986 +--+---+-----+--+----+---+-----+~~
1988 addresses: 0 @dots{}
1995 \line{\it Partial program \#1: \hfil}
1996 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1997 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1999 \line{\it Partial program \#2: \hfil}
2000 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
2001 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
2003 \line{\it linked program: \hfil}
2004 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
2005 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
2006 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
2007 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
2009 \line{\it addresses: \hfil}
2013 @c END TEXI2ROFF-KILL
2016 @section @value{AS} Internal Sections
2018 @cindex internal @code{@value{AS}} sections
2019 @cindex sections in messages, internal
2020 These sections are meant only for the internal use of @code{@value{AS}}. They
2021 have no meaning at run-time. You do not really need to know about these
2022 sections for most purposes; but they can be mentioned in @code{@value{AS}}
2023 warning messages, so it might be helpful to have an idea of their
2024 meanings to @code{@value{AS}}. These sections are used to permit the
2025 value of every expression in your assembly language program to be a
2026 section-relative address.
2029 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
2030 @cindex assembler internal logic error
2031 An internal assembler logic error has been found. This means there is a
2032 bug in the assembler.
2035 @cindex expr (internal section)
2036 The assembler stores complex expression internally as combinations of
2037 symbols. When it needs to represent an expression as a symbol, it puts
2038 it in the expr section.
2040 @c FIXME item transfer[t] vector preload
2041 @c FIXME item transfer[t] vector postload
2042 @c FIXME item register
2046 @section Sub-Sections
2048 @cindex numbered subsections
2049 @cindex grouping data
2055 fall into two sections: text and data.
2057 You may have separate groups of
2059 data in named sections
2063 data in named sections
2069 that you want to end up near to each other in the object file, even though they
2070 are not contiguous in the assembler source. @code{@value{AS}} allows you to
2071 use @dfn{subsections} for this purpose. Within each section, there can be
2072 numbered subsections with values from 0 to 8192. Objects assembled into the
2073 same subsection go into the object file together with other objects in the same
2074 subsection. For example, a compiler might want to store constants in the text
2075 section, but might not want to have them interspersed with the program being
2076 assembled. In this case, the compiler could issue a @samp{.text 0} before each
2077 section of code being output, and a @samp{.text 1} before each group of
2078 constants being output.
2080 Subsections are optional. If you do not use subsections, everything
2081 goes in subsection number zero.
2084 Each subsection is zero-padded up to a multiple of four bytes.
2085 (Subsections may be padded a different amount on different flavors
2086 of @code{@value{AS}}.)
2090 On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
2091 boundary (two bytes).
2092 The same is true on the Hitachi SH.
2095 @c FIXME section padding (alignment)?
2096 @c Rich Pixley says padding here depends on target obj code format; that
2097 @c doesn't seem particularly useful to say without further elaboration,
2098 @c so for now I say nothing about it. If this is a generic BFD issue,
2099 @c these paragraphs might need to vanish from this manual, and be
2100 @c discussed in BFD chapter of binutils (or some such).
2103 On the AMD 29K family, no particular padding is added to section or
2104 subsection sizes; @value{AS} forces no alignment on this platform.
2108 Subsections appear in your object file in numeric order, lowest numbered
2109 to highest. (All this to be compatible with other people's assemblers.)
2110 The object file contains no representation of subsections; @code{@value{LD}} and
2111 other programs that manipulate object files see no trace of them.
2112 They just see all your text subsections as a text section, and all your
2113 data subsections as a data section.
2115 To specify which subsection you want subsequent statements assembled
2116 into, use a numeric argument to specify it, in a @samp{.text
2117 @var{expression}} or a @samp{.data @var{expression}} statement.
2120 When generating COFF output, you
2125 can also use an extra subsection
2126 argument with arbitrary named sections: @samp{.section @var{name},
2129 @var{Expression} should be an absolute expression.
2130 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
2131 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
2132 begins in @code{text 0}. For instance:
2134 .text 0 # The default subsection is text 0 anyway.
2135 .ascii "This lives in the first text subsection. *"
2137 .ascii "But this lives in the second text subsection."
2139 .ascii "This lives in the data section,"
2140 .ascii "in the first data subsection."
2142 .ascii "This lives in the first text section,"
2143 .ascii "immediately following the asterisk (*)."
2146 Each section has a @dfn{location counter} incremented by one for every byte
2147 assembled into that section. Because subsections are merely a convenience
2148 restricted to @code{@value{AS}} there is no concept of a subsection location
2149 counter. There is no way to directly manipulate a location counter---but the
2150 @code{.align} directive changes it, and any label definition captures its
2151 current value. The location counter of the section where statements are being
2152 assembled is said to be the @dfn{active} location counter.
2155 @section bss Section
2158 @cindex common variable storage
2159 The bss section is used for local common variable storage.
2160 You may allocate address space in the bss section, but you may
2161 not dictate data to load into it before your program executes. When
2162 your program starts running, all the contents of the bss
2163 section are zeroed bytes.
2165 Addresses in the bss section are allocated with special directives; you
2166 may not assemble anything directly into the bss section. Hence there
2167 are no bss subsections. @xref{Comm,,@code{.comm}},
2168 @pxref{Lcomm,,@code{.lcomm}}.
2174 Symbols are a central concept: the programmer uses symbols to name
2175 things, the linker uses symbols to link, and the debugger uses symbols
2179 @cindex debuggers, and symbol order
2180 @emph{Warning:} @code{@value{AS}} does not place symbols in the object file in
2181 the same order they were declared. This may break some debuggers.
2186 * Setting Symbols:: Giving Symbols Other Values
2187 * Symbol Names:: Symbol Names
2188 * Dot:: The Special Dot Symbol
2189 * Symbol Attributes:: Symbol Attributes
2196 A @dfn{label} is written as a symbol immediately followed by a colon
2197 @samp{:}. The symbol then represents the current value of the
2198 active location counter, and is, for example, a suitable instruction
2199 operand. You are warned if you use the same symbol to represent two
2200 different locations: the first definition overrides any other
2204 On the HPPA, the usual form for a label need not be immediately followed by a
2205 colon, but instead must start in column zero. Only one label may be defined on
2206 a single line. To work around this, the HPPA version of @code{@value{AS}} also
2207 provides a special directive @code{.label} for defining labels more flexibly.
2210 @node Setting Symbols
2211 @section Giving Symbols Other Values
2213 @cindex assigning values to symbols
2214 @cindex symbol values, assigning
2215 A symbol can be given an arbitrary value by writing a symbol, followed
2216 by an equals sign @samp{=}, followed by an expression
2217 (@pxref{Expressions}). This is equivalent to using the @code{.set}
2218 directive. @xref{Set,,@code{.set}}.
2221 @section Symbol Names
2223 @cindex symbol names
2224 @cindex names, symbol
2225 @ifclear SPECIAL-SYMS
2226 Symbol names begin with a letter or with one of @samp{._}. On most
2227 machines, you can also use @code{$} in symbol names; exceptions are
2228 noted in @ref{Machine Dependencies}. That character may be followed by any
2229 string of digits, letters, dollar signs (unless otherwise noted in
2230 @ref{Machine Dependencies}), and underscores.
2233 For the AMD 29K family, @samp{?} is also allowed in the
2234 body of a symbol name, though not at its beginning.
2239 Symbol names begin with a letter or with one of @samp{._}. On the
2241 H8/500, you can also use @code{$} in symbol names. That character may
2242 be followed by any string of digits, letters, dollar signs (save on the
2243 H8/300), and underscores.
2247 Case of letters is significant: @code{foo} is a different symbol name
2250 Each symbol has exactly one name. Each name in an assembly language program
2251 refers to exactly one symbol. You may use that symbol name any number of times
2254 @subheading Local Symbol Names
2256 @cindex local symbol names
2257 @cindex symbol names, local
2258 @cindex temporary symbol names
2259 @cindex symbol names, temporary
2260 Local symbols help compilers and programmers use names temporarily.
2261 There are ten local symbol names, which are re-used throughout the
2262 program. You may refer to them using the names @samp{0} @samp{1}
2263 @dots{} @samp{9}. To define a local symbol, write a label of the form
2264 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
2265 recent previous definition of that symbol write @samp{@b{N}b}, using the
2266 same digit as when you defined the label. To refer to the next
2267 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
2268 a choice of 10 forward references. The @samp{b} stands for
2269 ``backwards'' and the @samp{f} stands for ``forwards''.
2271 Local symbols are not emitted by the current @sc{gnu} C compiler.
2273 There is no restriction on how you can use these labels, but
2274 remember that at any point in the assembly you can refer to at most
2275 10 prior local labels and to at most 10 forward local labels.
2277 Local symbol names are only a notation device. They are immediately
2278 transformed into more conventional symbol names before the assembler
2279 uses them. The symbol names stored in the symbol table, appearing in
2280 error messages and optionally emitted to the object file have these
2285 All local labels begin with @samp{L}. Normally both @code{@value{AS}} and
2286 @code{@value{LD}} forget symbols that start with @samp{L}. These labels are
2287 used for symbols you are never intended to see. If you use the
2288 @samp{-L} option then @code{@value{AS}} retains these symbols in the
2289 object file. If you also instruct @code{@value{LD}} to retain these symbols,
2290 you may use them in debugging.
2293 If the label is written @samp{0:} then the digit is @samp{0}.
2294 If the label is written @samp{1:} then the digit is @samp{1}.
2295 And so on up through @samp{9:}.
2298 This unusual character is included so you do not accidentally invent
2299 a symbol of the same name. The character has ASCII value
2302 @item @emph{ordinal number}
2303 This is a serial number to keep the labels distinct. The first
2304 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
2305 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
2309 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
2310 @code{3:} is named @code{L3@ctrl{A}44}.
2313 @section The Special Dot Symbol
2315 @cindex dot (symbol)
2316 @cindex @code{.} (symbol)
2317 @cindex current address
2318 @cindex location counter
2319 The special symbol @samp{.} refers to the current address that
2320 @code{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
2321 .long .} defines @code{melvin} to contain its own address.
2322 Assigning a value to @code{.} is treated the same as a @code{.org}
2323 directive. Thus, the expression @samp{.=.+4} is the same as saying
2324 @ifclear no-space-dir
2333 @node Symbol Attributes
2334 @section Symbol Attributes
2336 @cindex symbol attributes
2337 @cindex attributes, symbol
2338 Every symbol has, as well as its name, the attributes ``Value'' and
2339 ``Type''. Depending on output format, symbols can also have auxiliary
2342 The detailed definitions are in @file{a.out.h}.
2345 If you use a symbol without defining it, @code{@value{AS}} assumes zero for
2346 all these attributes, and probably won't warn you. This makes the
2347 symbol an externally defined symbol, which is generally what you
2351 * Symbol Value:: Value
2352 * Symbol Type:: Type
2355 * a.out Symbols:: Symbol Attributes: @code{a.out}
2359 * a.out Symbols:: Symbol Attributes: @code{a.out}
2362 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
2367 * COFF Symbols:: Symbol Attributes for COFF
2370 * SOM Symbols:: Symbol Attributes for SOM
2377 @cindex value of a symbol
2378 @cindex symbol value
2379 The value of a symbol is (usually) 32 bits. For a symbol which labels a
2380 location in the text, data, bss or absolute sections the value is the
2381 number of addresses from the start of that section to the label.
2382 Naturally for text, data and bss sections the value of a symbol changes
2383 as @code{@value{LD}} changes section base addresses during linking. Absolute
2384 symbols' values do not change during linking: that is why they are
2387 The value of an undefined symbol is treated in a special way. If it is
2388 0 then the symbol is not defined in this assembler source file, and
2389 @code{@value{LD}} tries to determine its value from other files linked into the
2390 same program. You make this kind of symbol simply by mentioning a symbol
2391 name without defining it. A non-zero value represents a @code{.comm}
2392 common declaration. The value is how much common storage to reserve, in
2393 bytes (addresses). The symbol refers to the first address of the
2399 @cindex type of a symbol
2401 The type attribute of a symbol contains relocation (section)
2402 information, any flag settings indicating that a symbol is external, and
2403 (optionally), other information for linkers and debuggers. The exact
2404 format depends on the object-code output format in use.
2409 @c The following avoids a "widow" subsection title. @group would be
2410 @c better if it were available outside examples.
2413 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
2415 @cindex @code{b.out} symbol attributes
2416 @cindex symbol attributes, @code{b.out}
2417 These symbol attributes appear only when @code{@value{AS}} is configured for
2418 one of the Berkeley-descended object output formats---@code{a.out} or
2424 @subsection Symbol Attributes: @code{a.out}
2426 @cindex @code{a.out} symbol attributes
2427 @cindex symbol attributes, @code{a.out}
2433 @subsection Symbol Attributes: @code{a.out}
2435 @cindex @code{a.out} symbol attributes
2436 @cindex symbol attributes, @code{a.out}
2440 * Symbol Desc:: Descriptor
2441 * Symbol Other:: Other
2445 @subsubsection Descriptor
2447 @cindex descriptor, of @code{a.out} symbol
2448 This is an arbitrary 16-bit value. You may establish a symbol's
2449 descriptor value by using a @code{.desc} statement
2450 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
2454 @subsubsection Other
2456 @cindex other attribute, of @code{a.out} symbol
2457 This is an arbitrary 8-bit value. It means nothing to @code{@value{AS}}.
2462 @subsection Symbol Attributes for COFF
2464 @cindex COFF symbol attributes
2465 @cindex symbol attributes, COFF
2467 The COFF format supports a multitude of auxiliary symbol attributes;
2468 like the primary symbol attributes, they are set between @code{.def} and
2469 @code{.endef} directives.
2471 @subsubsection Primary Attributes
2473 @cindex primary attributes, COFF symbols
2474 The symbol name is set with @code{.def}; the value and type,
2475 respectively, with @code{.val} and @code{.type}.
2477 @subsubsection Auxiliary Attributes
2479 @cindex auxiliary attributes, COFF symbols
2480 The @code{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
2481 @code{.size}, and @code{.tag} can generate auxiliary symbol table
2482 information for COFF.
2487 @subsection Symbol Attributes for SOM
2489 @cindex SOM symbol attributes
2490 @cindex symbol attributes, SOM
2492 The SOM format for the HPPA supports a multitude of symbol attributes set with
2493 the @code{.EXPORT} and @code{.IMPORT} directives.
2495 The attributes are described in @cite{HP9000 Series 800 Assembly
2496 Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
2497 @code{EXPORT} assembler directive documentation.
2501 @chapter Expressions
2505 @cindex numeric values
2506 An @dfn{expression} specifies an address or numeric value.
2507 Whitespace may precede and/or follow an expression.
2509 The result of an expression must be an absolute number, or else an offset into
2510 a particular section. If an expression is not absolute, and there is not
2511 enough information when @code{@value{AS}} sees the expression to know its
2512 section, a second pass over the source program might be necessary to interpret
2513 the expression---but the second pass is currently not implemented.
2514 @code{@value{AS}} aborts with an error message in this situation.
2517 * Empty Exprs:: Empty Expressions
2518 * Integer Exprs:: Integer Expressions
2522 @section Empty Expressions
2524 @cindex empty expressions
2525 @cindex expressions, empty
2526 An empty expression has no value: it is just whitespace or null.
2527 Wherever an absolute expression is required, you may omit the
2528 expression, and @code{@value{AS}} assumes a value of (absolute) 0. This
2529 is compatible with other assemblers.
2532 @section Integer Expressions
2534 @cindex integer expressions
2535 @cindex expressions, integer
2536 An @dfn{integer expression} is one or more @emph{arguments} delimited
2537 by @emph{operators}.
2540 * Arguments:: Arguments
2541 * Operators:: Operators
2542 * Prefix Ops:: Prefix Operators
2543 * Infix Ops:: Infix Operators
2547 @subsection Arguments
2549 @cindex expression arguments
2550 @cindex arguments in expressions
2551 @cindex operands in expressions
2552 @cindex arithmetic operands
2553 @dfn{Arguments} are symbols, numbers or subexpressions. In other
2554 contexts arguments are sometimes called ``arithmetic operands''. In
2555 this manual, to avoid confusing them with the ``instruction operands'' of
2556 the machine language, we use the term ``argument'' to refer to parts of
2557 expressions only, reserving the word ``operand'' to refer only to machine
2558 instruction operands.
2560 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
2561 @var{section} is one of text, data, bss, absolute,
2562 or undefined. @var{NNN} is a signed, 2's complement 32 bit
2565 Numbers are usually integers.
2567 A number can be a flonum or bignum. In this case, you are warned
2568 that only the low order 32 bits are used, and @code{@value{AS}} pretends
2569 these 32 bits are an integer. You may write integer-manipulating
2570 instructions that act on exotic constants, compatible with other
2573 @cindex subexpressions
2574 Subexpressions are a left parenthesis @samp{(} followed by an integer
2575 expression, followed by a right parenthesis @samp{)}; or a prefix
2576 operator followed by an argument.
2579 @subsection Operators
2581 @cindex operators, in expressions
2582 @cindex arithmetic functions
2583 @cindex functions, in expressions
2584 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
2585 operators are followed by an argument. Infix operators appear
2586 between their arguments. Operators may be preceded and/or followed by
2590 @subsection Prefix Operator
2592 @cindex prefix operators
2593 @code{@value{AS}} has the following @dfn{prefix operators}. They each take
2594 one argument, which must be absolute.
2596 @c the tex/end tex stuff surrounding this small table is meant to make
2597 @c it align, on the printed page, with the similar table in the next
2598 @c section (which is inside an enumerate).
2600 \global\advance\leftskip by \itemindent
2605 @dfn{Negation}. Two's complement negation.
2607 @dfn{Complementation}. Bitwise not.
2611 \global\advance\leftskip by -\itemindent
2615 @subsection Infix Operators
2617 @cindex infix operators
2618 @cindex operators, permitted arguments
2619 @dfn{Infix operators} take two arguments, one on either side. Operators
2620 have precedence, but operations with equal precedence are performed left
2621 to right. Apart from @code{+} or @code{-}, both arguments must be
2622 absolute, and the result is absolute.
2625 @cindex operator precedence
2626 @cindex precedence of operators
2633 @dfn{Multiplication}.
2636 @dfn{Division}. Truncation is the same as the C operator @samp{/}
2643 @dfn{Shift Left}. Same as the C operator @samp{<<}.
2647 @dfn{Shift Right}. Same as the C operator @samp{>>}.
2651 Intermediate precedence
2656 @dfn{Bitwise Inclusive Or}.
2662 @dfn{Bitwise Exclusive Or}.
2665 @dfn{Bitwise Or Not}.
2673 @cindex addition, permitted arguments
2674 @cindex plus, permitted arguments
2675 @cindex arguments for addition
2676 @dfn{Addition}. If either argument is absolute, the result has the section of
2677 the other argument. You may not add together arguments from different
2681 @cindex subtraction, permitted arguments
2682 @cindex minus, permitted arguments
2683 @cindex arguments for subtraction
2684 @dfn{Subtraction}. If the right argument is absolute, the
2685 result has the section of the left argument.
2686 If both arguments are in the same section, the result is absolute.
2687 You may not subtract arguments from different sections.
2688 @c FIXME is there still something useful to say about undefined - undefined ?
2692 In short, it's only meaningful to add or subtract the @emph{offsets} in an
2693 address; you can only have a defined section in one of the two arguments.
2696 @chapter Assembler Directives
2698 @cindex directives, machine independent
2699 @cindex pseudo-ops, machine independent
2700 @cindex machine independent directives
2701 All assembler directives have names that begin with a period (@samp{.}).
2702 The rest of the name is letters, usually in lower case.
2704 This chapter discusses directives that are available regardless of the
2705 target machine configuration for the @sc{gnu} assembler.
2707 Some machine configurations provide additional directives.
2708 @xref{Machine Dependencies}.
2711 @ifset machine-directives
2712 @xref{Machine Dependencies} for additional directives.
2717 * Abort:: @code{.abort}
2719 * ABORT:: @code{.ABORT}
2722 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
2723 * App-File:: @code{.app-file @var{string}}
2724 * Ascii:: @code{.ascii "@var{string}"}@dots{}
2725 * Asciz:: @code{.asciz "@var{string}"}@dots{}
2726 * Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}}
2727 * Byte:: @code{.byte @var{expressions}}
2728 * Comm:: @code{.comm @var{symbol} , @var{length} }
2729 * Data:: @code{.data @var{subsection}}
2731 * Def:: @code{.def @var{name}}
2734 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
2740 * Double:: @code{.double @var{flonums}}
2741 * Eject:: @code{.eject}
2742 * Else:: @code{.else}
2744 * Endef:: @code{.endef}
2747 * Endif:: @code{.endif}
2748 * Equ:: @code{.equ @var{symbol}, @var{expression}}
2749 * Extern:: @code{.extern}
2750 @ifclear no-file-dir
2751 * File:: @code{.file @var{string}}
2754 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
2755 * Float:: @code{.float @var{flonums}}
2756 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2757 * hword:: @code{.hword @var{expressions}}
2758 * Ident:: @code{.ident}
2759 * If:: @code{.if @var{absolute expression}}
2760 * Include:: @code{.include "@var{file}"}
2761 * Int:: @code{.int @var{expressions}}
2762 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
2763 * Lflags:: @code{.lflags}
2764 @ifclear no-line-dir
2765 * Line:: @code{.line @var{line-number}}
2768 * Ln:: @code{.ln @var{line-number}}
2769 * List:: @code{.list}
2770 * Long:: @code{.long @var{expressions}}
2772 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
2775 * Nolist:: @code{.nolist}
2776 * Octa:: @code{.octa @var{bignums}}
2777 * Org:: @code{.org @var{new-lc} , @var{fill}}
2778 * P2align:: @code{.p2align @var{abs-expr} , @var{abs-expr}}
2779 * Psize:: @code{.psize @var{lines}, @var{columns}}
2780 * Quad:: @code{.quad @var{bignums}}
2781 * Sbttl:: @code{.sbttl "@var{subheading}"}
2783 * Scl:: @code{.scl @var{class}}
2786 * Section:: @code{.section @var{name}, @var{subsection}}
2789 * Set:: @code{.set @var{symbol}, @var{expression}}
2790 * Short:: @code{.short @var{expressions}}
2791 * Single:: @code{.single @var{flonums}}
2793 * Size:: @code{.size}
2796 * Space:: @code{.space @var{size} , @var{fill}}
2798 * Stab:: @code{.stabd, .stabn, .stabs}
2801 * String:: @code{.string "@var{str}"}
2803 * Tag:: @code{.tag @var{structname}}
2806 * Text:: @code{.text @var{subsection}}
2807 * Title:: @code{.title "@var{heading}"}
2809 * Type:: @code{.type @var{int}}
2810 * Val:: @code{.val @var{addr}}
2813 * Word:: @code{.word @var{expressions}}
2814 * Deprecated:: Deprecated Directives
2818 @section @code{.abort}
2820 @cindex @code{abort} directive
2821 @cindex stopping the assembly
2822 This directive stops the assembly immediately. It is for
2823 compatibility with other assemblers. The original idea was that the
2824 assembly language source would be piped into the assembler. If the sender
2825 of the source quit, it could use this directive tells @code{@value{AS}} to
2826 quit also. One day @code{.abort} will not be supported.
2830 @section @code{.ABORT}
2832 @cindex @code{ABORT} directive
2833 When producing COFF output, @code{@value{AS}} accepts this directive as a
2834 synonym for @samp{.abort}.
2837 When producing @code{b.out} output, @code{@value{AS}} accepts this directive,
2843 @section @code{.align @var{abs-expr} , @var{abs-expr}}
2845 @cindex padding the location counter
2846 @cindex @code{align} directive
2847 Pad the location counter (in the current subsection) to a particular
2848 storage boundary. The first expression (which must be absolute) is the
2849 alignment required, as described below.
2850 The second expression (also absolute) gives the value to be stored in
2851 the padding bytes. It (and the comma) may be omitted. If it is
2852 omitted, the padding bytes are zero.
2854 The way the required alignment is specified varies from system to system.
2855 For the a29k, HPPA, m86k, m88k, w65, sparc, and i386 using ELF format,
2856 the first expression is the
2857 alignment request in bytes. For example @samp{.align 8} advances
2858 the location counter until it is a multiple of 8. If the location counter
2859 is already a multiple of 8, no change is needed.
2861 For other systems, including the i386 using a.out format, it is the
2862 number of low-order zero bits the location counter must have after
2863 advancement. For example @samp{.align 3} advances the location
2864 counter until it a multiple of 8. If the location counter is already a
2865 multiple of 8, no change is needed.
2867 This inconsistency is due to the different behaviors of the various
2868 native assemblers for these systems which GAS must emulate.
2869 GAS also provides @code{.balign} and @code{.p2align} directives,
2870 described later, which have a consistent behavior across all
2871 architectures (but are specific to GAS).
2874 @section @code{.app-file @var{string}}
2876 @cindex logical file name
2877 @cindex file name, logical
2878 @cindex @code{app-file} directive
2880 @ifclear no-file-dir
2881 (which may also be spelled @samp{.file})
2883 tells @code{@value{AS}} that we are about to start a new
2884 logical file. @var{string} is the new file name. In general, the
2885 filename is recognized whether or not it is surrounded by quotes @samp{"};
2886 but if you wish to specify an empty file name is permitted,
2887 you must give the quotes--@code{""}. This statement may go away in
2888 future: it is only recognized to be compatible with old @code{@value{AS}}
2892 @section @code{.ascii "@var{string}"}@dots{}
2894 @cindex @code{ascii} directive
2895 @cindex string literals
2896 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2897 separated by commas. It assembles each string (with no automatic
2898 trailing zero byte) into consecutive addresses.
2901 @section @code{.asciz "@var{string}"}@dots{}
2903 @cindex @code{asciz} directive
2904 @cindex zero-terminated strings
2905 @cindex null-terminated strings
2906 @code{.asciz} is just like @code{.ascii}, but each string is followed by
2907 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2910 @section @code{.balign @var{abs-expr} , @var{abs-expr}}
2912 @cindex padding the location counter given number of bytes
2913 @cindex @code{balign} directive
2914 Pad the location counter (in the current subsection) to a particular
2915 storage boundary. The first expression (which must be absolute) is the
2916 alignment request in bytes. For example @samp{.balign 8} advances
2917 the location counter until it is a multiple of 8. If the location counter
2918 is already a multiple of 8, no change is needed.
2920 The second expression (also absolute) gives the value to be stored in
2921 the padding bytes. It (and the comma) may be omitted. If it is
2922 omitted, the padding bytes are zero.
2925 @section @code{.byte @var{expressions}}
2927 @cindex @code{byte} directive
2928 @cindex integers, one byte
2929 @code{.byte} expects zero or more expressions, separated by commas.
2930 Each expression is assembled into the next byte.
2933 @section @code{.comm @var{symbol} , @var{length} }
2935 @cindex @code{comm} directive
2936 @cindex symbol, common
2937 @code{.comm} declares a named common area in the bss section. Normally
2938 @code{@value{LD}} reserves memory addresses for it during linking, so no partial
2939 program defines the location of the symbol. Use @code{.comm} to tell
2940 @code{@value{LD}} that it must be at least @var{length} bytes long. @code{@value{LD}}
2941 allocates space for each @code{.comm} symbol that is at least as
2942 long as the longest @code{.comm} request in any of the partial programs
2943 linked. @var{length} is an absolute expression.
2946 The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
2947 @samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
2951 @section @code{.data @var{subsection}}
2953 @cindex @code{data} directive
2954 @code{.data} tells @code{@value{AS}} to assemble the following statements onto the
2955 end of the data subsection numbered @var{subsection} (which is an
2956 absolute expression). If @var{subsection} is omitted, it defaults
2961 @section @code{.def @var{name}}
2963 @cindex @code{def} directive
2964 @cindex COFF symbols, debugging
2965 @cindex debugging COFF symbols
2966 Begin defining debugging information for a symbol @var{name}; the
2967 definition extends until the @code{.endef} directive is encountered.
2970 This directive is only observed when @code{@value{AS}} is configured for COFF
2971 format output; when producing @code{b.out}, @samp{.def} is recognized,
2978 @section @code{.desc @var{symbol}, @var{abs-expression}}
2980 @cindex @code{desc} directive
2981 @cindex COFF symbol descriptor
2982 @cindex symbol descriptor, COFF
2983 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2984 to the low 16 bits of an absolute expression.
2987 The @samp{.desc} directive is not available when @code{@value{AS}} is
2988 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2989 object format. For the sake of compatibility, @code{@value{AS}} accepts
2990 it, but produces no output, when configured for COFF.
2996 @section @code{.dim}
2998 @cindex @code{dim} directive
2999 @cindex COFF auxiliary symbol information
3000 @cindex auxiliary symbol information, COFF
3001 This directive is generated by compilers to include auxiliary debugging
3002 information in the symbol table. It is only permitted inside
3003 @code{.def}/@code{.endef} pairs.
3006 @samp{.dim} is only meaningful when generating COFF format output; when
3007 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3013 @section @code{.double @var{flonums}}
3015 @cindex @code{double} directive
3016 @cindex floating point numbers (double)
3017 @code{.double} expects zero or more flonums, separated by commas. It
3018 assembles floating point numbers.
3020 The exact kind of floating point numbers emitted depends on how
3021 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3025 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
3026 in @sc{ieee} format.
3031 @section @code{.eject}
3033 @cindex @code{eject} directive
3034 @cindex new page, in listings
3035 @cindex page, in listings
3036 @cindex listing control: new page
3037 Force a page break at this point, when generating assembly listings.
3040 @section @code{.else}
3042 @cindex @code{else} directive
3043 @code{.else} is part of the @code{@value{AS}} support for conditional
3044 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
3045 of code to be assembled if the condition for the preceding @code{.if}
3049 @node End, Endef, Else, Pseudo Ops
3050 @section @code{.end}
3052 @cindex @code{end} directive
3053 This doesn't do anything---but isn't an s_ignore, so I suspect it's
3054 meant to do something eventually (which is why it isn't documented here
3055 as "for compatibility with blah").
3060 @section @code{.endef}
3062 @cindex @code{endef} directive
3063 This directive flags the end of a symbol definition begun with
3067 @samp{.endef} is only meaningful when generating COFF format output; if
3068 @code{@value{AS}} is configured to generate @code{b.out}, it accepts this
3069 directive but ignores it.
3074 @section @code{.endif}
3076 @cindex @code{endif} directive
3077 @code{.endif} is part of the @code{@value{AS}} support for conditional assembly;
3078 it marks the end of a block of code that is only assembled
3079 conditionally. @xref{If,,@code{.if}}.
3082 @section @code{.equ @var{symbol}, @var{expression}}
3084 @cindex @code{equ} directive
3085 @cindex assigning values to symbols
3086 @cindex symbols, assigning values to
3087 This directive sets the value of @var{symbol} to @var{expression}.
3088 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
3091 The syntax for @code{equ} on the HPPA is
3092 @samp{@var{symbol} .equ @var{expression}}.
3096 @section @code{.extern}
3098 @cindex @code{extern} directive
3099 @code{.extern} is accepted in the source program---for compatibility
3100 with other assemblers---but it is ignored. @code{@value{AS}} treats
3101 all undefined symbols as external.
3103 @ifclear no-file-dir
3105 @section @code{.file @var{string}}
3107 @cindex @code{file} directive
3108 @cindex logical file name
3109 @cindex file name, logical
3110 @code{.file} (which may also be spelled @samp{.app-file}) tells
3111 @code{@value{AS}} that we are about to start a new logical file.
3112 @var{string} is the new file name. In general, the filename is
3113 recognized whether or not it is surrounded by quotes @samp{"}; but if
3114 you wish to specify an empty file name, you must give the
3115 quotes--@code{""}. This statement may go away in future: it is only
3116 recognized to be compatible with old @code{@value{AS}} programs.
3118 In some configurations of @code{@value{AS}}, @code{.file} has already been
3119 removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
3124 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
3126 @cindex @code{fill} directive
3127 @cindex writing patterns in memory
3128 @cindex patterns, writing in memory
3129 @var{result}, @var{size} and @var{value} are absolute expressions.
3130 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
3131 may be zero or more. @var{Size} may be zero or more, but if it is
3132 more than 8, then it is deemed to have the value 8, compatible with
3133 other people's assemblers. The contents of each @var{repeat} bytes
3134 is taken from an 8-byte number. The highest order 4 bytes are
3135 zero. The lowest order 4 bytes are @var{value} rendered in the
3136 byte-order of an integer on the computer @code{@value{AS}} is assembling for.
3137 Each @var{size} bytes in a repetition is taken from the lowest order
3138 @var{size} bytes of this number. Again, this bizarre behavior is
3139 compatible with other people's assemblers.
3141 @var{size} and @var{value} are optional.
3142 If the second comma and @var{value} are absent, @var{value} is
3143 assumed zero. If the first comma and following tokens are absent,
3144 @var{size} is assumed to be 1.
3147 @section @code{.float @var{flonums}}
3149 @cindex floating point numbers (single)
3150 @cindex @code{float} directive
3151 This directive assembles zero or more flonums, separated by commas. It
3152 has the same effect as @code{.single}.
3154 The exact kind of floating point numbers emitted depends on how
3155 @code{@value{AS}} is configured.
3156 @xref{Machine Dependencies}.
3160 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
3161 in @sc{ieee} format.
3166 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
3168 @cindex @code{global} directive
3169 @cindex symbol, making visible to linker
3170 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
3171 @var{symbol} in your partial program, its value is made available to
3172 other partial programs that are linked with it. Otherwise,
3173 @var{symbol} takes its attributes from a symbol of the same name
3174 from another file linked into the same program.
3176 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
3177 compatibility with other assemblers.
3180 On the HPPA, @code{.global} is not always enough to make it accessible to other
3181 partial programs. You may need the HPPA-only @code{.EXPORT} directive as well.
3182 @xref{HPPA Directives,, HPPA Assembler Directives}.
3186 @section @code{.hword @var{expressions}}
3188 @cindex @code{hword} directive
3189 @cindex integers, 16-bit
3190 @cindex numbers, 16-bit
3191 @cindex sixteen bit integers
3192 This expects zero or more @var{expressions}, and emits
3193 a 16 bit number for each.
3196 This directive is a synonym for @samp{.short}; depending on the target
3197 architecture, it may also be a synonym for @samp{.word}.
3201 This directive is a synonym for @samp{.short}.
3204 This directive is a synonym for both @samp{.short} and @samp{.word}.
3209 @section @code{.ident}
3211 @cindex @code{ident} directive
3212 This directive is used by some assemblers to place tags in object files.
3213 @code{@value{AS}} simply accepts the directive for source-file
3214 compatibility with such assemblers, but does not actually emit anything
3218 @section @code{.if @var{absolute expression}}
3220 @cindex conditional assembly
3221 @cindex @code{if} directive
3222 @code{.if} marks the beginning of a section of code which is only
3223 considered part of the source program being assembled if the argument
3224 (which must be an @var{absolute expression}) is non-zero. The end of
3225 the conditional section of code must be marked by @code{.endif}
3226 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
3227 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
3229 The following variants of @code{.if} are also supported:
3231 @item .ifdef @var{symbol}
3232 @cindex @code{ifdef} directive
3233 Assembles the following section of code if the specified @var{symbol}
3238 @cindex @code{ifeqs} directive
3239 Not yet implemented.
3242 @item .ifndef @var{symbol}
3243 @itemx ifnotdef @var{symbol}
3244 @cindex @code{ifndef} directive
3245 @cindex @code{ifnotdef} directive
3246 Assembles the following section of code if the specified @var{symbol}
3247 has not been defined. Both spelling variants are equivalent.
3251 Not yet implemented.
3256 @section @code{.include "@var{file}"}
3258 @cindex @code{include} directive
3259 @cindex supporting files, including
3260 @cindex files, including
3261 This directive provides a way to include supporting files at specified
3262 points in your source program. The code from @var{file} is assembled as
3263 if it followed the point of the @code{.include}; when the end of the
3264 included file is reached, assembly of the original file continues. You
3265 can control the search paths used with the @samp{-I} command-line option
3266 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
3270 @section @code{.int @var{expressions}}
3272 @cindex @code{int} directive
3273 @cindex integers, 32-bit
3274 Expect zero or more @var{expressions}, of any section, separated by commas.
3275 For each expression, emit a number that, at run time, is the value of that
3276 expression. The byte order and bit size of the number depends on what kind
3277 of target the assembly is for.
3281 On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
3282 integers. On the H8/300H and the Hitachi SH, however, @code{.int} emits
3288 @section @code{.lcomm @var{symbol} , @var{length}}
3290 @cindex @code{lcomm} directive
3291 @cindex local common symbols
3292 @cindex symbols, local common
3293 Reserve @var{length} (an absolute expression) bytes for a local common
3294 denoted by @var{symbol}. The section and value of @var{symbol} are
3295 those of the new local common. The addresses are allocated in the bss
3296 section, so that at run-time the bytes start off zeroed. @var{Symbol}
3297 is not declared global (@pxref{Global,,@code{.global}}), so is normally
3298 not visible to @code{@value{LD}}.
3301 The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
3302 @samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
3306 @section @code{.lflags}
3308 @cindex @code{lflags} directive (ignored)
3309 @code{@value{AS}} accepts this directive, for compatibility with other
3310 assemblers, but ignores it.
3312 @ifclear no-line-dir
3314 @section @code{.line @var{line-number}}
3316 @cindex @code{line} directive
3320 @section @code{.ln @var{line-number}}
3322 @cindex @code{ln} directive
3324 @cindex logical line number
3326 Change the logical line number. @var{line-number} must be an absolute
3327 expression. The next line has that logical line number. Therefore any other
3328 statements on the current line (after a statement separator character) are
3329 reported as on logical line number @var{line-number} @minus{} 1. One day
3330 @code{@value{AS}} will no longer support this directive: it is recognized only
3331 for compatibility with existing assembler programs.
3335 @emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
3336 not available; use the synonym @code{.ln} in that context.
3341 @ifclear no-line-dir
3342 Even though this is a directive associated with the @code{a.out} or
3343 @code{b.out} object-code formats, @code{@value{AS}} still recognizes it
3344 when producing COFF output, and treats @samp{.line} as though it
3345 were the COFF @samp{.ln} @emph{if} it is found outside a
3346 @code{.def}/@code{.endef} pair.
3348 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
3349 used by compilers to generate auxiliary symbol information for
3354 @section @code{.ln @var{line-number}}
3356 @cindex @code{ln} directive
3357 @ifclear no-line-dir
3358 @samp{.ln} is a synonym for @samp{.line}.
3361 Tell @code{@value{AS}} to change the logical line number. @var{line-number}
3362 must be an absolute expression. The next line has that logical
3363 line number, so any other statements on the current line (after a
3364 statement separator character @code{;}) are reported as on logical
3365 line number @var{line-number} @minus{} 1.
3368 This directive is accepted, but ignored, when @code{@value{AS}} is
3369 configured for @code{b.out}; its effect is only associated with COFF
3375 @section @code{.list}
3377 @cindex @code{list} directive
3378 @cindex listing control, turning on
3379 Control (in conjunction with the @code{.nolist} directive) whether or
3380 not assembly listings are generated. These two directives maintain an
3381 internal counter (which is zero initially). @code{.list} increments the
3382 counter, and @code{.nolist} decrements it. Assembly listings are
3383 generated whenever the counter is greater than zero.
3385 By default, listings are disabled. When you enable them (with the
3386 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
3387 the initial value of the listing counter is one.
3390 @section @code{.long @var{expressions}}
3392 @cindex @code{long} directive
3393 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
3396 @c no one seems to know what this is for or whether this description is
3397 @c what it really ought to do
3399 @section @code{.lsym @var{symbol}, @var{expression}}
3401 @cindex @code{lsym} directive
3402 @cindex symbol, not referenced in assembly
3403 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
3404 the hash table, ensuring it cannot be referenced by name during the
3405 rest of the assembly. This sets the attributes of the symbol to be
3406 the same as the expression value:
3408 @var{other} = @var{descriptor} = 0
3409 @var{type} = @r{(section of @var{expression})}
3410 @var{value} = @var{expression}
3413 The new symbol is not flagged as external.
3417 @section @code{.nolist}
3419 @cindex @code{nolist} directive
3420 @cindex listing control, turning off
3421 Control (in conjunction with the @code{.list} directive) whether or
3422 not assembly listings are generated. These two directives maintain an
3423 internal counter (which is zero initially). @code{.list} increments the
3424 counter, and @code{.nolist} decrements it. Assembly listings are
3425 generated whenever the counter is greater than zero.
3428 @section @code{.octa @var{bignums}}
3430 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
3431 @cindex @code{octa} directive
3432 @cindex integer, 16-byte
3433 @cindex sixteen byte integer
3434 This directive expects zero or more bignums, separated by commas. For each
3435 bignum, it emits a 16-byte integer.
3437 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
3438 hence @emph{octa}-word for 16 bytes.
3441 @section @code{.org @var{new-lc} , @var{fill}}
3443 @cindex @code{org} directive
3444 @cindex location counter, advancing
3445 @cindex advancing location counter
3446 @cindex current address, advancing
3447 Advance the location counter of the current section to
3448 @var{new-lc}. @var{new-lc} is either an absolute expression or an
3449 expression with the same section as the current subsection. That is,
3450 you can't use @code{.org} to cross sections: if @var{new-lc} has the
3451 wrong section, the @code{.org} directive is ignored. To be compatible
3452 with former assemblers, if the section of @var{new-lc} is absolute,
3453 @code{@value{AS}} issues a warning, then pretends the section of @var{new-lc}
3454 is the same as the current subsection.
3456 @code{.org} may only increase the location counter, or leave it
3457 unchanged; you cannot use @code{.org} to move the location counter
3460 @c double negative used below "not undefined" because this is a specific
3461 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
3462 @c section. pesch@cygnus.com 18feb91
3463 Because @code{@value{AS}} tries to assemble programs in one pass, @var{new-lc}
3464 may not be undefined. If you really detest this restriction we eagerly await
3465 a chance to share your improved assembler.
3467 Beware that the origin is relative to the start of the section, not
3468 to the start of the subsection. This is compatible with other
3469 people's assemblers.
3471 When the location counter (of the current subsection) is advanced, the
3472 intervening bytes are filled with @var{fill} which should be an
3473 absolute expression. If the comma and @var{fill} are omitted,
3474 @var{fill} defaults to zero.
3477 @section @code{.p2align @var{abs-expr} , @var{abs-expr}}
3479 @cindex padding the location counter given a power of two
3480 @cindex @code{p2align} directive
3481 Pad the location counter (in the current subsection) to a particular
3482 storage boundary. The first expression (which must be absolute) is the
3483 number of low-order zero bits the location counter must have after
3484 advancement. For example @samp{.p2align 3} advances the location
3485 counter until it a multiple of 8. If the location counter is already a
3486 multiple of 8, no change is needed.
3488 The second expression (also absolute) gives the value to be stored in
3489 the padding bytes. It (and the comma) may be omitted. If it is
3490 omitted, the padding bytes are zero.
3493 @section @code{.psize @var{lines} , @var{columns}}
3495 @cindex @code{psize} directive
3496 @cindex listing control: paper size
3497 @cindex paper size, for listings
3498 Use this directive to declare the number of lines---and, optionally, the
3499 number of columns---to use for each page, when generating listings.
3501 If you do not use @code{.psize}, listings use a default line-count
3502 of 60. You may omit the comma and @var{columns} specification; the
3503 default width is 200 columns.
3505 @code{@value{AS}} generates formfeeds whenever the specified number of
3506 lines is exceeded (or whenever you explicitly request one, using
3509 If you specify @var{lines} as @code{0}, no formfeeds are generated save
3510 those explicitly specified with @code{.eject}.
3513 @section @code{.quad @var{bignums}}
3515 @cindex @code{quad} directive
3516 @code{.quad} expects zero or more bignums, separated by commas. For
3517 each bignum, it emits
3519 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
3520 warning message; and just takes the lowest order 8 bytes of the bignum.
3521 @cindex eight-byte integer
3522 @cindex integer, 8-byte
3524 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
3525 hence @emph{quad}-word for 8 bytes.
3528 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
3529 warning message; and just takes the lowest order 16 bytes of the bignum.
3530 @cindex sixteen-byte integer
3531 @cindex integer, 16-byte
3535 @section @code{.sbttl "@var{subheading}"}
3537 @cindex @code{sbttl} directive
3538 @cindex subtitles for listings
3539 @cindex listing control: subtitle
3540 Use @var{subheading} as the title (third line, immediately after the
3541 title line) when generating assembly listings.
3543 This directive affects subsequent pages, as well as the current page if
3544 it appears within ten lines of the top of a page.
3548 @section @code{.scl @var{class}}
3550 @cindex @code{scl} directive
3551 @cindex symbol storage class (COFF)
3552 @cindex COFF symbol storage class
3553 Set the storage-class value for a symbol. This directive may only be
3554 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
3555 whether a symbol is static or external, or it may record further
3556 symbolic debugging information.
3559 The @samp{.scl} directive is primarily associated with COFF output; when
3560 configured to generate @code{b.out} output format, @code{@value{AS}}
3561 accepts this directive but ignores it.
3567 @section @code{.section @var{name}, @var{subsection}}
3569 @cindex @code{section} directive
3570 @cindex named section (COFF)
3571 @cindex COFF named section
3572 Assemble the following code into end of subsection numbered
3573 @var{subsection} in the COFF named section @var{name}. If you omit
3574 @var{subsection}, @code{@value{AS}} uses subsection number zero.
3575 @samp{.section .text} is equivalent to the @code{.text} directive;
3576 @samp{.section .data} is equivalent to the @code{.data} directive.
3578 This directive is only supported for targets that actually support arbitrarily
3579 named sections; on @code{a.out} targets, for example, it is not accepted, even
3580 with a standard @code{a.out} section name as its parameter.
3585 @section @code{.set @var{symbol}, @var{expression}}
3587 @cindex @code{set} directive
3588 @cindex symbol value, setting
3589 Set the value of @var{symbol} to @var{expression}. This
3590 changes @var{symbol}'s value and type to conform to
3591 @var{expression}. If @var{symbol} was flagged as external, it remains
3592 flagged. (@xref{Symbol Attributes}.)
3594 You may @code{.set} a symbol many times in the same assembly.
3596 If you @code{.set} a global symbol, the value stored in the object
3597 file is the last value stored into it.
3600 The syntax for @code{set} on the HPPA is
3601 @samp{@var{symbol} .set @var{expression}}.
3605 @section @code{.short @var{expressions}}
3607 @cindex @code{short} directive
3609 @code{.short} is normally the same as @samp{.word}.
3610 @xref{Word,,@code{.word}}.
3612 In some configurations, however, @code{.short} and @code{.word} generate
3613 numbers of different lengths; @pxref{Machine Dependencies}.
3617 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
3620 This expects zero or more @var{expressions}, and emits
3621 a 16 bit number for each.
3626 @section @code{.single @var{flonums}}
3628 @cindex @code{single} directive
3629 @cindex floating point numbers (single)
3630 This directive assembles zero or more flonums, separated by commas. It
3631 has the same effect as @code{.float}.
3633 The exact kind of floating point numbers emitted depends on how
3634 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3638 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
3639 numbers in @sc{ieee} format.
3645 @section @code{.size}
3647 @cindex @code{size} directive
3648 This directive is generated by compilers to include auxiliary debugging
3649 information in the symbol table. It is only permitted inside
3650 @code{.def}/@code{.endef} pairs.
3653 @samp{.size} is only meaningful when generating COFF format output; when
3654 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3659 @ifclear no-space-dir
3661 @section @code{.space @var{size} , @var{fill}}
3663 @cindex @code{space} directive
3664 @cindex filling memory
3665 This directive emits @var{size} bytes, each of value @var{fill}. Both
3666 @var{size} and @var{fill} are absolute expressions. If the comma
3667 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3671 @emph{Warning:} @code{.space} has a completely different meaning for HPPA
3672 targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
3673 Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the
3674 @code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives},
3683 @section @code{.space}
3684 @cindex @code{space} directive
3686 On the AMD 29K, this directive is ignored; it is accepted for
3687 compatibility with other AMD 29K assemblers.
3690 @emph{Warning:} In most versions of the @sc{gnu} assembler, the directive
3691 @code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
3697 @section @code{.stabd, .stabn, .stabs}
3699 @cindex symbolic debuggers, information for
3700 @cindex @code{stab@var{x}} directives
3701 There are three directives that begin @samp{.stab}.
3702 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
3703 The symbols are not entered in the @code{@value{AS}} hash table: they
3704 cannot be referenced elsewhere in the source file.
3705 Up to five fields are required:
3709 This is the symbol's name. It may contain any character except
3710 @samp{\000}, so is more general than ordinary symbol names. Some
3711 debuggers used to code arbitrarily complex structures into symbol names
3715 An absolute expression. The symbol's type is set to the low 8 bits of
3716 this expression. Any bit pattern is permitted, but @code{@value{LD}}
3717 and debuggers choke on silly bit patterns.
3720 An absolute expression. The symbol's ``other'' attribute is set to the
3721 low 8 bits of this expression.
3724 An absolute expression. The symbol's descriptor is set to the low 16
3725 bits of this expression.
3728 An absolute expression which becomes the symbol's value.
3731 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
3732 or @code{.stabs} statement, the symbol has probably already been created;
3733 you get a half-formed symbol in your object file. This is
3734 compatible with earlier assemblers!
3737 @cindex @code{stabd} directive
3738 @item .stabd @var{type} , @var{other} , @var{desc}
3740 The ``name'' of the symbol generated is not even an empty string.
3741 It is a null pointer, for compatibility. Older assemblers used a
3742 null pointer so they didn't waste space in object files with empty
3745 The symbol's value is set to the location counter,
3746 relocatably. When your program is linked, the value of this symbol
3747 is the address of the location counter when the @code{.stabd} was
3750 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
3751 @cindex @code{stabn} directive
3752 The name of the symbol is set to the empty string @code{""}.
3754 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
3755 @cindex @code{stabs} directive
3756 All five fields are specified.
3762 @section @code{.string} "@var{str}"
3764 @cindex string, copying to object file
3765 @cindex @code{string} directive
3767 Copy the characters in @var{str} to the object file. You may specify more than
3768 one string to copy, separated by commas. Unless otherwise specified for a
3769 particular machine, the assembler marks the end of each string with a 0 byte.
3770 You can use any of the escape sequences described in @ref{Strings,,Strings}.
3774 @section @code{.tag @var{structname}}
3776 @cindex COFF structure debugging
3777 @cindex structure debugging, COFF
3778 @cindex @code{tag} directive
3779 This directive is generated by compilers to include auxiliary debugging
3780 information in the symbol table. It is only permitted inside
3781 @code{.def}/@code{.endef} pairs. Tags are used to link structure
3782 definitions in the symbol table with instances of those structures.
3785 @samp{.tag} is only used when generating COFF format output; when
3786 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3792 @section @code{.text @var{subsection}}
3794 @cindex @code{text} directive
3795 Tells @code{@value{AS}} to assemble the following statements onto the end of
3796 the text subsection numbered @var{subsection}, which is an absolute
3797 expression. If @var{subsection} is omitted, subsection number zero
3801 @section @code{.title "@var{heading}"}
3803 @cindex @code{title} directive
3804 @cindex listing control: title line
3805 Use @var{heading} as the title (second line, immediately after the
3806 source file name and pagenumber) when generating assembly listings.
3808 This directive affects subsequent pages, as well as the current page if
3809 it appears within ten lines of the top of a page.
3813 @section @code{.type @var{int}}
3815 @cindex COFF symbol type
3816 @cindex symbol type, COFF
3817 @cindex @code{type} directive
3818 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3819 records the integer @var{int} as the type attribute of a symbol table entry.
3822 @samp{.type} is associated only with COFF format output; when
3823 @code{@value{AS}} is configured for @code{b.out} output, it accepts this
3824 directive but ignores it.
3830 @section @code{.val @var{addr}}
3832 @cindex @code{val} directive
3833 @cindex COFF value attribute
3834 @cindex value attribute, COFF
3835 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3836 records the address @var{addr} as the value attribute of a symbol table
3840 @samp{.val} is used only for COFF output; when @code{@value{AS}} is
3841 configured for @code{b.out}, it accepts this directive but ignores it.
3846 @section @code{.word @var{expressions}}
3848 @cindex @code{word} directive
3849 This directive expects zero or more @var{expressions}, of any section,
3850 separated by commas.
3853 For each expression, @code{@value{AS}} emits a 32-bit number.
3856 For each expression, @code{@value{AS}} emits a 16-bit number.
3861 The size of the number emitted, and its byte order,
3862 depend on what target computer the assembly is for.
3865 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
3866 @c happen---32-bit addressability, period; no long/short jumps.
3867 @ifset DIFF-TBL-KLUGE
3868 @cindex difference tables altered
3869 @cindex altered difference tables
3871 @emph{Warning: Special Treatment to support Compilers}
3875 Machines with a 32-bit address space, but that do less than 32-bit
3876 addressing, require the following special treatment. If the machine of
3877 interest to you does 32-bit addressing (or doesn't require it;
3878 @pxref{Machine Dependencies}), you can ignore this issue.
3881 In order to assemble compiler output into something that works,
3882 @code{@value{AS}} occasionlly does strange things to @samp{.word} directives.
3883 Directives of the form @samp{.word sym1-sym2} are often emitted by
3884 compilers as part of jump tables. Therefore, when @code{@value{AS}} assembles a
3885 directive of the form @samp{.word sym1-sym2}, and the difference between
3886 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{@value{AS}}
3887 creates a @dfn{secondary jump table}, immediately before the next label.
3888 This secondary jump table is preceded by a short-jump to the
3889 first byte after the secondary table. This short-jump prevents the flow
3890 of control from accidentally falling into the new table. Inside the
3891 table is a long-jump to @code{sym2}. The original @samp{.word}
3892 contains @code{sym1} minus the address of the long-jump to
3895 If there were several occurrences of @samp{.word sym1-sym2} before the
3896 secondary jump table, all of them are adjusted. If there was a
3897 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
3898 long-jump to @code{sym4} is included in the secondary jump table,
3899 and the @code{.word} directives are adjusted to contain @code{sym3}
3900 minus the address of the long-jump to @code{sym4}; and so on, for as many
3901 entries in the original jump table as necessary.
3904 @emph{This feature may be disabled by compiling @code{@value{AS}} with the
3905 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
3906 assembly language programmers.
3909 @c end DIFF-TBL-KLUGE
3912 @section Deprecated Directives
3914 @cindex deprecated directives
3915 @cindex obsolescent directives
3916 One day these directives won't work.
3917 They are included for compatibility with older assemblers.
3925 @node Machine Dependencies
3926 @chapter Machine Dependent Features
3928 @cindex machine dependencies
3929 The machine instruction sets are (almost by definition) different on
3930 each machine where @code{@value{AS}} runs. Floating point representations
3931 vary as well, and @code{@value{AS}} often supports a few additional
3932 directives or command-line options for compatibility with other
3933 assemblers on a particular platform. Finally, some versions of
3934 @code{@value{AS}} support special pseudo-instructions for branch
3937 This chapter discusses most of these differences, though it does not
3938 include details on any machine's instruction set. For details on that
3939 subject, see the hardware manufacturer's manual.
3942 @c start-sanitize-arc
3944 * ARC-Dependent:: ARC Dependent Features
3948 * Vax-Dependent:: VAX Dependent Features
3951 * AMD29K-Dependent:: AMD 29K Dependent Features
3954 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
3957 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
3960 * HPPA-Dependent:: HPPA Dependent Features
3963 * SH-Dependent:: Hitachi SH Dependent Features
3966 * i960-Dependent:: Intel 80960 Dependent Features
3969 * M68K-Dependent:: M680x0 Dependent Features
3972 * Sparc-Dependent:: SPARC Dependent Features
3975 * Z8000-Dependent:: Z8000 Dependent Features
3978 * MIPS-Dependent:: MIPS Dependent Features
3981 * i386-Dependent:: 80386 Dependent Features
3988 @c The following major nodes are *sections* in the GENERIC version, *chapters*
3989 @c in single-cpu versions. This is mainly achieved by @lowersections. There is a
3990 @c peculiarity: to preserve cross-references, there must be a node called
3991 @c "Machine Dependencies". Hence the conditional nodenames in each
3992 @c major node below. Node defaulting in makeinfo requires adjacency of
3993 @c node and sectioning commands; hence the repetition of @chapter BLAH
3994 @c in both conditional blocks.
3996 @c start-sanitize-arc
4001 @chapter ARC Dependent Features
4004 @node Machine Dependencies
4005 @chapter ARC Dependent Features
4010 * ARC-Opts:: Options
4011 * ARC-Float:: Floating Point
4012 * ARC-Directives:: Sparc Machine Directives
4018 @cindex options for ARC
4020 @cindex architectures, ARC
4021 @cindex ARC architectures
4022 The ARC chip family includes several successive levels (or other
4023 variants) of chip, using the same core instruction set, but including
4024 a few additional instructions at each level.
4026 By default, @code{@value{AS}} assumes the core instruction set (ARC
4027 base). The @code{.cpu} pseudo-op is used to select a different variant.
4030 @cindex @code{-mbig-endian} option (ARC)
4031 @cindex @code{-mlittle-endian} option (ARC)
4032 @cindex ARC big-endian output
4033 @cindex ARC little-endian output
4034 @cindex big-endian output, ARC
4035 @cindex little-endian output, ARC
4037 @itemx -mlittle-endian
4038 Any @sc{arc} configuration of @code{@value{AS}} can select big-endian or
4039 little-endian output at run time (unlike most other @sc{gnu} development
4040 tools, which must be configured for one or the other). Use
4041 @samp{-mbig-endian} to select big-endian output, and @samp{-mlittle-endian}
4046 @section Floating Point
4048 @cindex floating point, ARC (@sc{ieee})
4049 @cindex ARC floating point (@sc{ieee})
4050 The ARC cpu family currently does not have hardware floating point
4051 support. Software floating point support is provided by @code{GCC}
4052 and uses @sc{ieee} floating-point numbers.
4054 @node ARC-Directives
4055 @section ARC Machine Directives
4057 @cindex ARC machine directives
4058 @cindex machine directives, ARC
4059 The ARC version of @code{@value{AS}} supports the following additional
4064 @cindex @code{cpu} directive, SPARC
4065 This must be followed by the desired cpu. It must be one of
4066 @code{base}, @code{host}, @code{graphics}, or @code{audio}.
4076 @chapter VAX Dependent Features
4081 @node Machine Dependencies
4082 @chapter VAX Dependent Features
4088 * Vax-Opts:: VAX Command-Line Options
4089 * VAX-float:: VAX Floating Point
4090 * VAX-directives:: Vax Machine Directives
4091 * VAX-opcodes:: VAX Opcodes
4092 * VAX-branch:: VAX Branch Improvement
4093 * VAX-operands:: VAX Operands
4094 * VAX-no:: Not Supported on VAX
4099 @section VAX Command-Line Options
4101 @cindex command-line options ignored, VAX
4102 @cindex VAX command-line options ignored
4103 The Vax version of @code{@value{AS}} accepts any of the following options,
4104 gives a warning message that the option was ignored and proceeds.
4105 These options are for compatibility with scripts designed for other
4106 people's assemblers.
4109 @item @code{-D} (Debug)
4110 @itemx @code{-S} (Symbol Table)
4111 @itemx @code{-T} (Token Trace)
4112 @cindex @code{-D}, ignored on VAX
4113 @cindex @code{-S}, ignored on VAX
4114 @cindex @code{-T}, ignored on VAX
4115 These are obsolete options used to debug old assemblers.
4117 @item @code{-d} (Displacement size for JUMPs)
4118 @cindex @code{-d}, VAX option
4119 This option expects a number following the @samp{-d}. Like options
4120 that expect filenames, the number may immediately follow the
4121 @samp{-d} (old standard) or constitute the whole of the command line
4122 argument that follows @samp{-d} (@sc{gnu} standard).
4124 @item @code{-V} (Virtualize Interpass Temporary File)
4125 @cindex @code{-V}, redundant on VAX
4126 Some other assemblers use a temporary file. This option
4127 commanded them to keep the information in active memory rather
4128 than in a disk file. @code{@value{AS}} always does this, so this
4129 option is redundant.
4131 @item @code{-J} (JUMPify Longer Branches)
4132 @cindex @code{-J}, ignored on VAX
4133 Many 32-bit computers permit a variety of branch instructions
4134 to do the same job. Some of these instructions are short (and
4135 fast) but have a limited range; others are long (and slow) but
4136 can branch anywhere in virtual memory. Often there are 3
4137 flavors of branch: short, medium and long. Some other
4138 assemblers would emit short and medium branches, unless told by
4139 this option to emit short and long branches.
4141 @item @code{-t} (Temporary File Directory)
4142 @cindex @code{-t}, ignored on VAX
4143 Some other assemblers may use a temporary file, and this option
4144 takes a filename being the directory to site the temporary
4145 file. Since @code{@value{AS}} does not use a temporary disk file, this
4146 option makes no difference. @samp{-t} needs exactly one
4150 @cindex VMS (VAX) options
4151 @cindex options for VAX/VMS
4152 @cindex VAX/VMS options
4153 @cindex @code{-h} option, VAX/VMS
4154 @cindex @code{-+} option, VAX/VMS
4155 @cindex Vax-11 C compatibility
4156 @cindex symbols with lowercase, VAX/VMS
4157 @c FIXME! look into "I think" below, correct if needed, delete.
4158 The Vax version of the assembler accepts two options when
4159 compiled for VMS. They are @samp{-h}, and @samp{-+}. The
4160 @samp{-h} option prevents @code{@value{AS}} from modifying the
4161 symbol-table entries for symbols that contain lowercase
4162 characters (I think). The @samp{-+} option causes @code{@value{AS}} to
4163 print warning messages if the FILENAME part of the object file,
4164 or any symbol name is larger than 31 characters. The @samp{-+}
4165 option also inserts some code following the @samp{_main}
4166 symbol so that the object file is compatible with Vax-11
4170 @section VAX Floating Point
4172 @cindex VAX floating point
4173 @cindex floating point, VAX
4174 Conversion of flonums to floating point is correct, and
4175 compatible with previous assemblers. Rounding is
4176 towards zero if the remainder is exactly half the least significant bit.
4178 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
4181 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
4182 are rendered correctly. Again, rounding is towards zero in the
4185 @cindex @code{float} directive, VAX
4186 @cindex @code{double} directive, VAX
4187 The @code{.float} directive produces @code{f} format numbers.
4188 The @code{.double} directive produces @code{d} format numbers.
4190 @node VAX-directives
4191 @section Vax Machine Directives
4193 @cindex machine directives, VAX
4194 @cindex VAX machine directives
4195 The Vax version of the assembler supports four directives for
4196 generating Vax floating point constants. They are described in the
4199 @cindex wide floating point directives, VAX
4202 @cindex @code{dfloat} directive, VAX
4203 This expects zero or more flonums, separated by commas, and
4204 assembles Vax @code{d} format 64-bit floating point constants.
4207 @cindex @code{ffloat} directive, VAX
4208 This expects zero or more flonums, separated by commas, and
4209 assembles Vax @code{f} format 32-bit floating point constants.
4212 @cindex @code{gfloat} directive, VAX
4213 This expects zero or more flonums, separated by commas, and
4214 assembles Vax @code{g} format 64-bit floating point constants.
4217 @cindex @code{hfloat} directive, VAX
4218 This expects zero or more flonums, separated by commas, and
4219 assembles Vax @code{h} format 128-bit floating point constants.
4224 @section VAX Opcodes
4226 @cindex VAX opcode mnemonics
4227 @cindex opcode mnemonics, VAX
4228 @cindex mnemonics for opcodes, VAX
4229 All DEC mnemonics are supported. Beware that @code{case@dots{}}
4230 instructions have exactly 3 operands. The dispatch table that
4231 follows the @code{case@dots{}} instruction should be made with
4232 @code{.word} statements. This is compatible with all unix
4233 assemblers we know of.
4236 @section VAX Branch Improvement
4238 @cindex VAX branch improvement
4239 @cindex branch improvement, VAX
4240 @cindex pseudo-ops for branch, VAX
4241 Certain pseudo opcodes are permitted. They are for branch
4242 instructions. They expand to the shortest branch instruction that
4243 reaches the target. Generally these mnemonics are made by
4244 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
4245 This feature is included both for compatibility and to help
4246 compilers. If you do not need this feature, avoid these
4247 opcodes. Here are the mnemonics, and the code they can expand into.
4251 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
4253 @item (byte displacement)
4255 @item (word displacement)
4257 @item (long displacement)
4262 Unconditional branch.
4264 @item (byte displacement)
4266 @item (word displacement)
4268 @item (long displacement)
4272 @var{COND} may be any one of the conditional branches
4273 @code{neq}, @code{nequ}, @code{eql}, @code{eqlu}, @code{gtr},
4274 @code{geq}, @code{lss}, @code{gtru}, @code{lequ}, @code{vc}, @code{vs},
4275 @code{gequ}, @code{cc}, @code{lssu}, @code{cs}.
4276 @var{COND} may also be one of the bit tests
4277 @code{bs}, @code{bc}, @code{bss}, @code{bcs}, @code{bsc}, @code{bcc},
4278 @code{bssi}, @code{bcci}, @code{lbs}, @code{lbc}.
4279 @var{NOTCOND} is the opposite condition to @var{COND}.
4281 @item (byte displacement)
4282 @kbd{b@var{COND} @dots{}}
4283 @item (word displacement)
4284 @kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
4285 @item (long displacement)
4286 @kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
4289 @var{X} may be one of @code{b d f g h l w}.
4291 @item (word displacement)
4292 @kbd{@var{OPCODE} @dots{}}
4293 @item (long displacement)
4295 @var{OPCODE} @dots{}, foo ;
4302 @var{YYY} may be one of @code{lss leq}.
4304 @var{ZZZ} may be one of @code{geq gtr}.
4306 @item (byte displacement)
4307 @kbd{@var{OPCODE} @dots{}}
4308 @item (word displacement)
4310 @var{OPCODE} @dots{}, foo ;
4312 foo: brw @var{destination} ;
4315 @item (long displacement)
4317 @var{OPCODE} @dots{}, foo ;
4319 foo: jmp @var{destination} ;
4328 @item (byte displacement)
4329 @kbd{@var{OPCODE} @dots{}}
4330 @item (word displacement)
4332 @var{OPCODE} @dots{}, foo ;
4334 foo: brw @var{destination} ;
4337 @item (long displacement)
4339 @var{OPCODE} @dots{}, foo ;
4341 foo: jmp @var{destination} ;
4348 @section VAX Operands
4350 @cindex VAX operand notation
4351 @cindex operand notation, VAX
4352 @cindex immediate character, VAX
4353 @cindex VAX immediate character
4354 The immediate character is @samp{$} for Unix compatibility, not
4355 @samp{#} as DEC writes it.
4357 @cindex indirect character, VAX
4358 @cindex VAX indirect character
4359 The indirect character is @samp{*} for Unix compatibility, not
4360 @samp{@@} as DEC writes it.
4362 @cindex displacement sizing character, VAX
4363 @cindex VAX displacement sizing character
4364 The displacement sizing character is @samp{`} (an accent grave) for
4365 Unix compatibility, not @samp{^} as DEC writes it. The letter
4366 preceding @samp{`} may have either case. @samp{G} is not
4367 understood, but all other letters (@code{b i l s w}) are understood.
4369 @cindex register names, VAX
4370 @cindex VAX register names
4371 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
4372 pc}. Upper and lower case letters are equivalent.
4379 Any expression is permitted in an operand. Operands are comma
4382 @c There is some bug to do with recognizing expressions
4383 @c in operands, but I forget what it is. It is
4384 @c a syntax clash because () is used as an address mode
4385 @c and to encapsulate sub-expressions.
4388 @section Not Supported on VAX
4390 @cindex VAX bitfields not supported
4391 @cindex bitfields, not supported on VAX
4392 Vax bit fields can not be assembled with @code{@value{AS}}. Someone
4393 can add the required code if they really need it.
4400 @node AMD29K-Dependent
4401 @chapter AMD 29K Dependent Features
4404 @node Machine Dependencies
4405 @chapter AMD 29K Dependent Features
4408 @cindex AMD 29K support
4411 * AMD29K Options:: Options
4412 * AMD29K Syntax:: Syntax
4413 * AMD29K Floating Point:: Floating Point
4414 * AMD29K Directives:: AMD 29K Machine Directives
4415 * AMD29K Opcodes:: Opcodes
4418 @node AMD29K Options
4420 @cindex AMD 29K options (none)
4421 @cindex options for AMD29K (none)
4422 @code{@value{AS}} has no additional command-line options for the AMD
4428 * AMD29K-Chars:: Special Characters
4429 * AMD29K-Regs:: Register Names
4433 @subsection Special Characters
4435 @cindex line comment character, AMD 29K
4436 @cindex AMD 29K line comment character
4437 @samp{;} is the line comment character.
4439 @cindex line separator, AMD 29K
4440 @cindex AMD 29K line separator
4441 @cindex statement separator, AMD 29K
4442 @cindex AMD 29K statement separator
4443 @samp{@@} can be used instead of a newline to separate statements.
4445 @cindex identifiers, AMD 29K
4446 @cindex AMD 29K identifiers
4447 The character @samp{?} is permitted in identifiers (but may not begin
4451 @subsection Register Names
4453 @cindex AMD 29K register names
4454 @cindex register names, AMD 29K
4455 General-purpose registers are represented by predefined symbols of the
4456 form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
4457 (for local registers), where @var{nnn} represents a number between
4458 @code{0} and @code{127}, written with no leading zeros. The leading
4459 letters may be in either upper or lower case; for example, @samp{gr13}
4460 and @samp{LR7} are both valid register names.
4462 You may also refer to general-purpose registers by specifying the
4463 register number as the result of an expression (prefixed with @samp{%%}
4464 to flag the expression as a register number):
4469 ---where @var{expression} must be an absolute expression evaluating to a
4470 number between @code{0} and @code{255}. The range [0, 127] refers to
4471 global registers, and the range [128, 255] to local registers.
4473 @cindex special purpose registers, AMD 29K
4474 @cindex AMD 29K special purpose registers
4475 @cindex protected registers, AMD 29K
4476 @cindex AMD 29K protected registers
4477 In addition, @code{@value{AS}} understands the following protected
4478 special-purpose register names for the AMD 29K family:
4488 These unprotected special-purpose register names are also recognized:
4496 @node AMD29K Floating Point
4497 @section Floating Point
4499 @cindex floating point, AMD 29K (@sc{ieee})
4500 @cindex AMD 29K floating point (@sc{ieee})
4501 The AMD 29K family uses @sc{ieee} floating-point numbers.
4503 @node AMD29K Directives
4504 @section AMD 29K Machine Directives
4506 @cindex machine directives, AMD 29K
4507 @cindex AMD 29K machine directives
4509 @item .block @var{size} , @var{fill}
4510 @cindex @code{block} directive, AMD 29K
4511 This directive emits @var{size} bytes, each of value @var{fill}. Both
4512 @var{size} and @var{fill} are absolute expressions. If the comma
4513 and @var{fill} are omitted, @var{fill} is assumed to be zero.
4515 In other versions of the @sc{gnu} assembler, this directive is called
4521 @cindex @code{cputype} directive, AMD 29K
4522 This directive is ignored; it is accepted for compatibility with other
4526 @cindex @code{file} directive, AMD 29K
4527 This directive is ignored; it is accepted for compatibility with other
4531 @emph{Warning:} in other versions of the @sc{gnu} assembler, @code{.file} is
4532 used for the directive called @code{.app-file} in the AMD 29K support.
4536 @cindex @code{line} directive, AMD 29K
4537 This directive is ignored; it is accepted for compatibility with other
4541 @c since we're ignoring .lsym...
4542 @item .reg @var{symbol}, @var{expression}
4543 @cindex @code{reg} directive, AMD 29K
4544 @code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
4548 @cindex @code{sect} directive, AMD 29K
4549 This directive is ignored; it is accepted for compatibility with other
4552 @item .use @var{section name}
4553 @cindex @code{use} directive, AMD 29K
4554 Establishes the section and subsection for the following code;
4555 @var{section name} may be one of @code{.text}, @code{.data},
4556 @code{.data1}, or @code{.lit}. With one of the first three @var{section
4557 name} options, @samp{.use} is equivalent to the machine directive
4558 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
4562 @node AMD29K Opcodes
4565 @cindex AMD 29K opcodes
4566 @cindex opcodes for AMD 29K
4567 @code{@value{AS}} implements all the standard AMD 29K opcodes. No
4568 additional pseudo-instructions are needed on this family.
4570 For information on the 29K machine instruction set, see @cite{Am29000
4571 User's Manual}, Advanced Micro Devices, Inc.
4576 @node Machine Dependencies
4577 @chapter Machine Dependent Features
4579 The machine instruction sets are different on each Hitachi chip family,
4580 and there are also some syntax differences among the families. This
4581 chapter describes the specific @code{@value{AS}} features for each
4585 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4586 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4587 * SH-Dependent:: Hitachi SH Dependent Features
4597 @node H8/300-Dependent
4598 @chapter H8/300 Dependent Features
4600 @cindex H8/300 support
4602 * H8/300 Options:: Options
4603 * H8/300 Syntax:: Syntax
4604 * H8/300 Floating Point:: Floating Point
4605 * H8/300 Directives:: H8/300 Machine Directives
4606 * H8/300 Opcodes:: Opcodes
4609 @node H8/300 Options
4612 @cindex H8/300 options (none)
4613 @cindex options, H8/300 (none)
4614 @code{@value{AS}} has no additional command-line options for the Hitachi
4620 * H8/300-Chars:: Special Characters
4621 * H8/300-Regs:: Register Names
4622 * H8/300-Addressing:: Addressing Modes
4626 @subsection Special Characters
4628 @cindex line comment character, H8/300
4629 @cindex H8/300 line comment character
4630 @samp{;} is the line comment character.
4632 @cindex line separator, H8/300
4633 @cindex statement separator, H8/300
4634 @cindex H8/300 line separator
4635 @samp{$} can be used instead of a newline to separate statements.
4636 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
4639 @subsection Register Names
4641 @cindex H8/300 registers
4642 @cindex register names, H8/300
4643 You can use predefined symbols of the form @samp{r@var{n}h} and
4644 @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
4645 general-purpose registers. @var{n} is a digit from @samp{0} to
4646 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
4649 You can also use the eight predefined symbols @samp{r@var{n}} to refer
4650 to the H8/300 registers as 16-bit registers (you must use this form for
4653 On the H8/300H, you can also use the eight predefined symbols
4654 @samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit
4655 general purpose registers.
4657 The two control registers are called @code{pc} (program counter; a
4658 16-bit register, except on the H8/300H where it is 24 bits) and
4659 @code{ccr} (condition code register; an 8-bit register). @code{r7} is
4660 used as the stack pointer, and can also be called @code{sp}.
4662 @node H8/300-Addressing
4663 @subsection Addressing Modes
4665 @cindex addressing modes, H8/300
4666 @cindex H8/300 addressing modes
4667 @value{AS} understands the following addressing modes for the H8/300:
4675 @item @@(@var{d}, r@var{n})
4676 @itemx @@(@var{d}:16, r@var{n})
4677 @itemx @@(@var{d}:24, r@var{n})
4678 Register indirect: 16-bit or 24-bit displacement @var{d} from register
4679 @var{n}. (24-bit displacements are only meaningful on the H8/300H.)
4682 Register indirect with post-increment
4685 Register indirect with pre-decrement
4687 @item @code{@@}@var{aa}
4688 @itemx @code{@@}@var{aa}:8
4689 @itemx @code{@@}@var{aa}:16
4690 @itemx @code{@@}@var{aa}:24
4691 Absolute address @code{aa}. (The address size @samp{:24} only makes
4692 sense on the H8/300H.)
4698 Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or
4699 @samp{:32} for clarity, if you wish; but @code{@value{AS}} neither
4700 requires this nor uses it---the data size required is taken from
4703 @item @code{@@}@code{@@}@var{aa}
4704 @itemx @code{@@}@code{@@}@var{aa}:8
4705 Memory indirect. You may specify the @samp{:8} for clarity, if you
4706 wish; but @code{@value{AS}} neither requires this nor uses it.
4709 @node H8/300 Floating Point
4710 @section Floating Point
4712 @cindex floating point, H8/300 (@sc{ieee})
4713 @cindex H8/300 floating point (@sc{ieee})
4714 The H8/300 family has no hardware floating point, but the @code{.float}
4715 directive generates @sc{ieee} floating-point numbers for compatibility
4716 with other development tools.
4719 @node H8/300 Directives
4720 @section H8/300 Machine Directives
4722 @cindex H8/300 machine directives (none)
4723 @cindex machine directives, H8/300 (none)
4724 @cindex @code{word} directive, H8/300
4725 @cindex @code{int} directive, H8/300
4726 @code{@value{AS}} has only one machine-dependent directive for the
4730 @cindex H8/300H, assembling for
4732 Recognize and emit additional instructions for the H8/300H variant, and
4733 also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
4734 for the H8/300 family.
4737 On the H8/300 family (including the H8/300H) @samp{.word} directives
4738 generate 16-bit numbers.
4740 @node H8/300 Opcodes
4743 @cindex H8/300 opcode summary
4744 @cindex opcode summary, H8/300
4745 @cindex mnemonics, H8/300
4746 @cindex instruction summary, H8/300
4747 For detailed information on the H8/300 machine instruction set, see
4748 @cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025). For
4749 information specific to the H8/300H, see @cite{H8/300H Series
4750 Programming Manual} (Hitachi).
4752 @code{@value{AS}} implements all the standard H8/300 opcodes. No additional
4753 pseudo-instructions are needed on this family.
4756 @c this table, due to the multi-col faking and hardcoded order, looks silly
4757 @c except in smallbook. See comments below "@set SMALL" near top of this file.
4759 The following table summarizes the H8/300 opcodes, and their arguments.
4760 Entries marked @samp{*} are opcodes used only on the H8/300H.
4763 @c Using @group seems to use the normal baselineskip, not the smallexample
4764 @c baselineskip; looks approx doublespaced.
4766 Rs @r{source register}
4767 Rd @r{destination register}
4768 abs @r{absolute address}
4769 imm @r{immediate data}
4770 disp:N @r{N-bit displacement from a register}
4771 pcrel:N @r{N-bit displacement relative to program counter}
4773 add.b #imm,rd * andc #imm,ccr
4774 add.b rs,rd band #imm,rd
4775 add.w rs,rd band #imm,@@rd
4776 * add.w #imm,rd band #imm,@@abs:8
4777 * add.l rs,rd bra pcrel:8
4778 * add.l #imm,rd * bra pcrel:16
4779 adds #imm,rd bt pcrel:8
4780 addx #imm,rd * bt pcrel:16
4781 addx rs,rd brn pcrel:8
4782 and.b #imm,rd * brn pcrel:16
4783 and.b rs,rd bf pcrel:8
4784 * and.w rs,rd * bf pcrel:16
4785 * and.w #imm,rd bhi pcrel:8
4786 * and.l #imm,rd * bhi pcrel:16
4787 * and.l rs,rd bls pcrel:8
4789 * bls pcrel:16 bld #imm,rd
4790 bcc pcrel:8 bld #imm,@@rd
4791 * bcc pcrel:16 bld #imm,@@abs:8
4792 bhs pcrel:8 bnot #imm,rd
4793 * bhs pcrel:16 bnot #imm,@@rd
4794 bcs pcrel:8 bnot #imm,@@abs:8
4795 * bcs pcrel:16 bnot rs,rd
4796 blo pcrel:8 bnot rs,@@rd
4797 * blo pcrel:16 bnot rs,@@abs:8
4798 bne pcrel:8 bor #imm,rd
4799 * bne pcrel:16 bor #imm,@@rd
4800 beq pcrel:8 bor #imm,@@abs:8
4801 * beq pcrel:16 bset #imm,rd
4802 bvc pcrel:8 bset #imm,@@rd
4803 * bvc pcrel:16 bset #imm,@@abs:8
4804 bvs pcrel:8 bset rs,rd
4805 * bvs pcrel:16 bset rs,@@rd
4806 bpl pcrel:8 bset rs,@@abs:8
4807 * bpl pcrel:16 bsr pcrel:8
4808 bmi pcrel:8 bsr pcrel:16
4809 * bmi pcrel:16 bst #imm,rd
4810 bge pcrel:8 bst #imm,@@rd
4811 * bge pcrel:16 bst #imm,@@abs:8
4812 blt pcrel:8 btst #imm,rd
4813 * blt pcrel:16 btst #imm,@@rd
4814 bgt pcrel:8 btst #imm,@@abs:8
4815 * bgt pcrel:16 btst rs,rd
4816 ble pcrel:8 btst rs,@@rd
4817 * ble pcrel:16 btst rs,@@abs:8
4818 bclr #imm,rd bxor #imm,rd
4819 bclr #imm,@@rd bxor #imm,@@rd
4820 bclr #imm,@@abs:8 bxor #imm,@@abs:8
4821 bclr rs,rd cmp.b #imm,rd
4822 bclr rs,@@rd cmp.b rs,rd
4823 bclr rs,@@abs:8 cmp.w rs,rd
4824 biand #imm,rd cmp.w rs,rd
4825 biand #imm,@@rd * cmp.w #imm,rd
4826 biand #imm,@@abs:8 * cmp.l #imm,rd
4827 bild #imm,rd * cmp.l rs,rd
4828 bild #imm,@@rd daa rs
4829 bild #imm,@@abs:8 das rs
4830 bior #imm,rd dec.b rs
4831 bior #imm,@@rd * dec.w #imm,rd
4832 bior #imm,@@abs:8 * dec.l #imm,rd
4833 bist #imm,rd divxu.b rs,rd
4834 bist #imm,@@rd * divxu.w rs,rd
4835 bist #imm,@@abs:8 * divxs.b rs,rd
4836 bixor #imm,rd * divxs.w rs,rd
4837 bixor #imm,@@rd eepmov
4838 bixor #imm,@@abs:8 * eepmovw
4840 * exts.w rd mov.w rs,@@abs:16
4841 * exts.l rd * mov.l #imm,rd
4842 * extu.w rd * mov.l rs,rd
4843 * extu.l rd * mov.l @@rs,rd
4844 inc rs * mov.l @@(disp:16,rs),rd
4845 * inc.w #imm,rd * mov.l @@(disp:24,rs),rd
4846 * inc.l #imm,rd * mov.l @@rs+,rd
4847 jmp @@rs * mov.l @@abs:16,rd
4848 jmp abs * mov.l @@abs:24,rd
4849 jmp @@@@abs:8 * mov.l rs,@@rd
4850 jsr @@rs * mov.l rs,@@(disp:16,rd)
4851 jsr abs * mov.l rs,@@(disp:24,rd)
4852 jsr @@@@abs:8 * mov.l rs,@@-rd
4853 ldc #imm,ccr * mov.l rs,@@abs:16
4854 ldc rs,ccr * mov.l rs,@@abs:24
4855 * ldc @@abs:16,ccr movfpe @@abs:16,rd
4856 * ldc @@abs:24,ccr movtpe rs,@@abs:16
4857 * ldc @@(disp:16,rs),ccr mulxu.b rs,rd
4858 * ldc @@(disp:24,rs),ccr * mulxu.w rs,rd
4859 * ldc @@rs+,ccr * mulxs.b rs,rd
4860 * ldc @@rs,ccr * mulxs.w rs,rd
4861 * mov.b @@(disp:24,rs),rd neg.b rs
4862 * mov.b rs,@@(disp:24,rd) * neg.w rs
4863 mov.b @@abs:16,rd * neg.l rs
4865 mov.b @@abs:8,rd not.b rs
4866 mov.b rs,@@abs:8 * not.w rs
4867 mov.b rs,rd * not.l rs
4868 mov.b #imm,rd or.b #imm,rd
4869 mov.b @@rs,rd or.b rs,rd
4870 mov.b @@(disp:16,rs),rd * or.w #imm,rd
4871 mov.b @@rs+,rd * or.w rs,rd
4872 mov.b @@abs:8,rd * or.l #imm,rd
4873 mov.b rs,@@rd * or.l rs,rd
4874 mov.b rs,@@(disp:16,rd) orc #imm,ccr
4875 mov.b rs,@@-rd pop.w rs
4876 mov.b rs,@@abs:8 * pop.l rs
4877 mov.w rs,@@rd push.w rs
4878 * mov.w @@(disp:24,rs),rd * push.l rs
4879 * mov.w rs,@@(disp:24,rd) rotl.b rs
4880 * mov.w @@abs:24,rd * rotl.w rs
4881 * mov.w rs,@@abs:24 * rotl.l rs
4882 mov.w rs,rd rotr.b rs
4883 mov.w #imm,rd * rotr.w rs
4884 mov.w @@rs,rd * rotr.l rs
4885 mov.w @@(disp:16,rs),rd rotxl.b rs
4886 mov.w @@rs+,rd * rotxl.w rs
4887 mov.w @@abs:16,rd * rotxl.l rs
4888 mov.w rs,@@(disp:16,rd) rotxr.b rs
4889 mov.w rs,@@-rd * rotxr.w rs
4891 * rotxr.l rs * stc ccr,@@(disp:24,rd)
4893 rte * stc ccr,@@abs:16
4894 rts * stc ccr,@@abs:24
4895 shal.b rs sub.b rs,rd
4896 * shal.w rs sub.w rs,rd
4897 * shal.l rs * sub.w #imm,rd
4898 shar.b rs * sub.l rs,rd
4899 * shar.w rs * sub.l #imm,rd
4900 * shar.l rs subs #imm,rd
4901 shll.b rs subx #imm,rd
4902 * shll.w rs subx rs,rd
4903 * shll.l rs * trapa #imm
4904 shlr.b rs xor #imm,rd
4905 * shlr.w rs xor rs,rd
4906 * shlr.l rs * xor.w #imm,rd
4908 stc ccr,rd * xor.l #imm,rd
4909 * stc ccr,@@rs * xor.l rs,rd
4910 * stc ccr,@@(disp:16,rd) xorc #imm,ccr
4914 @cindex size suffixes, H8/300
4915 @cindex H8/300 size suffixes
4916 Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
4917 @code{sub}) are defined with variants using the suffixes @samp{.b},
4918 @samp{.w}, and @samp{.l} to specify the size of a memory operand.
4919 @code{@value{AS}} supports these suffixes, but does not require them;
4920 since one of the operands is always a register, @code{@value{AS}} can
4921 deduce the correct size.
4923 For example, since @code{r0} refers to a 16-bit register,
4926 @exdent is equivalent to
4930 If you use the size suffixes, @code{@value{AS}} issues a warning when
4931 the suffix and the register size do not match.
4936 @node H8/500-Dependent
4937 @chapter H8/500 Dependent Features
4939 @cindex H8/500 support
4941 * H8/500 Options:: Options
4942 * H8/500 Syntax:: Syntax
4943 * H8/500 Floating Point:: Floating Point
4944 * H8/500 Directives:: H8/500 Machine Directives
4945 * H8/500 Opcodes:: Opcodes
4948 @node H8/500 Options
4951 @cindex H8/500 options (none)
4952 @cindex options, H8/500 (none)
4953 @code{@value{AS}} has no additional command-line options for the Hitachi
4960 * H8/500-Chars:: Special Characters
4961 * H8/500-Regs:: Register Names
4962 * H8/500-Addressing:: Addressing Modes
4966 @subsection Special Characters
4968 @cindex line comment character, H8/500
4969 @cindex H8/500 line comment character
4970 @samp{!} is the line comment character.
4972 @cindex line separator, H8/500
4973 @cindex statement separator, H8/500
4974 @cindex H8/500 line separator
4975 @samp{;} can be used instead of a newline to separate statements.
4977 @cindex symbol names, @samp{$} in
4978 @cindex @code{$} in symbol names
4979 Since @samp{$} has no special meaning, you may use it in symbol names.
4982 @subsection Register Names
4984 @cindex H8/500 registers
4985 @cindex registers, H8/500
4986 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
4987 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, and @samp{r7} to refer to
4988 the H8/500 registers.
4990 The H8/500 also has these control registers:
5012 condition code register
5015 All registers are 16 bits long. To represent 32 bit numbers, use two
5016 adjacent registers; for distant memory addresses, use one of the segment
5017 pointers (@code{cp} for the program counter; @code{dp} for
5018 @code{r0}--@code{r3}; @code{ep} for @code{r4} and @code{r5}; and
5019 @code{tp} for @code{r6} and @code{r7}.
5021 @node H8/500-Addressing
5022 @subsection Addressing Modes
5024 @cindex addressing modes, H8/500
5025 @cindex H8/500 addressing modes
5026 @value{AS} understands the following addressing modes for the H8/500:
5034 @item @@(d:8, R@var{n})
5035 Register indirect with 8 bit signed displacement
5037 @item @@(d:16, R@var{n})
5038 Register indirect with 16 bit signed displacement
5041 Register indirect with pre-decrement
5044 Register indirect with post-increment
5047 8 bit absolute address
5050 16 bit absolute address
5059 @node H8/500 Floating Point
5060 @section Floating Point
5062 @cindex floating point, H8/500 (@sc{ieee})
5063 @cindex H8/500 floating point (@sc{ieee})
5064 The H8/500 family has no hardware floating point, but the @code{.float}
5065 directive generates @sc{ieee} floating-point numbers for compatibility
5066 with other development tools.
5068 @node H8/500 Directives
5069 @section H8/500 Machine Directives
5071 @cindex H8/500 machine directives (none)
5072 @cindex machine directives, H8/500 (none)
5073 @cindex @code{word} directive, H8/500
5074 @cindex @code{int} directive, H8/500
5075 @code{@value{AS}} has no machine-dependent directives for the H8/500.
5076 However, on this platform the @samp{.int} and @samp{.word} directives
5077 generate 16-bit numbers.
5079 @node H8/500 Opcodes
5082 @cindex H8/500 opcode summary
5083 @cindex opcode summary, H8/500
5084 @cindex mnemonics, H8/500
5085 @cindex instruction summary, H8/500
5086 For detailed information on the H8/500 machine instruction set, see
5087 @cite{H8/500 Series Programming Manual} (Hitachi M21T001).
5089 @code{@value{AS}} implements all the standard H8/500 opcodes. No additional
5090 pseudo-instructions are needed on this family.
5093 @c this table, due to the multi-col faking and hardcoded order, looks silly
5094 @c except in smallbook. See comments below "@set SMALL" near top of this file.
5096 The following table summarizes H8/500 opcodes and their operands:
5098 @c Use @group if it ever works, instead of @page
5102 abs8 @r{8-bit absolute address}
5103 abs16 @r{16-bit absolute address}
5104 abs24 @r{24-bit absolute address}
5105 crb @r{@code{ccr}, @code{br}, @code{ep}, @code{dp}, @code{tp}, @code{dp}}
5106 disp8 @r{8-bit displacement}
5107 ea @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
5108 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16},}
5109 @r{@code{#xx:8}, @code{#xx:16}}
5110 ea_mem @r{@code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
5111 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
5112 ea_noimm @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
5113 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
5115 imm4 @r{4-bit immediate data}
5116 imm8 @r{8-bit immediate data}
5117 imm16 @r{16-bit immediate data}
5118 pcrel8 @r{8-bit offset from program counter}
5119 pcrel16 @r{16-bit offset from program counter}
5120 qim @r{@code{-2}, @code{-1}, @code{1}, @code{2}}
5122 rs @r{a register distinct from rd}
5123 rlist @r{comma-separated list of registers in parentheses;}
5124 @r{register ranges @code{rd-rs} are allowed}
5125 sp @r{stack pointer (@code{r7})}
5126 sr @r{status register}
5127 sz @r{size; @samp{.b} or @samp{.w}. If omitted, default @samp{.w}}
5129 ldc[.b] ea,crb bcc[.w] pcrel16
5130 ldc[.w] ea,sr bcc[.b] pcrel8
5131 add[:q] sz qim,ea_noimm bhs[.w] pcrel16
5132 add[:g] sz ea,rd bhs[.b] pcrel8
5133 adds sz ea,rd bcs[.w] pcrel16
5134 addx sz ea,rd bcs[.b] pcrel8
5135 and sz ea,rd blo[.w] pcrel16
5136 andc[.b] imm8,crb blo[.b] pcrel8
5137 andc[.w] imm16,sr bne[.w] pcrel16
5139 bra[.w] pcrel16 beq[.w] pcrel16
5140 bra[.b] pcrel8 beq[.b] pcrel8
5141 bt[.w] pcrel16 bvc[.w] pcrel16
5142 bt[.b] pcrel8 bvc[.b] pcrel8
5143 brn[.w] pcrel16 bvs[.w] pcrel16
5144 brn[.b] pcrel8 bvs[.b] pcrel8
5145 bf[.w] pcrel16 bpl[.w] pcrel16
5146 bf[.b] pcrel8 bpl[.b] pcrel8
5147 bhi[.w] pcrel16 bmi[.w] pcrel16
5148 bhi[.b] pcrel8 bmi[.b] pcrel8
5149 bls[.w] pcrel16 bge[.w] pcrel16
5150 bls[.b] pcrel8 bge[.b] pcrel8
5152 blt[.w] pcrel16 mov[:g][.b] imm8,ea_mem
5153 blt[.b] pcrel8 mov[:g][.w] imm16,ea_mem
5154 bgt[.w] pcrel16 movfpe[.b] ea,rd
5155 bgt[.b] pcrel8 movtpe[.b] rs,ea_noimm
5156 ble[.w] pcrel16 mulxu sz ea,rd
5157 ble[.b] pcrel8 neg sz ea
5158 bclr sz imm4,ea_noimm nop
5159 bclr sz rs,ea_noimm not sz ea
5160 bnot sz imm4,ea_noimm or sz ea,rd
5161 bnot sz rs,ea_noimm orc[.b] imm8,crb
5162 bset sz imm4,ea_noimm orc[.w] imm16,sr
5163 bset sz rs,ea_noimm pjmp abs24
5164 bsr[.b] pcrel8 pjmp @@rd
5165 bsr[.w] pcrel16 pjsr abs24
5166 btst sz imm4,ea_noimm pjsr @@rd
5167 btst sz rs,ea_noimm prtd imm8
5168 clr sz ea prtd imm16
5169 cmp[:e][.b] imm8,rd prts
5170 cmp[:i][.w] imm16,rd rotl sz ea
5171 cmp[:g].b imm8,ea_noimm rotr sz ea
5172 cmp[:g][.w] imm16,ea_noimm rotxl sz ea
5173 Cmp[:g] sz ea,rd rotxr sz ea
5175 divxu sz ea,rd rtd imm16
5177 exts[.b] rd scb/f rs,pcrel8
5178 extu[.b] rd scb/ne rs,pcrel8
5179 jmp @@rd scb/eq rs,pcrel8
5180 jmp @@(imm8,rd) shal sz ea
5181 jmp @@(imm16,rd) shar sz ea
5182 jmp abs16 shll sz ea
5184 jsr @@(imm8,rd) sleep
5185 jsr @@(imm16,rd) stc[.b] crb,ea_noimm
5186 jsr abs16 stc[.w] sr,ea_noimm
5187 ldm @@sp+,(rlist) stm (rlist),@@-sp
5188 link fp,imm8 sub sz ea,rd
5189 link fp,imm16 subs sz ea,rd
5190 mov[:e][.b] imm8,rd subx sz ea,rd
5191 mov[:i][.w] imm16,rd swap[.b] rd
5192 mov[:l][.w] abs8,rd tas[.b] ea
5193 mov[:l].b abs8,rd trapa imm4
5194 mov[:s][.w] rs,abs8 trap/vs
5195 mov[:s].b rs,abs8 tst sz ea
5196 mov[:f][.w] @@(disp8,fp),rd unlk fp
5197 mov[:f][.w] rs,@@(disp8,fp) xch[.w] rs,rd
5198 mov[:f].b @@(disp8,fp),rd xor sz ea,rd
5199 mov[:f].b rs,@@(disp8,fp) xorc.b imm8,crb
5200 mov[:g] sz rs,ea_mem xorc.w imm16,sr
5208 @node HPPA-Dependent
5209 @chapter HPPA Dependent Features
5213 * HPPA Notes:: Notes
5214 * HPPA Options:: Options
5215 * HPPA Syntax:: Syntax
5216 * HPPA Floating Point:: Floating Point
5217 * HPPA Directives:: HPPA Machine Directives
5218 * HPPA Opcodes:: Opcodes
5223 As a back end for @sc{gnu} @sc{cc} @code{@value{AS}} has been throughly tested and should
5224 work extremely well. We have tested it only minimally on hand written assembly
5225 code and no one has tested it much on the assembly output from the HP
5228 The format of the debugging sections has changed since the original
5229 @code{@value{AS}} port (version 1.3X) was released; therefore,
5230 you must rebuild all HPPA objects and libraries with the new
5231 assembler so that you can debug the final executable.
5233 The HPPA @code{@value{AS}} port generates a small subset of the relocations
5234 available in the SOM and ELF object file formats. Additional relocation
5235 support will be added as it becomes necessary.
5239 @code{@value{AS}} has no machine-dependent command-line options for the HPPA.
5244 The assembler syntax closely follows the HPPA instruction set
5245 reference manual; assembler directives and general syntax closely follow the
5246 HPPA assembly language reference manual, with a few noteworthy differences.
5248 First, a colon may immediately follow a label definition. This is
5249 simply for compatibility with how most assembly language programmers
5252 Some obscure expression parsing problems may affect hand written code which
5253 uses the @code{spop} instructions, or code which makes significant
5254 use of the @code{!} line separator.
5256 @code{@value{AS}} is much less forgiving about missing arguments and other
5257 similar oversights than the HP assembler. @code{@value{AS}} notifies you
5258 of missing arguments as syntax errors; this is regarded as a feature, not a
5261 Finally, @code{@value{AS}} allows you to use an external symbol without
5262 explicitly importing the symbol. @emph{Warning:} in the future this will be
5263 an error for HPPA targets.
5265 Special characters for HPPA targets include:
5267 @samp{;} is the line comment character.
5269 @samp{!} can be used instead of a newline to separate statements.
5271 Since @samp{$} has no special meaning, you may use it in symbol names.
5273 @node HPPA Floating Point
5274 @section Floating Point
5275 @cindex floating point, HPPA (@sc{ieee})
5276 @cindex HPPA floating point (@sc{ieee})
5277 The HPPA family uses @sc{ieee} floating-point numbers.
5279 @node HPPA Directives
5280 @section HPPA Assembler Directives
5282 @code{@value{AS}} for the HPPA supports many additional directives for
5283 compatibility with the native assembler. This section describes them only
5284 briefly. For detailed information on HPPA-specific assembler directives, see
5285 @cite{HP9000 Series 800 Assembly Language Reference Manual} (HP 92432-90001).
5287 @cindex HPPA directives not supported
5288 @code{@value{AS}} does @emph{not} support the following assembler directives
5289 described in the HP manual:
5298 @cindex @code{.param} on HPPA
5299 Beyond those implemented for compatibility, @code{@value{AS}} supports one
5300 additional assembler directive for the HPPA: @code{.param}. It conveys
5301 register argument locations for static functions. Its syntax closely follows
5302 the @code{.export} directive.
5304 @cindex HPPA-only directives
5305 These are the additional directives in @code{@value{AS}} for the HPPA:
5308 @item .block @var{n}
5309 @itemx .blockz @var{n}
5310 Reserve @var{n} bytes of storage, and initialize them to zero.
5313 Mark the beginning of a procedure call. Only the special case with @emph{no
5314 arguments} is allowed.
5316 @item .callinfo [ @var{param}=@var{value}, @dots{} ] [ @var{flag}, @dots{} ]
5317 Specify a number of parameters and flags that define the environment for a
5320 @var{param} may be any of @samp{frame} (frame size), @samp{entry_gr} (end of
5321 general register range), @samp{entry_fr} (end of float register range),
5322 @samp{entry_sr} (end of space register range).
5324 The values for @var{flag} are @samp{calls} or @samp{caller} (proc has
5325 subroutines), @samp{no_calls} (proc does not call subroutines), @samp{save_rp}
5326 (preserve return pointer), @samp{save_sp} (proc preserves stack pointer),
5327 @samp{no_unwind} (do not unwind this proc), @samp{hpux_int} (proc is interrupt
5331 Assemble into the standard section called @samp{$TEXT$}, subsection
5335 @item .copyright "@var{string}"
5336 In the SOM object format, insert @var{string} into the object code, marked as a
5341 @item .copyright "@var{string}"
5342 In the ELF object format, insert @var{string} into the object code, marked as a
5347 Not yet supported; the assembler rejects programs containing this directive.
5350 Mark the beginning of a procedure.
5353 Mark the end of a procedure.
5355 @item .export @var{name} [ ,@var{typ} ] [ ,@var{param}=@var{r} ]
5356 Make a procedure @var{name} available to callers. @var{typ}, if present, must
5357 be one of @samp{absolute}, @samp{code} (ELF only, not SOM), @samp{data},
5358 @samp{entry}, @samp{data}, @samp{entry}, @samp{millicode}, @samp{plabel},
5359 @samp{pri_prog}, or @samp{sec_prog}.
5361 @var{param}, if present, provides either relocation information for the
5362 procedure arguments and result, or a privilege level. @var{param} may be
5363 @samp{argw@var{n}} (where @var{n} ranges from @code{0} to @code{3}, and
5364 indicates one of four one-word arguments); @samp{rtnval} (the procedure's
5365 result); or @samp{priv_lev} (privilege level). For arguments or the result,
5366 @var{r} specifies how to relocate, and must be one of @samp{no} (not
5367 relocatable), @samp{gr} (argument is in general register), @samp{fr} (in
5368 floating point register), or @samp{fu} (upper half of float register).
5369 For @samp{priv_lev}, @var{r} is an integer.
5372 Define a two-byte integer constant @var{n}; synonym for the portable
5373 @code{@value{AS}} directive @code{.short}.
5375 @item .import @var{name} [ ,@var{typ} ]
5376 Converse of @code{.export}; make a procedure available to call. The arguments
5377 use the same conventions as the first two arguments for @code{.export}.
5379 @item .label @var{name}
5380 Define @var{name} as a label for the current assembly location.
5383 Not yet supported; the assembler rejects programs containing this directive.
5385 @item .origin @var{lc}
5386 Advance location counter to @var{lc}. Synonym for the @code{@value{as}}
5387 portable directive @code{.org}.
5389 @item .param @var{name} [ ,@var{typ} ] [ ,@var{param}=@var{r} ]
5390 @c Not in HP manual; GNU HPPA extension
5391 Similar to @code{.export}, but used for static procedures.
5394 Use preceding the first statement of a procedure.
5397 Use following the last statement of a procedure.
5399 @item @var{label} .reg @var{expr}
5400 @c ?? Not in HP manual (Jan 1988 vn)
5401 Synonym for @code{.equ}; define @var{label} with the absolute expression
5402 @var{expr} as its value.
5404 @item .space @var{secname} [ ,@var{params} ]
5405 Switch to section @var{secname}, creating a new section by that name if
5406 necessary. You may only use @var{params} when creating a new section, not
5407 when switching to an existing one. @var{secname} may identify a section by
5408 number rather than by name.
5410 If specified, the list @var{params} declares attributes of the section,
5411 identified by keywords. The keywords recognized are @samp{spnum=@var{exp}}
5412 (identify this section by the number @var{exp}, an absolute expression),
5413 @samp{sort=@var{exp}} (order sections according to this sort key when linking;
5414 @var{exp} is an absolute expression), @samp{unloadable} (section contains no
5415 loadable data), @samp{notdefined} (this section defined elsewhere), and
5416 @samp{private} (data in this section not available to other programs).
5418 @item .spnum @var{secnam}
5419 @c ?? Not in HP manual (Jan 1988)
5420 Allocate four bytes of storage, and initialize them with the section number of
5421 the section named @var{secnam}. (You can define the section number with the
5422 HPPA @code{.space} directive.)
5424 @item .string "@var{str}"
5425 @cindex @code{string} directive on HPPA
5426 Copy the characters in the string @var{str} to the object file.
5427 @xref{Strings,,Strings}, for information on escape sequences you can use in
5428 @code{@value{AS}} strings.
5430 @emph{Warning!} The HPPA version of @code{.string} differs from the
5431 usual @code{@value{AS}} definition: it does @emph{not} write a zero byte
5432 after copying @var{str}.
5434 @item .stringz "@var{str}"
5435 Like @code{.string}, but appends a zero byte after copying @var{str} to object
5438 @item .subspa @var{name} [ ,@var{params} ]
5439 Similar to @code{.space}, but selects a subsection @var{name} within the
5440 current section. You may only specify @var{params} when you create a
5441 subsection (in the first instance of @code{.subspa} for this @var{name}).
5443 If specified, the list @var{params} declares attributes of the subsection,
5444 identified by keywords. The keywords recognized are @samp{quad=@var{expr}}
5445 (``quadrant'' for this subsection), @samp{align=@var{expr}} (alignment for
5446 beginning of this subsection; a power of two), @samp{access=@var{expr}} (value
5447 for ``access rights'' field), @samp{sort=@var{expr}} (sorting order for this
5448 subspace in link), @samp{code_only} (subsection contains only code),
5449 @samp{unloadable} (subsection cannot be loaded into memory), @samp{common}
5450 (subsection is common block), @samp{dup_comm} (initialized data may have
5451 duplicate names), or @samp{zero} (subsection is all zeros, do not write in
5454 @item .version "@var{str}"
5455 Write @var{str} as version identifier in object code.
5460 For detailed information on the HPPA machine instruction set, see
5461 @cite{PA-RISC Architecture and Instruction Set Reference Manual}
5468 @chapter Hitachi SH Dependent Features
5472 * SH Options:: Options
5473 * SH Syntax:: Syntax
5474 * SH Floating Point:: Floating Point
5475 * SH Directives:: SH Machine Directives
5476 * SH Opcodes:: Opcodes
5482 @cindex SH options (none)
5483 @cindex options, SH (none)
5484 @code{@value{AS}} has no additional command-line options for the Hitachi
5491 * SH-Chars:: Special Characters
5492 * SH-Regs:: Register Names
5493 * SH-Addressing:: Addressing Modes
5497 @subsection Special Characters
5499 @cindex line comment character, SH
5500 @cindex SH line comment character
5501 @samp{!} is the line comment character.
5503 @cindex line separator, SH
5504 @cindex statement separator, SH
5505 @cindex SH line separator
5506 You can use @samp{;} instead of a newline to separate statements.
5508 @cindex symbol names, @samp{$} in
5509 @cindex @code{$} in symbol names
5510 Since @samp{$} has no special meaning, you may use it in symbol names.
5513 @subsection Register Names
5515 @cindex SH registers
5516 @cindex registers, SH
5517 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
5518 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
5519 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
5520 and @samp{r15} to refer to the SH registers.
5522 The SH also has these control registers:
5526 procedure register (holds return address)
5533 high and low multiply accumulator registers
5539 global base register
5542 vector base register (for interrupt vectors)
5546 @subsection Addressing Modes
5548 @cindex addressing modes, SH
5549 @cindex SH addressing modes
5550 @code{@value{AS}} understands the following addressing modes for the SH.
5551 @code{R@var{n}} in the following refers to any of the numbered
5552 registers, but @emph{not} the control registers.
5562 Register indirect with pre-decrement
5565 Register indirect with post-increment
5567 @item @@(@var{disp}, R@var{n})
5568 Register indirect with displacement
5570 @item @@(R0, R@var{n})
5573 @item @@(@var{disp}, GBR)
5580 @itemx @@(@var{disp}, PC)
5581 PC relative address (for branch or for addressing memory). The
5582 @code{@value{AS}} implementation allows you to use the simpler form
5583 @var{addr} anywhere a PC relative address is called for; the alternate
5584 form is supported for compatibility with other assemblers.
5590 @node SH Floating Point
5591 @section Floating Point
5593 @cindex floating point, SH (@sc{ieee})
5594 @cindex SH floating point (@sc{ieee})
5595 The SH family has no hardware floating point, but the @code{.float}
5596 directive generates @sc{ieee} floating-point numbers for compatibility
5597 with other development tools.
5600 @section SH Machine Directives
5602 @cindex SH machine directives (none)
5603 @cindex machine directives, SH (none)
5604 @cindex @code{word} directive, SH
5605 @cindex @code{int} directive, SH
5606 @code{@value{AS}} has no machine-dependent directives for the SH.
5611 @cindex SH opcode summary
5612 @cindex opcode summary, SH
5613 @cindex mnemonics, SH
5614 @cindex instruction summary, SH
5615 For detailed information on the SH machine instruction set, see
5616 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
5618 @code{@value{AS}} implements all the standard SH opcodes. No additional
5619 pseudo-instructions are needed on this family. Note, however, that
5620 because @code{@value{AS}} supports a simpler form of PC-relative
5621 addressing, you may simply write (for example)
5628 where other assemblers might require an explicit displacement to
5629 @code{bar} from the program counter:
5632 mov.l @@(@var{disp}, PC)
5636 @c this table, due to the multi-col faking and hardcoded order, looks silly
5637 @c except in smallbook. See comments below "@set SMALL" near top of this file.
5639 Here is a summary of SH opcodes:
5644 Rn @r{a numbered register}
5645 Rm @r{another numbered register}
5646 #imm @r{immediate data}
5647 disp @r{displacement}
5648 disp8 @r{8-bit displacement}
5649 disp12 @r{12-bit displacement}
5651 add #imm,Rn lds.l @@Rn+,PR
5652 add Rm,Rn mac.w @@Rm+,@@Rn+
5653 addc Rm,Rn mov #imm,Rn
5654 addv Rm,Rn mov Rm,Rn
5655 and #imm,R0 mov.b Rm,@@(R0,Rn)
5656 and Rm,Rn mov.b Rm,@@-Rn
5657 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
5658 bf disp8 mov.b @@(disp,Rm),R0
5659 bra disp12 mov.b @@(disp,GBR),R0
5660 bsr disp12 mov.b @@(R0,Rm),Rn
5661 bt disp8 mov.b @@Rm+,Rn
5662 clrmac mov.b @@Rm,Rn
5663 clrt mov.b R0,@@(disp,Rm)
5664 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
5665 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
5666 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
5667 cmp/gt Rm,Rn mov.l Rm,@@-Rn
5668 cmp/hi Rm,Rn mov.l Rm,@@Rn
5669 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
5670 cmp/pl Rn mov.l @@(disp,GBR),R0
5671 cmp/pz Rn mov.l @@(disp,PC),Rn
5672 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
5673 div0s Rm,Rn mov.l @@Rm+,Rn
5675 div1 Rm,Rn mov.l R0,@@(disp,GBR)
5676 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
5677 exts.w Rm,Rn mov.w Rm,@@-Rn
5678 extu.b Rm,Rn mov.w Rm,@@Rn
5679 extu.w Rm,Rn mov.w @@(disp,Rm),R0
5680 jmp @@Rn mov.w @@(disp,GBR),R0
5681 jsr @@Rn mov.w @@(disp,PC),Rn
5682 ldc Rn,GBR mov.w @@(R0,Rm),Rn
5683 ldc Rn,SR mov.w @@Rm+,Rn
5684 ldc Rn,VBR mov.w @@Rm,Rn
5685 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
5686 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
5687 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
5689 lds Rn,MACL muls Rm,Rn
5690 lds Rn,PR mulu Rm,Rn
5691 lds.l @@Rn+,MACH neg Rm,Rn
5692 lds.l @@Rn+,MACL negc Rm,Rn
5695 not Rm,Rn stc.l GBR,@@-Rn
5696 or #imm,R0 stc.l SR,@@-Rn
5697 or Rm,Rn stc.l VBR,@@-Rn
5698 or.b #imm,@@(R0,GBR) sts MACH,Rn
5699 rotcl Rn sts MACL,Rn
5701 rotl Rn sts.l MACH,@@-Rn
5702 rotr Rn sts.l MACL,@@-Rn
5707 shar Rn swap.b Rm,Rn
5708 shll Rn swap.w Rm,Rn
5709 shll16 Rn tas.b @@Rn
5711 shll8 Rn tst #imm,R0
5713 shlr16 Rn tst.b #imm,@@(R0,GBR)
5714 shlr2 Rn xor #imm,R0
5716 sleep xor.b #imm,@@(R0,GBR)
5717 stc GBR,Rn xtrct Rm,Rn
5732 @node i960-Dependent
5733 @chapter Intel 80960 Dependent Features
5736 @node Machine Dependencies
5737 @chapter Intel 80960 Dependent Features
5740 @cindex i960 support
5742 * Options-i960:: i960 Command-line Options
5743 * Floating Point-i960:: Floating Point
5744 * Directives-i960:: i960 Machine Directives
5745 * Opcodes for i960:: i960 Opcodes
5748 @c FIXME! Add Syntax sec with discussion of bitfields here, at least so
5749 @c long as they're not turned on for other machines than 960.
5753 @section i960 Command-line Options
5755 @cindex i960 options
5756 @cindex options, i960
5759 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
5760 @cindex i960 architecture options
5761 @cindex architecture options, i960
5762 @cindex @code{-A} options, i960
5763 Select the 80960 architecture. Instructions or features not supported
5764 by the selected architecture cause fatal errors.
5766 @samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
5767 @samp{-AMC}. Synonyms are provided for compatibility with other tools.
5769 If you do not specify any of these options, @code{@value{AS}} generates code
5770 for any instruction or feature that is supported by @emph{some} version of the
5771 960 (even if this means mixing architectures!). In principle,
5772 @code{@value{AS}} attempts to deduce the minimal sufficient processor type if
5773 none is specified; depending on the object code format, the processor type may
5774 be recorded in the object file. If it is critical that the @code{@value{AS}}
5775 output match a specific architecture, specify that architecture explicitly.
5778 @cindex @code{-b} option, i960
5779 @cindex branch recording, i960
5780 @cindex i960 branch recording
5781 Add code to collect information about conditional branches taken, for
5782 later optimization using branch prediction bits. (The conditional branch
5783 instructions have branch prediction bits in the CA, CB, and CC
5784 architectures.) If @var{BR} represents a conditional branch instruction,
5785 the following represents the code generated by the assembler when
5786 @samp{-b} is specified:
5789 call @var{increment routine}
5790 .word 0 # pre-counter
5792 call @var{increment routine}
5793 .word 0 # post-counter
5796 The counter following a branch records the number of times that branch
5797 was @emph{not} taken; the differenc between the two counters is the
5798 number of times the branch @emph{was} taken.
5800 @cindex @code{gbr960}, i960 postprocessor
5801 @cindex branch statistics table, i960
5802 A table of every such @code{Label} is also generated, so that the
5803 external postprocessor @code{gbr960} (supplied by Intel) can locate all
5804 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
5805 this is a local symbol to permit collecting statistics for many separate
5806 object files. The table is word aligned, and begins with a two-word
5807 header. The first word, initialized to 0, is used in maintaining linked
5808 lists of branch tables. The second word is a count of the number of
5809 entries in the table, which follow immediately: each is a word, pointing
5810 to one of the labels illustrated above.
5814 @c END TEXI2ROFF-KILL
5816 +------------+------------+------------+ ... +------------+
5818 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
5820 +------------+------------+------------+ ... +------------+
5822 __BRANCH_TABLE__ layout
5829 \line{\leftskip=0pt\hskip\tableindent
5830 \boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
5831 *BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
5832 \centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
5834 @c END TEXI2ROFF-KILL
5836 The first word of the header is used to locate multiple branch tables,
5837 since each object file may contain one. Normally the links are
5838 maintained with a call to an initialization routine, placed at the
5839 beginning of each function in the file. The @sc{gnu} C compiler
5840 generates these calls automatically when you give it a @samp{-b} option.
5841 For further details, see the documentation of @samp{gbr960}.
5844 @cindex @code{-no-relax} option, i960
5845 Normally, Compare-and-Branch instructions with targets that require
5846 displacements greater than 13 bits (or that have external targets) are
5847 replaced with the corresponding compare (or @samp{chkbit}) and branch
5848 instructions. You can use the @samp{-no-relax} option to specify that
5849 @code{@value{AS}} should generate errors instead, if the target displacement
5850 is larger than 13 bits.
5852 This option does not affect the Compare-and-Jump instructions; the code
5853 emitted for them is @emph{always} adjusted when necessary (depending on
5854 displacement size), regardless of whether you use @samp{-no-relax}.
5857 @node Floating Point-i960
5858 @section Floating Point
5860 @cindex floating point, i960 (@sc{ieee})
5861 @cindex i960 floating point (@sc{ieee})
5862 @code{@value{AS}} generates @sc{ieee} floating-point numbers for the directives
5863 @samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
5865 @node Directives-i960
5866 @section i960 Machine Directives
5868 @cindex machine directives, i960
5869 @cindex i960 machine directives
5872 @cindex @code{bss} directive, i960
5873 @item .bss @var{symbol}, @var{length}, @var{align}
5874 Reserve @var{length} bytes in the bss section for a local @var{symbol},
5875 aligned to the power of two specified by @var{align}. @var{length} and
5876 @var{align} must be positive absolute expressions. This directive
5877 differs from @samp{.lcomm} only in that it permits you to specify
5878 an alignment. @xref{Lcomm,,@code{.lcomm}}.
5882 @item .extended @var{flonums}
5883 @cindex @code{extended} directive, i960
5884 @code{.extended} expects zero or more flonums, separated by commas; for
5885 each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
5886 floating-point number.
5888 @item .leafproc @var{call-lab}, @var{bal-lab}
5889 @cindex @code{leafproc} directive, i960
5890 You can use the @samp{.leafproc} directive in conjunction with the
5891 optimized @code{callj} instruction to enable faster calls of leaf
5892 procedures. If a procedure is known to call no other procedures, you
5893 may define an entry point that skips procedure prolog code (and that does
5894 not depend on system-supplied saved context), and declare it as the
5895 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
5896 entry point that goes through the normal prolog, you can specify that
5897 entry point as @var{call-lab}.
5899 A @samp{.leafproc} declaration is meant for use in conjunction with the
5900 optimized call instruction @samp{callj}; the directive records the data
5901 needed later to choose between converting the @samp{callj} into a
5902 @code{bal} or a @code{call}.
5904 @var{call-lab} is optional; if only one argument is present, or if the
5905 two arguments are identical, the single argument is assumed to be the
5906 @code{bal} entry point.
5908 @item .sysproc @var{name}, @var{index}
5909 @cindex @code{sysproc} directive, i960
5910 The @samp{.sysproc} directive defines a name for a system procedure.
5911 After you define it using @samp{.sysproc}, you can use @var{name} to
5912 refer to the system procedure identified by @var{index} when calling
5913 procedures with the optimized call instruction @samp{callj}.
5915 Both arguments are required; @var{index} must be between 0 and 31
5919 @node Opcodes for i960
5920 @section i960 Opcodes
5922 @cindex opcodes, i960
5923 @cindex i960 opcodes
5924 All Intel 960 machine instructions are supported;
5925 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
5926 selecting the instruction subset for a particular 960
5927 architecture.@refill
5929 Some opcodes are processed beyond simply emitting a single corresponding
5930 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
5931 instructions with target displacements larger than 13 bits.
5934 * callj-i960:: @code{callj}
5935 * Compare-and-branch-i960:: Compare-and-Branch
5939 @subsection @code{callj}
5941 @cindex @code{callj}, i960 pseudo-opcode
5942 @cindex i960 @code{callj} pseudo-opcode
5943 You can write @code{callj} to have the assembler or the linker determine
5944 the most appropriate form of subroutine call: @samp{call},
5945 @samp{bal}, or @samp{calls}. If the assembly source contains
5946 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
5947 defining the operand---then @code{@value{AS}} translates the
5948 @code{callj}; if not, it simply emits the @code{callj}, leaving it
5949 for the linker to resolve.
5951 @node Compare-and-branch-i960
5952 @subsection Compare-and-Branch
5954 @cindex i960 compare/branch instructions
5955 @cindex compare/branch instructions, i960
5956 The 960 architectures provide combined Compare-and-Branch instructions
5957 that permit you to store the branch target in the lower 13 bits of the
5958 instruction word itself. However, if you specify a branch target far
5959 enough away that its address won't fit in 13 bits, the assembler can
5960 either issue an error, or convert your Compare-and-Branch instruction
5961 into separate instructions to do the compare and the branch.
5963 @cindex compare and jump expansions, i960
5964 @cindex i960 compare and jump expansions
5965 Whether @code{@value{AS}} gives an error or expands the instruction depends
5966 on two choices you can make: whether you use the @samp{-no-relax} option,
5967 and whether you use a ``Compare and Branch'' instruction or a ``Compare
5968 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
5969 expanded if necessary; the ``Branch'' instructions are expanded when
5970 necessary @emph{unless} you specify @code{-no-relax}---in which case
5971 @code{@value{AS}} gives an error instead.
5973 These are the Compare-and-Branch instructions, their ``Jump'' variants,
5974 and the instruction pairs they may expand into:
5978 @c END TEXI2ROFF-KILL
5981 Branch Jump Expanded to
5982 ------ ------ ------------
5985 cmpibe cmpije cmpi; be
5986 cmpibg cmpijg cmpi; bg
5987 cmpibge cmpijge cmpi; bge
5988 cmpibl cmpijl cmpi; bl
5989 cmpible cmpijle cmpi; ble
5990 cmpibno cmpijno cmpi; bno
5991 cmpibne cmpijne cmpi; bne
5992 cmpibo cmpijo cmpi; bo
5993 cmpobe cmpoje cmpo; be
5994 cmpobg cmpojg cmpo; bg
5995 cmpobge cmpojge cmpo; bge
5996 cmpobl cmpojl cmpo; bl
5997 cmpoble cmpojle cmpo; ble
5998 cmpobne cmpojne cmpo; bne
6004 \halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
6005 \omit{\hfil\it Compare and\hfil}\span\omit&\cr
6006 {\it Branch}&{\it Jump}&{\it Expanded to}\cr
6007 bbc& & chkbit; bno\cr
6008 bbs& & chkbit; bo\cr
6009 cmpibe& cmpije& cmpi; be\cr
6010 cmpibg& cmpijg& cmpi; bg\cr
6011 cmpibge& cmpijge& cmpi; bge\cr
6012 cmpibl& cmpijl& cmpi; bl\cr
6013 cmpible& cmpijle& cmpi; ble\cr
6014 cmpibno& cmpijno& cmpi; bno\cr
6015 cmpibne& cmpijne& cmpi; bne\cr
6016 cmpibo& cmpijo& cmpi; bo\cr
6017 cmpobe& cmpoje& cmpo; be\cr
6018 cmpobg& cmpojg& cmpo; bg\cr
6019 cmpobge& cmpojge& cmpo; bge\cr
6020 cmpobl& cmpojl& cmpo; bl\cr
6021 cmpoble& cmpojle& cmpo; ble\cr
6022 cmpobne& cmpojne& cmpo; bne\cr}
6024 @c END TEXI2ROFF-KILL
6030 @node M68K-Dependent
6031 @chapter M680x0 Dependent Features
6034 @node Machine Dependencies
6035 @chapter M680x0 Dependent Features
6038 @cindex M680x0 support
6040 * M68K-Opts:: M680x0 Options
6041 * M68K-Syntax:: Syntax
6042 * M68K-Moto-Syntax:: Motorola Syntax
6043 * M68K-Float:: Floating Point
6044 * M68K-Directives:: 680x0 Machine Directives
6045 * M68K-opcodes:: Opcodes
6049 @section M680x0 Options
6051 @cindex options, M680x0
6052 @cindex M680x0 options
6053 The Motorola 680x0 version of @code{@value{AS}} has two machine dependent options.
6054 One shortens undefined references from 32 to 16 bits, while the
6055 other is used to tell @code{@value{AS}} what kind of machine it is
6058 @cindex @code{-l} option, M680x0
6059 You can use the @samp{-l} option to shorten the size of references to undefined
6060 symbols. If you do not use the @samp{-l} option, references to undefined
6061 symbols are wide enough for a full @code{long} (32 bits). (Since
6062 @code{@value{AS}} cannot know where these symbols end up, @code{@value{AS}} can
6063 only allocate space for the linker to fill in later. Since @code{@value{AS}}
6064 does not know how far away these symbols are, it allocates as much space as it
6065 can.) If you use this option, the references are only one word wide (16 bits).
6066 This may be useful if you want the object file to be as small as possible, and
6067 you know that the relevant symbols are always less than 17 bits away.
6069 @cindex @code{-m68000} and related options
6070 @cindex architecture options, M680x0
6071 @cindex M680x0 architecture options
6072 The 680x0 version of @code{@value{AS}} is most frequently used to assemble
6073 programs for the Motorola MC68020 microprocessor. Occasionally it is
6074 used to assemble programs for the mostly similar, but slightly different
6075 MC68000 or MC68010 microprocessors. You can give @code{@value{AS}} the options
6076 @samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
6077 @samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
6084 This syntax for the Motorola 680x0 was developed at @sc{mit}.
6086 @cindex M680x0 syntax
6087 @cindex syntax, M680x0
6088 @cindex M680x0 size modifiers
6089 @cindex size modifiers, M680x0
6090 The 680x0 version of @code{@value{AS}} uses syntax compatible with the Sun
6091 assembler. Intervening periods are ignored; for example, @samp{movl} is
6092 equivalent to @samp{move.l}.
6095 If @code{@value{AS}} is compiled with SUN_ASM_SYNTAX defined, it
6096 also allows Sun-style local labels of the form @samp{1$} through
6100 In the following table @dfn{apc} stands for any of the address
6101 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
6102 Program Counter (@samp{pc}), or the zero-address relative to the
6103 program counter (@samp{zpc}).
6105 @cindex M680x0 addressing modes
6106 @cindex addressing modes, M680x0
6107 The following addressing modes are understood:
6110 @samp{#@var{digits}}
6113 @samp{%d0} through @samp{%d7}
6115 @item Address Register
6116 @samp{%a0} through @samp{%a7}@*
6117 @samp{%a7} is also known as @samp{%sp}, i.e. the Stack Pointer. @code{%a6}
6118 is also known as @samp{%fp}, the Frame Pointer.
6120 @item Address Register Indirect
6121 @samp{%a0@@} through @samp{%a7@@}
6123 @item Address Register Postincrement
6124 @samp{%a0@@+} through @samp{%a7@@+}
6126 @item Address Register Predecrement
6127 @samp{%a0@@-} through @samp{%a7@@-}
6129 @item Indirect Plus Offset
6130 @samp{%@var{apc}@@(@var{digits})}
6133 @samp{%@var{apc}@@(@var{digits},%@var{register}:@var{size}:@var{scale})}
6135 or @samp{%@var{apc}@@(%@var{register}:@var{size}:@var{scale})}
6138 @samp{%@var{apc}@@(@var{digits})@@(@var{digits},%@var{register}:@var{size}:@var{scale})}
6140 or @samp{%@var{apc}@@(@var{digits})@@(%@var{register}:@var{size}:@var{scale})}
6143 @samp{%@var{apc}@@(@var{digits},%@var{register}:@var{size}:@var{scale})@@(@var{digits})}
6145 or @samp{%@var{apc}@@(%@var{register}:@var{size}:@var{scale})@@(@var{digits})}
6147 @item Memory Indirect
6148 @samp{%@var{apc}@@(@var{digits})@@(@var{digits})}
6151 @samp{@var{symbol}}, or @samp{@var{digits}}
6153 @c pesch@cygnus.com: gnu, rich concur the following needs careful
6154 @c research before documenting.
6155 , or either of the above followed
6156 by @samp{:b}, @samp{:w}, or @samp{:l}.
6160 For some configurations, especially those where the compiler normally does not
6161 prepend an underscore to the names of user variables, the assembler requires a
6162 @samp{%} before any use of a register name. This is intended to let the
6163 assembler distinguish between C variables and registers named @samp{a0} through
6164 @samp{a7}, and so on. The @samp{%} is always accepted, but is not required for
6165 certain configurations, notably @samp{sun3}.
6167 @node M68K-Moto-Syntax
6168 @section Motorola Syntax
6170 @cindex Motorola syntax for the 680x0
6171 @cindex alternate syntax for the 680x0
6173 The standard Motorola syntax for this chip differs from the syntax already
6174 discussed (@pxref{M68K-Syntax,,Syntax}). @code{@value{AS}} can accept some
6175 forms of Motorola syntax for operands, even if @sc{mit} syntax is used for
6176 other operands in the same instruction. The two kinds of syntax are fully
6177 compatible; our support for Motorola syntax is simply incomplete at present.
6179 @cindex M680x0 syntax
6180 @cindex syntax, M680x0
6181 In particular, you may write or generate M68K assembler with the
6182 following conventions:
6184 (In the following table @dfn{%apc} stands for any of the address registers
6185 (@samp{%a0} through @samp{%a7}), nothing (@samp{}), the Program Counter
6186 (@samp{%pc}), or the zero-address relative to the program counter
6189 @cindex M680x0 addressing modes
6190 @cindex addressing modes, M680x0
6191 The following additional addressing modes are understood:
6193 @item Address Register Indirect
6194 @samp{%a0} through @samp{%a7}@*
6195 @samp{%a7} is also known as @samp{%sp}, i.e. the Stack Pointer. @code{%a6}
6196 is also known as @samp{%fp}, the Frame Pointer.
6198 @item Address Register Postincrement
6199 @samp{(%a0)+} through @samp{(%a7)+}
6201 @item Address Register Predecrement
6202 @samp{-(%a0)} through @samp{-(%a7)}
6204 @item Indirect Plus Offset
6205 @samp{@var{digits}(%@var{apc})}
6208 @samp{@var{digits}(%@var{apc},(%@var{register}.@var{size}*@var{scale}))}@*
6209 or @samp{(%@var{apc},%@var{register}.@var{size}*@var{scale})}@*
6210 In either case, @var{size} and @var{scale} are optional
6211 (@var{scale} defaults to @samp{1}, @var{size} defaults to @samp{l}).
6212 @var{scale} can be @samp{1}, @samp{2}, @samp{4}, or @samp{8}.
6213 @var{size} can be @samp{w} or @samp{l}. @var{scale} is only supported
6214 on the 68020 and greater.
6217 Other, more complex addressing modes permitted in Motorola syntax are not
6221 @section Floating Point
6223 @cindex floating point, M680x0
6224 @cindex M680x0 floating point
6225 @c FIXME is this "not too well tested" crud STILL true?
6226 The floating point code is not too well tested, and may have
6229 Packed decimal (P) format floating literals are not supported.
6230 Feel free to add the code!
6232 The floating point formats generated by directives are these.
6236 @cindex @code{float} directive, M680x0
6237 @code{Single} precision floating point constants.
6240 @cindex @code{double} directive, M680x0
6241 @code{Double} precision floating point constants.
6244 There is no directive to produce regions of memory holding
6245 extended precision numbers, however they can be used as
6246 immediate operands to floating-point instructions. Adding a
6247 directive to create extended precision numbers would not be
6248 hard, but it has not yet seemed necessary.
6250 @node M68K-Directives
6251 @section 680x0 Machine Directives
6253 @cindex M680x0 directives
6254 @cindex directives, M680x0
6255 In order to be compatible with the Sun assembler the 680x0 assembler
6256 understands the following directives.
6260 @cindex @code{data1} directive, M680x0
6261 This directive is identical to a @code{.data 1} directive.
6264 @cindex @code{data2} directive, M680x0
6265 This directive is identical to a @code{.data 2} directive.
6268 @cindex @code{even} directive, M680x0
6269 This directive is identical to a @code{.align 1} directive.
6270 @c Is this true? does it work???
6273 @cindex @code{skip} directive, M680x0
6274 This directive is identical to a @code{.space} directive.
6281 @cindex M680x0 opcodes
6282 @cindex opcodes, M680x0
6283 @cindex instruction set, M680x0
6284 @c pesch@cygnus.com: I don't see any point in the following
6285 @c paragraph. Bugs are bugs; how does saying this
6288 Danger: Several bugs have been found in the opcode table (and
6289 fixed). More bugs may exist. Be careful when using obscure
6294 * M68K-Branch:: Branch Improvement
6295 * M68K-Chars:: Special Characters
6299 @subsection Branch Improvement
6301 @cindex pseudo-opcodes, M680x0
6302 @cindex M680x0 pseudo-opcodes
6303 @cindex branch improvement, M680x0
6304 @cindex M680x0 branch improvement
6305 Certain pseudo opcodes are permitted for branch instructions.
6306 They expand to the shortest branch instruction that reach the
6307 target. Generally these mnemonics are made by substituting @samp{j} for
6308 @samp{b} at the start of a Motorola mnemonic.
6310 The following table summarizes the pseudo-operations. A @code{*} flags
6311 cases that are more fully described after the table:
6315 +-------------------------------------------------
6317 Pseudo-Op |BYTE WORD LONG LONG non-PC relative
6318 +-------------------------------------------------
6319 jbsr |bsrs bsr bsrl jsr jsr
6320 jra |bras bra bral jmp jmp
6321 * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
6322 * dbXX |dbXX dbXX dbXX; bra; jmpl
6323 * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
6326 NX: negative of condition XX
6329 @center @code{*}---see full description below
6334 These are the simplest jump pseudo-operations; they always map to one
6335 particular machine instruction, depending on the displacement to the
6339 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
6340 where @var{XX} is a conditional branch or condition-code test. The full
6341 list of pseudo-ops in this family is:
6343 jhi jls jcc jcs jne jeq jvc
6344 jvs jpl jmi jge jlt jgt jle
6347 For the cases of non-PC relative displacements and long displacements on
6348 the 68000 or 68010, @code{@value{AS}} issues a longer code fragment in terms of
6349 @var{NX}, the opposite condition to @var{XX}. For example, for the
6350 non-PC relative case:
6362 The full family of pseudo-operations covered here is
6364 dbhi dbls dbcc dbcs dbne dbeq dbvc
6365 dbvs dbpl dbmi dbge dblt dbgt dble
6369 Other than for word and byte displacements, when the source reads
6370 @samp{db@var{XX} foo}, @code{@value{AS}} emits
6379 This family includes
6381 fjne fjeq fjge fjlt fjgt fjle fjf
6382 fjt fjgl fjgle fjnge fjngl fjngle fjngt
6383 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
6384 fjor fjseq fjsf fjsne fjst fjueq fjuge
6385 fjugt fjule fjult fjun
6388 For branch targets that are not PC relative, @code{@value{AS}} emits
6394 when it encounters @samp{fj@var{XX} foo}.
6399 @subsection Special Characters
6401 @cindex special characters, M680x0
6402 @cindex M680x0 immediate character
6403 @cindex immediate character, M680x0
6404 @cindex M680x0 line comment character
6405 @cindex line comment character, M680x0
6406 @cindex comments, M680x0
6407 The immediate character is @samp{#} for Sun compatibility. The
6408 line-comment character is @samp{|}. If a @samp{#} appears at the
6409 beginning of a line, it is treated as a comment unless it looks like
6410 @samp{# line file}, in which case it is treated normally.
6414 @c FIXME! Stop ignoring when filled in.
6419 The 32x32 version of @code{@value{AS}} accepts a @samp{-m32032} option to
6420 specify thiat it is compiling for a 32032 processor, or a
6421 @samp{-m32532} to specify that it is compiling for a 32532 option.
6422 The default (if neither is specified) is chosen when the assembler
6426 I don't know anything about the 32x32 syntax assembled by
6427 @code{@value{AS}}. Someone who undersands the processor (I've never seen
6428 one) and the possible syntaxes should write this section.
6430 @section Floating Point
6431 The 32x32 uses @sc{ieee} floating point numbers, but @code{@value{AS}}
6432 only creates single or double precision values. I don't know if the
6433 32x32 understands extended precision numbers.
6435 @section 32x32 Machine Directives
6436 The 32x32 has no machine dependent directives.
6442 @node Sparc-Dependent
6443 @chapter SPARC Dependent Features
6446 @node Machine Dependencies
6447 @chapter SPARC Dependent Features
6450 @cindex SPARC support
6452 * Sparc-Opts:: Options
6453 * Sparc-Float:: Floating Point
6454 * Sparc-Directives:: Sparc Machine Directives
6460 @cindex options for SPARC
6461 @cindex SPARC options
6462 @cindex architectures, SPARC
6463 @cindex SPARC architectures
6464 The SPARC chip family includes several successive levels (or other
6465 variants) of chip, using the same core instruction set, but including
6466 a few additional instructions at each level.
6468 By default, @code{@value{AS}} assumes the core instruction set (SPARC
6469 v6), but ``bumps'' the architecture level as needed: it switches to
6470 successively higher architectures as it encounters instructions that
6471 only exist in the higher levels.
6474 @item -Av6 | -Av7 | -Av8 | -Av9 | -Asparclite
6480 Use one of the @samp{-A} options to select one of the SPARC
6481 architectures explicitly. If you select an architecture explicitly,
6482 @code{@value{AS}} reports a fatal error if it encounters an instruction
6483 or feature requiring a higher level.
6486 Permit the assembler to ``bump'' the architecture level as required, but
6487 warn whenever it is necessary to switch to another level.
6491 @c FIXME: (sparc) Fill in "syntax" section!
6492 @c subsection syntax
6493 I don't know anything about Sparc syntax. Someone who does
6494 will have to write this section.
6498 @section Floating Point
6500 @cindex floating point, SPARC (@sc{ieee})
6501 @cindex SPARC floating point (@sc{ieee})
6502 The Sparc uses @sc{ieee} floating-point numbers.
6504 @node Sparc-Directives
6505 @section Sparc Machine Directives
6507 @cindex SPARC machine directives
6508 @cindex machine directives, SPARC
6509 The Sparc version of @code{@value{AS}} supports the following additional
6514 @cindex @code{align} directive, SPARC
6515 This must be followed by the desired alignment in bytes.
6518 @cindex @code{common} directive, SPARC
6519 This must be followed by a symbol name, a positive number, and
6520 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
6521 syntax is different.
6524 @cindex @code{half} directive, SPARC
6525 This is functionally identical to @code{.short}.
6528 @cindex @code{proc} directive, SPARC
6529 This directive is ignored. Any text following it on the same
6530 line is also ignored.
6533 @cindex @code{reserve} directive, SPARC
6534 This must be followed by a symbol name, a positive number, and
6535 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
6536 syntax is different.
6539 @cindex @code{seg} directive, SPARC
6540 This must be followed by @code{"text"}, @code{"data"}, or
6541 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
6545 @cindex @code{skip} directive, SPARC
6546 This is functionally identical to the @code{.space} directive.
6549 @cindex @code{word} directive, SPARC
6550 On the Sparc, the @code{.word} directive produces 32 bit values,
6551 instead of the 16 bit values it produces on many other machines.
6554 @cindex @code{xword} directive, SPARC
6555 On the Sparc V9 processor, the @code{.xword} directive produces
6563 @node i386-Dependent
6564 @chapter 80386 Dependent Features
6567 @node Machine Dependencies
6568 @chapter 80386 Dependent Features
6571 @cindex i386 support
6572 @cindex i80306 support
6574 * i386-Options:: Options
6575 * i386-Syntax:: AT&T Syntax versus Intel Syntax
6576 * i386-Opcodes:: Opcode Naming
6577 * i386-Regs:: Register Naming
6578 * i386-prefixes:: Opcode Prefixes
6579 * i386-Memory:: Memory References
6580 * i386-jumps:: Handling of Jump Instructions
6581 * i386-Float:: Floating Point
6582 * i386-16bit:: Writing 16-bit Code
6583 * i386-Notes:: Notes
6589 @cindex options for i386 (none)
6590 @cindex i386 options (none)
6591 The 80386 has no machine dependent options.
6594 @section AT&T Syntax versus Intel Syntax
6596 @cindex i386 syntax compatibility
6597 @cindex syntax compatibility, i386
6598 In order to maintain compatibility with the output of @code{@value{GCC}},
6599 @code{@value{AS}} supports AT&T System V/386 assembler syntax. This is quite
6600 different from Intel syntax. We mention these differences because
6601 almost all 80386 documents used only Intel syntax. Notable differences
6602 between the two syntaxes are:
6606 @cindex immediate operands, i386
6607 @cindex i386 immediate operands
6608 @cindex register operands, i386
6609 @cindex i386 register operands
6610 @cindex jump/call operands, i386
6611 @cindex i386 jump/call operands
6612 @cindex operand delimiters, i386
6613 AT&T immediate operands are preceded by @samp{$}; Intel immediate
6614 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
6615 AT&T register operands are preceded by @samp{%}; Intel register operands
6616 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
6617 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
6620 @cindex i386 source, destination operands
6621 @cindex source, destination operands; i386
6622 AT&T and Intel syntax use the opposite order for source and destination
6623 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
6624 @samp{source, dest} convention is maintained for compatibility with
6625 previous Unix assemblers.
6628 @cindex opcode suffixes, i386
6629 @cindex sizes operands, i386
6630 @cindex i386 size suffixes
6631 In AT&T syntax the size of memory operands is determined from the last
6632 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
6633 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
6634 memory references. Intel syntax accomplishes this by prefixes memory
6635 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
6636 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
6637 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
6640 @cindex return instructions, i386
6641 @cindex i386 jump, call, return
6642 Immediate form long jumps and calls are
6643 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
6645 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
6647 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
6648 @samp{ret far @var{stack-adjust}}.
6651 @cindex sections, i386
6652 @cindex i386 sections
6653 The AT&T assembler does not provide support for multiple section
6654 programs. Unix style systems expect all programs to be single sections.
6658 @section Opcode Naming
6660 @cindex i386 opcode naming
6661 @cindex opcode naming, i386
6662 Opcode names are suffixed with one character modifiers which specify the
6663 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
6664 byte, word, and long operands. If no suffix is specified by an
6665 instruction and it contains no memory operands then @code{@value{AS}} tries to
6666 fill in the missing suffix based on the destination register operand
6667 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
6668 to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
6669 @samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
6670 assembler which assumes that a missing opcode suffix implies long
6671 operand size. (This incompatibility does not affect compiler output
6672 since compilers always explicitly specify the opcode suffix.)
6674 Almost all opcodes have the same names in AT&T and Intel format. There
6675 are a few exceptions. The sign extend and zero extend instructions need
6676 two sizes to specify them. They need a size to sign/zero extend
6677 @emph{from} and a size to zero extend @emph{to}. This is accomplished
6678 by using two opcode suffixes in AT&T syntax. Base names for sign extend
6679 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
6680 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
6681 suffixes are tacked on to this base name, the @emph{from} suffix before
6682 the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
6683 ``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
6684 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
6685 and @samp{wl} (from word to long).
6687 @cindex conversion instructions, i386
6688 @cindex i386 conversion instructions
6689 The Intel-syntax conversion instructions
6693 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
6696 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
6699 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
6702 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
6706 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
6707 AT&T naming. @code{@value{AS}} accepts either naming for these instructions.
6709 @cindex jump instructions, i386
6710 @cindex call instructions, i386
6711 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
6712 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
6716 @section Register Naming
6718 @cindex i386 registers
6719 @cindex registers, i386
6720 Register operands are always prefixes with @samp{%}. The 80386 registers
6725 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
6726 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
6727 frame pointer), and @samp{%esp} (the stack pointer).
6730 the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
6731 @samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
6734 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
6735 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
6736 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
6737 @samp{%cx}, and @samp{%dx})
6740 the 6 section registers @samp{%cs} (code section), @samp{%ds}
6741 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
6745 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
6749 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
6750 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
6753 the 2 test registers @samp{%tr6} and @samp{%tr7}.
6756 the 8 floating point register stack @samp{%st} or equivalently
6757 @samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
6758 @samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
6762 @section Opcode Prefixes
6764 @cindex i386 opcode prefixes
6765 @cindex opcode prefixes, i386
6766 @cindex prefixes, i386
6767 Opcode prefixes are used to modify the following opcode. They are used
6768 to repeat string instructions, to provide section overrides, to perform
6769 bus lock operations, and to give operand and address size (16-bit
6770 operands are specified in an instruction by prefixing what would
6771 normally be 32-bit operands with a ``operand size'' opcode prefix).
6772 Opcode prefixes are usually given as single-line instructions with no
6773 operands, and must directly precede the instruction they act upon. For
6774 example, the @samp{scas} (scan string) instruction is repeated with:
6780 Here is a list of opcode prefixes:
6784 @cindex section override prefixes, i386
6785 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
6786 @samp{fs}, @samp{gs}. These are automatically added by specifying
6787 using the @var{section}:@var{memory-operand} form for memory references.
6790 @cindex size prefixes, i386
6791 Operand/Address size prefixes @samp{data16} and @samp{addr16}
6792 change 32-bit operands/addresses into 16-bit operands/addresses. Note
6793 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
6794 are not supported (yet).
6797 @cindex bus lock prefixes, i386
6798 @cindex inhibiting interrupts, i386
6799 The bus lock prefix @samp{lock} inhibits interrupts during
6800 execution of the instruction it precedes. (This is only valid with
6801 certain instructions; see a 80386 manual for details).
6804 @cindex coprocessor wait, i386
6805 The wait for coprocessor prefix @samp{wait} waits for the
6806 coprocessor to complete the current instruction. This should never be
6807 needed for the 80386/80387 combination.
6810 @cindex repeat prefixes, i386
6811 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
6812 to string instructions to make them repeat @samp{%ecx} times.
6816 @section Memory References
6818 @cindex i386 memory references
6819 @cindex memory references, i386
6820 An Intel syntax indirect memory reference of the form
6823 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
6827 is translated into the AT&T syntax
6830 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
6834 where @var{base} and @var{index} are the optional 32-bit base and
6835 index registers, @var{disp} is the optional displacement, and
6836 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
6837 to calculate the address of the operand. If no @var{scale} is
6838 specified, @var{scale} is taken to be 1. @var{section} specifies the
6839 optional section register for the memory operand, and may override the
6840 default section register (see a 80386 manual for section register
6841 defaults). Note that section overrides in AT&T syntax @emph{must} have
6842 be preceded by a @samp{%}. If you specify a section override which
6843 coincides with the default section register, @code{@value{AS}} does @emph{not}
6844 output any section register override prefixes to assemble the given
6845 instruction. Thus, section overrides can be specified to emphasize which
6846 section register is used for a given memory operand.
6848 Here are some examples of Intel and AT&T style memory references:
6851 @item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
6852 @var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
6853 missing, and the default section is used (@samp{%ss} for addressing with
6854 @samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
6856 @item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
6857 @var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
6858 @samp{foo}. All other fields are missing. The section register here
6859 defaults to @samp{%ds}.
6861 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
6862 This uses the value pointed to by @samp{foo} as a memory operand.
6863 Note that @var{base} and @var{index} are both missing, but there is only
6864 @emph{one} @samp{,}. This is a syntactic exception.
6866 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
6867 This selects the contents of the variable @samp{foo} with section
6868 register @var{section} being @samp{%gs}.
6871 Absolute (as opposed to PC relative) call and jump operands must be
6872 prefixed with @samp{*}. If no @samp{*} is specified, @code{@value{AS}}
6873 always chooses PC relative addressing for jump/call labels.
6875 Any instruction that has a memory operand @emph{must} specify its size (byte,
6876 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
6880 @section Handling of Jump Instructions
6882 @cindex jump optimization, i386
6883 @cindex i386 jump optimization
6884 Jump instructions are always optimized to use the smallest possible
6885 displacements. This is accomplished by using byte (8-bit) displacement
6886 jumps whenever the target is sufficiently close. If a byte displacement
6887 is insufficient a long (32-bit) displacement is used. We do not support
6888 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
6889 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
6890 @samp{%eip} to 16 bits after the word displacement is added.
6892 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
6893 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in byte
6894 displacements, so that if you use these instructions (@code{@value{GCC}} does
6895 not use them) you may get an error message (and incorrect code). The AT&T
6896 80386 assembler tries to get around this problem by expanding @samp{jcxz foo}
6907 @section Floating Point
6909 @cindex i386 floating point
6910 @cindex floating point, i386
6911 All 80387 floating point types except packed BCD are supported.
6912 (BCD support may be added without much difficulty). These data
6913 types are 16-, 32-, and 64- bit integers, and single (32-bit),
6914 double (64-bit), and extended (80-bit) precision floating point.
6915 Each supported type has an opcode suffix and a constructor
6916 associated with it. Opcode suffixes specify operand's data
6917 types. Constructors build these data types into memory.
6921 @cindex @code{float} directive, i386
6922 @cindex @code{single} directive, i386
6923 @cindex @code{double} directive, i386
6924 @cindex @code{tfloat} directive, i386
6925 Floating point constructors are @samp{.float} or @samp{.single},
6926 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
6927 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
6928 @samp{t} stands for temporary real, and that the 80387 only supports
6929 this format via the @samp{fldt} (load temporary real to stack top) and
6930 @samp{fstpt} (store temporary real and pop stack) instructions.
6933 @cindex @code{word} directive, i386
6934 @cindex @code{long} directive, i386
6935 @cindex @code{int} directive, i386
6936 @cindex @code{quad} directive, i386
6937 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
6938 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
6939 opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
6940 (quad). As with the temporary real format the 64-bit @samp{q} format is
6941 only present in the @samp{fildq} (load quad integer to stack top) and
6942 @samp{fistpq} (store quad integer and pop stack) instructions.
6945 Register to register operations do not require opcode suffixes,
6946 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
6948 @cindex i386 @code{fwait} instruction
6949 @cindex @code{fwait instruction}, i386
6950 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
6951 instructions are almost never needed (this is not the case for the
6952 80286/80287 and 8086/8087 combinations). Therefore, @code{@value{AS}} suppresses
6953 the @samp{fwait} instruction whenever it is implicitly selected by one
6954 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
6955 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
6956 instructions are made equivalent to @samp{f@dots{}} instructions. If
6957 @samp{fwait} is desired it must be explicitly coded.
6960 @section Writing 16-bit Code
6962 @cindex i386 16-bit code
6963 @cindex 16-bit code, i386
6964 @cindex real-mode code, i386
6965 @cindex @code{code16} directive, i386
6966 @cindex @code{code32} directive, i386
6967 While GAS normally writes only ``pure'' 32-bit i386 code, it has limited
6968 support for writing code to run in real mode or in 16-bit protected mode
6969 code segments. To do this, insert a @samp{.code16} directive before the
6970 assembly language instructions to be run in 16-bit mode. You can switch
6971 GAS back to writing normal 32-bit code with the @samp{.code32} directive.
6973 GAS understands exactly the same assembly language syntax in 16-bit mode as
6974 in 32-bit mode. The function of any given instruction is exactly the same
6975 regardless of mode, as long as the resulting object code is executed in the
6976 mode for which GAS wrote it. So, for example, the @samp{ret} mnemonic
6977 produces a 32-bit return instruction regardless of whether it is to be run
6978 in 16-bit or 32-bit mode. (If GAS is in 16-bit mode, it will add an
6979 operand size prefix to the instruction to force it to be a 32-bit return.)
6981 This means, for one thing, that you can use GNU CC to write code to be run
6982 in real mode or 16-bit protected mode. Just insert the statement
6983 @samp{asm(".code16");} at the beginning of your C source file, and while
6984 GNU CC will still be generating 32-bit code, GAS will automatically add all
6985 the necessary size prefixes to make that code run in 16-bit mode. Of
6986 course, since GNU CC only writes small-model code (it doesn't know how to
6987 attach segment selectors to pointers like native x86 compilers do), any
6988 16-bit code you write with GNU CC will essentially be limited to a 64K
6989 address space. Also, there will be a code size and performance penalty
6990 due to all the extra address and operand size prefixes GAS has to add to
6993 Note that placing GAS in 16-bit mode does not mean that the resulting
6994 code will necessarily run on a 16-bit pre-80386 processor. To write code
6995 that runs on such a processor, you would have to refrain from using
6996 @emph{any} 32-bit constructs which require GAS to output address or
6997 operand size prefixes. At the moment this would be rather difficult,
6998 because GAS currently supports @emph{only} 32-bit addressing modes: when
6999 writing 16-bit code, it @emph{always} outputs address size prefixes for any
7000 instruction that uses a non-register addressing mode. So you can write
7001 code that runs on 16-bit processors, but only if that code never references
7007 @cindex i386 @code{mul}, @code{imul} instructions
7008 @cindex @code{mul} instruction, i386
7009 @cindex @code{imul} instruction, i386
7010 There is some trickery concerning the @samp{mul} and @samp{imul}
7011 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
7012 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
7013 for @samp{imul}) can be output only in the one operand form. Thus,
7014 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
7015 the expanding multiply would clobber the @samp{%edx} register, and this
7016 would confuse @code{@value{GCC}} output. Use @samp{imul %ebx} to get the
7017 64-bit product in @samp{%edx:%eax}.
7019 We have added a two operand form of @samp{imul} when the first operand
7020 is an immediate mode expression and the second operand is a register.
7021 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
7022 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
7029 @node Z8000-Dependent
7030 @chapter Z8000 Dependent Features
7033 @node Machine Dependencies
7034 @chapter Z8000 Dependent Features
7037 @cindex Z8000 support
7038 The Z8000 @value{AS} supports both members of the Z8000 family: the
7039 unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with
7042 When the assembler is in unsegmented mode (specified with the
7043 @code{unsegm} directive), an address takes up one word (16 bit)
7044 sized register. When the assembler is in segmented mode (specified with
7045 the @code{segm} directive), a 24-bit address takes up a long (32 bit)
7046 register. @xref{Z8000 Directives,,Assembler Directives for the Z8000},
7047 for a list of other Z8000 specific assembler directives.
7050 * Z8000 Options:: No special command-line options for Z8000
7051 * Z8000 Syntax:: Assembler syntax for the Z8000
7052 * Z8000 Directives:: Special directives for the Z8000
7053 * Z8000 Opcodes:: Opcodes
7059 @cindex Z8000 options
7060 @cindex options, Z8000
7061 @code{@value{AS}} has no additional command-line options for the Zilog
7067 * Z8000-Chars:: Special Characters
7068 * Z8000-Regs:: Register Names
7069 * Z8000-Addressing:: Addressing Modes
7073 @subsection Special Characters
7075 @cindex line comment character, Z8000
7076 @cindex Z8000 line comment character
7077 @samp{!} is the line comment character.
7079 @cindex line separator, Z8000
7080 @cindex statement separator, Z8000
7081 @cindex Z8000 line separator
7082 You can use @samp{;} instead of a newline to separate statements.
7085 @subsection Register Names
7087 @cindex Z8000 registers
7088 @cindex registers, Z8000
7089 The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer
7090 to different sized groups of registers by register number, with the
7091 prefix @samp{r} for 16 bit registers, @samp{rr} for 32 bit registers and
7092 @samp{rq} for 64 bit registers. You can also refer to the contents of
7093 the first eight (of the sixteen 16 bit registers) by bytes. They are
7094 named @samp{r@var{n}h} and @samp{r@var{n}l}.
7097 @exdent @emph{byte registers}
7098 r0l r0h r1h r1l r2h r2l r3h r3l
7099 r4h r4l r5h r5l r6h r6l r7h r7l
7101 @exdent @emph{word registers}
7102 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
7104 @exdent @emph{long word registers}
7105 rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14
7107 @exdent @emph{quad word registers}
7111 @node Z8000-Addressing
7112 @subsection Addressing Modes
7114 @cindex addressing modes, Z8000
7115 @cindex Z800 addressing modes
7116 @value{AS} understands the following addressing modes for the Z8000:
7126 Direct: the 16 bit or 24 bit address (depending on whether the assembler
7127 is in segmented or unsegmented mode) of the operand is in the instruction.
7129 @item address(r@var{n})
7130 Indexed: the 16 or 24 bit address is added to the 16 bit register to produce
7131 the final address in memory of the operand.
7133 @item r@var{n}(#@var{imm})
7134 Base Address: the 16 or 24 bit register is added to the 16 bit sign
7135 extended immediate displacement to produce the final address in memory
7138 @item r@var{n}(r@var{m})
7139 Base Index: the 16 or 24 bit register r@var{n} is added to the sign
7140 extended 16 bit index register r@var{m} to produce the final address in
7141 memory of the operand.
7144 Immediate data @var{xx}.
7147 @node Z8000 Directives
7148 @section Assembler Directives for the Z8000
7150 @cindex Z8000 directives
7151 @cindex directives, Z8000
7152 The Z8000 port of @value{AS} includes these additional assembler directives,
7153 for compatibility with other Z8000 assemblers. As shown, these do not
7154 begin with @samp{.} (unlike the ordinary @value{AS} directives).
7159 Generates code for the segmented Z8001.
7163 Generates code for the unsegmented Z8002.
7167 Synonym for @code{.file}
7171 Synonum for @code{.global}
7175 Synonym for @code{.word}
7179 Synonym for @code{.long}
7183 Synonym for @code{.byte}
7187 Assemble a string. @code{sval} expects one string literal, delimited by
7188 single quotes. It assembles each byte of the string into consecutive
7189 addresses. You can use the escape sequence @samp{%@var{xx}} (where
7190 @var{xx} represents a two-digit hexadecimal number) to represent the
7191 character whose @sc{ascii} value is @var{xx}. Use this feature to
7192 describe single quote and other characters that may not appear in string
7193 literals as themselves. For example, the C statement @w{@samp{char *a =
7194 "he said \"it's 50% off\"";}} is represented in Z8000 assembly language
7195 (shown with the assembler output in hex at the left) as
7199 @let@nonarrowing=@comment
7202 68652073 sval 'he said %22it%27s 50%25 off%22%00'
7215 synonym for @code{.section}
7219 synonym for @code{.space}
7223 synonym for @code{.align 1}
7229 @cindex Z8000 opcode summary
7230 @cindex opcode summary, Z8000
7231 @cindex mnemonics, Z8000
7232 @cindex instruction summary, Z8000
7233 For detailed information on the Z8000 machine instruction set, see
7234 @cite{Z8000 Technical Manual}.
7237 @c this table, due to the multi-col faking and hardcoded order, looks silly
7238 @c except in smallbook. See comments below "@set SMALL" near top of this file.
7240 The following table summarizes the opcodes and their arguments:
7243 @let@nonarrowing=@comment
7247 rs @r{16 bit source register}
7248 rd @r{16 bit destination register}
7249 rbs @r{8 bit source register}
7250 rbd @r{8 bit destination register}
7251 rrs @r{32 bit source register}
7252 rrd @r{32 bit destination register}
7253 rqs @r{64 bit source register}
7254 rqd @r{64 bit destination register}
7255 addr @r{16/24 bit address}
7256 imm @r{immediate data}
7258 adc rd,rs clrb addr cpsir @@rd,@@rs,rr,cc
7259 adcb rbd,rbs clrb addr(rd) cpsirb @@rd,@@rs,rr,cc
7260 add rd,@@rs clrb rbd dab rbd
7261 add rd,addr com @@rd dbjnz rbd,disp7
7262 add rd,addr(rs) com addr dec @@rd,imm4m1
7263 add rd,imm16 com addr(rd) dec addr(rd),imm4m1
7264 add rd,rs com rd dec addr,imm4m1
7265 addb rbd,@@rs comb @@rd dec rd,imm4m1
7266 addb rbd,addr comb addr decb @@rd,imm4m1
7267 addb rbd,addr(rs) comb addr(rd) decb addr(rd),imm4m1
7268 addb rbd,imm8 comb rbd decb addr,imm4m1
7269 addb rbd,rbs comflg flags decb rbd,imm4m1
7270 addl rrd,@@rs cp @@rd,imm16 di i2
7271 addl rrd,addr cp addr(rd),imm16 div rrd,@@rs
7272 addl rrd,addr(rs) cp addr,imm16 div rrd,addr
7273 addl rrd,imm32 cp rd,@@rs div rrd,addr(rs)
7274 addl rrd,rrs cp rd,addr div rrd,imm16
7275 and rd,@@rs cp rd,addr(rs) div rrd,rs
7276 and rd,addr cp rd,imm16 divl rqd,@@rs
7277 and rd,addr(rs) cp rd,rs divl rqd,addr
7278 and rd,imm16 cpb @@rd,imm8 divl rqd,addr(rs)
7279 and rd,rs cpb addr(rd),imm8 divl rqd,imm32
7280 andb rbd,@@rs cpb addr,imm8 divl rqd,rrs
7281 andb rbd,addr cpb rbd,@@rs djnz rd,disp7
7282 andb rbd,addr(rs) cpb rbd,addr ei i2
7283 andb rbd,imm8 cpb rbd,addr(rs) ex rd,@@rs
7284 andb rbd,rbs cpb rbd,imm8 ex rd,addr
7285 bit @@rd,imm4 cpb rbd,rbs ex rd,addr(rs)
7286 bit addr(rd),imm4 cpd rd,@@rs,rr,cc ex rd,rs
7287 bit addr,imm4 cpdb rbd,@@rs,rr,cc exb rbd,@@rs
7288 bit rd,imm4 cpdr rd,@@rs,rr,cc exb rbd,addr
7289 bit rd,rs cpdrb rbd,@@rs,rr,cc exb rbd,addr(rs)
7290 bitb @@rd,imm4 cpi rd,@@rs,rr,cc exb rbd,rbs
7291 bitb addr(rd),imm4 cpib rbd,@@rs,rr,cc ext0e imm8
7292 bitb addr,imm4 cpir rd,@@rs,rr,cc ext0f imm8
7293 bitb rbd,imm4 cpirb rbd,@@rs,rr,cc ext8e imm8
7294 bitb rbd,rs cpl rrd,@@rs ext8f imm8
7295 bpt cpl rrd,addr exts rrd
7296 call @@rd cpl rrd,addr(rs) extsb rd
7297 call addr cpl rrd,imm32 extsl rqd
7298 call addr(rd) cpl rrd,rrs halt
7299 calr disp12 cpsd @@rd,@@rs,rr,cc in rd,@@rs
7300 clr @@rd cpsdb @@rd,@@rs,rr,cc in rd,imm16
7301 clr addr cpsdr @@rd,@@rs,rr,cc inb rbd,@@rs
7302 clr addr(rd) cpsdrb @@rd,@@rs,rr,cc inb rbd,imm16
7303 clr rd cpsi @@rd,@@rs,rr,cc inc @@rd,imm4m1
7304 clrb @@rd cpsib @@rd,@@rs,rr,cc inc addr(rd),imm4m1
7305 inc addr,imm4m1 ldb rbd,rs(rx) mult rrd,addr(rs)
7306 inc rd,imm4m1 ldb rd(imm16),rbs mult rrd,imm16
7307 incb @@rd,imm4m1 ldb rd(rx),rbs mult rrd,rs
7308 incb addr(rd),imm4m1 ldctl ctrl,rs multl rqd,@@rs
7309 incb addr,imm4m1 ldctl rd,ctrl multl rqd,addr
7310 incb rbd,imm4m1 ldd @@rs,@@rd,rr multl rqd,addr(rs)
7311 ind @@rd,@@rs,ra lddb @@rs,@@rd,rr multl rqd,imm32
7312 indb @@rd,@@rs,rba lddr @@rs,@@rd,rr multl rqd,rrs
7313 inib @@rd,@@rs,ra lddrb @@rs,@@rd,rr neg @@rd
7314 inibr @@rd,@@rs,ra ldi @@rd,@@rs,rr neg addr
7315 iret ldib @@rd,@@rs,rr neg addr(rd)
7316 jp cc,@@rd ldir @@rd,@@rs,rr neg rd
7317 jp cc,addr ldirb @@rd,@@rs,rr negb @@rd
7318 jp cc,addr(rd) ldk rd,imm4 negb addr
7319 jr cc,disp8 ldl @@rd,rrs negb addr(rd)
7320 ld @@rd,imm16 ldl addr(rd),rrs negb rbd
7321 ld @@rd,rs ldl addr,rrs nop
7322 ld addr(rd),imm16 ldl rd(imm16),rrs or rd,@@rs
7323 ld addr(rd),rs ldl rd(rx),rrs or rd,addr
7324 ld addr,imm16 ldl rrd,@@rs or rd,addr(rs)
7325 ld addr,rs ldl rrd,addr or rd,imm16
7326 ld rd(imm16),rs ldl rrd,addr(rs) or rd,rs
7327 ld rd(rx),rs ldl rrd,imm32 orb rbd,@@rs
7328 ld rd,@@rs ldl rrd,rrs orb rbd,addr
7329 ld rd,addr ldl rrd,rs(imm16) orb rbd,addr(rs)
7330 ld rd,addr(rs) ldl rrd,rs(rx) orb rbd,imm8
7331 ld rd,imm16 ldm @@rd,rs,n orb rbd,rbs
7332 ld rd,rs ldm addr(rd),rs,n out @@rd,rs
7333 ld rd,rs(imm16) ldm addr,rs,n out imm16,rs
7334 ld rd,rs(rx) ldm rd,@@rs,n outb @@rd,rbs
7335 lda rd,addr ldm rd,addr(rs),n outb imm16,rbs
7336 lda rd,addr(rs) ldm rd,addr,n outd @@rd,@@rs,ra
7337 lda rd,rs(imm16) ldps @@rs outdb @@rd,@@rs,rba
7338 lda rd,rs(rx) ldps addr outib @@rd,@@rs,ra
7339 ldar rd,disp16 ldps addr(rs) outibr @@rd,@@rs,ra
7340 ldb @@rd,imm8 ldr disp16,rs pop @@rd,@@rs
7341 ldb @@rd,rbs ldr rd,disp16 pop addr(rd),@@rs
7342 ldb addr(rd),imm8 ldrb disp16,rbs pop addr,@@rs
7343 ldb addr(rd),rbs ldrb rbd,disp16 pop rd,@@rs
7344 ldb addr,imm8 ldrl disp16,rrs popl @@rd,@@rs
7345 ldb addr,rbs ldrl rrd,disp16 popl addr(rd),@@rs
7346 ldb rbd,@@rs mbit popl addr,@@rs
7347 ldb rbd,addr mreq rd popl rrd,@@rs
7348 ldb rbd,addr(rs) mres push @@rd,@@rs
7349 ldb rbd,imm8 mset push @@rd,addr
7350 ldb rbd,rbs mult rrd,@@rs push @@rd,addr(rs)
7351 ldb rbd,rs(imm16) mult rrd,addr push @@rd,imm16
7352 push @@rd,rs set addr,imm4 subl rrd,imm32
7353 pushl @@rd,@@rs set rd,imm4 subl rrd,rrs
7354 pushl @@rd,addr set rd,rs tcc cc,rd
7355 pushl @@rd,addr(rs) setb @@rd,imm4 tccb cc,rbd
7356 pushl @@rd,rrs setb addr(rd),imm4 test @@rd
7357 res @@rd,imm4 setb addr,imm4 test addr
7358 res addr(rd),imm4 setb rbd,imm4 test addr(rd)
7359 res addr,imm4 setb rbd,rs test rd
7360 res rd,imm4 setflg imm4 testb @@rd
7361 res rd,rs sinb rbd,imm16 testb addr
7362 resb @@rd,imm4 sinb rd,imm16 testb addr(rd)
7363 resb addr(rd),imm4 sind @@rd,@@rs,ra testb rbd
7364 resb addr,imm4 sindb @@rd,@@rs,rba testl @@rd
7365 resb rbd,imm4 sinib @@rd,@@rs,ra testl addr
7366 resb rbd,rs sinibr @@rd,@@rs,ra testl addr(rd)
7367 resflg imm4 sla rd,imm8 testl rrd
7368 ret cc slab rbd,imm8 trdb @@rd,@@rs,rba
7369 rl rd,imm1or2 slal rrd,imm8 trdrb @@rd,@@rs,rba
7370 rlb rbd,imm1or2 sll rd,imm8 trib @@rd,@@rs,rbr
7371 rlc rd,imm1or2 sllb rbd,imm8 trirb @@rd,@@rs,rbr
7372 rlcb rbd,imm1or2 slll rrd,imm8 trtdrb @@ra,@@rb,rbr
7373 rldb rbb,rba sout imm16,rs trtib @@ra,@@rb,rr
7374 rr rd,imm1or2 soutb imm16,rbs trtirb @@ra,@@rb,rbr
7375 rrb rbd,imm1or2 soutd @@rd,@@rs,ra trtrb @@ra,@@rb,rbr
7376 rrc rd,imm1or2 soutdb @@rd,@@rs,rba tset @@rd
7377 rrcb rbd,imm1or2 soutib @@rd,@@rs,ra tset addr
7378 rrdb rbb,rba soutibr @@rd,@@rs,ra tset addr(rd)
7379 rsvd36 sra rd,imm8 tset rd
7380 rsvd38 srab rbd,imm8 tsetb @@rd
7381 rsvd78 sral rrd,imm8 tsetb addr
7382 rsvd7e srl rd,imm8 tsetb addr(rd)
7383 rsvd9d srlb rbd,imm8 tsetb rbd
7384 rsvd9f srll rrd,imm8 xor rd,@@rs
7385 rsvdb9 sub rd,@@rs xor rd,addr
7386 rsvdbf sub rd,addr xor rd,addr(rs)
7387 sbc rd,rs sub rd,addr(rs) xor rd,imm16
7388 sbcb rbd,rbs sub rd,imm16 xor rd,rs
7389 sc imm8 sub rd,rs xorb rbd,@@rs
7390 sda rd,rs subb rbd,@@rs xorb rbd,addr
7391 sdab rbd,rs subb rbd,addr xorb rbd,addr(rs)
7392 sdal rrd,rs subb rbd,addr(rs) xorb rbd,imm8
7393 sdl rd,rs subb rbd,imm8 xorb rbd,rbs
7394 sdlb rbd,rs subb rbd,rbs xorb rbd,rbs
7395 sdll rrd,rs subl rrd,@@rs
7396 set @@rd,imm4 subl rrd,addr
7397 set addr(rd),imm4 subl rrd,addr(rs)
7409 @node MIPS-Dependent
7410 @chapter MIPS Dependent Features
7413 @node Machine Dependencies
7414 @chapter MIPS Dependent Features
7421 @sc{gnu} @code{@value{AS}} for @sc{mips} architectures supports the @sc{mips}
7422 @sc{r2000}, @sc{r3000}, @sc{r4000} and @sc{r6000} processors. For information
7423 about the @sc{mips} instruction set, see @cite{MIPS RISC Architecture}, by Kane
7424 and Heindrich (Prentice-Hall). For an overview of @sc{mips} assembly
7425 conventions, see ``Appendix D: Assembly Language Programming'' in the same
7429 * MIPS Opts:: Assembler options
7430 * MIPS Object:: ECOFF object code
7431 * MIPS Stabs:: Directives for debugging information
7432 * MIPS ISA:: Directives to override the ISA level
7436 @section Assembler options
7438 The @sc{mips} configurations of @sc{gnu} @code{@value{AS}} support these
7442 @cindex @code{-G} option (MIPS)
7444 This option sets the largest size of an object that can be referenced
7445 implicitly with the @code{gp} register. It is only accepted for targets
7446 that use @sc{ecoff} format. The default value is 8.
7448 @cindex @code{-EB} option (MIPS)
7449 @cindex @code{-EL} option (MIPS)
7450 @cindex MIPS big-endian output
7451 @cindex MIPS little-endian output
7452 @cindex big-endian output, MIPS
7453 @cindex little-endian output, MIPS
7456 Any @sc{mips} configuration of @code{@value{AS}} can select big-endian or
7457 little-endian output at run time (unlike the other @sc{gnu} development
7458 tools, which must be configured for one or the other). Use @samp{-EB}
7459 to select big-endian output, and @samp{-EL} for little-endian.
7461 @cindex MIPS architecture options
7465 Generate code for a particular MIPS Instruction Set Architecture level.
7466 @samp{-mips1} corresponds to the @sc{r2000} and @sc{r3000} processors,
7467 @samp{-mips2} to the @sc{r6000} processor, and @samp{-mips3} to the @sc{r4000}
7468 processor. You can also switch instruction sets during the assembly; see
7469 @ref{MIPS ISA,, Directives to override the ISA level}.
7473 Generate code for the MIPS @sc{r4650} chip. This tells the assembler to accept
7474 the @samp{mad} and @samp{madu} instruction, and to not schedule @samp{nop}
7475 instructions around accesses to the @samp{HI} and @samp{LO} registers.
7476 @samp{-no-m4650} turns off this option.
7478 @item -mcpu=@var{CPU}
7479 Generate code for a particular MIPS cpu. This has little effect on the
7480 assembler, but it is passed by @code{@value{GCC}}.
7482 @cindex @code{-nocpp} ignored (MIPS)
7484 This option is ignored. It is accepted for command-line compatibility with
7485 other assemblers, which use it to turn off C style preprocessing. With
7486 @sc{gnu} @code{@value{AS}}, there is no need for @samp{-nocpp}, because the
7487 @sc{gnu} assembler itself never runs the C preprocessor.
7491 @c FIXME! (1) reflect these options (next item too) in option summaries;
7492 @c (2) stop teasing, say _which_ instructions expanded _how_.
7493 @code{@value{AS}} automatically macro expands certain division and
7494 multiplication instructions to check for overflow and division by zero. This
7495 option causes @code{@value{AS}} to generate code to take a trap exception
7496 rather than a break exception when an error is detected. The trap instructions
7497 are only supported at Instruction Set Architecture level 2 and higher.
7501 Generate code to take a break exception rather than a trap exception when an
7502 error is detected. This is the default.
7506 @section MIPS ECOFF object code
7508 @cindex ECOFF sections
7509 @cindex MIPS ECOFF sections
7510 Assembling for a @sc{mips} @sc{ecoff} target supports some additional sections
7511 besides the usual @code{.text}, @code{.data} and @code{.bss}. The
7512 additional sections are @code{.rdata}, used for read-only data,
7513 @code{.sdata}, used for small data, and @code{.sbss}, used for small
7516 @cindex small objects, MIPS ECOFF
7517 @cindex @code{gp} register, MIPS
7518 When assembling for @sc{ecoff}, the assembler uses the @code{$gp} (@code{$28})
7519 register to form the address of a ``small object''. Any object in the
7520 @code{.sdata} or @code{.sbss} sections is considered ``small'' in this sense.
7521 For external objects, or for objects in the @code{.bss} section, you can use
7522 the @code{@value{GCC}} @samp{-G} option to control the size of objects addressed via
7523 @code{$gp}; the default value is 8, meaning that a reference to any object
7524 eight bytes or smaller uses @code{$gp}. Passing @samp{-G 0} to
7525 @code{@value{AS}} prevents it from using the @code{$gp} register on the basis
7526 of object size (but the assembler uses @code{$gp} for objects in @code{.sdata}
7527 or @code{sbss} in any case). The size of an object in the @code{.bss} section
7528 is set by the @code{.comm} or @code{.lcomm} directive that defines it. The
7529 size of an external object may be set with the @code{.extern} directive. For
7530 example, @samp{.extern sym,4} declares that the object at @code{sym} is 4 bytes
7531 in length, whie leaving @code{sym} otherwise undefined.
7533 Using small @sc{ecoff} objects requires linker support, and assumes that the
7534 @code{$gp} register is correctly initialized (normally done automatically by
7535 the startup code). @sc{mips} @sc{ecoff} assembly code must not modify the
7536 @code{$gp} register.
7539 @section Directives for debugging information
7541 @cindex MIPS debugging directives
7542 @sc{mips} @sc{ecoff} @code{@value{AS}} supports several directives used for
7543 generating debugging information which are not support by traditional @sc{mips}
7544 assemblers. These are @code{.def}, @code{.endef}, @code{.dim}, @code{.file},
7545 @code{.scl}, @code{.size}, @code{.tag}, @code{.type}, @code{.val},
7546 @code{.stabd}, @code{.stabn}, and @code{.stabs}. The debugging information
7547 generated by the three @code{.stab} directives can only be read by @sc{gdb},
7548 not by traditional @sc{mips} debuggers (this enhancement is required to fully
7549 support C++ debugging). These directives are primarily used by compilers, not
7550 assembly language programmers!
7553 @section Directives to override the ISA level
7555 @cindex MIPS ISA override
7556 @kindex @code{.set mips@var{n}}
7557 @sc{gnu} @code{@value{AS}} supports an additional directive to change the
7558 @sc{mips} Instruction Set Architecture level on the fly: @code{.set
7559 mips@var{n}}. @var{n} should be a number from 0 to 3. A value from 1 to 3
7560 makes the assembler accept instructions for the corresponding @sc{isa} level,
7561 from that point on in the assembly. @code{.set mips@var{n}} affects not only
7562 which instructions are permitted, but also how certain macros are expanded.
7563 @code{.set mips0} restores the @sc{isa} level to its original level: either the
7564 level you selected with command line options, or the default for your
7565 configuration. You can use this feature to permit specific @sc{r4000}
7566 instructions while assembling in 32 bit mode. Use this directive with care!
7568 Traditional @sc{mips} assemblers do not support this directive.
7572 @c reverse effect of @down at top of generic Machine-Dep chapter
7576 @node Acknowledgements
7577 @chapter Acknowledgements
7579 If you have contributed to @code{@value{AS}} and your name isn't listed here,
7580 it is not meant as a slight. We just don't know about it. Send mail to the
7581 maintainer, and we'll correct the situation. Currently (January 1994), the
7582 maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
7584 Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any more
7587 Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug
7588 information and the 68k series machines, most of the preprocessing pass, and
7589 extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}.
7591 K. Richard Pixley maintained GAS for a while, adding various enhancements and
7592 many bug fixes, including merging support for several processors, breaking GAS
7593 up to handle multiple object file format back ends (including heavy rewrite,
7594 testing, an integration of the coff and b.out back ends), adding configuration
7595 including heavy testing and verification of cross assemblers and file splits
7596 and renaming, converted GAS to strictly ANSI C including full prototypes, added
7597 support for m680[34]0 and cpu32, did considerable work on i960 including a COFF
7598 port (including considerable amounts of reverse engineering), a SPARC opcode
7599 file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know''
7600 assertions and made them work, much other reorganization, cleanup, and lint.
7602 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
7603 in format-specific I/O modules.
7605 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
7606 has done much work with it since.
7608 The Intel 80386 machine description was written by Eliot Dresselhaus.
7610 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
7612 The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
7613 University and Torbjorn Granlund of the Swedish Institute of Computer Science.
7615 Keith Knowles at the Open Software Foundation wrote the original MIPS back end
7616 (@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support
7617 (which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to
7618 support a.out format.
7620 Support for the Zilog Z8k and Hitachi H8/300 and H8/500 processors (tc-z8k,
7621 tc-h8300, tc-h8500), and IEEE 695 object file format (obj-ieee), was written by
7622 Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
7623 use BFD for some low-level operations, for use with the H8/300 and AMD 29k
7626 John Gilmore built the AMD 29000 support, added @code{.include} support, and
7627 simplified the configuration of which versions accept which directives. He
7628 updated the 68k machine description so that Motorola's opcodes always produced
7629 fixed-size instructions (e.g. @code{jsr}), while synthetic instructions
7630 remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested
7631 cross-compilation support, and one bug in relaxation that took a week and
7632 required the proverbial one-bit fix.
7634 Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the
7635 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
7636 added support for MIPS ECOFF and ELF targets, and made a few other minor
7639 Steve Chamberlain made @code{@value{AS}} able to generate listings.
7641 Hewlett-Packard contributed support for the HP9000/300.
7643 Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM)
7644 along with a fairly extensive HPPA testsuite (for both SOM and ELF object
7645 formats). This work was supported by both the Center for Software Science at
7646 the University of Utah and Cygnus Support.
7648 Support for ELF format files has been worked on by Mark Eichin of Cygnus
7649 Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
7650 Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
7651 Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
7652 and some initial 64-bit support).
7654 Several engineers at Cygnus Support have also provided many small bug fixes and
7655 configuration enhancements.
7657 Many others have contributed large or small bugfixes and enhancements. If
7658 you have contributed significant work and are not mentioned on this list, and
7659 want to be, let us know. Some of the history has been lost; we are not
7660 intentionally leaving anyone out.