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 asdoc-config.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.
73 START-INFO-DIR-ENTRY As: (as). The GNU assembler. END-INFO-DIR-ENTRY
81 This file documents the GNU Assembler "@value{AS}".
83 Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
85 Permission is granted to make and distribute verbatim copies of
86 this manual provided the copyright notice and this permission notice
87 are preserved on all copies.
90 Permission is granted to process this file through Tex and print the
91 results, provided the printed document carries copying permission
92 notice identical to this one except for the removal of this paragraph
93 (this paragraph not being relevant to the printed manual).
96 Permission is granted to copy and distribute modified versions of this manual
97 under the conditions for verbatim copying, provided that the entire resulting
98 derived work is distributed under the terms of a permission notice identical to
101 Permission is granted to copy and distribute translations of this manual
102 into another language, under the above conditions for modified versions.
106 @title Using @value{AS}
107 @subtitle The GNU Assembler
109 @subtitle for the @value{TARGET} family
112 @subtitle January 1994
115 The Free Software Foundation Inc. thanks The Nice Computer
116 Company of Australia for loaning Dean Elsner to write the
117 first (Vax) version of @code{as} for Project GNU.
118 The proprietors, management and staff of TNCCA thank FSF for
119 distracting the boss while they got some work
122 @author Dean Elsner, Jay Fenlason & friends
126 \hfill {\it Using {\tt @value{AS}}}\par
127 \hfill Edited by Roland Pesch for Cygnus Support\par
129 %"boxit" macro for figures:
130 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
131 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
132 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
133 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
134 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
137 @vskip 0pt plus 1filll
138 Copyright @copyright{} 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
140 Permission is granted to make and distribute verbatim copies of
141 this manual provided the copyright notice and this permission notice
142 are preserved on all copies.
144 Permission is granted to copy and distribute modified versions of this manual
145 under the conditions for verbatim copying, provided that the entire resulting
146 derived work is distributed under the terms of a permission notice identical to
149 Permission is granted to copy and distribute translations of this manual
150 into another language, under the above conditions for modified versions.
155 @top Using @value{AS}
157 This file is a user guide to the GNU assembler @code{@value{AS}}.
159 This version of the file describes @code{@value{AS}} configured to generate
160 code for @value{TARGET} architectures.
163 * Overview:: Overview
164 * Invoking:: Command-Line Options
166 * Sections:: Sections and Relocation
168 * Expressions:: Expressions
169 * Pseudo Ops:: Assembler Directives
170 * Machine Dependencies:: Machine Dependent Features
171 * Acknowledgements:: Who Did What
179 This manual is a user guide to the GNU assembler @code{@value{AS}}.
181 This version of the manual describes @code{@value{AS}} configured to generate
182 code for @value{TARGET} architectures.
186 @cindex invocation summary
187 @cindex option summary
188 @cindex summary of options
189 Here is a brief summary of how to invoke @code{@value{AS}}. For details,
190 @pxref{Invoking,,Comand-Line Options}.
192 @c We don't use deffn and friends for the following because they seem
193 @c to be limited to one line for the header.
195 @value{AS} [ -a[dhlns] ] [ -D ] [ -f ] [ -I @var{path} ]
196 [ -K ] [ -L ] [ -o @var{objfile} ] [ -R ]
197 [ --statistics] [ -v ] [ -W ] [ -Z ]
199 @c am29k has no machine-dependent assembler options
202 @c Hitachi family chips have no machine-dependent assembler options
205 @c HPPA has no machine-dependent assembler options (yet).
208 [ -Av6 | -Av7 | -Av8 | -Asparclite | -bump ]
211 @c Z8000 has no machine-dependent assembler options
214 @c see md_parse_option in tc-i960.c
215 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
219 [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
222 [ -nocpp ] [ -EL ] [ -EB ] [ -G @var{num} ]
224 [ -- | @var{files} @dots{} ]
229 Turn on listings, in any of a variety of ways:
233 omit debugging directives from listing
236 include high-level source
248 You may combine these options; for example, use @samp{-aln} for assembly
249 listing without forms processing. By itself, @samp{-a} defaults to
250 @samp{-ahls}---that is, all listings turned on.
253 This option is accepted only for script compatibility with calls to
254 other assemblers; it has no effect on @code{@value{AS}}.
257 ``fast''---skip whitespace and comment preprocessing (assume source is
261 Add @var{path} to the search list for @code{.include} directives
264 @ifclear DIFF-TBL-KLUGE
265 This option is accepted but has no effect on the @value{TARGET} family.
267 @ifset DIFF-TBL-KLUGE
268 Issue warnings when difference tables altered for long displacements.
272 Keep (in symbol table) local symbols, starting with @samp{L}
274 @item -o @var{objfile}
275 Name the object-file output from @code{@value{AS}}
278 Fold data section into text section
281 Display maximum space (in bytes), and total time (in seconds), taken by
285 Announce @code{as} version
288 Suppress warning messages
291 Generate object file even after errors
293 @item -- | @var{files} @dots{}
294 Standard input, or source files to assemble.
299 The following options are available when @value{AS} is configured for the
300 Intel 80960 processor.
303 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
304 Specify which variant of the 960 architecture is the target.
307 Add code to collect statistics about branches taken.
310 Do not alter compare-and-branch instructions for long displacements;
317 The following options are available when @value{AS} is configured for the
318 Motorola 68000 series.
323 Shorten references to undefined symbols, to one word instead of two.
325 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040
326 @itemx | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32
327 Specify what processor in the 68000 family is the target. The default
328 is normally the 68020, but this can be changed at configuration time.
330 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
331 The target machine does (or does not) have a floating-point coprocessor.
332 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
333 the basic 68000 is not compatible with the 68881, a combination of the
334 two can be specified, since it's possible to do emulation of the
335 coprocessor instructions with the main processor.
337 @item -m68851 | -mno-68851
338 The target machine does (or does not) have a memory-management
339 unit coprocessor. The default is to assume an MMU for 68020 and up.
345 The following options are available when @code{@value{AS}} is configured
346 for the SPARC architecture:
349 @item -Av6 | -Av7 | -Av8 | -Asparclite
350 Explicitly select a variant of the SPARC architecture.
353 Warn when the assembler switches to another architecture.
358 The following options are available when @value{AS} is configured for
359 the MIPS R2000/R3000 processors.
363 This option sets the largest size of an object that can be referenced
364 implicitly with the @code{gp} register. It is only accepted for targets
365 that use ECOFF format, such as a DECstation running Ultrix. The default
368 @cindex MIPS endianness
369 @cindex endianness, MIPS
371 @cindex big endian output, MIPS
372 Generate ``big endian'' format output.
375 @cindex little endian output, MIPS
376 Generate ``little endian'' format output.
379 This option is ignored. It is accepted for compatibility with the native
385 * Manual:: Structure of this Manual
386 * GNU Assembler:: @value{AS}, the GNU Assembler
387 * Object Formats:: Object File Formats
388 * Command Line:: Command Line
389 * Input Files:: Input Files
390 * Object:: Output (Object) File
391 * Errors:: Error and Warning Messages
395 @section Structure of this Manual
397 @cindex manual, structure and purpose
398 This manual is intended to describe what you need to know to use
399 @sc{gnu} @code{@value{AS}}. We cover the syntax expected in source files, including
400 notation for symbols, constants, and expressions; the directives that
401 @code{@value{AS}} understands; and of course how to invoke @code{@value{AS}}.
404 We also cover special features in the @value{TARGET}
405 configuration of @code{@value{AS}}, including assembler directives.
408 This manual also describes some of the machine-dependent features of
409 various flavors of the assembler.
412 @cindex machine instructions (not covered)
413 On the other hand, this manual is @emph{not} intended as an introduction
414 to programming in assembly language---let alone programming in general!
415 In a similar vein, we make no attempt to introduce the machine
416 architecture; we do @emph{not} describe the instruction set, standard
417 mnemonics, registers or addressing modes that are standard to a
418 particular architecture.
420 You may want to consult the manufacturer's
421 machine architecture manual for this information.
425 For information on the H8/300 machine instruction set, see @cite{H8/300
426 Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,
427 see @cite{H8/300H Series Programming Manual} (Hitachi).
430 For information on the H8/500 machine instruction set, see @cite{H8/500
431 Series Programming Manual} (Hitachi M21T001).
434 For information on the Hitachi SH machine instruction set, see
435 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
438 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
442 @c I think this is premature---pesch@cygnus.com, 17jan1991
444 Throughout this manual, we assume that you are running @dfn{GNU},
445 the portable operating system from the @dfn{Free Software
446 Foundation, Inc.}. This restricts our attention to certain kinds of
447 computer (in particular, the kinds of computers that GNU can run on);
448 once this assumption is granted examples and definitions need less
451 @code{@value{AS}} is part of a team of programs that turn a high-level
452 human-readable series of instructions into a low-level
453 computer-readable series of instructions. Different versions of
454 @code{@value{AS}} are used for different kinds of computer.
457 @c There used to be a section "Terminology" here, which defined
458 @c "contents", "byte", "word", and "long". Defining "word" to any
459 @c particular size is confusing when the .word directive may generate 16
460 @c bits on one machine and 32 bits on another; in general, for the user
461 @c version of this manual, none of these terms seem essential to define.
462 @c They were used very little even in the former draft of the manual;
463 @c this draft makes an effort to avoid them (except in names of
467 @section @value{AS}, the GNU Assembler
469 GNU @code{as} is really a family of assemblers.
471 This manual describes @code{@value{AS}}, a member of that family which is
472 configured for the @value{TARGET} architectures.
474 If you use (or have used) the GNU assembler on one architecture, you
475 should find a fairly similar environment when you use it on another
476 architecture. Each version has much in common with the others,
477 including object file formats, most assembler directives (often called
478 @dfn{pseudo-ops}) and assembler syntax.@refill
480 @cindex purpose of @sc{gnu} @code{@value{AS}}
481 @code{@value{AS}} is primarily intended to assemble the output of the
482 GNU C compiler @code{@value{GCC}} for use by the linker
483 @code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}
484 assemble correctly everything that other assemblers for the same
485 machine would assemble.
487 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
490 @c This remark should appear in generic version of manual; assumption
491 @c here is that generic version sets M680x0.
492 This doesn't mean @code{@value{AS}} always uses the same syntax as another
493 assembler for the same architecture; for example, we know of several
494 incompatible versions of 680x0 assembly language syntax.
497 Unlike older assemblers, @code{@value{AS}} is designed to assemble a source
498 program in one pass of the source file. This has a subtle impact on the
499 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
502 @section Object File Formats
504 @cindex object file format
505 The GNU assembler can be configured to produce several alternative
506 object file formats. For the most part, this does not affect how you
507 write assembly language programs; but directives for debugging symbols
508 are typically different in different file formats. @xref{Symbol
509 Attributes,,Symbol Attributes}.
512 On the @value{TARGET}, @code{@value{AS}} is configured to produce
513 @value{OBJ-NAME} format object files.
515 @c The following should exhaust all configs that set MULTI-OBJ, ideally
517 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
518 @code{a.out} or COFF format object files.
521 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
522 @code{b.out} or COFF format object files.
525 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
526 SOM or ELF format object files.
531 @section Command Line
533 @cindex command line conventions
534 After the program name @code{@value{AS}}, the command line may contain
535 options and file names. Options may appear in any order, and may be
536 before, after, or between file names. The order of file names is
539 @cindex standard input, as input file
541 @file{--} (two hyphens) by itself names the standard input file
542 explicitly, as one of the files for @code{@value{AS}} to assemble.
544 @cindex options, command line
545 Except for @samp{--} any command line argument that begins with a
546 hyphen (@samp{-}) is an option. Each option changes the behavior of
547 @code{@value{AS}}. No option changes the way another option works. An
548 option is a @samp{-} followed by one or more letters; the case of
549 the letter is important. All options are optional.
551 Some options expect exactly one file name to follow them. The file
552 name may either immediately follow the option's letter (compatible
553 with older assemblers) or it may be the next command argument (GNU
554 standard). These two command lines are equivalent:
557 @value{AS} -o my-object-file.o mumble.s
558 @value{AS} -omy-object-file.o mumble.s
565 @cindex source program
567 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
568 describe the program input to one run of @code{@value{AS}}. The program may
569 be in one or more files; how the source is partitioned into files
570 doesn't change the meaning of the source.
572 @c I added "con" prefix to "catenation" just to prove I can overcome my
573 @c APL training... pesch@cygnus.com
574 The source program is a concatenation of the text in all the files, in the
577 Each time you run @code{@value{AS}} it assembles exactly one source
578 program. The source program is made up of one or more files.
579 (The standard input is also a file.)
581 You give @code{@value{AS}} a command line that has zero or more input file
582 names. The input files are read (from left file name to right). A
583 command line argument (in any position) that has no special meaning
584 is taken to be an input file name.
586 If you give @code{@value{AS}} no file names it attempts to read one input file
587 from the @code{@value{AS}} standard input, which is normally your terminal. You
588 may have to type @key{ctl-D} to tell @code{@value{AS}} there is no more program
591 Use @samp{--} if you need to explicitly name the standard input file
592 in your command line.
594 If the source is empty, @code{@value{AS}} produces a small, empty object
597 @subheading Filenames and Line-numbers
599 @cindex input file linenumbers
600 @cindex line numbers, in input files
601 There are two ways of locating a line in the input file (or files) and
602 either may be used in reporting error messages. One way refers to a line
603 number in a physical file; the other refers to a line number in a
604 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
606 @dfn{Physical files} are those files named in the command line given
607 to @code{@value{AS}}.
609 @dfn{Logical files} are simply names declared explicitly by assembler
610 directives; they bear no relation to physical files. Logical file names
611 help error messages reflect the original source file, when @code{@value{AS}}
612 source is itself synthesized from other files.
613 @xref{App-File,,@code{.app-file}}.
616 @section Output (Object) File
622 Every time you run @code{@value{AS}} it produces an output file, which is
623 your assembly language program translated into numbers. This file
624 is the object file, named
628 if @code{@value{AS}} is configured for the Intel 80960, or
634 unless you tell @code{@value{AS}} to
635 give it another name by using the @code{-o} option. Conventionally,
636 object file names end with @file{.o}. The default name of
637 @file{a.out} is used for historical reasons: older assemblers were
638 capable of assembling self-contained programs directly into a
640 (For some formats, this isn't currently possible, but it can be done for
641 @code{a.out} format.)
645 The object file is meant for input to the linker @code{@value{LD}}. It contains
646 assembled program code, information to help @code{@value{LD}} integrate
647 the assembled program into a runnable file, and (optionally) symbolic
648 information for the debugger.
650 @c link above to some info file(s) like the description of a.out.
651 @c don't forget to describe GNU info as well as Unix lossage.
654 @section Error and Warning Messages
656 @cindex error messsages
657 @cindex warning messages
658 @cindex messages from @code{@value{AS}}
659 @code{@value{AS}} may write warnings and error messages to the standard error
660 file (usually your terminal). This should not happen when a compiler
661 runs @code{@value{AS}} automatically. Warnings report an assumption made so
662 that @code{@value{AS}} could keep assembling a flawed program; errors report a
663 grave problem that stops the assembly.
665 @cindex format of warning messages
666 Warning messages have the format
669 file_name:@b{NNN}:Warning Message Text
673 @cindex line numbers, in warnings/errors
674 (where @b{NNN} is a line number). If a logical file name has been given
675 (@pxref{App-File,,@code{.app-file}}) it is used for the filename,
676 otherwise the name of the current input file is used. If a logical line
679 (@pxref{Line,,@code{.line}})
683 (@pxref{Line,,@code{.line}})
686 (@pxref{Ln,,@code{.ln}})
689 then it is used to calculate the number printed,
690 otherwise the actual line in the current source file is printed. The
691 message text is intended to be self explanatory (in the grand Unix
694 @cindex format of error messages
695 Error messages have the format
697 file_name:@b{NNN}:FATAL:Error Message Text
699 The file name and line number are derived as for warning
700 messages. The actual message text may be rather less explanatory
701 because many of them aren't supposed to happen.
704 @chapter Command-Line Options
706 @cindex options, all versions of @code{@value{AS}}
707 This chapter describes command-line options available in @emph{all}
708 versions of the GNU assembler; @pxref{Machine Dependencies}, for options specific
710 to the @value{TARGET}.
713 to particular machine architectures.
716 If you are invoking @code{@value{AS}} via the GNU C compiler (version 2), you
717 can use the @samp{-Wa} option to pass arguments through to the
718 assembler. The assembler arguments must be separated from each other
719 (and the @samp{-Wa}) by commas. For example:
722 gcc -c -g -O -Wa,-alh,-L file.c
726 emits a listing to standard output with high-level
729 Usually you do not need to use this @samp{-Wa} mechanism, since many compiler
730 command-line options are automatically passed to the assembler by the compiler.
731 (You can call the GNU compiler driver with the @samp{-v} option to see
732 precisely what options it passes to each compilation pass, including the
736 * a:: -a[dhlns] enable listings
737 * D:: -D for compatibility
738 * f:: -f to work faster
739 * I:: -I for .include search path
740 @ifclear DIFF-TBL-KLUGE
741 * K:: -K for compatibility
743 @ifset DIFF-TBL-KLUGE
744 * K:: -K for difference tables
747 * L:: -L to retain local labels
748 * o:: -o to name the object file
749 * R:: -R to join data and text sections
750 * statistics:: --statistics to see statistics about assembly
751 * v:: -v to announce version
752 * W:: -W to suppress warnings
753 * Z:: -Z to make object file even after errors
757 @section Enable Listings: @code{-a[dhlns]}
765 @cindex listings, enabling
766 @cindex assembly listings, enabling
768 These options enable listing output from the assembler. By itself,
769 @samp{-a} requests high-level, assembly, and symbols listing.
770 Other letters may be used to select specific options for the list:
771 @samp{-ah} requests a high-level language listing,
772 @samp{-al} requests an output-program assembly listing, and
773 @samp{-as} requests a symbol table listing.
774 High-level listings require that a compiler debugging option like
775 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
778 The @samp{-ad} option may be used to omit debugging directives from the
781 Once you have specified one of these options, you can further control
782 listing output and its appearance using the directives @code{.list},
783 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
785 The @samp{-an} option turns off all forms processing.
786 If you do not request listing output with one of the @samp{-a} options, the
787 listing-control directives have no effect.
789 The letters after @samp{-a} may be combined into one option,
790 @emph{e.g.}, @samp{-aln}.
796 This option has no effect whatsoever, but it is accepted to make it more
797 likely that scripts written for other assemblers also work with
801 @section Work Faster: @code{-f}
804 @cindex trusted compiler
805 @cindex faster processing (@code{-f})
806 @samp{-f} should only be used when assembling programs written by a
807 (trusted) compiler. @samp{-f} stops the assembler from doing whitespace
808 and comment preprocessing on
809 the input file(s) before assembling them. @xref{Preprocessing,
813 @emph{Warning:} if you use @samp{-f} when the files actually need to be
814 preprocessed (if they contain comments, for example), @code{@value{AS}} does
819 @section @code{.include} search path: @code{-I} @var{path}
821 @kindex -I @var{path}
822 @cindex paths for @code{.include}
823 @cindex search path for @code{.include}
824 @cindex @code{include} directive search path
825 Use this option to add a @var{path} to the list of directories
826 @code{@value{AS}} searches for files specified in @code{.include}
827 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
828 many times as necessary to include a variety of paths. The current
829 working directory is always searched first; after that, @code{@value{AS}}
830 searches any @samp{-I} directories in the same order as they were
831 specified (left to right) on the command line.
834 @section Difference Tables: @code{-K}
837 @ifclear DIFF-TBL-KLUGE
838 On the @value{TARGET} family, this option is allowed, but has no effect. It is
839 permitted for compatibility with the GNU assembler on other platforms,
840 where it can be used to warn when the assembler alters the machine code
841 generated for @samp{.word} directives in difference tables. The @value{TARGET}
842 family does not have the addressing limitations that sometimes lead to this
843 alteration on other platforms.
846 @ifset DIFF-TBL-KLUGE
847 @cindex difference tables, warning
848 @cindex warning for altered difference tables
849 @code{@value{AS}} sometimes alters the code emitted for directives of the form
850 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
851 You can use the @samp{-K} option if you want a warning issued when this
856 @section Include Local Labels: @code{-L}
859 @cindex local labels, retaining in output
860 Labels beginning with @samp{L} (upper case only) are called @dfn{local
861 labels}. @xref{Symbol Names}. Normally you do not see such labels when
862 debugging, because they are intended for the use of programs (like
863 compilers) that compose assembler programs, not for your notice.
864 Normally both @code{@value{AS}} and @code{@value{LD}} discard such labels, so you do not
865 normally debug with them.
867 This option tells @code{@value{AS}} to retain those @samp{L@dots{}} symbols
868 in the object file. Usually if you do this you also tell the linker
869 @code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
871 By default, a local label is any label beginning with @samp{L}, but each
872 target is allowed to redefine the local label prefix.
874 On the HPPA local labels begin with @samp{L$}.
878 @section Name the Object File: @code{-o}
881 @cindex naming object file
882 @cindex object file name
883 There is always one object file output when you run @code{@value{AS}}. By
884 default it has the name
887 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
901 You use this option (which takes exactly one filename) to give the
902 object file a different name.
904 Whatever the object file is called, @code{@value{AS}} overwrites any
905 existing file of the same name.
908 @section Join Data and Text Sections: @code{-R}
911 @cindex data and text sections, joining
912 @cindex text and data sections, joining
913 @cindex joining text and data sections
914 @cindex merging text and data sections
915 @code{-R} tells @code{@value{AS}} to write the object file as if all
916 data-section data lives in the text section. This is only done at
917 the very last moment: your binary data are the same, but data
918 section parts are relocated differently. The data section part of
919 your object file is zero bytes long because all its bytes are
920 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
922 When you specify @code{-R} it would be possible to generate shorter
923 address displacements (because we do not have to cross between text and
924 data section). We refrain from doing this simply for compatibility with
925 older versions of @code{@value{AS}}. In future, @code{-R} may work this way.
928 When @code{@value{AS}} is configured for COFF output,
929 this option is only useful if you use sections named @samp{.text} and
934 @code{-R} is not supported for any of the HPPA targets. Using
935 @code{-R} generates a warning from @code{@value{AS}}.
939 @section Display Assembly Statistics: @code{--statistics}
942 @cindex statistics, about assembly
943 @cindex time, total for assembly
944 @cindex space used, maximum for assembly
945 Use @samp{--statistics} to display two statistics about the resources used by
946 @code{@value{AS}}: the maximum amount of space allocated during the assembly
947 (in bytes), and the total execution time taken for the assembly (in @sc{cpu}
951 @section Announce Version: @code{-v}
955 @cindex @code{@value{AS}} version
956 @cindex version of @code{@value{AS}}
957 You can find out what version of as is running by including the
958 option @samp{-v} (which you can also spell as @samp{-version}) on the
962 @section Suppress Warnings: @code{-W}
965 @cindex suppressing warnings
966 @cindex warnings, suppressing
967 @code{@value{AS}} should never give a warning or error message when
968 assembling compiler output. But programs written by people often
969 cause @code{@value{AS}} to give a warning that a particular assumption was
970 made. All such warnings are directed to the standard error file.
971 If you use this option, no warnings are issued. This option only
972 affects the warning messages: it does not change any particular of how
973 @code{@value{AS}} assembles your file. Errors, which stop the assembly, are
977 @section Generate Object File in Spite of Errors: @code{-Z}
978 @cindex object file, after errors
979 @cindex errors, continuing after
980 After an error message, @code{@value{AS}} normally produces no output. If for
981 some reason you are interested in object file output even after
982 @code{@value{AS}} gives an error message on your program, use the @samp{-Z}
983 option. If there are any errors, @code{@value{AS}} continues anyways, and
984 writes an object file after a final warning message of the form @samp{@var{n}
985 errors, @var{m} warnings, generating bad object file.}
990 @cindex machine-independent syntax
991 @cindex syntax, machine-independent
992 This chapter describes the machine-independent syntax allowed in a
993 source file. @code{@value{AS}} syntax is similar to what many other
994 assemblers use; it is inspired by the BSD 4.2
999 assembler, except that @code{@value{AS}} does not assemble Vax bit-fields.
1003 * Preprocessing:: Preprocessing
1004 * Whitespace:: Whitespace
1005 * Comments:: Comments
1006 * Symbol Intro:: Symbols
1007 * Statements:: Statements
1008 * Constants:: Constants
1012 @section Preprocessing
1014 @cindex preprocessing
1015 The @code{@value{AS}} internal preprocessor:
1017 @cindex whitespace, removed by preprocessor
1019 adjusts and removes extra whitespace. It leaves one space or tab before
1020 the keywords on a line, and turns any other whitespace on the line into
1023 @cindex comments, removed by preprocessor
1025 removes all comments, replacing them with a single space, or an
1026 appropriate number of newlines.
1028 @cindex constants, converted by preprocessor
1030 converts character constants into the appropriate numeric values.
1033 Note that it does not do macro processing, include file handling, or
1034 anything else you may get from your C compiler's preprocessor. You can
1035 do include file processing with the @code{.include} directive
1036 (@pxref{Include,,@code{.include}}). Other ``CPP'' style preprocessing
1037 can be done with the @sc{GNU} C compiler, by giving the input file a
1038 @samp{.S} suffix; see the compiler documentation for details.
1040 Excess whitespace, comments, and character constants
1041 cannot be used in the portions of the input text that are not
1044 @cindex turning preprocessing on and off
1045 @cindex preprocessing, turning on and off
1048 If the first line of an input file is @code{#NO_APP} or if you use the
1049 @samp{-f} option, whitespace and comments are not removed from the input file.
1050 Within an input file, you can ask for whitespace and comment removal in
1051 specific portions of the by putting a line that says @code{#APP} before the
1052 text that may contain whitespace or comments, and putting a line that says
1053 @code{#NO_APP} after this text. This feature is mainly intend to support
1054 @code{asm} statements in compilers whose output is otherwise free of comments
1061 @dfn{Whitespace} is one or more blanks or tabs, in any order.
1062 Whitespace is used to separate symbols, and to make programs neater for
1063 people to read. Unless within character constants
1064 (@pxref{Characters,,Character Constants}), any whitespace means the same
1065 as exactly one space.
1071 There are two ways of rendering comments to @code{@value{AS}}. In both
1072 cases the comment is equivalent to one space.
1074 Anything from @samp{/*} through the next @samp{*/} is a comment.
1075 This means you may not nest these comments.
1079 The only way to include a newline ('\n') in a comment
1080 is to use this sort of comment.
1083 /* This sort of comment does not nest. */
1086 @cindex line comment character
1087 Anything from the @dfn{line comment} character to the next newline
1088 is considered a comment and is ignored. The line comment character is
1090 @samp{#} on the Vax;
1093 @samp{#} on the i960;
1096 @samp{!} on the SPARC;
1099 @samp{|} on the 680x0;
1102 @samp{;} for the AMD 29K family;
1105 @samp{;} for the H8/300 family;
1108 @samp{!} for the H8/500 family;
1111 @samp{;} for the HPPA;
1114 @samp{!} for the Hitachi SH;
1117 @samp{!} for the Z8000;
1119 see @ref{Machine Dependencies}. @refill
1120 @c FIXME What about i386, m88k, i860?
1123 On some machines there are two different line comment characters. One
1124 character only begins a comment if it is the first non-whitespace character on
1125 a line, while the other always begins a comment.
1129 @cindex lines starting with @code{#}
1130 @cindex logical line numbers
1131 To be compatible with past assemblers, a special interpretation is given to
1132 lines that begin with @samp{#}. Following the @samp{#} should be an absolute
1133 expression (@pxref{Expressions}): the logical line number of the @emph{next}
1134 line. Then a string (@xref{Strings}.) is allowed: if present it is a new
1135 logical file name. The rest of the line, if any, should be whitespace.
1137 If the first non-whitespace characters on the line are not numeric,
1138 the line is ignored. (Just like a comment.)
1140 # This is an ordinary comment.
1141 # 42-6 "new_file_name" # New logical file name
1142 # This is logical line # 36.
1144 This feature is deprecated, and may disappear from future versions
1145 of @code{@value{AS}}.
1150 @cindex characters used in symbols
1151 @ifclear SPECIAL-SYMS
1152 A @dfn{symbol} is one or more characters chosen from the set of all
1153 letters (both upper and lower case), digits and the three characters
1159 A @dfn{symbol} is one or more characters chosen from the set of all
1160 letters (both upper and lower case), digits and the three characters
1161 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
1167 On most machines, you can also use @code{$} in symbol names; exceptions
1168 are noted in @ref{Machine Dependencies}.
1170 No symbol may begin with a digit. Case is significant.
1171 There is no length limit: all characters are significant. Symbols are
1172 delimited by characters not in that set, or by the beginning of a file
1173 (since the source program must end with a newline, the end of a file is
1174 not a possible symbol delimiter). @xref{Symbols}.
1175 @cindex length of symbols
1180 @cindex statements, structure of
1181 @cindex line separator character
1182 @cindex statement separator character
1184 @ifclear abnormal-separator
1185 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
1186 semicolon (@samp{;}). The newline or semicolon is considered part of
1187 the preceding statement. Newlines and semicolons within character
1188 constants are an exception: they do not end statements.
1190 @ifset abnormal-separator
1192 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
1193 sign (@samp{@@}). The newline or at sign is considered part of the
1194 preceding statement. Newlines and at signs within character constants
1195 are an exception: they do not end statements.
1198 A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
1199 point (@samp{!}). The newline or exclamation point is considered part of the
1200 preceding statement. Newlines and exclamation points within character
1201 constants are an exception: they do not end statements.
1204 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
1205 H8/300) a dollar sign (@samp{$}); or (for the
1208 (@samp{;}). The newline or separator character is considered part of
1209 the preceding statement. Newlines and separators within character
1210 constants are an exception: they do not end statements.
1215 A @dfn{statement} ends at a newline character (@samp{\n}) or line
1216 separator character. (The line separator is usually @samp{;}, unless
1217 this conflicts with the comment character; @pxref{Machine Dependencies}.) The
1218 newline or separator character is considered part of the preceding
1219 statement. Newlines and separators within character constants are an
1220 exception: they do not end statements.
1223 @cindex newline, required at file end
1224 @cindex EOF, newline must precede
1225 It is an error to end any statement with end-of-file: the last
1226 character of any input file should be a newline.@refill
1228 @cindex continuing statements
1229 @cindex multi-line statements
1230 @cindex statement on multiple lines
1231 You may write a statement on more than one line if you put a
1232 backslash (@kbd{\}) immediately in front of any newlines within the
1233 statement. When @code{@value{AS}} reads a backslashed newline both
1234 characters are ignored. You can even put backslashed newlines in
1235 the middle of symbol names without changing the meaning of your
1238 An empty statement is allowed, and may include whitespace. It is ignored.
1240 @cindex instructions and directives
1241 @cindex directives and instructions
1242 @c "key symbol" is not used elsewhere in the document; seems pedantic to
1243 @c @defn{} it in that case, as was done previously... pesch@cygnus.com,
1245 A statement begins with zero or more labels, optionally followed by a
1246 key symbol which determines what kind of statement it is. The key
1247 symbol determines the syntax of the rest of the statement. If the
1248 symbol begins with a dot @samp{.} then the statement is an assembler
1249 directive: typically valid for any computer. If the symbol begins with
1250 a letter the statement is an assembly language @dfn{instruction}: it
1251 assembles into a machine language instruction.
1253 Different versions of @code{@value{AS}} for different computers
1254 recognize different instructions. In fact, the same symbol may
1255 represent a different instruction in a different computer's assembly
1259 @cindex @code{:} (label)
1260 @cindex label (@code{:})
1261 A label is a symbol immediately followed by a colon (@code{:}).
1262 Whitespace before a label or after a colon is permitted, but you may not
1263 have whitespace between a label's symbol and its colon. @xref{Labels}.
1266 For HPPA targets, labels need not be immediately followed by a colon, but
1267 the definition of a label must begin in column zero. This also implies that
1268 only one label may be defined on each line.
1272 label: .directive followed by something
1273 another_label: # This is an empty statement.
1274 instruction operand_1, operand_2, @dots{}
1281 A constant is a number, written so that its value is known by
1282 inspection, without knowing any context. Like this:
1285 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
1286 .ascii "Ring the bell\7" # A string constant.
1287 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
1288 .float 0f-314159265358979323846264338327\
1289 95028841971.693993751E-40 # - pi, a flonum.
1294 * Characters:: Character Constants
1295 * Numbers:: Number Constants
1299 @subsection Character Constants
1301 @cindex character constants
1302 @cindex constants, character
1303 There are two kinds of character constants. A @dfn{character} stands
1304 for one character in one byte and its value may be used in
1305 numeric expressions. String constants (properly called string
1306 @emph{literals}) are potentially many bytes and their values may not be
1307 used in arithmetic expressions.
1311 * Chars:: Characters
1315 @subsubsection Strings
1317 @cindex string constants
1318 @cindex constants, string
1319 A @dfn{string} is written between double-quotes. It may contain
1320 double-quotes or null characters. The way to get special characters
1321 into a string is to @dfn{escape} these characters: precede them with
1322 a backslash @samp{\} character. For example @samp{\\} represents
1323 one backslash: the first @code{\} is an escape which tells
1324 @code{@value{AS}} to interpret the second character literally as a backslash
1325 (which prevents @code{@value{AS}} from recognizing the second @code{\} as an
1326 escape character). The complete list of escapes follows.
1328 @cindex escape codes, character
1329 @cindex character escape codes
1332 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
1335 @cindex @code{\b} (backspace character)
1336 @cindex backspace (@code{\b})
1337 Mnemonic for backspace; for ASCII this is octal code 010.
1340 @c Mnemonic for EOText; for ASCII this is octal code 004.
1343 @cindex @code{\f} (formfeed character)
1344 @cindex formfeed (@code{\f})
1345 Mnemonic for FormFeed; for ASCII this is octal code 014.
1348 @cindex @code{\n} (newline character)
1349 @cindex newline (@code{\n})
1350 Mnemonic for newline; for ASCII this is octal code 012.
1353 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
1356 @cindex @code{\r} (carriage return character)
1357 @cindex carriage return (@code{\r})
1358 Mnemonic for carriage-Return; for ASCII this is octal code 015.
1361 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
1362 @c other assemblers.
1365 @cindex @code{\t} (tab)
1366 @cindex tab (@code{\t})
1367 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
1370 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
1371 @c @item \x @var{digit} @var{digit} @var{digit}
1372 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
1374 @item \ @var{digit} @var{digit} @var{digit}
1375 @cindex @code{\@var{ddd}} (octal character code)
1376 @cindex octal character code (@code{\@var{ddd}})
1377 An octal character code. The numeric code is 3 octal digits.
1378 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
1379 for example, @code{\008} has the value 010, and @code{\009} the value 011.
1382 @item \@code{x} @var{hex-digit} @var{hex-digit}
1383 @cindex @code{\@var{xdd}} (hex character code)
1384 @cindex hex character code (@code{\@var{xdd}})
1385 A hex character code. The numeric code is 2 hexadecimal digits. Either
1386 upper or lower case @code{x} works.
1390 @cindex @code{\\} (@samp{\} character)
1391 @cindex backslash (@code{\\})
1392 Represents one @samp{\} character.
1395 @c Represents one @samp{'} (accent acute) character.
1396 @c This is needed in single character literals
1397 @c (@xref{Characters,,Character Constants}.) to represent
1401 @cindex @code{\"} (doublequote character)
1402 @cindex doublequote (@code{\"})
1403 Represents one @samp{"} character. Needed in strings to represent
1404 this character, because an unescaped @samp{"} would end the string.
1406 @item \ @var{anything-else}
1407 Any other character when escaped by @kbd{\} gives a warning, but
1408 assemble as if the @samp{\} was not present. The idea is that if
1409 you used an escape sequence you clearly didn't want the literal
1410 interpretation of the following character. However @code{@value{AS}} has no
1411 other interpretation, so @code{@value{AS}} knows it is giving you the wrong
1412 code and warns you of the fact.
1415 Which characters are escapable, and what those escapes represent,
1416 varies widely among assemblers. The current set is what we think
1417 the BSD 4.2 assembler recognizes, and is a subset of what most C
1418 compilers recognize. If you are in doubt, do not use an escape
1422 @subsubsection Characters
1424 @cindex single character constant
1425 @cindex character, single
1426 @cindex constant, single character
1427 A single character may be written as a single quote immediately
1428 followed by that character. The same escapes apply to characters as
1429 to strings. So if you want to write the character backslash, you
1430 must write @kbd{'\\} where the first @code{\} escapes the second
1431 @code{\}. As you can see, the quote is an acute accent, not a
1432 grave accent. A newline
1434 @ifclear abnormal-separator
1435 (or semicolon @samp{;})
1437 @ifset abnormal-separator
1439 (or at sign @samp{@@})
1442 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
1448 immediately following an acute accent is taken as a literal character
1449 and does not count as the end of a statement. The value of a character
1450 constant in a numeric expression is the machine's byte-wide code for
1451 that character. @code{@value{AS}} assumes your character code is ASCII:
1452 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
1455 @subsection Number Constants
1457 @cindex constants, number
1458 @cindex number constants
1459 @code{@value{AS}} distinguishes three kinds of numbers according to how they
1460 are stored in the target machine. @emph{Integers} are numbers that
1461 would fit into an @code{int} in the C language. @emph{Bignums} are
1462 integers, but they are stored in more than 32 bits. @emph{Flonums}
1463 are floating point numbers, described below.
1466 * Integers:: Integers
1471 * Bit Fields:: Bit Fields
1477 @subsubsection Integers
1479 @cindex constants, integer
1481 @cindex binary integers
1482 @cindex integers, binary
1483 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
1484 the binary digits @samp{01}.
1486 @cindex octal integers
1487 @cindex integers, octal
1488 An octal integer is @samp{0} followed by zero or more of the octal
1489 digits (@samp{01234567}).
1491 @cindex decimal integers
1492 @cindex integers, decimal
1493 A decimal integer starts with a non-zero digit followed by zero or
1494 more digits (@samp{0123456789}).
1496 @cindex hexadecimal integers
1497 @cindex integers, hexadecimal
1498 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1499 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
1501 Integers have the usual values. To denote a negative integer, use
1502 the prefix operator @samp{-} discussed under expressions
1503 (@pxref{Prefix Ops,,Prefix Operators}).
1506 @subsubsection Bignums
1509 @cindex constants, bignum
1510 A @dfn{bignum} has the same syntax and semantics as an integer
1511 except that the number (or its negative) takes more than 32 bits to
1512 represent in binary. The distinction is made because in some places
1513 integers are permitted while bignums are not.
1516 @subsubsection Flonums
1518 @cindex floating point numbers
1519 @cindex constants, floating point
1521 @cindex precision, floating point
1522 A @dfn{flonum} represents a floating point number. The translation is
1523 indirect: a decimal floating point number from the text is converted by
1524 @code{@value{AS}} to a generic binary floating point number of more than
1525 sufficient precision. This generic floating point number is converted
1526 to a particular computer's floating point format (or formats) by a
1527 portion of @code{@value{AS}} specialized to that computer.
1529 A flonum is written by writing (in order)
1534 (@samp{0} is optional on the HPPA.)
1538 A letter, to tell @code{@value{AS}} the rest of the number is a flonum.
1540 @kbd{e} is recommended. Case is not important.
1542 @c FIXME: verify if flonum syntax really this vague for most cases
1543 (Any otherwise illegal letter works here, but that might be changed. Vax BSD
1544 4.2 assembler seems to allow any of @samp{defghDEFGH}.)
1547 On the H8/300, H8/500,
1549 and AMD 29K architectures, the letter must be
1550 one of the letters @samp{DFPRSX} (in upper or lower case).
1552 On the Intel 960 architecture, the letter must be
1553 one of the letters @samp{DFT} (in upper or lower case).
1555 On the HPPA architecture, the letter must be @samp{E} (upper case only).
1559 One of the letters @samp{DFPRSX} (in upper or lower case).
1562 One of the letters @samp{DFPRSX} (in upper or lower case).
1565 One of the letters @samp{DFT} (in upper or lower case).
1568 The letter @samp{E} (upper case only).
1573 An optional sign: either @samp{+} or @samp{-}.
1576 An optional @dfn{integer part}: zero or more decimal digits.
1579 An optional @dfn{fractional part}: @samp{.} followed by zero
1580 or more decimal digits.
1583 An optional exponent, consisting of:
1587 An @samp{E} or @samp{e}.
1588 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1589 @c principle this can perfectly well be different on different targets.
1591 Optional sign: either @samp{+} or @samp{-}.
1593 One or more decimal digits.
1598 At least one of the integer part or the fractional part must be
1599 present. The floating point number has the usual base-10 value.
1601 @code{@value{AS}} does all processing using integers. Flonums are computed
1602 independently of any floating point hardware in the computer running
1607 @c Bit fields are written as a general facility but are also controlled
1608 @c by a conditional-compilation flag---which is as of now (21mar91)
1609 @c turned on only by the i960 config of GAS.
1611 @subsubsection Bit Fields
1614 @cindex constants, bit field
1615 You can also define numeric constants as @dfn{bit fields}.
1616 specify two numbers separated by a colon---
1618 @var{mask}:@var{value}
1621 @code{@value{AS}} applies a bitwise @sc{and} between @var{mask} and
1624 The resulting number is then packed
1626 @c this conditional paren in case bit fields turned on elsewhere than 960
1627 (in host-dependent byte order)
1629 into a field whose width depends on which assembler directive has the
1630 bit-field as its argument. Overflow (a result from the bitwise and
1631 requiring more binary digits to represent) is not an error; instead,
1632 more constants are generated, of the specified width, beginning with the
1633 least significant digits.@refill
1635 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1636 @code{.short}, and @code{.word} accept bit-field arguments.
1641 @chapter Sections and Relocation
1646 * Secs Background:: Background
1647 * Ld Sections:: @value{LD} Sections
1648 * As Sections:: @value{AS} Internal Sections
1649 * Sub-Sections:: Sub-Sections
1653 @node Secs Background
1656 Roughly, a section is a range of addresses, with no gaps; all data
1657 ``in'' those addresses is treated the same for some particular purpose.
1658 For example there may be a ``read only'' section.
1660 @cindex linker, and assembler
1661 @cindex assembler, and linker
1662 The linker @code{@value{LD}} reads many object files (partial programs) and
1663 combines their contents to form a runnable program. When @code{@value{AS}}
1664 emits an object file, the partial program is assumed to start at address 0.
1665 @code{@value{LD}} assigns the final addresses for the partial program, so that
1666 different partial programs do not overlap. This is actually an
1667 oversimplification, but it suffices to explain how @code{@value{AS}} uses
1670 @code{@value{LD}} moves blocks of bytes of your program to their run-time
1671 addresses. These blocks slide to their run-time addresses as rigid
1672 units; their length does not change and neither does the order of bytes
1673 within them. Such a rigid unit is called a @emph{section}. Assigning
1674 run-time addresses to sections is called @dfn{relocation}. It includes
1675 the task of adjusting mentions of object-file addresses so they refer to
1676 the proper run-time addresses.
1678 For the H8/300 and H8/500,
1679 and for the Hitachi SH,
1680 @code{@value{AS}} pads sections if needed to
1681 ensure they end on a word (sixteen bit) boundary.
1684 @cindex standard @code{@value{AS}} sections
1685 An object file written by @code{@value{AS}} has at least three sections, any
1686 of which may be empty. These are named @dfn{text}, @dfn{data} and
1691 When it generates COFF output,
1693 @code{@value{AS}} can also generate whatever other named sections you specify
1694 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1695 If you do not use any directives that place output in the @samp{.text}
1696 or @samp{.data} sections, these sections still exist, but are empty.
1701 When @code{@value{AS}} generates SOM or ELF output for the HPPA,
1703 @code{@value{AS}} can also generate whatever other named sections you
1704 specify using the @samp{.space} and @samp{.subspace} directives. See
1705 @cite{HP9000 Series 800 Assembly Language Reference Manual}
1706 (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
1707 assembler directives.
1710 Additionally, @code{@value{AS}} uses different names for the standard
1711 text, data, and bss sections when generating SOM output. Program text
1712 is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
1713 BSS into @samp{$BSS$}.
1717 Within the object file, the text section starts at address @code{0}, the
1718 data section follows, and the bss section follows the data section.
1721 When generating either SOM or ELF output files on the HPPA, the text
1722 section starts at address @code{0}, the data section at address
1723 @code{0x4000000}, and the bss section follows the data section.
1726 To let @code{@value{LD}} know which data changes when the sections are
1727 relocated, and how to change that data, @code{@value{AS}} also writes to the
1728 object file details of the relocation needed. To perform relocation
1729 @code{@value{LD}} must know, each time an address in the object
1733 Where in the object file is the beginning of this reference to
1736 How long (in bytes) is this reference?
1738 Which section does the address refer to? What is the numeric value of
1740 (@var{address}) @minus{} (@var{start-address of section})?
1743 Is the reference to an address ``Program-Counter relative''?
1746 @cindex addresses, format of
1747 @cindex section-relative addressing
1748 In fact, every address @code{@value{AS}} ever uses is expressed as
1750 (@var{section}) + (@var{offset into section})
1753 Further, every expression @code{@value{AS}} computes is of this section-relative
1754 nature. @dfn{Absolute expression} means an expression with section
1755 ``absolute'' (@pxref{Ld Sections}). A @dfn{pass1 expression} means
1756 an expression with section ``pass1'' (@pxref{As Sections,,@value{AS}
1757 Internal Sections}). In this manual we use the notation @{@var{secname}
1758 @var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1760 Apart from text, data and bss sections you need to know about the
1761 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
1762 addresses in the absolute section remain unchanged. For example, address
1763 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by
1764 @code{@value{LD}}. Although the linker never arranges two partial programs'
1765 data sections with overlapping addresses after linking, @emph{by definition}
1766 their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one
1767 part of a program is always the same address when the program is running as
1768 address @code{@{absolute@ 239@}} in any other part of the program.
1770 The idea of sections is extended to the @dfn{undefined} section. Any
1771 address whose section is unknown at assembly time is by definition
1772 rendered @{undefined @var{U}@}---where @var{U} is filled in later.
1773 Since numbers are always defined, the only way to generate an undefined
1774 address is to mention an undefined symbol. A reference to a named
1775 common block would be such a symbol: its value is unknown at assembly
1776 time so it has section @emph{undefined}.
1778 By analogy the word @emph{section} is used to describe groups of sections in
1779 the linked program. @code{@value{LD}} puts all partial programs' text
1780 sections in contiguous addresses in the linked program. It is
1781 customary to refer to the @emph{text section} of a program, meaning all
1782 the addresses of all partial programs' text sections. Likewise for
1783 data and bss sections.
1785 Some sections are manipulated by @code{@value{LD}}; others are invented for
1786 use of @code{@value{AS}} and have no meaning except during assembly.
1789 @section @value{LD} Sections
1790 @code{@value{LD}} deals with just four kinds of sections, summarized below.
1795 @cindex named sections
1796 @cindex sections, named
1797 @item named sections
1800 @cindex text section
1801 @cindex data section
1805 These sections hold your program. @code{@value{AS}} and @code{@value{LD}} treat them as
1806 separate but equal sections. Anything you can say of one section is
1809 When the program is running, however, it is
1810 customary for the text section to be unalterable. The
1811 text section is often shared among processes: it contains
1812 instructions, constants and the like. The data section of a running
1813 program is usually alterable: for example, C variables would be stored
1814 in the data section.
1819 This section contains zeroed bytes when your program begins running. It
1820 is used to hold unitialized variables or common storage. The length of
1821 each partial program's bss section is important, but because it starts
1822 out containing zeroed bytes there is no need to store explicit zero
1823 bytes in the object file. The bss section was invented to eliminate
1824 those explicit zeros from object files.
1826 @cindex absolute section
1827 @item absolute section
1828 Address 0 of this section is always ``relocated'' to runtime address 0.
1829 This is useful if you want to refer to an address that @code{@value{LD}} must
1830 not change when relocating. In this sense we speak of absolute
1831 addresses being ``unrelocatable'': they do not change during relocation.
1833 @cindex undefined section
1834 @item undefined section
1835 This ``section'' is a catch-all for address references to objects not in
1836 the preceding sections.
1837 @c FIXME: ref to some other doc on obj-file formats could go here.
1840 @cindex relocation example
1841 An idealized example of three relocatable sections follows.
1843 The example uses the traditional section names @samp{.text} and @samp{.data}.
1845 Memory addresses are on the horizontal axis.
1849 @c END TEXI2ROFF-KILL
1852 partial program # 1: |ttttt|dddd|00|
1859 partial program # 2: |TTT|DDD|000|
1862 +--+---+-----+--+----+---+-----+~~
1863 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1864 +--+---+-----+--+----+---+-----+~~
1866 addresses: 0 @dots{}
1870 @c FIXME make sure no page breaks inside figure!!
1873 \line{\it Partial program \#1: \hfil}
1874 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1875 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1877 \line{\it Partial program \#2: \hfil}
1878 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1879 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
1881 \line{\it linked program: \hfil}
1882 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
1883 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
1884 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1885 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1887 \line{\it addresses: \hfil}
1891 @c END TEXI2ROFF-KILL
1894 @section @value{AS} Internal Sections
1896 @cindex internal @code{@value{AS}} sections
1897 @cindex sections in messages, internal
1898 These sections are meant only for the internal use of @code{@value{AS}}. They
1899 have no meaning at run-time. You do not really need to know about these
1900 sections for most purposes; but they can be mentioned in @code{@value{AS}}
1901 warning messages, so it might be helpful to have an idea of their
1902 meanings to @code{@value{AS}}. These sections are used to permit the
1903 value of every expression in your assembly language program to be a
1904 section-relative address.
1907 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1908 @cindex assembler internal logic error
1909 An internal assembler logic error has been found. This means there is a
1910 bug in the assembler.
1913 @cindex expr (internal section)
1914 The assembler stores complex expression internally as combinations of
1915 symbols. When it needs to represent an expression as a symbol, it puts
1916 it in the expr section.
1918 @c FIXME item transfer[t] vector preload
1919 @c FIXME item transfer[t] vector postload
1920 @c FIXME item register
1924 @section Sub-Sections
1926 @cindex numbered subsections
1927 @cindex grouping data
1933 fall into two sections: text and data.
1935 You may have separate groups of
1937 data in named sections
1941 data in named sections
1947 that you want to end up near to each other in the object file, even though they
1948 are not contiguous in the assembler source. @code{@value{AS}} allows you to
1949 use @dfn{subsections} for this purpose. Within each section, there can be
1950 numbered subsections with values from 0 to 8192. Objects assembled into the
1951 same subsection go into the object file together with other objects in the same
1952 subsection. For example, a compiler might want to store constants in the text
1953 section, but might not want to have them interspersed with the program being
1954 assembled. In this case, the compiler could issue a @samp{.text 0} before each
1955 section of code being output, and a @samp{.text 1} before each group of
1956 constants being output.
1958 Subsections are optional. If you do not use subsections, everything
1959 goes in subsection number zero.
1962 Each subsection is zero-padded up to a multiple of four bytes.
1963 (Subsections may be padded a different amount on different flavors
1964 of @code{@value{AS}}.)
1968 On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
1969 boundary (two bytes).
1970 The same is true on the Hitachi SH.
1973 @c FIXME section padding (alignment)?
1974 @c Rich Pixley says padding here depends on target obj code format; that
1975 @c doesn't seem particularly useful to say without further elaboration,
1976 @c so for now I say nothing about it. If this is a generic BFD issue,
1977 @c these paragraphs might need to vanish from this manual, and be
1978 @c discussed in BFD chapter of binutils (or some such).
1981 On the AMD 29K family, no particular padding is added to section or
1982 subsection sizes; @value{AS} forces no alignment on this platform.
1986 Subsections appear in your object file in numeric order, lowest numbered
1987 to highest. (All this to be compatible with other people's assemblers.)
1988 The object file contains no representation of subsections; @code{@value{LD}} and
1989 other programs that manipulate object files see no trace of them.
1990 They just see all your text subsections as a text section, and all your
1991 data subsections as a data section.
1993 To specify which subsection you want subsequent statements assembled
1994 into, use a numeric argument to specify it, in a @samp{.text
1995 @var{expression}} or a @samp{.data @var{expression}} statement.
1998 When generating COFF output, you
2003 can also use an extra subsection
2004 argument with arbitrary named sections: @samp{.section @var{name},
2007 @var{Expression} should be an absolute expression.
2008 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
2009 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
2010 begins in @code{text 0}. For instance:
2012 .text 0 # The default subsection is text 0 anyway.
2013 .ascii "This lives in the first text subsection. *"
2015 .ascii "But this lives in the second text subsection."
2017 .ascii "This lives in the data section,"
2018 .ascii "in the first data subsection."
2020 .ascii "This lives in the first text section,"
2021 .ascii "immediately following the asterisk (*)."
2024 Each section has a @dfn{location counter} incremented by one for every byte
2025 assembled into that section. Because subsections are merely a convenience
2026 restricted to @code{@value{AS}} there is no concept of a subsection location
2027 counter. There is no way to directly manipulate a location counter---but the
2028 @code{.align} directive changes it, and any label definition captures its
2029 current value. The location counter of the section where statements are being
2030 assembled is said to be the @dfn{active} location counter.
2033 @section bss Section
2036 @cindex common variable storage
2037 The bss section is used for local common variable storage.
2038 You may allocate address space in the bss section, but you may
2039 not dictate data to load into it before your program executes. When
2040 your program starts running, all the contents of the bss
2041 section are zeroed bytes.
2043 Addresses in the bss section are allocated with special directives; you
2044 may not assemble anything directly into the bss section. Hence there
2045 are no bss subsections. @xref{Comm,,@code{.comm}},
2046 @pxref{Lcomm,,@code{.lcomm}}.
2052 Symbols are a central concept: the programmer uses symbols to name
2053 things, the linker uses symbols to link, and the debugger uses symbols
2057 @cindex debuggers, and symbol order
2058 @emph{Warning:} @code{@value{AS}} does not place symbols in the object file in
2059 the same order they were declared. This may break some debuggers.
2064 * Setting Symbols:: Giving Symbols Other Values
2065 * Symbol Names:: Symbol Names
2066 * Dot:: The Special Dot Symbol
2067 * Symbol Attributes:: Symbol Attributes
2074 A @dfn{label} is written as a symbol immediately followed by a colon
2075 @samp{:}. The symbol then represents the current value of the
2076 active location counter, and is, for example, a suitable instruction
2077 operand. You are warned if you use the same symbol to represent two
2078 different locations: the first definition overrides any other
2082 On the HPPA, the usual form for a label need not be immediately followed by a
2083 colon, but instead must start in column zero. Only one label may be defined on
2084 a single line. To work around this, the HPPA version of @code{@value{AS}} also
2085 provides a special directive @code{.label} for defining labels more flexibly.
2088 @node Setting Symbols
2089 @section Giving Symbols Other Values
2091 @cindex assigning values to symbols
2092 @cindex symbol values, assigning
2093 A symbol can be given an arbitrary value by writing a symbol, followed
2094 by an equals sign @samp{=}, followed by an expression
2095 (@pxref{Expressions}). This is equivalent to using the @code{.set}
2096 directive. @xref{Set,,@code{.set}}.
2099 @section Symbol Names
2101 @cindex symbol names
2102 @cindex names, symbol
2103 @ifclear SPECIAL-SYMS
2104 Symbol names begin with a letter or with one of @samp{._}. On most
2105 machines, you can also use @code{$} in symbol names; exceptions are
2106 noted in @ref{Machine Dependencies}. That character may be followed by any
2107 string of digits, letters, dollar signs (unless otherwise noted in
2108 @ref{Machine Dependencies}), and underscores.
2111 For the AMD 29K family, @samp{?} is also allowed in the
2112 body of a symbol name, though not at its beginning.
2117 Symbol names begin with a letter or with one of @samp{._}. On the
2119 H8/500, you can also use @code{$} in symbol names. That character may
2120 be followed by any string of digits, letters, dollar signs (save on the
2121 H8/300), and underscores.
2125 Case of letters is significant: @code{foo} is a different symbol name
2128 Each symbol has exactly one name. Each name in an assembly language program
2129 refers to exactly one symbol. You may use that symbol name any number of times
2132 @subheading Local Symbol Names
2134 @cindex local symbol names
2135 @cindex symbol names, local
2136 @cindex temporary symbol names
2137 @cindex symbol names, temporary
2138 Local symbols help compilers and programmers use names temporarily.
2139 There are ten local symbol names, which are re-used throughout the
2140 program. You may refer to them using the names @samp{0} @samp{1}
2141 @dots{} @samp{9}. To define a local symbol, write a label of the form
2142 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
2143 recent previous definition of that symbol write @samp{@b{N}b}, using the
2144 same digit as when you defined the label. To refer to the next
2145 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
2146 a choice of 10 forward references. The @samp{b} stands for
2147 ``backwards'' and the @samp{f} stands for ``forwards''.
2149 Local symbols are not emitted by the current GNU C compiler.
2151 There is no restriction on how you can use these labels, but
2152 remember that at any point in the assembly you can refer to at most
2153 10 prior local labels and to at most 10 forward local labels.
2155 Local symbol names are only a notation device. They are immediately
2156 transformed into more conventional symbol names before the assembler
2157 uses them. The symbol names stored in the symbol table, appearing in
2158 error messages and optionally emitted to the object file have these
2163 All local labels begin with @samp{L}. Normally both @code{@value{AS}} and
2164 @code{@value{LD}} forget symbols that start with @samp{L}. These labels are
2165 used for symbols you are never intended to see. If you use the
2166 @samp{-L} option then @code{@value{AS}} retains these symbols in the
2167 object file. If you also instruct @code{@value{LD}} to retain these symbols,
2168 you may use them in debugging.
2171 If the label is written @samp{0:} then the digit is @samp{0}.
2172 If the label is written @samp{1:} then the digit is @samp{1}.
2173 And so on up through @samp{9:}.
2176 This unusual character is included so you do not accidentally invent
2177 a symbol of the same name. The character has ASCII value
2180 @item @emph{ordinal number}
2181 This is a serial number to keep the labels distinct. The first
2182 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
2183 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
2187 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
2188 @code{3:} is named @code{L3@ctrl{A}44}.
2191 @section The Special Dot Symbol
2193 @cindex dot (symbol)
2194 @cindex @code{.} (symbol)
2195 @cindex current address
2196 @cindex location counter
2197 The special symbol @samp{.} refers to the current address that
2198 @code{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
2199 .long .} defines @code{melvin} to contain its own address.
2200 Assigning a value to @code{.} is treated the same as a @code{.org}
2201 directive. Thus, the expression @samp{.=.+4} is the same as saying
2202 @ifclear no-space-dir
2211 @node Symbol Attributes
2212 @section Symbol Attributes
2214 @cindex symbol attributes
2215 @cindex attributes, symbol
2216 Every symbol has, as well as its name, the attributes ``Value'' and
2217 ``Type''. Depending on output format, symbols can also have auxiliary
2220 The detailed definitions are in @file{a.out.h}.
2223 If you use a symbol without defining it, @code{@value{AS}} assumes zero for
2224 all these attributes, and probably won't warn you. This makes the
2225 symbol an externally defined symbol, which is generally what you
2229 * Symbol Value:: Value
2230 * Symbol Type:: Type
2233 * a.out Symbols:: Symbol Attributes: @code{a.out}
2237 * a.out Symbols:: Symbol Attributes: @code{a.out}
2240 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
2245 * COFF Symbols:: Symbol Attributes for COFF
2248 * SOM Symbols:: Symbol Attributes for SOM
2255 @cindex value of a symbol
2256 @cindex symbol value
2257 The value of a symbol is (usually) 32 bits. For a symbol which labels a
2258 location in the text, data, bss or absolute sections the value is the
2259 number of addresses from the start of that section to the label.
2260 Naturally for text, data and bss sections the value of a symbol changes
2261 as @code{@value{LD}} changes section base addresses during linking. Absolute
2262 symbols' values do not change during linking: that is why they are
2265 The value of an undefined symbol is treated in a special way. If it is
2266 0 then the symbol is not defined in this assembler source file, and
2267 @code{@value{LD}} tries to determine its value from other files linked into the
2268 same program. You make this kind of symbol simply by mentioning a symbol
2269 name without defining it. A non-zero value represents a @code{.comm}
2270 common declaration. The value is how much common storage to reserve, in
2271 bytes (addresses). The symbol refers to the first address of the
2277 @cindex type of a symbol
2279 The type attribute of a symbol contains relocation (section)
2280 information, any flag settings indicating that a symbol is external, and
2281 (optionally), other information for linkers and debuggers. The exact
2282 format depends on the object-code output format in use.
2287 @c The following avoids a "widow" subsection title. @group would be
2288 @c better if it were available outside examples.
2291 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
2293 @cindex @code{b.out} symbol attributes
2294 @cindex symbol attributes, @code{b.out}
2295 These symbol attributes appear only when @code{@value{AS}} is configured for
2296 one of the Berkeley-descended object output formats---@code{a.out} or
2302 @subsection Symbol Attributes: @code{a.out}
2304 @cindex @code{a.out} symbol attributes
2305 @cindex symbol attributes, @code{a.out}
2311 @subsection Symbol Attributes: @code{a.out}
2313 @cindex @code{a.out} symbol attributes
2314 @cindex symbol attributes, @code{a.out}
2318 * Symbol Desc:: Descriptor
2319 * Symbol Other:: Other
2323 @subsubsection Descriptor
2325 @cindex descriptor, of @code{a.out} symbol
2326 This is an arbitrary 16-bit value. You may establish a symbol's
2327 descriptor value by using a @code{.desc} statement
2328 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
2332 @subsubsection Other
2334 @cindex other attribute, of @code{a.out} symbol
2335 This is an arbitrary 8-bit value. It means nothing to @code{@value{AS}}.
2340 @subsection Symbol Attributes for COFF
2342 @cindex COFF symbol attributes
2343 @cindex symbol attributes, COFF
2345 The COFF format supports a multitude of auxiliary symbol attributes;
2346 like the primary symbol attributes, they are set between @code{.def} and
2347 @code{.endef} directives.
2349 @subsubsection Primary Attributes
2351 @cindex primary attributes, COFF symbols
2352 The symbol name is set with @code{.def}; the value and type,
2353 respectively, with @code{.val} and @code{.type}.
2355 @subsubsection Auxiliary Attributes
2357 @cindex auxiliary attributes, COFF symbols
2358 The @code{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
2359 @code{.size}, and @code{.tag} can generate auxiliary symbol table
2360 information for COFF.
2365 @subsection Symbol Attributes for SOM
2367 @cindex SOM symbol attributes
2368 @cindex symbol attributes, SOM
2370 The SOM format for the HPPA supports a multitude of symbol attributes set with
2371 the @code{.EXPORT} and @code{.IMPORT} directives.
2373 The attributes are described in @cite{HP9000 Series 800 Assembly
2374 Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
2375 @code{EXPORT} assembler directive documentation.
2379 @chapter Expressions
2383 @cindex numeric values
2384 An @dfn{expression} specifies an address or numeric value.
2385 Whitespace may precede and/or follow an expression.
2388 * Empty Exprs:: Empty Expressions
2389 * Integer Exprs:: Integer Expressions
2393 @section Empty Expressions
2395 @cindex empty expressions
2396 @cindex expressions, empty
2397 An empty expression has no value: it is just whitespace or null.
2398 Wherever an absolute expression is required, you may omit the
2399 expression, and @code{@value{AS}} assumes a value of (absolute) 0. This
2400 is compatible with other assemblers.
2403 @section Integer Expressions
2405 @cindex integer expressions
2406 @cindex expressions, integer
2407 An @dfn{integer expression} is one or more @emph{arguments} delimited
2408 by @emph{operators}.
2411 * Arguments:: Arguments
2412 * Operators:: Operators
2413 * Prefix Ops:: Prefix Operators
2414 * Infix Ops:: Infix Operators
2418 @subsection Arguments
2420 @cindex expression arguments
2421 @cindex arguments in expressions
2422 @cindex operands in expressions
2423 @cindex arithmetic operands
2424 @dfn{Arguments} are symbols, numbers or subexpressions. In other
2425 contexts arguments are sometimes called ``arithmetic operands''. In
2426 this manual, to avoid confusing them with the ``instruction operands'' of
2427 the machine language, we use the term ``argument'' to refer to parts of
2428 expressions only, reserving the word ``operand'' to refer only to machine
2429 instruction operands.
2431 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
2432 @var{section} is one of text, data, bss, absolute,
2433 or undefined. @var{NNN} is a signed, 2's complement 32 bit
2436 Numbers are usually integers.
2438 A number can be a flonum or bignum. In this case, you are warned
2439 that only the low order 32 bits are used, and @code{@value{AS}} pretends
2440 these 32 bits are an integer. You may write integer-manipulating
2441 instructions that act on exotic constants, compatible with other
2444 @cindex subexpressions
2445 Subexpressions are a left parenthesis @samp{(} followed by an integer
2446 expression, followed by a right parenthesis @samp{)}; or a prefix
2447 operator followed by an argument.
2450 @subsection Operators
2452 @cindex operators, in expressions
2453 @cindex arithmetic functions
2454 @cindex functions, in expressions
2455 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
2456 operators are followed by an argument. Infix operators appear
2457 between their arguments. Operators may be preceded and/or followed by
2461 @subsection Prefix Operator
2463 @cindex prefix operators
2464 @code{@value{AS}} has the following @dfn{prefix operators}. They each take
2465 one argument, which must be absolute.
2467 @c the tex/end tex stuff surrounding this small table is meant to make
2468 @c it align, on the printed page, with the similar table in the next
2469 @c section (which is inside an enumerate).
2471 \global\advance\leftskip by \itemindent
2476 @dfn{Negation}. Two's complement negation.
2478 @dfn{Complementation}. Bitwise not.
2482 \global\advance\leftskip by -\itemindent
2486 @subsection Infix Operators
2488 @cindex infix operators
2489 @cindex operators, permitted arguments
2490 @dfn{Infix operators} take two arguments, one on either side. Operators
2491 have precedence, but operations with equal precedence are performed left
2492 to right. Apart from @code{+} or @code{-}, both arguments must be
2493 absolute, and the result is absolute.
2496 @cindex operator precedence
2497 @cindex precedence of operators
2504 @dfn{Multiplication}.
2507 @dfn{Division}. Truncation is the same as the C operator @samp{/}
2514 @dfn{Shift Left}. Same as the C operator @samp{<<}.
2518 @dfn{Shift Right}. Same as the C operator @samp{>>}.
2522 Intermediate precedence
2527 @dfn{Bitwise Inclusive Or}.
2533 @dfn{Bitwise Exclusive Or}.
2536 @dfn{Bitwise Or Not}.
2544 @cindex addition, permitted arguments
2545 @cindex plus, permitted arguments
2546 @cindex arguments for addition
2547 @dfn{Addition}. If either argument is absolute, the result
2548 has the section of the other argument.
2549 If either argument is pass1 or undefined, the result is pass1.
2550 Otherwise @code{+} is illegal.
2553 @cindex subtraction, permitted arguments
2554 @cindex minus, permitted arguments
2555 @cindex arguments for subtraction
2556 @dfn{Subtraction}. If the right argument is absolute, the
2557 result has the section of the left argument.
2558 If either argument is pass1 the result is pass1.
2559 If either argument is undefined the result is difference section.
2560 If both arguments are in the same section, the result is absolute---provided
2561 that section is one of text, data or bss.
2562 Otherwise subtraction is illegal.
2566 The sense of the rule for addition is that it's only meaningful to add
2567 the @emph{offsets} in an address; you can only have a defined section in
2568 one of the two arguments.
2570 Similarly, you can't subtract quantities from two different sections.
2573 @chapter Assembler Directives
2575 @cindex directives, machine independent
2576 @cindex pseudo-ops, machine independent
2577 @cindex machine independent directives
2578 All assembler directives have names that begin with a period (@samp{.}).
2579 The rest of the name is letters, usually in lower case.
2581 This chapter discusses directives that are available regardless of the
2582 target machine configuration for the GNU assembler.
2584 Some machine configurations provide additional directives.
2585 @xref{Machine Dependencies}.
2588 @ifset machine-directives
2589 @xref{Machine Dependencies} for additional directives.
2594 * Abort:: @code{.abort}
2596 * ABORT:: @code{.ABORT}
2599 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
2600 * App-File:: @code{.app-file @var{string}}
2601 * Ascii:: @code{.ascii "@var{string}"}@dots{}
2602 * Asciz:: @code{.asciz "@var{string}"}@dots{}
2603 * Byte:: @code{.byte @var{expressions}}
2604 * Comm:: @code{.comm @var{symbol} , @var{length} }
2605 * Data:: @code{.data @var{subsection}}
2607 * Def:: @code{.def @var{name}}
2610 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
2616 * Double:: @code{.double @var{flonums}}
2617 * Eject:: @code{.eject}
2618 * Else:: @code{.else}
2620 * Endef:: @code{.endef}
2623 * Endif:: @code{.endif}
2624 * Equ:: @code{.equ @var{symbol}, @var{expression}}
2625 * Extern:: @code{.extern}
2626 @ifclear no-file-dir
2627 * File:: @code{.file @var{string}}
2630 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
2631 * Float:: @code{.float @var{flonums}}
2632 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2633 * hword:: @code{.hword @var{expressions}}
2634 * Ident:: @code{.ident}
2635 * If:: @code{.if @var{absolute expression}}
2636 * Include:: @code{.include "@var{file}"}
2637 * Int:: @code{.int @var{expressions}}
2638 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
2639 * Lflags:: @code{.lflags}
2640 @ifclear no-line-dir
2641 * Line:: @code{.line @var{line-number}}
2644 * Ln:: @code{.ln @var{line-number}}
2645 * List:: @code{.list}
2646 * Long:: @code{.long @var{expressions}}
2648 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
2651 * Nolist:: @code{.nolist}
2652 * Octa:: @code{.octa @var{bignums}}
2653 * Org:: @code{.org @var{new-lc} , @var{fill}}
2654 * Psize:: @code{.psize @var{lines}, @var{columns}}
2655 * Quad:: @code{.quad @var{bignums}}
2656 * Sbttl:: @code{.sbttl "@var{subheading}"}
2658 * Scl:: @code{.scl @var{class}}
2661 * Section:: @code{.section @var{name}, @var{subsection}}
2664 * Set:: @code{.set @var{symbol}, @var{expression}}
2665 * Short:: @code{.short @var{expressions}}
2666 * Single:: @code{.single @var{flonums}}
2668 * Size:: @code{.size}
2671 * Space:: @code{.space @var{size} , @var{fill}}
2673 * Stab:: @code{.stabd, .stabn, .stabs}
2676 * String:: @code{.string "@var{str}"}
2678 * Tag:: @code{.tag @var{structname}}
2681 * Text:: @code{.text @var{subsection}}
2682 * Title:: @code{.title "@var{heading}"}
2684 * Type:: @code{.type @var{int}}
2685 * Val:: @code{.val @var{addr}}
2688 * Word:: @code{.word @var{expressions}}
2689 * Deprecated:: Deprecated Directives
2693 @section @code{.abort}
2695 @cindex @code{abort} directive
2696 @cindex stopping the assembly
2697 This directive stops the assembly immediately. It is for
2698 compatibility with other assemblers. The original idea was that the
2699 assembly language source would be piped into the assembler. If the sender
2700 of the source quit, it could use this directive tells @code{@value{AS}} to
2701 quit also. One day @code{.abort} will not be supported.
2705 @section @code{.ABORT}
2707 @cindex @code{ABORT} directive
2708 When producing COFF output, @code{@value{AS}} accepts this directive as a
2709 synonym for @samp{.abort}.
2712 When producing @code{b.out} output, @code{@value{AS}} accepts this directive,
2718 @section @code{.align @var{abs-expr} , @var{abs-expr}}
2720 @cindex padding the location counter
2721 @cindex @code{align} directive
2722 Pad the location counter (in the current subsection) to a particular
2723 storage boundary. The first expression (which must be absolute) is the
2724 number of low-order zero bits the location counter must have after
2725 advancement. For example @samp{.align 3} advances the location
2726 counter until it a multiple of 8. If the location counter is already a
2727 multiple of 8, no change is needed.
2730 For the HPPA, the first expression (which must be absolute) is the
2731 alignment request in bytes. For example @samp{.align 8} advances
2732 the location counter until it is a multiple of 8. If the location counter
2733 is already a multiple of 8, no change is needed.
2736 The second expression (also absolute) gives the value to be stored in
2737 the padding bytes. It (and the comma) may be omitted. If it is
2738 omitted, the padding bytes are zero.
2741 @section @code{.app-file @var{string}}
2743 @cindex logical file name
2744 @cindex file name, logical
2745 @cindex @code{app-file} directive
2747 @ifclear no-file-dir
2748 (which may also be spelled @samp{.file})
2750 tells @code{@value{AS}} that we are about to start a new
2751 logical file. @var{string} is the new file name. In general, the
2752 filename is recognized whether or not it is surrounded by quotes @samp{"};
2753 but if you wish to specify an empty file name is permitted,
2754 you must give the quotes--@code{""}. This statement may go away in
2755 future: it is only recognized to be compatible with old @code{@value{AS}}
2759 @section @code{.ascii "@var{string}"}@dots{}
2761 @cindex @code{ascii} directive
2762 @cindex string literals
2763 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2764 separated by commas. It assembles each string (with no automatic
2765 trailing zero byte) into consecutive addresses.
2768 @section @code{.asciz "@var{string}"}@dots{}
2770 @cindex @code{asciz} directive
2771 @cindex zero-terminated strings
2772 @cindex null-terminated strings
2773 @code{.asciz} is just like @code{.ascii}, but each string is followed by
2774 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2777 @section @code{.byte @var{expressions}}
2779 @cindex @code{byte} directive
2780 @cindex integers, one byte
2781 @code{.byte} expects zero or more expressions, separated by commas.
2782 Each expression is assembled into the next byte.
2785 @section @code{.comm @var{symbol} , @var{length} }
2787 @cindex @code{comm} directive
2788 @cindex symbol, common
2789 @code{.comm} declares a named common area in the bss section. Normally
2790 @code{@value{LD}} reserves memory addresses for it during linking, so no partial
2791 program defines the location of the symbol. Use @code{.comm} to tell
2792 @code{@value{LD}} that it must be at least @var{length} bytes long. @code{@value{LD}}
2793 allocates space for each @code{.comm} symbol that is at least as
2794 long as the longest @code{.comm} request in any of the partial programs
2795 linked. @var{length} is an absolute expression.
2798 The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
2799 @samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
2803 @section @code{.data @var{subsection}}
2805 @cindex @code{data} directive
2806 @code{.data} tells @code{@value{AS}} to assemble the following statements onto the
2807 end of the data subsection numbered @var{subsection} (which is an
2808 absolute expression). If @var{subsection} is omitted, it defaults
2813 @section @code{.def @var{name}}
2815 @cindex @code{def} directive
2816 @cindex COFF symbols, debugging
2817 @cindex debugging COFF symbols
2818 Begin defining debugging information for a symbol @var{name}; the
2819 definition extends until the @code{.endef} directive is encountered.
2822 This directive is only observed when @code{@value{AS}} is configured for COFF
2823 format output; when producing @code{b.out}, @samp{.def} is recognized,
2830 @section @code{.desc @var{symbol}, @var{abs-expression}}
2832 @cindex @code{desc} directive
2833 @cindex COFF symbol descriptor
2834 @cindex symbol descriptor, COFF
2835 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2836 to the low 16 bits of an absolute expression.
2839 The @samp{.desc} directive is not available when @code{@value{AS}} is
2840 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2841 object format. For the sake of compatibility, @code{@value{AS}} accepts
2842 it, but produces no output, when configured for COFF.
2848 @section @code{.dim}
2850 @cindex @code{dim} directive
2851 @cindex COFF auxiliary symbol information
2852 @cindex auxiliary symbol information, COFF
2853 This directive is generated by compilers to include auxiliary debugging
2854 information in the symbol table. It is only permitted inside
2855 @code{.def}/@code{.endef} pairs.
2858 @samp{.dim} is only meaningful when generating COFF format output; when
2859 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
2865 @section @code{.double @var{flonums}}
2867 @cindex @code{double} directive
2868 @cindex floating point numbers (double)
2869 @code{.double} expects zero or more flonums, separated by commas. It
2870 assembles floating point numbers.
2872 The exact kind of floating point numbers emitted depends on how
2873 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
2877 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
2878 in @sc{ieee} format.
2883 @section @code{.eject}
2885 @cindex @code{eject} directive
2886 @cindex new page, in listings
2887 @cindex page, in listings
2888 @cindex listing control: new page
2889 Force a page break at this point, when generating assembly listings.
2892 @section @code{.else}
2894 @cindex @code{else} directive
2895 @code{.else} is part of the @code{@value{AS}} support for conditional
2896 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2897 of code to be assembled if the condition for the preceding @code{.if}
2901 @node End, Endef, Else, Pseudo Ops
2902 @section @code{.end}
2904 @cindex @code{end} directive
2905 This doesn't do anything---but isn't an s_ignore, so I suspect it's
2906 meant to do something eventually (which is why it isn't documented here
2907 as "for compatibility with blah").
2912 @section @code{.endef}
2914 @cindex @code{endef} directive
2915 This directive flags the end of a symbol definition begun with
2919 @samp{.endef} is only meaningful when generating COFF format output; if
2920 @code{@value{AS}} is configured to generate @code{b.out}, it accepts this
2921 directive but ignores it.
2926 @section @code{.endif}
2928 @cindex @code{endif} directive
2929 @code{.endif} is part of the @code{@value{AS}} support for conditional assembly;
2930 it marks the end of a block of code that is only assembled
2931 conditionally. @xref{If,,@code{.if}}.
2934 @section @code{.equ @var{symbol}, @var{expression}}
2936 @cindex @code{equ} directive
2937 @cindex assigning values to symbols
2938 @cindex symbols, assigning values to
2939 This directive sets the value of @var{symbol} to @var{expression}.
2940 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2943 The syntax for @code{equ} on the HPPA is
2944 @samp{@var{symbol} .equ @var{expression}}.
2948 @section @code{.extern}
2950 @cindex @code{extern} directive
2951 @code{.extern} is accepted in the source program---for compatibility
2952 with other assemblers---but it is ignored. @code{@value{AS}} treats
2953 all undefined symbols as external.
2955 @ifclear no-file-dir
2957 @section @code{.file @var{string}}
2959 @cindex @code{file} directive
2960 @cindex logical file name
2961 @cindex file name, logical
2962 @code{.file} (which may also be spelled @samp{.app-file}) tells
2963 @code{@value{AS}} that we are about to start a new logical file.
2964 @var{string} is the new file name. In general, the filename is
2965 recognized whether or not it is surrounded by quotes @samp{"}; but if
2966 you wish to specify an empty file name, you must give the
2967 quotes--@code{""}. This statement may go away in future: it is only
2968 recognized to be compatible with old @code{@value{AS}} programs.
2970 In some configurations of @code{@value{AS}}, @code{.file} has already been
2971 removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
2976 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
2978 @cindex @code{fill} directive
2979 @cindex writing patterns in memory
2980 @cindex patterns, writing in memory
2981 @var{result}, @var{size} and @var{value} are absolute expressions.
2982 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2983 may be zero or more. @var{Size} may be zero or more, but if it is
2984 more than 8, then it is deemed to have the value 8, compatible with
2985 other people's assemblers. The contents of each @var{repeat} bytes
2986 is taken from an 8-byte number. The highest order 4 bytes are
2987 zero. The lowest order 4 bytes are @var{value} rendered in the
2988 byte-order of an integer on the computer @code{@value{AS}} is assembling for.
2989 Each @var{size} bytes in a repetition is taken from the lowest order
2990 @var{size} bytes of this number. Again, this bizarre behavior is
2991 compatible with other people's assemblers.
2993 @var{size} and @var{value} are optional.
2994 If the second comma and @var{value} are absent, @var{value} is
2995 assumed zero. If the first comma and following tokens are absent,
2996 @var{size} is assumed to be 1.
2999 @section @code{.float @var{flonums}}
3001 @cindex floating point numbers (single)
3002 @cindex @code{float} directive
3003 This directive assembles zero or more flonums, separated by commas. It
3004 has the same effect as @code{.single}.
3006 The exact kind of floating point numbers emitted depends on how
3007 @code{@value{AS}} is configured.
3008 @xref{Machine Dependencies}.
3012 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
3013 in @sc{ieee} format.
3018 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
3020 @cindex @code{global} directive
3021 @cindex symbol, making visible to linker
3022 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
3023 @var{symbol} in your partial program, its value is made available to
3024 other partial programs that are linked with it. Otherwise,
3025 @var{symbol} takes its attributes from a symbol of the same name
3026 from another file linked into the same program.
3028 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
3029 compatibility with other assemblers.
3032 On the HPPA, @code{.global} is not always enough to make it accessible to other
3033 partial programs. You may need the HPPA-only @code{.EXPORT} directive as well.
3034 @xref{HPPA Directives,, HPPA Assembler Directives}.
3038 @section @code{.hword @var{expressions}}
3040 @cindex @code{hword} directive
3041 @cindex integers, 16-bit
3042 @cindex numbers, 16-bit
3043 @cindex sixteen bit integers
3044 This expects zero or more @var{expressions}, and emits
3045 a 16 bit number for each.
3048 This directive is a synonym for @samp{.short}; depending on the target
3049 architecture, it may also be a synonym for @samp{.word}.
3053 This directive is a synonym for @samp{.short}.
3056 This directive is a synonym for both @samp{.short} and @samp{.word}.
3061 @section @code{.ident}
3063 @cindex @code{ident} directive
3064 This directive is used by some assemblers to place tags in object files.
3065 @code{@value{AS}} simply accepts the directive for source-file
3066 compatibility with such assemblers, but does not actually emit anything
3070 @section @code{.if @var{absolute expression}}
3072 @cindex conditional assembly
3073 @cindex @code{if} directive
3074 @code{.if} marks the beginning of a section of code which is only
3075 considered part of the source program being assembled if the argument
3076 (which must be an @var{absolute expression}) is non-zero. The end of
3077 the conditional section of code must be marked by @code{.endif}
3078 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
3079 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
3081 The following variants of @code{.if} are also supported:
3083 @item .ifdef @var{symbol}
3084 @cindex @code{ifdef} directive
3085 Assembles the following section of code if the specified @var{symbol}
3090 @cindex @code{ifeqs} directive
3091 Not yet implemented.
3094 @item .ifndef @var{symbol}
3095 @itemx ifnotdef @var{symbol}
3096 @cindex @code{ifndef} directive
3097 @cindex @code{ifnotdef} directive
3098 Assembles the following section of code if the specified @var{symbol}
3099 has not been defined. Both spelling variants are equivalent.
3103 Not yet implemented.
3108 @section @code{.include "@var{file}"}
3110 @cindex @code{include} directive
3111 @cindex supporting files, including
3112 @cindex files, including
3113 This directive provides a way to include supporting files at specified
3114 points in your source program. The code from @var{file} is assembled as
3115 if it followed the point of the @code{.include}; when the end of the
3116 included file is reached, assembly of the original file continues. You
3117 can control the search paths used with the @samp{-I} command-line option
3118 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
3122 @section @code{.int @var{expressions}}
3124 @cindex @code{int} directive
3125 @cindex integers, 32-bit
3126 Expect zero or more @var{expressions}, of any section, separated by commas.
3127 For each expression, emit a number that, at run time, is the value of that
3128 expression. The byte order and bit size of the number depends on what kind
3129 of target the assembly is for.
3133 On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
3134 integers. On the H8/300H and the Hitachi SH, however, @code{.int} emits
3140 @section @code{.lcomm @var{symbol} , @var{length}}
3142 @cindex @code{lcomm} directive
3143 @cindex local common symbols
3144 @cindex symbols, local common
3145 Reserve @var{length} (an absolute expression) bytes for a local common
3146 denoted by @var{symbol}. The section and value of @var{symbol} are
3147 those of the new local common. The addresses are allocated in the bss
3148 section, so that at run-time the bytes start off zeroed. @var{Symbol}
3149 is not declared global (@pxref{Global,,@code{.global}}), so is normally
3150 not visible to @code{@value{LD}}.
3153 The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
3154 @samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
3158 @section @code{.lflags}
3160 @cindex @code{lflags} directive (ignored)
3161 @code{@value{AS}} accepts this directive, for compatibility with other
3162 assemblers, but ignores it.
3164 @ifclear no-line-dir
3166 @section @code{.line @var{line-number}}
3168 @cindex @code{line} directive
3172 @section @code{.ln @var{line-number}}
3174 @cindex @code{ln} directive
3176 @cindex logical line number
3178 Change the logical line number. @var{line-number} must be an absolute
3179 expression. The next line has that logical line number. Therefore any other
3180 statements on the current line (after a statement separator character) are
3181 reported as on logical line number @var{line-number} @minus{} 1. One day
3182 @code{@value{AS}} will no longer support this directive: it is recognized only
3183 for compatibility with existing assembler programs.
3187 @emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
3188 only available with the name @code{.ln}, rather than as either
3189 @code{.line} or @code{.ln}.
3194 @ifclear no-line-dir
3195 Even though this is a directive associated with the @code{a.out} or
3196 @code{b.out} object-code formats, @code{@value{AS}} still recognizes it
3197 when producing COFF output, and treats @samp{.line} as though it
3198 were the COFF @samp{.ln} @emph{if} it is found outside a
3199 @code{.def}/@code{.endef} pair.
3201 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
3202 used by compilers to generate auxiliary symbol information for
3207 @section @code{.ln @var{line-number}}
3209 @cindex @code{ln} directive
3210 @ifclear no-line-dir
3211 @samp{.ln} is a synonym for @samp{.line}.
3214 Tell @code{@value{AS}} to change the logical line number. @var{line-number}
3215 must be an absolute expression. The next line has that logical
3216 line number, so any other statements on the current line (after a
3217 statement separator character @code{;}) are reported as on logical
3218 line number @var{line-number} @minus{} 1.
3221 This directive is accepted, but ignored, when @code{@value{AS}} is
3222 configured for @code{b.out}; its effect is only associated with COFF
3228 @section @code{.list}
3230 @cindex @code{list} directive
3231 @cindex listing control, turning on
3232 Control (in conjunction with the @code{.nolist} directive) whether or
3233 not assembly listings are generated. These two directives maintain an
3234 internal counter (which is zero initially). @code{.list} increments the
3235 counter, and @code{.nolist} decrements it. Assembly listings are
3236 generated whenever the counter is greater than zero.
3238 By default, listings are disabled. When you enable them (with the
3239 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
3240 the initial value of the listing counter is one.
3243 @section @code{.long @var{expressions}}
3245 @cindex @code{long} directive
3246 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
3249 @c no one seems to know what this is for or whether this description is
3250 @c what it really ought to do
3252 @section @code{.lsym @var{symbol}, @var{expression}}
3254 @cindex @code{lsym} directive
3255 @cindex symbol, not referenced in assembly
3256 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
3257 the hash table, ensuring it cannot be referenced by name during the
3258 rest of the assembly. This sets the attributes of the symbol to be
3259 the same as the expression value:
3261 @var{other} = @var{descriptor} = 0
3262 @var{type} = @r{(section of @var{expression})}
3263 @var{value} = @var{expression}
3266 The new symbol is not flagged as external.
3270 @section @code{.nolist}
3272 @cindex @code{nolist} directive
3273 @cindex listing control, turning off
3274 Control (in conjunction with the @code{.list} directive) whether or
3275 not assembly listings are generated. These two directives maintain an
3276 internal counter (which is zero initially). @code{.list} increments the
3277 counter, and @code{.nolist} decrements it. Assembly listings are
3278 generated whenever the counter is greater than zero.
3281 @section @code{.octa @var{bignums}}
3283 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
3284 @cindex @code{octa} directive
3285 @cindex integer, 16-byte
3286 @cindex sixteen byte integer
3287 This directive expects zero or more bignums, separated by commas. For each
3288 bignum, it emits a 16-byte integer.
3290 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
3291 hence @emph{octa}-word for 16 bytes.
3294 @section @code{.org @var{new-lc} , @var{fill}}
3296 @cindex @code{org} directive
3297 @cindex location counter, advancing
3298 @cindex advancing location counter
3299 @cindex current address, advancing
3300 Advance the location counter of the current section to
3301 @var{new-lc}. @var{new-lc} is either an absolute expression or an
3302 expression with the same section as the current subsection. That is,
3303 you can't use @code{.org} to cross sections: if @var{new-lc} has the
3304 wrong section, the @code{.org} directive is ignored. To be compatible
3305 with former assemblers, if the section of @var{new-lc} is absolute,
3306 @code{@value{AS}} issues a warning, then pretends the section of @var{new-lc}
3307 is the same as the current subsection.
3309 @code{.org} may only increase the location counter, or leave it
3310 unchanged; you cannot use @code{.org} to move the location counter
3313 @c double negative used below "not undefined" because this is a specific
3314 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
3315 @c section. pesch@cygnus.com 18feb91
3316 Because @code{@value{AS}} tries to assemble programs in one pass @var{new-lc}
3317 may not be undefined. If you really detest this restriction we eagerly await
3318 a chance to share your improved assembler.
3320 Beware that the origin is relative to the start of the section, not
3321 to the start of the subsection. This is compatible with other
3322 people's assemblers.
3324 When the location counter (of the current subsection) is advanced, the
3325 intervening bytes are filled with @var{fill} which should be an
3326 absolute expression. If the comma and @var{fill} are omitted,
3327 @var{fill} defaults to zero.
3330 @section @code{.psize @var{lines} , @var{columns}}
3332 @cindex @code{psize} directive
3333 @cindex listing control: paper size
3334 @cindex paper size, for listings
3335 Use this directive to declare the number of lines---and, optionally, the
3336 number of columns---to use for each page, when generating listings.
3338 If you do not use @code{.psize}, listings use a default line-count
3339 of 60. You may omit the comma and @var{columns} specification; the
3340 default width is 200 columns.
3342 @code{@value{AS}} generates formfeeds whenever the specified number of
3343 lines is exceeded (or whenever you explicitly request one, using
3346 If you specify @var{lines} as @code{0}, no formfeeds are generated save
3347 those explicitly specified with @code{.eject}.
3350 @section @code{.quad @var{bignums}}
3352 @cindex @code{quad} directive
3353 @code{.quad} expects zero or more bignums, separated by commas. For
3354 each bignum, it emits
3356 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
3357 warning message; and just takes the lowest order 8 bytes of the bignum.
3358 @cindex eight-byte integer
3359 @cindex integer, 8-byte
3361 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
3362 hence @emph{quad}-word for 8 bytes.
3365 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
3366 warning message; and just takes the lowest order 16 bytes of the bignum.
3367 @cindex sixteen-byte integer
3368 @cindex integer, 16-byte
3372 @section @code{.sbttl "@var{subheading}"}
3374 @cindex @code{sbttl} directive
3375 @cindex subtitles for listings
3376 @cindex listing control: subtitle
3377 Use @var{subheading} as the title (third line, immediately after the
3378 title line) when generating assembly listings.
3380 This directive affects subsequent pages, as well as the current page if
3381 it appears within ten lines of the top of a page.
3385 @section @code{.scl @var{class}}
3387 @cindex @code{scl} directive
3388 @cindex symbol storage class (COFF)
3389 @cindex COFF symbol storage class
3390 Set the storage-class value for a symbol. This directive may only be
3391 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
3392 whether a symbol is static or external, or it may record further
3393 symbolic debugging information.
3396 The @samp{.scl} directive is primarily associated with COFF output; when
3397 configured to generate @code{b.out} output format, @code{@value{AS}}
3398 accepts this directive but ignores it.
3404 @section @code{.section @var{name}, @var{subsection}}
3406 @cindex @code{section} directive
3407 @cindex named section (COFF)
3408 @cindex COFF named section
3409 Assemble the following code into end of subsection numbered
3410 @var{subsection} in the COFF named section @var{name}. If you omit
3411 @var{subsection}, @code{@value{AS}} uses subsection number zero.
3412 @samp{.section .text} is equivalent to the @code{.text} directive;
3413 @samp{.section .data} is equivalent to the @code{.data} directive.
3417 @section @code{.set @var{symbol}, @var{expression}}
3419 @cindex @code{set} directive
3420 @cindex symbol value, setting
3421 Set the value of @var{symbol} to @var{expression}. This
3422 changes @var{symbol}'s value and type to conform to
3423 @var{expression}. If @var{symbol} was flagged as external, it remains
3424 flagged. (@xref{Symbol Attributes}.)
3426 You may @code{.set} a symbol many times in the same assembly.
3427 If the expression's section is unknowable during pass 1, a second
3428 pass over the source program is necessary. The second pass is
3429 currently not implemented. @code{@value{AS}} aborts with an error
3430 message if one is required.
3432 If you @code{.set} a global symbol, the value stored in the object
3433 file is the last value stored into it.
3436 The syntax for @code{set} on the HPPA is
3437 @samp{@var{symbol} .set @var{expression}}.
3441 @section @code{.short @var{expressions}}
3443 @cindex @code{short} directive
3445 @code{.short} is normally the same as @samp{.word}.
3446 @xref{Word,,@code{.word}}.
3448 In some configurations, however, @code{.short} and @code{.word} generate
3449 numbers of different lengths; @pxref{Machine Dependencies}.
3453 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
3456 This expects zero or more @var{expressions}, and emits
3457 a 16 bit number for each.
3462 @section @code{.single @var{flonums}}
3464 @cindex @code{single} directive
3465 @cindex floating point numbers (single)
3466 This directive assembles zero or more flonums, separated by commas. It
3467 has the same effect as @code{.float}.
3469 The exact kind of floating point numbers emitted depends on how
3470 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3474 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
3475 numbers in @sc{ieee} format.
3481 @section @code{.size}
3483 @cindex @code{size} directive
3484 This directive is generated by compilers to include auxiliary debugging
3485 information in the symbol table. It is only permitted inside
3486 @code{.def}/@code{.endef} pairs.
3489 @samp{.size} is only meaningful when generating COFF format output; when
3490 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3495 @ifclear no-space-dir
3497 @section @code{.space @var{size} , @var{fill}}
3499 @cindex @code{space} directive
3500 @cindex filling memory
3501 This directive emits @var{size} bytes, each of value @var{fill}. Both
3502 @var{size} and @var{fill} are absolute expressions. If the comma
3503 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3507 @emph{Warning:} @code{.space} has a completely different meaning for HPPA
3508 targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
3509 Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the
3510 @code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives},
3519 @section @code{.space}
3520 @cindex @code{space} directive
3522 On the AMD 29K, this directive is ignored; it is accepted for
3523 compatibility with other AMD 29K assemblers.
3526 @emph{Warning:} In most versions of the GNU assembler, the directive
3527 @code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
3533 @section @code{.stabd, .stabn, .stabs}
3535 @cindex symbolic debuggers, information for
3536 @cindex @code{stab@var{x}} directives
3537 There are three directives that begin @samp{.stab}.
3538 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
3539 The symbols are not entered in the @code{@value{AS}} hash table: they
3540 cannot be referenced elsewhere in the source file.
3541 Up to five fields are required:
3545 This is the symbol's name. It may contain any character except
3546 @samp{\000}, so is more general than ordinary symbol names. Some
3547 debuggers used to code arbitrarily complex structures into symbol names
3551 An absolute expression. The symbol's type is set to the low 8 bits of
3552 this expression. Any bit pattern is permitted, but @code{@value{LD}}
3553 and debuggers choke on silly bit patterns.
3556 An absolute expression. The symbol's ``other'' attribute is set to the
3557 low 8 bits of this expression.
3560 An absolute expression. The symbol's descriptor is set to the low 16
3561 bits of this expression.
3564 An absolute expression which becomes the symbol's value.
3567 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
3568 or @code{.stabs} statement, the symbol has probably already been created;
3569 you get a half-formed symbol in your object file. This is
3570 compatible with earlier assemblers!
3573 @cindex @code{stabd} directive
3574 @item .stabd @var{type} , @var{other} , @var{desc}
3576 The ``name'' of the symbol generated is not even an empty string.
3577 It is a null pointer, for compatibility. Older assemblers used a
3578 null pointer so they didn't waste space in object files with empty
3581 The symbol's value is set to the location counter,
3582 relocatably. When your program is linked, the value of this symbol
3583 is the address of the location counter when the @code{.stabd} was
3586 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
3587 @cindex @code{stabn} directive
3588 The name of the symbol is set to the empty string @code{""}.
3590 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
3591 @cindex @code{stabs} directive
3592 All five fields are specified.
3598 @section @code{.string} "@var{str}"
3600 @cindex string, copying to object file
3601 @cindex @code{string} directive
3603 Copy the characters in @var{str} to the object file. You may specify more than
3604 one string to copy, separated by commas. Unless otherwise specified for a
3605 particular machine, the assembler marks the end of each string with a 0 byte.
3606 You can use any of the escape sequences described in @ref{Strings,,Strings}.
3610 @section @code{.tag @var{structname}}
3612 @cindex COFF structure debugging
3613 @cindex structure debugging, COFF
3614 @cindex @code{tag} directive
3615 This directive is generated by compilers to include auxiliary debugging
3616 information in the symbol table. It is only permitted inside
3617 @code{.def}/@code{.endef} pairs. Tags are used to link structure
3618 definitions in the symbol table with instances of those structures.
3621 @samp{.tag} is only used when generating COFF format output; when
3622 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3628 @section @code{.text @var{subsection}}
3630 @cindex @code{text} directive
3631 Tells @code{@value{AS}} to assemble the following statements onto the end of
3632 the text subsection numbered @var{subsection}, which is an absolute
3633 expression. If @var{subsection} is omitted, subsection number zero
3637 @section @code{.title "@var{heading}"}
3639 @cindex @code{title} directive
3640 @cindex listing control: title line
3641 Use @var{heading} as the title (second line, immediately after the
3642 source file name and pagenumber) when generating assembly listings.
3644 This directive affects subsequent pages, as well as the current page if
3645 it appears within ten lines of the top of a page.
3649 @section @code{.type @var{int}}
3651 @cindex COFF symbol type
3652 @cindex symbol type, COFF
3653 @cindex @code{type} directive
3654 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3655 records the integer @var{int} as the type attribute of a symbol table entry.
3658 @samp{.type} is associated only with COFF format output; when
3659 @code{@value{AS}} is configured for @code{b.out} output, it accepts this
3660 directive but ignores it.
3666 @section @code{.val @var{addr}}
3668 @cindex @code{val} directive
3669 @cindex COFF value attribute
3670 @cindex value attribute, COFF
3671 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3672 records the address @var{addr} as the value attribute of a symbol table
3676 @samp{.val} is used only for COFF output; when @code{@value{AS}} is
3677 configured for @code{b.out}, it accepts this directive but ignores it.
3682 @section @code{.word @var{expressions}}
3684 @cindex @code{word} directive
3685 This directive expects zero or more @var{expressions}, of any section,
3686 separated by commas.
3689 For each expression, @code{@value{AS}} emits a 32-bit number.
3692 For each expression, @code{@value{AS}} emits a 16-bit number.
3697 The size of the number emitted, and its byte order,
3698 depend on what target computer the assembly is for.
3701 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
3702 @c happen---32-bit addressability, period; no long/short jumps.
3703 @ifset DIFF-TBL-KLUGE
3704 @cindex difference tables altered
3705 @cindex altered difference tables
3707 @emph{Warning: Special Treatment to support Compilers}
3711 Machines with a 32-bit address space, but that do less than 32-bit
3712 addressing, require the following special treatment. If the machine of
3713 interest to you does 32-bit addressing (or doesn't require it;
3714 @pxref{Machine Dependencies}), you can ignore this issue.
3717 In order to assemble compiler output into something that works,
3718 @code{@value{AS}} occasionlly does strange things to @samp{.word} directives.
3719 Directives of the form @samp{.word sym1-sym2} are often emitted by
3720 compilers as part of jump tables. Therefore, when @code{@value{AS}} assembles a
3721 directive of the form @samp{.word sym1-sym2}, and the difference between
3722 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{@value{AS}}
3723 creates a @dfn{secondary jump table}, immediately before the next label.
3724 This secondary jump table is preceded by a short-jump to the
3725 first byte after the secondary table. This short-jump prevents the flow
3726 of control from accidentally falling into the new table. Inside the
3727 table is a long-jump to @code{sym2}. The original @samp{.word}
3728 contains @code{sym1} minus the address of the long-jump to
3731 If there were several occurrences of @samp{.word sym1-sym2} before the
3732 secondary jump table, all of them are adjusted. If there was a
3733 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
3734 long-jump to @code{sym4} is included in the secondary jump table,
3735 and the @code{.word} directives are adjusted to contain @code{sym3}
3736 minus the address of the long-jump to @code{sym4}; and so on, for as many
3737 entries in the original jump table as necessary.
3740 @emph{This feature may be disabled by compiling @code{@value{AS}} with the
3741 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
3742 assembly language programmers.
3745 @c end DIFF-TBL-KLUGE
3748 @section Deprecated Directives
3750 @cindex deprecated directives
3751 @cindex obsolescent directives
3752 One day these directives won't work.
3753 They are included for compatibility with older assemblers.
3761 @node Machine Dependencies
3762 @chapter Machine Dependent Features
3764 @cindex machine dependencies
3765 The machine instruction sets are (almost by definition) different on
3766 each machine where @code{@value{AS}} runs. Floating point representations
3767 vary as well, and @code{@value{AS}} often supports a few additional
3768 directives or command-line options for compatibility with other
3769 assemblers on a particular platform. Finally, some versions of
3770 @code{@value{AS}} support special pseudo-instructions for branch
3773 This chapter discusses most of these differences, though it does not
3774 include details on any machine's instruction set. For details on that
3775 subject, see the hardware manufacturer's manual.
3779 * Vax-Dependent:: VAX Dependent Features
3782 * AMD29K-Dependent:: AMD 29K Dependent Features
3785 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
3788 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
3791 * HPPA-Dependent:: HPPA Dependent Features
3794 * SH-Dependent:: Hitachi SH Dependent Features
3797 * i960-Dependent:: Intel 80960 Dependent Features
3800 * M68K-Dependent:: M680x0 Dependent Features
3803 * Sparc-Dependent:: SPARC Dependent Features
3806 * Z8000-Dependent:: Z8000 Dependent Features
3809 * MIPS-Dependent:: MIPS Dependent Features
3812 * i386-Dependent:: 80386 Dependent Features
3819 @c The following major nodes are *sections* in the GENERIC version, *chapters*
3820 @c in single-cpu versions. This is mainly achieved by @lowersections. There is a
3821 @c peculiarity: to preserve cross-references, there must be a node called
3822 @c "Machine Dependencies". Hence the conditional nodenames in each
3823 @c major node below. Node defaulting in makeinfo requires adjacency of
3824 @c node and sectioning commands; hence the repetition of @chapter BLAH
3825 @c in both conditional blocks.
3830 @chapter VAX Dependent Features
3835 @node Machine Dependencies
3836 @chapter VAX Dependent Features
3842 * Vax-Opts:: VAX Command-Line Options
3843 * VAX-float:: VAX Floating Point
3844 * VAX-directives:: Vax Machine Directives
3845 * VAX-opcodes:: VAX Opcodes
3846 * VAX-branch:: VAX Branch Improvement
3847 * VAX-operands:: VAX Operands
3848 * VAX-no:: Not Supported on VAX
3853 @section VAX Command-Line Options
3855 @cindex command-line options ignored, VAX
3856 @cindex VAX command-line options ignored
3857 The Vax version of @code{@value{AS}} accepts any of the following options,
3858 gives a warning message that the option was ignored and proceeds.
3859 These options are for compatibility with scripts designed for other
3860 people's assemblers.
3863 @item @code{-D} (Debug)
3864 @itemx @code{-S} (Symbol Table)
3865 @itemx @code{-T} (Token Trace)
3866 @cindex @code{-D}, ignored on VAX
3867 @cindex @code{-S}, ignored on VAX
3868 @cindex @code{-T}, ignored on VAX
3869 These are obsolete options used to debug old assemblers.
3871 @item @code{-d} (Displacement size for JUMPs)
3872 @cindex @code{-d}, VAX option
3873 This option expects a number following the @samp{-d}. Like options
3874 that expect filenames, the number may immediately follow the
3875 @samp{-d} (old standard) or constitute the whole of the command line
3876 argument that follows @samp{-d} (GNU standard).
3878 @item @code{-V} (Virtualize Interpass Temporary File)
3879 @cindex @code{-V}, redundant on VAX
3880 Some other assemblers use a temporary file. This option
3881 commanded them to keep the information in active memory rather
3882 than in a disk file. @code{@value{AS}} always does this, so this
3883 option is redundant.
3885 @item @code{-J} (JUMPify Longer Branches)
3886 @cindex @code{-J}, ignored on VAX
3887 Many 32-bit computers permit a variety of branch instructions
3888 to do the same job. Some of these instructions are short (and
3889 fast) but have a limited range; others are long (and slow) but
3890 can branch anywhere in virtual memory. Often there are 3
3891 flavors of branch: short, medium and long. Some other
3892 assemblers would emit short and medium branches, unless told by
3893 this option to emit short and long branches.
3895 @item @code{-t} (Temporary File Directory)
3896 @cindex @code{-t}, ignored on VAX
3897 Some other assemblers may use a temporary file, and this option
3898 takes a filename being the directory to site the temporary
3899 file. Since @code{@value{AS}} does not use a temporary disk file, this
3900 option makes no difference. @samp{-t} needs exactly one
3904 @cindex VMS (VAX) options
3905 @cindex options for VAX/VMS
3906 @cindex VAX/VMS options
3907 @cindex @code{-h} option, VAX/VMS
3908 @cindex @code{-+} option, VAX/VMS
3909 @cindex Vax-11 C compatibility
3910 @cindex symbols with lowercase, VAX/VMS
3911 @c FIXME! look into "I think" below, correct if needed, delete.
3912 The Vax version of the assembler accepts two options when
3913 compiled for VMS. They are @samp{-h}, and @samp{-+}. The
3914 @samp{-h} option prevents @code{@value{AS}} from modifying the
3915 symbol-table entries for symbols that contain lowercase
3916 characters (I think). The @samp{-+} option causes @code{@value{AS}} to
3917 print warning messages if the FILENAME part of the object file,
3918 or any symbol name is larger than 31 characters. The @samp{-+}
3919 option also inserts some code following the @samp{_main}
3920 symbol so that the object file is compatible with Vax-11
3924 @section VAX Floating Point
3926 @cindex VAX floating point
3927 @cindex floating point, VAX
3928 Conversion of flonums to floating point is correct, and
3929 compatible with previous assemblers. Rounding is
3930 towards zero if the remainder is exactly half the least significant bit.
3932 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
3935 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
3936 are rendered correctly. Again, rounding is towards zero in the
3939 @cindex @code{float} directive, VAX
3940 @cindex @code{double} directive, VAX
3941 The @code{.float} directive produces @code{f} format numbers.
3942 The @code{.double} directive produces @code{d} format numbers.
3944 @node VAX-directives
3945 @section Vax Machine Directives
3947 @cindex machine directives, VAX
3948 @cindex VAX machine directives
3949 The Vax version of the assembler supports four directives for
3950 generating Vax floating point constants. They are described in the
3953 @cindex wide floating point directives, VAX
3956 @cindex @code{dfloat} directive, VAX
3957 This expects zero or more flonums, separated by commas, and
3958 assembles Vax @code{d} format 64-bit floating point constants.
3961 @cindex @code{ffloat} directive, VAX
3962 This expects zero or more flonums, separated by commas, and
3963 assembles Vax @code{f} format 32-bit floating point constants.
3966 @cindex @code{gfloat} directive, VAX
3967 This expects zero or more flonums, separated by commas, and
3968 assembles Vax @code{g} format 64-bit floating point constants.
3971 @cindex @code{hfloat} directive, VAX
3972 This expects zero or more flonums, separated by commas, and
3973 assembles Vax @code{h} format 128-bit floating point constants.
3978 @section VAX Opcodes
3980 @cindex VAX opcode mnemonics
3981 @cindex opcode mnemonics, VAX
3982 @cindex mnemonics for opcodes, VAX
3983 All DEC mnemonics are supported. Beware that @code{case@dots{}}
3984 instructions have exactly 3 operands. The dispatch table that
3985 follows the @code{case@dots{}} instruction should be made with
3986 @code{.word} statements. This is compatible with all unix
3987 assemblers we know of.
3990 @section VAX Branch Improvement
3992 @cindex VAX branch improvement
3993 @cindex branch improvement, VAX
3994 @cindex pseudo-ops for branch, VAX
3995 Certain pseudo opcodes are permitted. They are for branch
3996 instructions. They expand to the shortest branch instruction that
3997 reaches the target. Generally these mnemonics are made by
3998 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
3999 This feature is included both for compatibility and to help
4000 compilers. If you do not need this feature, avoid these
4001 opcodes. Here are the mnemonics, and the code they can expand into.
4005 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
4007 @item (byte displacement)
4009 @item (word displacement)
4011 @item (long displacement)
4016 Unconditional branch.
4018 @item (byte displacement)
4020 @item (word displacement)
4022 @item (long displacement)
4026 @var{COND} may be any one of the conditional branches
4027 @code{neq}, @code{nequ}, @code{eql}, @code{eqlu}, @code{gtr},
4028 @code{geq}, @code{lss}, @code{gtru}, @code{lequ}, @code{vc}, @code{vs},
4029 @code{gequ}, @code{cc}, @code{lssu}, @code{cs}.
4030 @var{COND} may also be one of the bit tests
4031 @code{bs}, @code{bc}, @code{bss}, @code{bcs}, @code{bsc}, @code{bcc},
4032 @code{bssi}, @code{bcci}, @code{lbs}, @code{lbc}.
4033 @var{NOTCOND} is the opposite condition to @var{COND}.
4035 @item (byte displacement)
4036 @kbd{b@var{COND} @dots{}}
4037 @item (word displacement)
4038 @kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
4039 @item (long displacement)
4040 @kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
4043 @var{X} may be one of @code{b d f g h l w}.
4045 @item (word displacement)
4046 @kbd{@var{OPCODE} @dots{}}
4047 @item (long displacement)
4049 @var{OPCODE} @dots{}, foo ;
4056 @var{YYY} may be one of @code{lss leq}.
4058 @var{ZZZ} may be one of @code{geq gtr}.
4060 @item (byte displacement)
4061 @kbd{@var{OPCODE} @dots{}}
4062 @item (word displacement)
4064 @var{OPCODE} @dots{}, foo ;
4066 foo: brw @var{destination} ;
4069 @item (long displacement)
4071 @var{OPCODE} @dots{}, foo ;
4073 foo: jmp @var{destination} ;
4082 @item (byte displacement)
4083 @kbd{@var{OPCODE} @dots{}}
4084 @item (word displacement)
4086 @var{OPCODE} @dots{}, foo ;
4088 foo: brw @var{destination} ;
4091 @item (long displacement)
4093 @var{OPCODE} @dots{}, foo ;
4095 foo: jmp @var{destination} ;
4102 @section VAX Operands
4104 @cindex VAX operand notation
4105 @cindex operand notation, VAX
4106 @cindex immediate character, VAX
4107 @cindex VAX immediate character
4108 The immediate character is @samp{$} for Unix compatibility, not
4109 @samp{#} as DEC writes it.
4111 @cindex indirect character, VAX
4112 @cindex VAX indirect character
4113 The indirect character is @samp{*} for Unix compatibility, not
4114 @samp{@@} as DEC writes it.
4116 @cindex displacement sizing character, VAX
4117 @cindex VAX displacement sizing character
4118 The displacement sizing character is @samp{`} (an accent grave) for
4119 Unix compatibility, not @samp{^} as DEC writes it. The letter
4120 preceding @samp{`} may have either case. @samp{G} is not
4121 understood, but all other letters (@code{b i l s w}) are understood.
4123 @cindex register names, VAX
4124 @cindex VAX register names
4125 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
4126 pc}. Upper and lower case letters are equivalent.
4133 Any expression is permitted in an operand. Operands are comma
4136 @c There is some bug to do with recognizing expressions
4137 @c in operands, but I forget what it is. It is
4138 @c a syntax clash because () is used as an address mode
4139 @c and to encapsulate sub-expressions.
4142 @section Not Supported on VAX
4144 @cindex VAX bitfields not supported
4145 @cindex bitfields, not supported on VAX
4146 Vax bit fields can not be assembled with @code{@value{AS}}. Someone
4147 can add the required code if they really need it.
4153 @node AMD29K-Dependent
4154 @chapter AMD 29K Dependent Features
4157 @node Machine Dependencies
4158 @chapter AMD 29K Dependent Features
4161 @cindex AMD 29K support
4164 * AMD29K Options:: Options
4165 * AMD29K Syntax:: Syntax
4166 * AMD29K Floating Point:: Floating Point
4167 * AMD29K Directives:: AMD 29K Machine Directives
4168 * AMD29K Opcodes:: Opcodes
4171 @node AMD29K Options
4173 @cindex AMD 29K options (none)
4174 @cindex options for AMD29K (none)
4175 @code{@value{AS}} has no additional command-line options for the AMD
4181 * AMD29K-Chars:: Special Characters
4182 * AMD29K-Regs:: Register Names
4186 @subsection Special Characters
4188 @cindex line comment character, AMD 29K
4189 @cindex AMD 29K line comment character
4190 @samp{;} is the line comment character.
4192 @cindex line separator, AMD 29K
4193 @cindex AMD 29K line separator
4194 @cindex statement separator, AMD 29K
4195 @cindex AMD 29K statement separator
4196 @samp{@@} can be used instead of a newline to separate statements.
4198 @cindex identifiers, AMD 29K
4199 @cindex AMD 29K identifiers
4200 The character @samp{?} is permitted in identifiers (but may not begin
4204 @subsection Register Names
4206 @cindex AMD 29K register names
4207 @cindex register names, AMD 29K
4208 General-purpose registers are represented by predefined symbols of the
4209 form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
4210 (for local registers), where @var{nnn} represents a number between
4211 @code{0} and @code{127}, written with no leading zeros. The leading
4212 letters may be in either upper or lower case; for example, @samp{gr13}
4213 and @samp{LR7} are both valid register names.
4215 You may also refer to general-purpose registers by specifying the
4216 register number as the result of an expression (prefixed with @samp{%%}
4217 to flag the expression as a register number):
4222 ---where @var{expression} must be an absolute expression evaluating to a
4223 number between @code{0} and @code{255}. The range [0, 127] refers to
4224 global registers, and the range [128, 255] to local registers.
4226 @cindex special purpose registers, AMD 29K
4227 @cindex AMD 29K special purpose registers
4228 @cindex protected registers, AMD 29K
4229 @cindex AMD 29K protected registers
4230 In addition, @code{@value{AS}} understands the following protected
4231 special-purpose register names for the AMD 29K family:
4241 These unprotected special-purpose register names are also recognized:
4249 @node AMD29K Floating Point
4250 @section Floating Point
4252 @cindex floating point, AMD 29K (@sc{ieee})
4253 @cindex AMD 29K floating point (@sc{ieee})
4254 The AMD 29K family uses @sc{ieee} floating-point numbers.
4256 @node AMD29K Directives
4257 @section AMD 29K Machine Directives
4259 @cindex machine directives, AMD 29K
4260 @cindex AMD 29K machine directives
4262 @item .block @var{size} , @var{fill}
4263 @cindex @code{block} directive, AMD 29K
4264 This directive emits @var{size} bytes, each of value @var{fill}. Both
4265 @var{size} and @var{fill} are absolute expressions. If the comma
4266 and @var{fill} are omitted, @var{fill} is assumed to be zero.
4268 In other versions of the GNU assembler, this directive is called
4274 @cindex @code{cputype} directive, AMD 29K
4275 This directive is ignored; it is accepted for compatibility with other
4279 @cindex @code{file} directive, AMD 29K
4280 This directive is ignored; it is accepted for compatibility with other
4284 @emph{Warning:} in other versions of the GNU assembler, @code{.file} is
4285 used for the directive called @code{.app-file} in the AMD 29K support.
4289 @cindex @code{line} directive, AMD 29K
4290 This directive is ignored; it is accepted for compatibility with other
4294 @c since we're ignoring .lsym...
4295 @item .reg @var{symbol}, @var{expression}
4296 @cindex @code{reg} directive, AMD 29K
4297 @code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
4301 @cindex @code{sect} directive, AMD 29K
4302 This directive is ignored; it is accepted for compatibility with other
4305 @item .use @var{section name}
4306 @cindex @code{use} directive, AMD 29K
4307 Establishes the section and subsection for the following code;
4308 @var{section name} may be one of @code{.text}, @code{.data},
4309 @code{.data1}, or @code{.lit}. With one of the first three @var{section
4310 name} options, @samp{.use} is equivalent to the machine directive
4311 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
4315 @node AMD29K Opcodes
4318 @cindex AMD 29K opcodes
4319 @cindex opcodes for AMD 29K
4320 @code{@value{AS}} implements all the standard AMD 29K opcodes. No
4321 additional pseudo-instructions are needed on this family.
4323 For information on the 29K machine instruction set, see @cite{Am29000
4324 User's Manual}, Advanced Micro Devices, Inc.
4329 @node Machine Dependencies
4330 @chapter Machine Dependent Features
4332 The machine instruction sets are different on each Hitachi chip family,
4333 and there are also some syntax differences among the families. This
4334 chapter describes the specific @code{@value{AS}} features for each
4338 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4339 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4340 * SH-Dependent:: Hitachi SH Dependent Features
4350 @node H8/300-Dependent
4351 @chapter H8/300 Dependent Features
4353 @cindex H8/300 support
4355 * H8/300 Options:: Options
4356 * H8/300 Syntax:: Syntax
4357 * H8/300 Floating Point:: Floating Point
4358 * H8/300 Directives:: H8/300 Machine Directives
4359 * H8/300 Opcodes:: Opcodes
4362 @node H8/300 Options
4365 @cindex H8/300 options (none)
4366 @cindex options, H8/300 (none)
4367 @code{@value{AS}} has no additional command-line options for the Hitachi
4373 * H8/300-Chars:: Special Characters
4374 * H8/300-Regs:: Register Names
4375 * H8/300-Addressing:: Addressing Modes
4379 @subsection Special Characters
4381 @cindex line comment character, H8/300
4382 @cindex H8/300 line comment character
4383 @samp{;} is the line comment character.
4385 @cindex line separator, H8/300
4386 @cindex statement separator, H8/300
4387 @cindex H8/300 line separator
4388 @samp{$} can be used instead of a newline to separate statements.
4389 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
4392 @subsection Register Names
4394 @cindex H8/300 registers
4395 @cindex register names, H8/300
4396 You can use predefined symbols of the form @samp{r@var{n}h} and
4397 @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
4398 general-purpose registers. @var{n} is a digit from @samp{0} to
4399 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
4402 You can also use the eight predefined symbols @samp{r@var{n}} to refer
4403 to the H8/300 registers as 16-bit registers (you must use this form for
4406 On the H8/300H, you can also use the eight predefined symbols
4407 @samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit
4408 general purpose registers.
4410 The two control registers are called @code{pc} (program counter; a
4411 16-bit register, except on the H8/300H where it is 24 bits) and
4412 @code{ccr} (condition code register; an 8-bit register). @code{r7} is
4413 used as the stack pointer, and can also be called @code{sp}.
4415 @node H8/300-Addressing
4416 @subsection Addressing Modes
4418 @cindex addressing modes, H8/300
4419 @cindex H8/300 addressing modes
4420 @value{AS} understands the following addressing modes for the H8/300:
4428 @item @@(@var{d}, r@var{n})
4429 @itemx @@(@var{d}:16, r@var{n})
4430 @itemx @@(@var{d}:24, r@var{n})
4431 Register indirect: 16-bit or 24-bit displacement @var{d} from register
4432 @var{n}. (24-bit displacements are only meaningful on the H8/300H.)
4435 Register indirect with post-increment
4438 Register indirect with pre-decrement
4440 @item @code{@@}@var{aa}
4441 @itemx @code{@@}@var{aa}:8
4442 @itemx @code{@@}@var{aa}:16
4443 @itemx @code{@@}@var{aa}:24
4444 Absolute address @code{aa}. (The address size @samp{:24} only makes
4445 sense on the H8/300H.)
4451 Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or
4452 @samp{:32} for clarity, if you wish; but @code{@value{AS}} neither
4453 requires this nor uses it---the data size required is taken from
4456 @item @code{@@}@code{@@}@var{aa}
4457 @itemx @code{@@}@code{@@}@var{aa}:8
4458 Memory indirect. You may specify the @samp{:8} for clarity, if you
4459 wish; but @code{@value{AS}} neither requires this nor uses it.
4462 @node H8/300 Floating Point
4463 @section Floating Point
4465 @cindex floating point, H8/300 (@sc{ieee})
4466 @cindex H8/300 floating point (@sc{ieee})
4467 The H8/300 family has no hardware floating point, but the @code{.float}
4468 directive generates @sc{ieee} floating-point numbers for compatibility
4469 with other development tools.
4472 @node H8/300 Directives
4473 @section H8/300 Machine Directives
4475 @cindex H8/300 machine directives (none)
4476 @cindex machine directives, H8/300 (none)
4477 @cindex @code{word} directive, H8/300
4478 @cindex @code{int} directive, H8/300
4479 @code{@value{AS}} has only one machine-dependent directive for the
4484 @cindex H8/300H, assembling for
4485 Recognize and emit additional instructions for the H8/300H variant, and
4486 also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
4487 for the H8/300 family.
4490 On the H8/300 family (including the H8/300H) @samp{.word} directives
4491 generate 16-bit numbers.
4493 @node H8/300 Opcodes
4496 @cindex H8/300 opcode summary
4497 @cindex opcode summary, H8/300
4498 @cindex mnemonics, H8/300
4499 @cindex instruction summary, H8/300
4500 For detailed information on the H8/300 machine instruction set, see
4501 @cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025). For
4502 information specific to the H8/300H, see @cite{H8/300H Series
4503 Programming Manual} (Hitachi).
4505 @code{@value{AS}} implements all the standard H8/300 opcodes. No additional
4506 pseudo-instructions are needed on this family.
4509 @c this table, due to the multi-col faking and hardcoded order, looks silly
4510 @c except in smallbook. See comments below "@set SMALL" near top of this file.
4512 The following table summarizes the H8/300 opcodes, and their arguments.
4513 Entries marked @samp{*} are opcodes used only on the H8/300H.
4516 @c Using @group seems to use the normal baselineskip, not the smallexample
4517 @c baselineskip; looks approx doublespaced.
4519 Rs @r{source register}
4520 Rd @r{destination register}
4521 abs @r{absolute address}
4522 imm @r{immediate data}
4523 disp:N @r{N-bit displacement from a register}
4524 pcrel:N @r{N-bit displacement relative to program counter}
4526 add.b #imm,rd * andc #imm,ccr
4527 add.b rs,rd band #imm,rd
4528 add.w rs,rd band #imm,@@rd
4529 * add.w #imm,rd band #imm,@@abs:8
4530 * add.l rs,rd bra pcrel:8
4531 * add.l #imm,rd * bra pcrel:16
4532 adds #imm,rd bt pcrel:8
4533 addx #imm,rd * bt pcrel:16
4534 addx rs,rd brn pcrel:8
4535 and.b #imm,rd * brn pcrel:16
4536 and.b rs,rd bf pcrel:8
4537 * and.w rs,rd * bf pcrel:16
4538 * and.w #imm,rd bhi pcrel:8
4539 * and.l #imm,rd * bhi pcrel:16
4540 * and.l rs,rd bls pcrel:8
4542 * bls pcrel:16 bld #imm,rd
4543 bcc pcrel:8 bld #imm,@@rd
4544 * bcc pcrel:16 bld #imm,@@abs:8
4545 bhs pcrel:8 bnot #imm,rd
4546 * bhs pcrel:16 bnot #imm,@@rd
4547 bcs pcrel:8 bnot #imm,@@abs:8
4548 * bcs pcrel:16 bnot rs,rd
4549 blo pcrel:8 bnot rs,@@rd
4550 * blo pcrel:16 bnot rs,@@abs:8
4551 bne pcrel:8 bor #imm,rd
4552 * bne pcrel:16 bor #imm,@@rd
4553 beq pcrel:8 bor #imm,@@abs:8
4554 * beq pcrel:16 bset #imm,rd
4555 bvc pcrel:8 bset #imm,@@rd
4556 * bvc pcrel:16 bset #imm,@@abs:8
4557 bvs pcrel:8 bset rs,rd
4558 * bvs pcrel:16 bset rs,@@rd
4559 bpl pcrel:8 bset rs,@@abs:8
4560 * bpl pcrel:16 bsr pcrel:8
4561 bmi pcrel:8 bsr pcrel:16
4562 * bmi pcrel:16 bst #imm,rd
4563 bge pcrel:8 bst #imm,@@rd
4564 * bge pcrel:16 bst #imm,@@abs:8
4565 blt pcrel:8 btst #imm,rd
4566 * blt pcrel:16 btst #imm,@@rd
4567 bgt pcrel:8 btst #imm,@@abs:8
4568 * bgt pcrel:16 btst rs,rd
4569 ble pcrel:8 btst rs,@@rd
4570 * ble pcrel:16 btst rs,@@abs:8
4571 bclr #imm,rd bxor #imm,rd
4572 bclr #imm,@@rd bxor #imm,@@rd
4573 bclr #imm,@@abs:8 bxor #imm,@@abs:8
4574 bclr rs,rd cmp.b #imm,rd
4575 bclr rs,@@rd cmp.b rs,rd
4576 bclr rs,@@abs:8 cmp.w rs,rd
4577 biand #imm,rd cmp.w rs,rd
4578 biand #imm,@@rd * cmp.w #imm,rd
4579 biand #imm,@@abs:8 * cmp.l #imm,rd
4580 bild #imm,rd * cmp.l rs,rd
4581 bild #imm,@@rd daa rs
4582 bild #imm,@@abs:8 das rs
4583 bior #imm,rd dec.b rs
4584 bior #imm,@@rd * dec.w #imm,rd
4585 bior #imm,@@abs:8 * dec.l #imm,rd
4586 bist #imm,rd divxu.b rs,rd
4587 bist #imm,@@rd * divxu.w rs,rd
4588 bist #imm,@@abs:8 * divxs.b rs,rd
4589 bixor #imm,rd * divxs.w rs,rd
4590 bixor #imm,@@rd eepmov
4591 bixor #imm,@@abs:8 * eepmovw
4593 * exts.w rd mov.w rs,@@abs:16
4594 * exts.l rd * mov.l #imm,rd
4595 * extu.w rd * mov.l rs,rd
4596 * extu.l rd * mov.l @@rs,rd
4597 inc rs * mov.l @@(disp:16,rs),rd
4598 * inc.w #imm,rd * mov.l @@(disp:24,rs),rd
4599 * inc.l #imm,rd * mov.l @@rs+,rd
4600 jmp @@rs * mov.l @@abs:16,rd
4601 jmp abs * mov.l @@abs:24,rd
4602 jmp @@@@abs:8 * mov.l rs,@@rd
4603 jsr @@rs * mov.l rs,@@(disp:16,rd)
4604 jsr abs * mov.l rs,@@(disp:24,rd)
4605 jsr @@@@abs:8 * mov.l rs,@@-rd
4606 ldc #imm,ccr * mov.l rs,@@abs:16
4607 ldc rs,ccr * mov.l rs,@@abs:24
4608 * ldc @@abs:16,ccr movfpe @@abs:16,rd
4609 * ldc @@abs:24,ccr movtpe rs,@@abs:16
4610 * ldc @@(disp:16,rs),ccr mulxu.b rs,rd
4611 * ldc @@(disp:24,rs),ccr * mulxu.w rs,rd
4612 * ldc @@rs+,ccr * mulxs.b rs,rd
4613 * ldc @@rs,ccr * mulxs.w rs,rd
4614 * mov.b @@(disp:24,rs),rd neg.b rs
4615 * mov.b rs,@@(disp:24,rd) * neg.w rs
4616 mov.b @@abs:16,rd * neg.l rs
4618 mov.b @@abs:8,rd not.b rs
4619 mov.b rs,@@abs:8 * not.w rs
4620 mov.b rs,rd * not.l rs
4621 mov.b #imm,rd or.b #imm,rd
4622 mov.b @@rs,rd or.b rs,rd
4623 mov.b @@(disp:16,rs),rd * or.w #imm,rd
4624 mov.b @@rs+,rd * or.w rs,rd
4625 mov.b @@abs:8,rd * or.l #imm,rd
4626 mov.b rs,@@rd * or.l rs,rd
4627 mov.b rs,@@(disp:16,rd) orc #imm,ccr
4628 mov.b rs,@@-rd pop.w rs
4629 mov.b rs,@@abs:8 * pop.l rs
4630 mov.w rs,@@rd push.w rs
4631 * mov.w @@(disp:24,rs),rd * push.l rs
4632 * mov.w rs,@@(disp:24,rd) rotl.b rs
4633 * mov.w @@abs:24,rd * rotl.w rs
4634 * mov.w rs,@@abs:24 * rotl.l rs
4635 mov.w rs,rd rotr.b rs
4636 mov.w #imm,rd * rotr.w rs
4637 mov.w @@rs,rd * rotr.l rs
4638 mov.w @@(disp:16,rs),rd rotxl.b rs
4639 mov.w @@rs+,rd * rotxl.w rs
4640 mov.w @@abs:16,rd * rotxl.l rs
4641 mov.w rs,@@(disp:16,rd) rotxr.b rs
4642 mov.w rs,@@-rd * rotxr.w rs
4644 * rotxr.l rs * stc ccr,@@(disp:24,rd)
4646 rte * stc ccr,@@abs:16
4647 rts * stc ccr,@@abs:24
4648 shal.b rs sub.b rs,rd
4649 * shal.w rs sub.w rs,rd
4650 * shal.l rs * sub.w #imm,rd
4651 shar.b rs * sub.l rs,rd
4652 * shar.w rs * sub.l #imm,rd
4653 * shar.l rs subs #imm,rd
4654 shll.b rs subx #imm,rd
4655 * shll.w rs subx rs,rd
4656 * shll.l rs * trapa #imm
4657 shlr.b rs xor #imm,rd
4658 * shlr.w rs xor rs,rd
4659 * shlr.l rs * xor.w #imm,rd
4661 stc ccr,rd * xor.l #imm,rd
4662 * stc ccr,@@rs * xor.l rs,rd
4663 * stc ccr,@@(disp:16,rd) xorc #imm,ccr
4667 @cindex size suffixes, H8/300
4668 @cindex H8/300 size suffixes
4669 Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
4670 @code{sub}) are defined with variants using the suffixes @samp{.b},
4671 @samp{.w}, and @samp{.l} to specify the size of a memory operand.
4672 @code{@value{AS}} supports these suffixes, but does not require them;
4673 since one of the operands is always a register, @code{@value{AS}} can
4674 deduce the correct size.
4676 For example, since @code{r0} refers to a 16-bit register,
4679 @exdent is equivalent to
4683 If you use the size suffixes, @code{@value{AS}} issues a warning when
4684 the suffix and the register size do not match.
4689 @node H8/500-Dependent
4690 @chapter H8/500 Dependent Features
4692 @cindex H8/500 support
4694 * H8/500 Options:: Options
4695 * H8/500 Syntax:: Syntax
4696 * H8/500 Floating Point:: Floating Point
4697 * H8/500 Directives:: H8/500 Machine Directives
4698 * H8/500 Opcodes:: Opcodes
4701 @node H8/500 Options
4704 @cindex H8/500 options (none)
4705 @cindex options, H8/500 (none)
4706 @code{@value{AS}} has no additional command-line options for the Hitachi
4713 * H8/500-Chars:: Special Characters
4714 * H8/500-Regs:: Register Names
4715 * H8/500-Addressing:: Addressing Modes
4719 @subsection Special Characters
4721 @cindex line comment character, H8/500
4722 @cindex H8/500 line comment character
4723 @samp{!} is the line comment character.
4725 @cindex line separator, H8/500
4726 @cindex statement separator, H8/500
4727 @cindex H8/500 line separator
4728 @samp{;} can be used instead of a newline to separate statements.
4730 @cindex symbol names, @samp{$} in
4731 @cindex @code{$} in symbol names
4732 Since @samp{$} has no special meaning, you may use it in symbol names.
4735 @subsection Register Names
4737 @cindex H8/500 registers
4738 @cindex registers, H8/500
4739 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
4740 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, and @samp{r7} to refer to
4741 the H8/500 registers.
4743 The H8/500 also has these control registers:
4765 condition code register
4768 All registers are 16 bits long. To represent 32 bit numbers, use two
4769 adjacent registers; for distant memory addresses, use one of the segment
4770 pointers (@code{cp} for the program counter; @code{dp} for
4771 @code{r0}--@code{r3}; @code{ep} for @code{r4} and @code{r5}; and
4772 @code{tp} for @code{r6} and @code{r7}.
4774 @node H8/500-Addressing
4775 @subsection Addressing Modes
4777 @cindex addressing modes, H8/500
4778 @cindex H8/500 addressing modes
4779 @value{AS} understands the following addressing modes for the H8/500:
4787 @item @@(d:8, R@var{n})
4788 Register indirect with 8 bit signed displacement
4790 @item @@(d:16, R@var{n})
4791 Register indirect with 16 bit signed displacement
4794 Register indirect with pre-decrement
4797 Register indirect with post-increment
4800 8 bit absolute address
4803 16 bit absolute address
4812 @node H8/500 Floating Point
4813 @section Floating Point
4815 @cindex floating point, H8/500 (@sc{ieee})
4816 @cindex H8/500 floating point (@sc{ieee})
4817 The H8/500 family uses @sc{ieee} floating-point numbers.
4819 @node H8/500 Directives
4820 @section H8/500 Machine Directives
4822 @cindex H8/500 machine directives (none)
4823 @cindex machine directives, H8/500 (none)
4824 @cindex @code{word} directive, H8/500
4825 @cindex @code{int} directive, H8/500
4826 @code{@value{AS}} has no machine-dependent directives for the H8/500.
4827 However, on this platform the @samp{.int} and @samp{.word} directives
4828 generate 16-bit numbers.
4830 @node H8/500 Opcodes
4833 @cindex H8/500 opcode summary
4834 @cindex opcode summary, H8/500
4835 @cindex mnemonics, H8/500
4836 @cindex instruction summary, H8/500
4837 For detailed information on the H8/500 machine instruction set, see
4838 @cite{H8/500 Series Programming Manual} (Hitachi M21T001).
4840 @code{@value{AS}} implements all the standard H8/500 opcodes. No additional
4841 pseudo-instructions are needed on this family.
4844 @c this table, due to the multi-col faking and hardcoded order, looks silly
4845 @c except in smallbook. See comments below "@set SMALL" near top of this file.
4847 The following table summarizes H8/500 opcodes and their operands:
4849 @c Use @group if it ever works, instead of @page
4853 abs8 @r{8-bit absolute address}
4854 abs16 @r{16-bit absolute address}
4855 abs24 @r{24-bit absolute address}
4856 crb @r{@code{ccr}, @code{br}, @code{ep}, @code{dp}, @code{tp}, @code{dp}}
4857 disp8 @r{8-bit displacement}
4858 ea @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4859 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16},}
4860 @r{@code{#xx:8}, @code{#xx:16}}
4861 ea_mem @r{@code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4862 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4863 ea_noimm @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4864 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4866 imm4 @r{4-bit immediate data}
4867 imm8 @r{8-bit immediate data}
4868 imm16 @r{16-bit immediate data}
4869 pcrel8 @r{8-bit offset from program counter}
4870 pcrel16 @r{16-bit offset from program counter}
4871 qim @r{@code{-2}, @code{-1}, @code{1}, @code{2}}
4873 rs @r{a register distinct from rd}
4874 rlist @r{comma-separated list of registers in parentheses;}
4875 @r{register ranges @code{rd-rs} are allowed}
4876 sp @r{stack pointer (@code{r7})}
4877 sr @r{status register}
4878 sz @r{size; @samp{.b} or @samp{.w}. If omitted, default @samp{.w}}
4880 ldc[.b] ea,crb bcc[.w] pcrel16
4881 ldc[.w] ea,sr bcc[.b] pcrel8
4882 add[:q] sz qim,ea_noimm bhs[.w] pcrel16
4883 add[:g] sz ea,rd bhs[.b] pcrel8
4884 adds sz ea,rd bcs[.w] pcrel16
4885 addx sz ea,rd bcs[.b] pcrel8
4886 and sz ea,rd blo[.w] pcrel16
4887 andc[.b] imm8,crb blo[.b] pcrel8
4888 andc[.w] imm16,sr bne[.w] pcrel16
4890 bra[.w] pcrel16 beq[.w] pcrel16
4891 bra[.b] pcrel8 beq[.b] pcrel8
4892 bt[.w] pcrel16 bvc[.w] pcrel16
4893 bt[.b] pcrel8 bvc[.b] pcrel8
4894 brn[.w] pcrel16 bvs[.w] pcrel16
4895 brn[.b] pcrel8 bvs[.b] pcrel8
4896 bf[.w] pcrel16 bpl[.w] pcrel16
4897 bf[.b] pcrel8 bpl[.b] pcrel8
4898 bhi[.w] pcrel16 bmi[.w] pcrel16
4899 bhi[.b] pcrel8 bmi[.b] pcrel8
4900 bls[.w] pcrel16 bge[.w] pcrel16
4901 bls[.b] pcrel8 bge[.b] pcrel8
4903 blt[.w] pcrel16 mov[:g][.b] imm8,ea_mem
4904 blt[.b] pcrel8 mov[:g][.w] imm16,ea_mem
4905 bgt[.w] pcrel16 movfpe[.b] ea,rd
4906 bgt[.b] pcrel8 movtpe[.b] rs,ea_noimm
4907 ble[.w] pcrel16 mulxu sz ea,rd
4908 ble[.b] pcrel8 neg sz ea
4909 bclr sz imm4,ea_noimm nop
4910 bclr sz rs,ea_noimm not sz ea
4911 bnot sz imm4,ea_noimm or sz ea,rd
4912 bnot sz rs,ea_noimm orc[.b] imm8,crb
4913 bset sz imm4,ea_noimm orc[.w] imm16,sr
4914 bset sz rs,ea_noimm pjmp abs24
4915 bsr[.b] pcrel8 pjmp @@rd
4916 bsr[.w] pcrel16 pjsr abs24
4917 btst sz imm4,ea_noimm pjsr @@rd
4918 btst sz rs,ea_noimm prtd imm8
4919 clr sz ea prtd imm16
4920 cmp[:e][.b] imm8,rd prts
4921 cmp[:i][.w] imm16,rd rotl sz ea
4922 cmp[:g].b imm8,ea_noimm rotr sz ea
4923 cmp[:g][.w] imm16,ea_noimm rotxl sz ea
4924 Cmp[:g] sz ea,rd rotxr sz ea
4926 divxu sz ea,rd rtd imm16
4928 exts[.b] rd scb/f rs,pcrel8
4929 extu[.b] rd scb/ne rs,pcrel8
4930 jmp @@rd scb/eq rs,pcrel8
4931 jmp @@(imm8,rd) shal sz ea
4932 jmp @@(imm16,rd) shar sz ea
4933 jmp abs16 shll sz ea
4935 jsr @@(imm8,rd) sleep
4936 jsr @@(imm16,rd) stc[.b] crb,ea_noimm
4937 jsr abs16 stc[.w] sr,ea_noimm
4938 ldm @@sp+,(rlist) stm (rlist),@@-sp
4939 link fp,imm8 sub sz ea,rd
4940 link fp,imm16 subs sz ea,rd
4941 mov[:e][.b] imm8,rd subx sz ea,rd
4942 mov[:i][.w] imm16,rd swap[.b] rd
4943 mov[:l][.w] abs8,rd tas[.b] ea
4944 mov[:l].b abs8,rd trapa imm4
4945 mov[:s][.w] rs,abs8 trap/vs
4946 mov[:s].b rs,abs8 tst sz ea
4947 mov[:f][.w] @@(disp8,fp),rd unlk fp
4948 mov[:f][.w] rs,@@(disp8,fp) xch[.w] rs,rd
4949 mov[:f].b @@(disp8,fp),rd xor sz ea,rd
4950 mov[:f].b rs,@@(disp8,fp) xorc.b imm8,crb
4951 mov[:g] sz rs,ea_mem xorc.w imm16,sr
4959 @node HPPA-Dependent
4960 @chapter HPPA Dependent Features
4964 * HPPA Notes:: Notes
4965 * HPPA Options:: Options
4966 * HPPA Syntax:: Syntax
4967 * HPPA Floating Point:: Floating Point
4968 * HPPA Directives:: HPPA Machine Directives
4969 * HPPA Opcodes:: Opcodes
4974 As a back end for GNU CC @code{@value{AS}} has been throughly tested and should
4975 work extremely well. We have tested it only minimally on hand written assembly
4976 code and no one has tested it much on the assembly output from the HP
4979 The format of the debugging sections has changed since the original
4980 @code{@value{AS}} port (version 1.3X) was released; therefore,
4981 you must rebuild all HPPA objects and libraries with the new
4982 assembler so that you can debug the final executable.
4984 The HPPA @code{@value{AS}} port generates a small subset of the relocations
4985 available in the SOM and ELF object file formats. Additional relocation
4986 support will be added as it becomes necessary.
4990 @code{@value{AS}} has no machine-dependent command-line options for the HPPA.
4995 The assembler syntax closely follows the HPPA instruction set
4996 reference manual; assembler directives and general syntax closely follow the
4997 HPPA assembly language reference manual, with a few noteworthy differences.
4999 First, a colon may immediately follow a label definition. This is
5000 simply for compatibility with how most assembly language programmers
5003 Some obscure expression parsing problems may affect hand written code which
5004 uses the @code{spop} instructions, or code which makes significant
5005 use of the @code{!} line separator.
5007 @code{@value{AS}} is much less forgiving about missing arguments and other
5008 similar oversights than the HP assembler. @code{@value{AS}} notifies you
5009 of missing arguments as syntax errors; this is regarded as a feature, not a
5012 Finally, @code{@value{AS}} allows you to use an external symbol without
5013 explicitly importing the symbol. @emph{Warning:} in the future this will be
5014 an error for HPPA targets.
5016 Special characters for HPPA targets include:
5018 @samp{;} is the line comment character.
5020 @samp{!} can be used instead of a newline to separate statements.
5022 Since @samp{$} has no special meaning, you may use it in symbol names.
5024 @node HPPA Floating Point
5025 @section Floating Point
5026 @cindex floating point, HPPA (@sc{ieee})
5027 @cindex HPPA floating point (@sc{ieee})
5028 The HPPA family uses @sc{ieee} floating-point numbers.
5030 @node HPPA Directives
5031 @section HPPA Assembler Directives
5033 @code{@value{AS}} for the HPPA supports many additional directives for
5034 compatibility with the native assembler. This section describes them only
5035 briefly. For detailed information on HPPA-specific assembler directives, see
5036 @cite{HP9000 Series 800 Assembly Language Reference Manual} (HP 92432-90001).
5038 @cindex HPPA directives not supported
5039 @code{@value{AS}} does @emph{not} support the following assembler directives
5040 described in the HP manual:
5049 @cindex @code{.param} on HPPA
5050 Beyond those implemented for compatibility, @code{@value{AS}} supports one
5051 additional assembler directive for the HPPA: @code{.param}. It conveys
5052 register argument locations for static functions. Its syntax closely follows
5053 the @code{.export} directive.
5055 @cindex HPPA-only directives
5056 These are the additional directives in @code{@value{AS}} for the HPPA:
5059 @item .block @var{n}
5060 @itemx .blockz @var{n}
5061 Reserve @var{n} bytes of storage, and initialize them to zero.
5064 Mark the beginning of a procedure call. Only the special case with @emph{no
5065 arguments} is allowed.
5067 @item .callinfo [ @var{param}=@var{value}, @dots{} ] [ @var{flag}, @dots{} ]
5068 Specify a number of parameters and flags that define the environment for a
5071 @var{param} may be any of @samp{frame} (frame size), @samp{entry_gr} (end of
5072 general register range), @samp{entry_fr} (end of float register range),
5073 @samp{entry_sr} (end of space register range).
5075 The values for @var{flag} are @samp{calls} or @samp{caller} (proc has
5076 subroutines), @samp{no_calls} (proc does not call subroutines), @samp{save_rp}
5077 (preserve return pointer), @samp{save_sp} (proc preserves stack pointer),
5078 @samp{no_unwind} (do not unwind this proc), @samp{hpux_int} (proc is interrupt
5082 Assemble into the standard section called @samp{$TEXT$}, subsection
5086 @item .copyright "@var{string}"
5087 In the SOM object format, insert @var{string} into the object code, marked as a
5092 @item .copyright "@var{string}"
5093 In the ELF object format, insert @var{string} into the object code, marked as a
5098 Not yet supported; the assembler rejects programs containing this directive.
5101 Mark the beginning of a procedure.
5104 Mark the end of a procedure.
5106 @item .export @var{name} [ ,@var{typ} ] [ ,@var{param}=@var{r} ]
5107 Make a procedure @var{name} available to callers. @var{typ}, if present, must
5108 be one of @samp{absolute}, @samp{code} (ELF only, not SOM), @samp{data},
5109 @samp{entry}, @samp{data}, @samp{entry}, @samp{millicode}, @samp{plabel},
5110 @samp{pri_prog}, or @samp{sec_prog}.
5112 @var{param}, if present, provides either relocation information for the
5113 procedure arguments and result, or a privilege level. @var{param} may be
5114 @samp{argw@var{n}} (where @var{n} ranges from @code{0} to @code{3}, and
5115 indicates one of four one-word arguments); @samp{rtnval} (the procedure's
5116 result); or @samp{priv_lev} (privilege level). For arguments or the result,
5117 @var{r} specifies how to relocate, and must be one of @samp{no} (not
5118 relocatable), @samp{gr} (argument is in general register), @samp{fr} (in
5119 floating point register), or @samp{fu} (upper half of float register).
5120 For @samp{priv_lev}, @var{r} is an integer.
5123 Define a two-byte integer constant @var{n}; synonym for the portable
5124 @code{@value{AS}} directive @code{.short}.
5126 @item .import @var{name} [ ,@var{typ} ]
5127 Converse of @code{.export}; make a procedure available to call. The arguments
5128 use the same conventions as the first two arguments for @code{.export}.
5130 @item .label @var{name}
5131 Define @var{name} as a label for the current assembly location.
5134 Not yet supported; the assembler rejects programs containing this directive.
5136 @item .origin @var{lc}
5137 Advance location counter to @var{lc}. Synonym for the @code{@value{as}}
5138 portable directive @code{.org}.
5140 @item .param @var{name} [ ,@var{typ} ] [ ,@var{param}=@var{r} ]
5141 @c Not in HP manual; GNU HPPA extension
5142 Similar to @code{.export}, but used for static procedures.
5145 Use preceding the first statement of a procedure.
5148 Use following the last statement of a procedure.
5150 @item @var{label} .reg @var{expr}
5151 @c ?? Not in HP manual (Jan 1988 vn)
5152 Synonym for @code{.equ}; define @var{label} with the absolute expression
5153 @var{expr} as its value.
5155 @item .space @var{secname} [ ,@var{params} ]
5156 Switch to section @var{secname}, creating a new section by that name if
5157 necessary. You may only use @var{params} when creating a new section, not
5158 when switching to an existing one. @var{secname} may identify a section by
5159 number rather than by name.
5161 If specified, the list @var{params} declares attributes of the section,
5162 identified by keywords. The keywords recognized are @samp{spnum=@var{exp}}
5163 (identify this section by the number @var{exp}, an absolute expression),
5164 @samp{sort=@var{exp}} (order sections according to this sort key when linking;
5165 @var{exp} is an absolute expression), @samp{unloadable} (section contains no
5166 loadable data), @samp{notdefined} (this section defined elsewhere), and
5167 @samp{private} (data in this section not available to other programs).
5169 @item .spnum @var{secnam}
5170 @c ?? Not in HP manual (Jan 1988)
5171 Allocate four bytes of storage, and initialize them with the section number of
5172 the section named @var{secnam}. (You can define the section number with the
5173 HPPA @code{.space} directive.)
5175 @item .string "@var{str}"
5176 @cindex @code{string} directive on HPPA
5177 Copy the characters in the string @var{str} to the object file.
5178 @xref{Strings,,Strings}, for information on escape sequences you can use in
5179 @code{@value{AS}} strings.
5181 @emph{Warning!} The HPPA version of @code{.string} differs from the
5182 usual @code{@value{AS}} definition: it does @emph{not} write a zero byte
5183 after copying @var{str}.
5185 @item .stringz "@var{str}"
5186 Like @code{.string}, but appends a zero byte after copying @var{str} to object
5189 @item .subspa @var{name} [ ,@var{params} ]
5190 Similar to @code{.space}, but selects a subsection @var{name} within the
5191 current section. You may only specify @var{params} when you create a
5192 subsection (in the first instance of @code{.subspa} for this @var{name}).
5194 If specified, the list @var{params} declares attributes of the subsection,
5195 identified by keywords. The keywords recognized are @samp{quad=@var{expr}}
5196 (``quadrant'' for this subsection), @samp{align=@var{expr}} (alignment for
5197 beginning of this subsection; a power of two), @samp{access=@var{expr}} (value
5198 for ``access rights'' field), @samp{sort=@var{expr}} (sorting order for this
5199 subspace in link), @samp{code_only} (subsection contains only code),
5200 @samp{unloadable} (subsection cannot be loaded into memory), @samp{common}
5201 (subsection is common block), @samp{dup_comm} (initialized data may have
5202 duplicate names), or @samp{zero} (subsection is all zeros, do not write in
5205 @item .version "@var{str}"
5206 Write @var{str} as version identifier in object code.
5211 For detailed information on the HPPA machine instruction set, see
5212 @cite{PA-RISC Architecture and Instruction Set Reference Manual}
5219 @chapter Hitachi SH Dependent Features
5223 * SH Options:: Options
5224 * SH Syntax:: Syntax
5225 * SH Floating Point:: Floating Point
5226 * SH Directives:: SH Machine Directives
5227 * SH Opcodes:: Opcodes
5233 @cindex SH options (none)
5234 @cindex options, SH (none)
5235 @code{@value{AS}} has no additional command-line options for the Hitachi
5242 * SH-Chars:: Special Characters
5243 * SH-Regs:: Register Names
5244 * SH-Addressing:: Addressing Modes
5248 @subsection Special Characters
5250 @cindex line comment character, SH
5251 @cindex SH line comment character
5252 @samp{!} is the line comment character.
5254 @cindex line separator, SH
5255 @cindex statement separator, SH
5256 @cindex SH line separator
5257 You can use @samp{;} instead of a newline to separate statements.
5259 @cindex symbol names, @samp{$} in
5260 @cindex @code{$} in symbol names
5261 Since @samp{$} has no special meaning, you may use it in symbol names.
5264 @subsection Register Names
5266 @cindex SH registers
5267 @cindex registers, SH
5268 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
5269 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
5270 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
5271 and @samp{r15} to refer to the SH registers.
5273 The SH also has these control registers:
5277 procedure register (holds return address)
5284 high and low multiply accumulator registers
5290 global base register
5293 vector base register (for interrupt vectors)
5297 @subsection Addressing Modes
5299 @cindex addressing modes, SH
5300 @cindex SH addressing modes
5301 @code{@value{AS}} understands the following addressing modes for the SH.
5302 @code{R@var{n}} in the following refers to any of the numbered
5303 registers, but @emph{not} the control registers.
5313 Register indirect with pre-decrement
5316 Register indirect with post-increment
5318 @item @@(@var{disp}, R@var{n})
5319 Register indirect with displacement
5321 @item @@(R0, R@var{n})
5324 @item @@(@var{disp}, GBR)
5331 @itemx @@(@var{disp}, PC)
5332 PC relative address (for branch or for addressing memory). The
5333 @code{@value{AS}} implementation allows you to use the simpler form
5334 @var{addr} anywhere a PC relative address is called for; the alternate
5335 form is supported for compatibility with other assemblers.
5341 @node SH Floating Point
5342 @section Floating Point
5344 @cindex floating point, SH (@sc{ieee})
5345 @cindex SH floating point (@sc{ieee})
5346 The SH family uses @sc{ieee} floating-point numbers.
5349 @section SH Machine Directives
5351 @cindex SH machine directives (none)
5352 @cindex machine directives, SH (none)
5353 @cindex @code{word} directive, SH
5354 @cindex @code{int} directive, SH
5355 @code{@value{AS}} has no machine-dependent directives for the SH.
5360 @cindex SH opcode summary
5361 @cindex opcode summary, SH
5362 @cindex mnemonics, SH
5363 @cindex instruction summary, SH
5364 For detailed information on the SH machine instruction set, see
5365 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
5367 @code{@value{AS}} implements all the standard SH opcodes. No additional
5368 pseudo-instructions are needed on this family. Note, however, that
5369 because @code{@value{AS}} supports a simpler form of PC-relative
5370 addressing, you may simply write (for example)
5377 where other assemblers might require an explicit displacement to
5378 @code{bar} from the program counter:
5381 mov.l @@(@var{disp}, PC)
5385 @c this table, due to the multi-col faking and hardcoded order, looks silly
5386 @c except in smallbook. See comments below "@set SMALL" near top of this file.
5388 Here is a summary of SH opcodes:
5393 Rn @r{a numbered register}
5394 Rm @r{another numbered register}
5395 #imm @r{immediate data}
5396 disp @r{displacement}
5397 disp8 @r{8-bit displacement}
5398 disp12 @r{12-bit displacement}
5400 add #imm,Rn lds.l @@Rn+,PR
5401 add Rm,Rn mac.w @@Rm+,@@Rn+
5402 addc Rm,Rn mov #imm,Rn
5403 addv Rm,Rn mov Rm,Rn
5404 and #imm,R0 mov.b Rm,@@(R0,Rn)
5405 and Rm,Rn mov.b Rm,@@-Rn
5406 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
5407 bf disp8 mov.b @@(disp,Rm),R0
5408 bra disp12 mov.b @@(disp,GBR),R0
5409 bsr disp12 mov.b @@(R0,Rm),Rn
5410 bt disp8 mov.b @@Rm+,Rn
5411 clrmac mov.b @@Rm,Rn
5412 clrt mov.b R0,@@(disp,Rm)
5413 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
5414 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
5415 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
5416 cmp/gt Rm,Rn mov.l Rm,@@-Rn
5417 cmp/hi Rm,Rn mov.l Rm,@@Rn
5418 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
5419 cmp/pl Rn mov.l @@(disp,GBR),R0
5420 cmp/pz Rn mov.l @@(disp,PC),Rn
5421 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
5422 div0s Rm,Rn mov.l @@Rm+,Rn
5424 div1 Rm,Rn mov.l R0,@@(disp,GBR)
5425 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
5426 exts.w Rm,Rn mov.w Rm,@@-Rn
5427 extu.b Rm,Rn mov.w Rm,@@Rn
5428 extu.w Rm,Rn mov.w @@(disp,Rm),R0
5429 jmp @@Rn mov.w @@(disp,GBR),R0
5430 jsr @@Rn mov.w @@(disp,PC),Rn
5431 ldc Rn,GBR mov.w @@(R0,Rm),Rn
5432 ldc Rn,SR mov.w @@Rm+,Rn
5433 ldc Rn,VBR mov.w @@Rm,Rn
5434 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
5435 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
5436 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
5438 lds Rn,MACL muls Rm,Rn
5439 lds Rn,PR mulu Rm,Rn
5440 lds.l @@Rn+,MACH neg Rm,Rn
5441 lds.l @@Rn+,MACL negc Rm,Rn
5444 not Rm,Rn stc.l GBR,@@-Rn
5445 or #imm,R0 stc.l SR,@@-Rn
5446 or Rm,Rn stc.l VBR,@@-Rn
5447 or.b #imm,@@(R0,GBR) sts MACH,Rn
5448 rotcl Rn sts MACL,Rn
5450 rotl Rn sts.l MACH,@@-Rn
5451 rotr Rn sts.l MACL,@@-Rn
5456 shar Rn swap.b Rm,Rn
5457 shll Rn swap.w Rm,Rn
5458 shll16 Rn tas.b @@Rn
5460 shll8 Rn tst #imm,R0
5462 shlr16 Rn tst.b #imm,@@(R0,GBR)
5463 shlr2 Rn xor #imm,R0
5465 sleep xor.b #imm,@@(R0,GBR)
5466 stc GBR,Rn xtrct Rm,Rn
5481 @node i960-Dependent
5482 @chapter Intel 80960 Dependent Features
5485 @node Machine Dependencies
5486 @chapter Intel 80960 Dependent Features
5489 @cindex i960 support
5491 * Options-i960:: i960 Command-line Options
5492 * Floating Point-i960:: Floating Point
5493 * Directives-i960:: i960 Machine Directives
5494 * Opcodes for i960:: i960 Opcodes
5497 @c FIXME! Add Syntax sec with discussion of bitfields here, at least so
5498 @c long as they're not turned on for other machines than 960.
5502 @section i960 Command-line Options
5504 @cindex i960 options
5505 @cindex options, i960
5508 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
5509 @cindex i960 architecture options
5510 @cindex architecture options, i960
5511 @cindex @code{-A} options, i960
5512 Select the 80960 architecture. Instructions or features not supported
5513 by the selected architecture cause fatal errors.
5515 @samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
5516 @samp{-AMC}. Synonyms are provided for compatibility with other tools.
5518 If none of these options is specified, @code{@value{AS}} generates code for any
5519 instruction or feature that is supported by @emph{some} version of the
5520 960 (even if this means mixing architectures!). In principle,
5521 @code{@value{AS}} attempts to deduce the minimal sufficient processor
5522 type if none is specified; depending on the object code format, the
5523 processor type may be recorded in the object file. If it is critical
5524 that the @code{@value{AS}} output match a specific architecture, specify that
5525 architecture explicitly.
5528 @cindex @code{-b} option, i960
5529 @cindex branch recording, i960
5530 @cindex i960 branch recording
5531 Add code to collect information about conditional branches taken, for
5532 later optimization using branch prediction bits. (The conditional branch
5533 instructions have branch prediction bits in the CA, CB, and CC
5534 architectures.) If @var{BR} represents a conditional branch instruction,
5535 the following represents the code generated by the assembler when
5536 @samp{-b} is specified:
5539 call @var{increment routine}
5540 .word 0 # pre-counter
5542 call @var{increment routine}
5543 .word 0 # post-counter
5546 The counter following a branch records the number of times that branch
5547 was @emph{not} taken; the differenc between the two counters is the
5548 number of times the branch @emph{was} taken.
5550 @cindex @code{gbr960}, i960 postprocessor
5551 @cindex branch statistics table, i960
5552 A table of every such @code{Label} is also generated, so that the
5553 external postprocessor @code{gbr960} (supplied by Intel) can locate all
5554 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
5555 this is a local symbol to permit collecting statistics for many separate
5556 object files. The table is word aligned, and begins with a two-word
5557 header. The first word, initialized to 0, is used in maintaining linked
5558 lists of branch tables. The second word is a count of the number of
5559 entries in the table, which follow immediately: each is a word, pointing
5560 to one of the labels illustrated above.
5564 @c END TEXI2ROFF-KILL
5566 +------------+------------+------------+ ... +------------+
5568 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
5570 +------------+------------+------------+ ... +------------+
5572 __BRANCH_TABLE__ layout
5578 \line{\leftskip=0pt\hskip\tableindent
5579 \boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
5580 *BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
5581 \centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
5583 @c END TEXI2ROFF-KILL
5585 The first word of the header is used to locate multiple branch tables,
5586 since each object file may contain one. Normally the links are
5587 maintained with a call to an initialization routine, placed at the
5588 beginning of each function in the file. The GNU C compiler
5589 generates these calls automatically when you give it a @samp{-b} option.
5590 For further details, see the documentation of @samp{gbr960}.
5593 @cindex @code{-norelax} option, i960
5594 Normally, Compare-and-Branch instructions with targets that require
5595 displacements greater than 13 bits (or that have external targets) are
5596 replaced with the corresponding compare (or @samp{chkbit}) and branch
5597 instructions. You can use the @samp{-norelax} option to specify that
5598 @code{@value{AS}} should generate errors instead, if the target displacement
5599 is larger than 13 bits.
5601 This option does not affect the Compare-and-Jump instructions; the code
5602 emitted for them is @emph{always} adjusted when necessary (depending on
5603 displacement size), regardless of whether you use @samp{-norelax}.
5606 @node Floating Point-i960
5607 @section Floating Point
5609 @cindex floating point, i960 (@sc{ieee})
5610 @cindex i960 floating point (@sc{ieee})
5611 @code{@value{AS}} generates @sc{ieee} floating-point numbers for the directives
5612 @samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
5614 @node Directives-i960
5615 @section i960 Machine Directives
5617 @cindex machine directives, i960
5618 @cindex i960 machine directives
5621 @cindex @code{bss} directive, i960
5622 @item .bss @var{symbol}, @var{length}, @var{align}
5623 Reserve @var{length} bytes in the bss section for a local @var{symbol},
5624 aligned to the power of two specified by @var{align}. @var{length} and
5625 @var{align} must be positive absolute expressions. This directive
5626 differs from @samp{.lcomm} only in that it permits you to specify
5627 an alignment. @xref{Lcomm,,@code{.lcomm}}.
5631 @item .extended @var{flonums}
5632 @cindex @code{extended} directive, i960
5633 @code{.extended} expects zero or more flonums, separated by commas; for
5634 each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
5635 floating-point number.
5637 @item .leafproc @var{call-lab}, @var{bal-lab}
5638 @cindex @code{leafproc} directive, i960
5639 You can use the @samp{.leafproc} directive in conjunction with the
5640 optimized @code{callj} instruction to enable faster calls of leaf
5641 procedures. If a procedure is known to call no other procedures, you
5642 may define an entry point that skips procedure prolog code (and that does
5643 not depend on system-supplied saved context), and declare it as the
5644 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
5645 entry point that goes through the normal prolog, you can specify that
5646 entry point as @var{call-lab}.
5648 A @samp{.leafproc} declaration is meant for use in conjunction with the
5649 optimized call instruction @samp{callj}; the directive records the data
5650 needed later to choose between converting the @samp{callj} into a
5651 @code{bal} or a @code{call}.
5653 @var{call-lab} is optional; if only one argument is present, or if the
5654 two arguments are identical, the single argument is assumed to be the
5655 @code{bal} entry point.
5657 @item .sysproc @var{name}, @var{index}
5658 @cindex @code{sysproc} directive, i960
5659 The @samp{.sysproc} directive defines a name for a system procedure.
5660 After you define it using @samp{.sysproc}, you can use @var{name} to
5661 refer to the system procedure identified by @var{index} when calling
5662 procedures with the optimized call instruction @samp{callj}.
5664 Both arguments are required; @var{index} must be between 0 and 31
5668 @node Opcodes for i960
5669 @section i960 Opcodes
5671 @cindex opcodes, i960
5672 @cindex i960 opcodes
5673 All Intel 960 machine instructions are supported;
5674 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
5675 selecting the instruction subset for a particular 960
5676 architecture.@refill
5678 Some opcodes are processed beyond simply emitting a single corresponding
5679 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
5680 instructions with target displacements larger than 13 bits.
5683 * callj-i960:: @code{callj}
5684 * Compare-and-branch-i960:: Compare-and-Branch
5688 @subsection @code{callj}
5690 @cindex @code{callj}, i960 pseudo-opcode
5691 @cindex i960 @code{callj} pseudo-opcode
5692 You can write @code{callj} to have the assembler or the linker determine
5693 the most appropriate form of subroutine call: @samp{call},
5694 @samp{bal}, or @samp{calls}. If the assembly source contains
5695 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
5696 defining the operand---then @code{@value{AS}} translates the
5697 @code{callj}; if not, it simply emits the @code{callj}, leaving it
5698 for the linker to resolve.
5700 @node Compare-and-branch-i960
5701 @subsection Compare-and-Branch
5703 @cindex i960 compare/branch instructions
5704 @cindex compare/branch instructions, i960
5705 The 960 architectures provide combined Compare-and-Branch instructions
5706 that permit you to store the branch target in the lower 13 bits of the
5707 instruction word itself. However, if you specify a branch target far
5708 enough away that its address won't fit in 13 bits, the assembler can
5709 either issue an error, or convert your Compare-and-Branch instruction
5710 into separate instructions to do the compare and the branch.
5712 @cindex compare and jump expansions, i960
5713 @cindex i960 compare and jump expansions
5714 Whether @code{@value{AS}} gives an error or expands the instruction depends
5715 on two choices you can make: whether you use the @samp{-norelax} option,
5716 and whether you use a ``Compare and Branch'' instruction or a ``Compare
5717 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
5718 expanded if necessary; the ``Branch'' instructions are expanded when
5719 necessary @emph{unless} you specify @code{-norelax}---in which case
5720 @code{@value{AS}} gives an error instead.
5722 These are the Compare-and-Branch instructions, their ``Jump'' variants,
5723 and the instruction pairs they may expand into:
5727 @c END TEXI2ROFF-KILL
5730 Branch Jump Expanded to
5731 ------ ------ ------------
5734 cmpibe cmpije cmpi; be
5735 cmpibg cmpijg cmpi; bg
5736 cmpibge cmpijge cmpi; bge
5737 cmpibl cmpijl cmpi; bl
5738 cmpible cmpijle cmpi; ble
5739 cmpibno cmpijno cmpi; bno
5740 cmpibne cmpijne cmpi; bne
5741 cmpibo cmpijo cmpi; bo
5742 cmpobe cmpoje cmpo; be
5743 cmpobg cmpojg cmpo; bg
5744 cmpobge cmpojge cmpo; bge
5745 cmpobl cmpojl cmpo; bl
5746 cmpoble cmpojle cmpo; ble
5747 cmpobne cmpojne cmpo; bne
5753 \halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
5754 \omit{\hfil\it Compare and\hfil}\span\omit&\cr
5755 {\it Branch}&{\it Jump}&{\it Expanded to}\cr
5756 bbc& & chkbit; bno\cr
5757 bbs& & chkbit; bo\cr
5758 cmpibe& cmpije& cmpi; be\cr
5759 cmpibg& cmpijg& cmpi; bg\cr
5760 cmpibge& cmpijge& cmpi; bge\cr
5761 cmpibl& cmpijl& cmpi; bl\cr
5762 cmpible& cmpijle& cmpi; ble\cr
5763 cmpibno& cmpijno& cmpi; bno\cr
5764 cmpibne& cmpijne& cmpi; bne\cr
5765 cmpibo& cmpijo& cmpi; bo\cr
5766 cmpobe& cmpoje& cmpo; be\cr
5767 cmpobg& cmpojg& cmpo; bg\cr
5768 cmpobge& cmpojge& cmpo; bge\cr
5769 cmpobl& cmpojl& cmpo; bl\cr
5770 cmpoble& cmpojle& cmpo; ble\cr
5771 cmpobne& cmpojne& cmpo; bne\cr}
5773 @c END TEXI2ROFF-KILL
5779 @node M68K-Dependent
5780 @chapter M680x0 Dependent Features
5783 @node Machine Dependencies
5784 @chapter M680x0 Dependent Features
5787 @cindex M680x0 support
5789 * M68K-Opts:: M680x0 Options
5790 * M68K-Syntax:: Syntax
5791 * M68K-Moto-Syntax:: Motorola Syntax
5792 * M68K-Float:: Floating Point
5793 * M68K-Directives:: 680x0 Machine Directives
5794 * M68K-opcodes:: Opcodes
5798 @section M680x0 Options
5800 @cindex options, M680x0
5801 @cindex M680x0 options
5802 The Motorola 680x0 version of @code{@value{AS}} has two machine dependent options.
5803 One shortens undefined references from 32 to 16 bits, while the
5804 other is used to tell @code{@value{AS}} what kind of machine it is
5807 @cindex @code{-l} option, M680x0
5808 You can use the @samp{-l} option to shorten the size of references to undefined
5809 symbols. If you do not use the @samp{-l} option, references to undefined
5810 symbols are wide enough for a full @code{long} (32 bits). (Since
5811 @code{@value{AS}} cannot know where these symbols end up, @code{@value{AS}} can
5812 only allocate space for the linker to fill in later. Since @code{@value{AS}}
5813 doesn't know how far away these symbols are, it allocates as much space as it
5814 can.) If you use this option, the references are only one word wide (16 bits).
5815 This may be useful if you want the object file to be as small as possible, and
5816 you know that the relevant symbols are always less than 17 bits away.
5818 @cindex @code{-m68000} and related options
5819 @cindex architecture options, M680x0
5820 @cindex M680x0 architecture options
5821 The 680x0 version of @code{@value{AS}} is most frequently used to assemble
5822 programs for the Motorola MC68020 microprocessor. Occasionally it is
5823 used to assemble programs for the mostly similar, but slightly different
5824 MC68000 or MC68010 microprocessors. You can give @code{@value{AS}} the options
5825 @samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
5826 @samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
5833 This syntax for the Motorola 680x0 was developed at @sc{mit}.
5835 @cindex M680x0 syntax
5836 @cindex syntax, M680x0
5837 @cindex M680x0 size modifiers
5838 @cindex size modifiers, M680x0
5839 The 680x0 version of @code{@value{AS}} uses syntax compatible with the Sun
5840 assembler. Intervening periods are ignored; for example, @samp{movl} is
5841 equivalent to @samp{move.l}.
5844 If @code{@value{AS}} is compiled with SUN_ASM_SYNTAX defined, it
5845 also allows Sun-style local labels of the form @samp{1$} through
5849 In the following table @dfn{apc} stands for any of the address
5850 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
5851 Program Counter (@samp{pc}), or the zero-address relative to the
5852 program counter (@samp{zpc}).
5854 @cindex M680x0 addressing modes
5855 @cindex addressing modes, M680x0
5856 The following addressing modes are understood:
5859 @samp{#@var{digits}}
5862 @samp{d0} through @samp{d7}
5864 @item Address Register
5865 @samp{a0} through @samp{a7}@*
5866 @samp{a7} is also known as @samp{sp}, i.e. the Stack Pointer. @code{a6}
5867 is also known as @samp{fp}, the Frame Pointer.
5869 @item Address Register Indirect
5870 @samp{a0@@} through @samp{a7@@}
5872 @item Address Register Postincrement
5873 @samp{a0@@+} through @samp{a7@@+}
5875 @item Address Register Predecrement
5876 @samp{a0@@-} through @samp{a7@@-}
5878 @item Indirect Plus Offset
5879 @samp{@var{apc}@@(@var{digits})}
5882 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5884 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
5887 @samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5889 or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
5892 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5894 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5896 @item Memory Indirect
5897 @samp{@var{apc}@@(@var{digits})@@(@var{digits})}
5900 @samp{@var{symbol}}, or @samp{@var{digits}}
5902 @c pesch@cygnus.com: gnu, rich concur the following needs careful
5903 @c research before documenting.
5904 , or either of the above followed
5905 by @samp{:b}, @samp{:w}, or @samp{:l}.
5909 For some configurations, especially those where the compiler normally
5910 does not prepend an underscore to the names of user variables, the
5911 assembler requires a @samp{%} before any use of a register name. This
5912 is intended to let the assembler distinguish between user variables and
5913 registers named @samp{a0} through @samp{a7}, and so on. The @samp{%} is
5914 always accepted, but is only required for some configurations, notably
5917 @node M68K-Moto-Syntax
5918 @section Motorola Syntax
5920 @cindex Motorola syntax for the 680x0
5921 @cindex alternate syntax for the 680x0
5923 The standard Motorola syntax for this chip differs from the syntax
5924 already discussed (@pxref{M68K-Syntax,,Syntax}). @code{@value{AS}} can
5925 accept both kinds of syntax, even within a single instruction. The
5926 two kinds of syntax are fully compatible.
5928 @c FIXME! I can't figure out what this means. Surely the "always" is in some
5929 @c restricted context, for instance. It's not necessary for the preceding text
5930 @c to explain this, so just ignore it for now; re-enable someday when someone
5931 @c has time to explain it better.
5932 , because the Motorola syntax never uses
5933 the @samp{@@} character and the @sc{mit} syntax always does, except in
5934 cases where the syntaxes are identical.
5937 @cindex M680x0 syntax
5938 @cindex syntax, M680x0
5939 In particular, you may write or generate M68K assembler with the
5940 following conventions:
5942 (In the following table @dfn{apc} stands for any of the address
5943 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
5944 Program Counter (@samp{pc}), or the zero-address relative to the
5945 program counter (@samp{zpc}).)
5947 @cindex M680x0 addressing modes
5948 @cindex addressing modes, M680x0
5949 The following additional addressing modes are understood:
5951 @item Address Register Indirect
5952 @samp{a0} through @samp{a7}@*
5953 @samp{a7} is also known as @samp{sp}, i.e. the Stack Pointer. @code{a6}
5954 is also known as @samp{fp}, the Frame Pointer.
5956 @item Address Register Postincrement
5957 @samp{(a0)+} through @samp{(a7)+}
5959 @item Address Register Predecrement
5960 @samp{-(a0)} through @samp{-(a7)}
5962 @item Indirect Plus Offset
5963 @samp{@var{digits}(@var{apc})}
5966 @samp{@var{digits}(@var{apc},(@var{register}.@var{size}*@var{scale})}@*
5967 or @samp{(@var{apc},@var{register}.@var{size}*@var{scale})}@*
5968 In either case, @var{size} and @var{scale} are optional
5969 (@var{scale} defaults to @samp{1}, @var{size} defaults to @samp{l}).
5970 @var{scale} can be @samp{1}, @samp{2}, @samp{4}, or @samp{8}.
5971 @var{size} can be @samp{w} or @samp{l}. @var{scale} is only supported
5972 on the 68020 and greater.
5976 @section Floating Point
5978 @cindex floating point, M680x0
5979 @cindex M680x0 floating point
5980 @c FIXME is this "not too well tested" crud STILL true?
5981 The floating point code is not too well tested, and may have
5984 Packed decimal (P) format floating literals are not supported.
5985 Feel free to add the code!
5987 The floating point formats generated by directives are these.
5991 @cindex @code{float} directive, M680x0
5992 @code{Single} precision floating point constants.
5995 @cindex @code{double} directive, M680x0
5996 @code{Double} precision floating point constants.
5999 There is no directive to produce regions of memory holding
6000 extended precision numbers, however they can be used as
6001 immediate operands to floating-point instructions. Adding a
6002 directive to create extended precision numbers would not be
6003 hard, but it has not yet seemed necessary.
6005 @node M68K-Directives
6006 @section 680x0 Machine Directives
6008 @cindex M680x0 directives
6009 @cindex directives, M680x0
6010 In order to be compatible with the Sun assembler the 680x0 assembler
6011 understands the following directives.
6015 @cindex @code{data1} directive, M680x0
6016 This directive is identical to a @code{.data 1} directive.
6019 @cindex @code{data2} directive, M680x0
6020 This directive is identical to a @code{.data 2} directive.
6023 @cindex @code{even} directive, M680x0
6024 This directive is identical to a @code{.align 1} directive.
6025 @c Is this true? does it work???
6028 @cindex @code{skip} directive, M680x0
6029 This directive is identical to a @code{.space} directive.
6036 @cindex M680x0 opcodes
6037 @cindex opcodes, M680x0
6038 @cindex instruction set, M680x0
6039 @c pesch@cygnus.com: I don't see any point in the following
6040 @c paragraph. Bugs are bugs; how does saying this
6043 Danger: Several bugs have been found in the opcode table (and
6044 fixed). More bugs may exist. Be careful when using obscure
6049 * M68K-Branch:: Branch Improvement
6050 * M68K-Chars:: Special Characters
6054 @subsection Branch Improvement
6056 @cindex pseudo-opcodes, M680x0
6057 @cindex M680x0 pseudo-opcodes
6058 @cindex branch improvement, M680x0
6059 @cindex M680x0 branch improvement
6060 Certain pseudo opcodes are permitted for branch instructions.
6061 They expand to the shortest branch instruction that reach the
6062 target. Generally these mnemonics are made by substituting @samp{j} for
6063 @samp{b} at the start of a Motorola mnemonic.
6065 The following table summarizes the pseudo-operations. A @code{*} flags
6066 cases that are more fully described after the table:
6070 +-------------------------------------------------
6072 Pseudo-Op |BYTE WORD LONG LONG non-PC relative
6073 +-------------------------------------------------
6074 jbsr |bsrs bsr bsrl jsr jsr
6075 jra |bras bra bral jmp jmp
6076 * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
6077 * dbXX |dbXX dbXX dbXX; bra; jmpl
6078 * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
6081 NX: negative of condition XX
6084 @center @code{*}---see full description below
6089 These are the simplest jump pseudo-operations; they always map to one
6090 particular machine instruction, depending on the displacement to the
6094 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
6095 where @var{XX} is a conditional branch or condition-code test. The full
6096 list of pseudo-ops in this family is:
6098 jhi jls jcc jcs jne jeq jvc
6099 jvs jpl jmi jge jlt jgt jle
6102 For the cases of non-PC relative displacements and long displacements on
6103 the 68000 or 68010, @code{@value{AS}} issues a longer code fragment in terms of
6104 @var{NX}, the opposite condition to @var{XX}. For example, for the
6105 non-PC relative case:
6117 The full family of pseudo-operations covered here is
6119 dbhi dbls dbcc dbcs dbne dbeq dbvc
6120 dbvs dbpl dbmi dbge dblt dbgt dble
6124 Other than for word and byte displacements, when the source reads
6125 @samp{db@var{XX} foo}, @code{@value{AS}} emits
6134 This family includes
6136 fjne fjeq fjge fjlt fjgt fjle fjf
6137 fjt fjgl fjgle fjnge fjngl fjngle fjngt
6138 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
6139 fjor fjseq fjsf fjsne fjst fjueq fjuge
6140 fjugt fjule fjult fjun
6143 For branch targets that are not PC relative, @code{@value{AS}} emits
6149 when it encounters @samp{fj@var{XX} foo}.
6154 @subsection Special Characters
6156 @cindex special characters, M680x0
6157 @cindex M680x0 immediate character
6158 @cindex immediate character, M680x0
6159 @cindex M680x0 line comment character
6160 @cindex line comment character, M680x0
6161 @cindex comments, M680x0
6162 The immediate character is @samp{#} for Sun compatibility. The
6163 line-comment character is @samp{|}. If a @samp{#} appears at the
6164 beginning of a line, it is treated as a comment unless it looks like
6165 @samp{# line file}, in which case it is treated normally.
6169 @c FIXME! Stop ignoring when filled in.
6174 The 32x32 version of @code{@value{AS}} accepts a @samp{-m32032} option to
6175 specify thiat it is compiling for a 32032 processor, or a
6176 @samp{-m32532} to specify that it is compiling for a 32532 option.
6177 The default (if neither is specified) is chosen when the assembler
6181 I don't know anything about the 32x32 syntax assembled by
6182 @code{@value{AS}}. Someone who undersands the processor (I've never seen
6183 one) and the possible syntaxes should write this section.
6185 @section Floating Point
6186 The 32x32 uses @sc{ieee} floating point numbers, but @code{@value{AS}}
6187 only creates single or double precision values. I don't know if the
6188 32x32 understands extended precision numbers.
6190 @section 32x32 Machine Directives
6191 The 32x32 has no machine dependent directives.
6197 @node Sparc-Dependent
6198 @chapter SPARC Dependent Features
6201 @node Machine Dependencies
6202 @chapter SPARC Dependent Features
6205 @cindex SPARC support
6207 * Sparc-Opts:: Options
6208 * Sparc-Float:: Floating Point
6209 * Sparc-Directives:: Sparc Machine Directives
6215 @cindex options for SPARC
6216 @cindex SPARC options
6217 @cindex architectures, SPARC
6218 @cindex SPARC architectures
6219 The SPARC chip family includes several successive levels (or other
6220 variants) of chip, using the same core instruction set, but including
6221 a few additional instructions at each level.
6223 By default, @code{@value{AS}} assumes the core instruction set (SPARC
6224 v6), but ``bumps'' the architecture level as needed: it switches to
6225 successively higher architectures as it encounters instructions that
6226 only exist in the higher levels.
6229 @item -Av6 | -Av7 | -Av8 | -Asparclite
6234 Use one of the @samp{-A} options to select one of the SPARC
6235 architectures explicitly. If you select an architecture explicitly,
6236 @code{@value{AS}} reports a fatal error if it encounters an instruction
6237 or feature requiring a higher level.
6240 Permit the assembler to ``bump'' the architecture level as required, but
6241 warn whenever it is necessary to switch to another level.
6245 @c FIXME: (sparc) Fill in "syntax" section!
6246 @c subsection syntax
6247 I don't know anything about Sparc syntax. Someone who does
6248 will have to write this section.
6252 @section Floating Point
6254 @cindex floating point, SPARC (@sc{ieee})
6255 @cindex SPARC floating point (@sc{ieee})
6256 The Sparc uses @sc{ieee} floating-point numbers.
6258 @node Sparc-Directives
6259 @section Sparc Machine Directives
6261 @cindex SPARC machine directives
6262 @cindex machine directives, SPARC
6263 The Sparc version of @code{@value{AS}} supports the following additional
6268 @cindex @code{common} directive, SPARC
6269 This must be followed by a symbol name, a positive number, and
6270 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
6271 syntax is different.
6274 @cindex @code{half} directive, SPARC
6275 This is functionally identical to @code{.short}.
6278 @cindex @code{proc} directive, SPARC
6279 This directive is ignored. Any text following it on the same
6280 line is also ignored.
6283 @cindex @code{reserve} directive, SPARC
6284 This must be followed by a symbol name, a positive number, and
6285 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
6286 syntax is different.
6289 @cindex @code{seg} directive, SPARC
6290 This must be followed by @code{"text"}, @code{"data"}, or
6291 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
6295 @cindex @code{skip} directive, SPARC
6296 This is functionally identical to the @code{.space} directive.
6299 @cindex @code{word} directive, SPARC
6300 On the Sparc, the .word directive produces 32 bit values,
6301 instead of the 16 bit values it produces on many other machines.
6308 @node i386-Dependent
6309 @chapter 80386 Dependent Features
6312 @node Machine Dependencies
6313 @chapter 80386 Dependent Features
6316 @cindex i386 support
6317 @cindex i80306 support
6319 * i386-Options:: Options
6320 * i386-Syntax:: AT&T Syntax versus Intel Syntax
6321 * i386-Opcodes:: Opcode Naming
6322 * i386-Regs:: Register Naming
6323 * i386-prefixes:: Opcode Prefixes
6324 * i386-Memory:: Memory References
6325 * i386-jumps:: Handling of Jump Instructions
6326 * i386-Float:: Floating Point
6327 * i386-Notes:: Notes
6333 @cindex options for i386 (none)
6334 @cindex i386 options (none)
6335 The 80386 has no machine dependent options.
6338 @section AT&T Syntax versus Intel Syntax
6340 @cindex i386 syntax compatibility
6341 @cindex syntax compatibility, i386
6342 In order to maintain compatibility with the output of @code{@value{GCC}},
6343 @code{@value{AS}} supports AT&T System V/386 assembler syntax. This is quite
6344 different from Intel syntax. We mention these differences because
6345 almost all 80386 documents used only Intel syntax. Notable differences
6346 between the two syntaxes are:
6350 @cindex immediate operands, i386
6351 @cindex i386 immediate operands
6352 @cindex register operands, i386
6353 @cindex i386 register operands
6354 @cindex jump/call operands, i386
6355 @cindex i386 jump/call operands
6356 @cindex operand delimiters, i386
6357 AT&T immediate operands are preceded by @samp{$}; Intel immediate
6358 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
6359 AT&T register operands are preceded by @samp{%}; Intel register operands
6360 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
6361 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
6364 @cindex i386 source, destination operands
6365 @cindex source, destination operands; i386
6366 AT&T and Intel syntax use the opposite order for source and destination
6367 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
6368 @samp{source, dest} convention is maintained for compatibility with
6369 previous Unix assemblers.
6372 @cindex opcode suffixes, i386
6373 @cindex sizes operands, i386
6374 @cindex i386 size suffixes
6375 In AT&T syntax the size of memory operands is determined from the last
6376 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
6377 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
6378 memory references. Intel syntax accomplishes this by prefixes memory
6379 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
6380 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
6381 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
6384 @cindex return instructions, i386
6385 @cindex i386 jump, call, return
6386 Immediate form long jumps and calls are
6387 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
6389 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
6391 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
6392 @samp{ret far @var{stack-adjust}}.
6395 @cindex sections, i386
6396 @cindex i386 sections
6397 The AT&T assembler does not provide support for multiple section
6398 programs. Unix style systems expect all programs to be single sections.
6402 @section Opcode Naming
6404 @cindex i386 opcode naming
6405 @cindex opcode naming, i386
6406 Opcode names are suffixed with one character modifiers which specify the
6407 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
6408 byte, word, and long operands. If no suffix is specified by an
6409 instruction and it contains no memory operands then @code{@value{AS}} tries to
6410 fill in the missing suffix based on the destination register operand
6411 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
6412 to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
6413 @samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
6414 assembler which assumes that a missing opcode suffix implies long
6415 operand size. (This incompatibility does not affect compiler output
6416 since compilers always explicitly specify the opcode suffix.)
6418 Almost all opcodes have the same names in AT&T and Intel format. There
6419 are a few exceptions. The sign extend and zero extend instructions need
6420 two sizes to specify them. They need a size to sign/zero extend
6421 @emph{from} and a size to zero extend @emph{to}. This is accomplished
6422 by using two opcode suffixes in AT&T syntax. Base names for sign extend
6423 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
6424 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
6425 suffixes are tacked on to this base name, the @emph{from} suffix before
6426 the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
6427 ``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
6428 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
6429 and @samp{wl} (from word to long).
6431 @cindex conversion instructions, i386
6432 @cindex i386 conversion instructions
6433 The Intel-syntax conversion instructions
6437 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
6440 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
6443 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
6446 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
6450 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
6451 AT&T naming. @code{@value{AS}} accepts either naming for these instructions.
6453 @cindex jump instructions, i386
6454 @cindex call instructions, i386
6455 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
6456 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
6460 @section Register Naming
6462 @cindex i386 registers
6463 @cindex registers, i386
6464 Register operands are always prefixes with @samp{%}. The 80386 registers
6469 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
6470 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
6471 frame pointer), and @samp{%esp} (the stack pointer).
6474 the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
6475 @samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
6478 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
6479 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
6480 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
6481 @samp{%cx}, and @samp{%dx})
6484 the 6 section registers @samp{%cs} (code section), @samp{%ds}
6485 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
6489 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
6493 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
6494 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
6497 the 2 test registers @samp{%tr6} and @samp{%tr7}.
6500 the 8 floating point register stack @samp{%st} or equivalently
6501 @samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
6502 @samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
6506 @section Opcode Prefixes
6508 @cindex i386 opcode prefixes
6509 @cindex opcode prefixes, i386
6510 @cindex prefixes, i386
6511 Opcode prefixes are used to modify the following opcode. They are used
6512 to repeat string instructions, to provide section overrides, to perform
6513 bus lock operations, and to give operand and address size (16-bit
6514 operands are specified in an instruction by prefixing what would
6515 normally be 32-bit operands with a ``operand size'' opcode prefix).
6516 Opcode prefixes are usually given as single-line instructions with no
6517 operands, and must directly precede the instruction they act upon. For
6518 example, the @samp{scas} (scan string) instruction is repeated with:
6524 Here is a list of opcode prefixes:
6528 @cindex section override prefixes, i386
6529 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
6530 @samp{fs}, @samp{gs}. These are automatically added by specifying
6531 using the @var{section}:@var{memory-operand} form for memory references.
6534 @cindex size prefixes, i386
6535 Operand/Address size prefixes @samp{data16} and @samp{addr16}
6536 change 32-bit operands/addresses into 16-bit operands/addresses. Note
6537 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
6538 are not supported (yet).
6541 @cindex bus lock prefixes, i386
6542 @cindex inhibiting interrupts, i386
6543 The bus lock prefix @samp{lock} inhibits interrupts during
6544 execution of the instruction it precedes. (This is only valid with
6545 certain instructions; see a 80386 manual for details).
6548 @cindex coprocessor wait, i386
6549 The wait for coprocessor prefix @samp{wait} waits for the
6550 coprocessor to complete the current instruction. This should never be
6551 needed for the 80386/80387 combination.
6554 @cindex repeat prefixes, i386
6555 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
6556 to string instructions to make them repeat @samp{%ecx} times.
6560 @section Memory References
6562 @cindex i386 memory references
6563 @cindex memory references, i386
6564 An Intel syntax indirect memory reference of the form
6567 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
6571 is translated into the AT&T syntax
6574 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
6578 where @var{base} and @var{index} are the optional 32-bit base and
6579 index registers, @var{disp} is the optional displacement, and
6580 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
6581 to calculate the address of the operand. If no @var{scale} is
6582 specified, @var{scale} is taken to be 1. @var{section} specifies the
6583 optional section register for the memory operand, and may override the
6584 default section register (see a 80386 manual for section register
6585 defaults). Note that section overrides in AT&T syntax @emph{must} have
6586 be preceded by a @samp{%}. If you specify a section override which
6587 coincides with the default section register, @code{@value{AS}} does @emph{not}
6588 output any section register override prefixes to assemble the given
6589 instruction. Thus, section overrides can be specified to emphasize which
6590 section register is used for a given memory operand.
6592 Here are some examples of Intel and AT&T style memory references:
6595 @item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
6596 @var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
6597 missing, and the default section is used (@samp{%ss} for addressing with
6598 @samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
6600 @item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
6601 @var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
6602 @samp{foo}. All other fields are missing. The section register here
6603 defaults to @samp{%ds}.
6605 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
6606 This uses the value pointed to by @samp{foo} as a memory operand.
6607 Note that @var{base} and @var{index} are both missing, but there is only
6608 @emph{one} @samp{,}. This is a syntactic exception.
6610 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
6611 This selects the contents of the variable @samp{foo} with section
6612 register @var{section} being @samp{%gs}.
6615 Absolute (as opposed to PC relative) call and jump operands must be
6616 prefixed with @samp{*}. If no @samp{*} is specified, @code{@value{AS}}
6617 always chooses PC relative addressing for jump/call labels.
6619 Any instruction that has a memory operand @emph{must} specify its size (byte,
6620 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
6624 @section Handling of Jump Instructions
6626 @cindex jump optimization, i386
6627 @cindex i386 jump optimization
6628 Jump instructions are always optimized to use the smallest possible
6629 displacements. This is accomplished by using byte (8-bit) displacement
6630 jumps whenever the target is sufficiently close. If a byte displacement
6631 is insufficient a long (32-bit) displacement is used. We do not support
6632 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
6633 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
6634 @samp{%eip} to 16 bits after the word displacement is added.
6636 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
6637 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in byte
6638 displacements, so that if you use these instructions (@code{@value{GCC}} does
6639 not use them) you may get an error message (and incorrect code). The AT&T
6640 80386 assembler tries to get around this problem by expanding @samp{jcxz foo}
6651 @section Floating Point
6653 @cindex i386 floating point
6654 @cindex floating point, i386
6655 All 80387 floating point types except packed BCD are supported.
6656 (BCD support may be added without much difficulty). These data
6657 types are 16-, 32-, and 64- bit integers, and single (32-bit),
6658 double (64-bit), and extended (80-bit) precision floating point.
6659 Each supported type has an opcode suffix and a constructor
6660 associated with it. Opcode suffixes specify operand's data
6661 types. Constructors build these data types into memory.
6665 @cindex @code{float} directive, i386
6666 @cindex @code{single} directive, i386
6667 @cindex @code{double} directive, i386
6668 @cindex @code{tfloat} directive, i386
6669 Floating point constructors are @samp{.float} or @samp{.single},
6670 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
6671 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
6672 @samp{t} stands for temporary real, and that the 80387 only supports
6673 this format via the @samp{fldt} (load temporary real to stack top) and
6674 @samp{fstpt} (store temporary real and pop stack) instructions.
6677 @cindex @code{word} directive, i386
6678 @cindex @code{long} directive, i386
6679 @cindex @code{int} directive, i386
6680 @cindex @code{quad} directive, i386
6681 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
6682 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
6683 opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
6684 (quad). As with the temporary real format the 64-bit @samp{q} format is
6685 only present in the @samp{fildq} (load quad integer to stack top) and
6686 @samp{fistpq} (store quad integer and pop stack) instructions.
6689 Register to register operations do not require opcode suffixes,
6690 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
6692 @cindex i386 @code{fwait} instruction
6693 @cindex @code{fwait instruction}, i386
6694 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
6695 instructions are almost never needed (this is not the case for the
6696 80286/80287 and 8086/8087 combinations). Therefore, @code{@value{AS}} suppresses
6697 the @samp{fwait} instruction whenever it is implicitly selected by one
6698 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
6699 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
6700 instructions are made equivalent to @samp{f@dots{}} instructions. If
6701 @samp{fwait} is desired it must be explicitly coded.
6706 @cindex i386 @code{mul}, @code{imul} instructions
6707 @cindex @code{mul} instruction, i386
6708 @cindex @code{imul} instruction, i386
6709 There is some trickery concerning the @samp{mul} and @samp{imul}
6710 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
6711 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
6712 for @samp{imul}) can be output only in the one operand form. Thus,
6713 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
6714 the expanding multiply would clobber the @samp{%edx} register, and this
6715 would confuse @code{@value{GCC}} output. Use @samp{imul %ebx} to get the
6716 64-bit product in @samp{%edx:%eax}.
6718 We have added a two operand form of @samp{imul} when the first operand
6719 is an immediate mode expression and the second operand is a register.
6720 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
6721 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
6728 @node Z8000-Dependent
6729 @chapter Z8000 Dependent Features
6732 @node Machine Dependencies
6733 @chapter Z8000 Dependent Features
6736 @cindex Z8000 support
6737 The Z8000 @value{AS} supports both members of the Z8000 family: the
6738 unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with
6741 When the assembler is in unsegmented mode (specified with the
6742 @code{unsegm} directive), an address takes up one word (16 bit)
6743 sized register. When the assembler is in segmented mode (specified with
6744 the @code{segm} directive), a 24-bit address takes up a long (32 bit)
6745 register. @xref{Z8000 Directives,,Assembler Directives for the Z8000},
6746 for a list of other Z8000 specific assembler directives.
6749 * Z8000 Options:: No special command-line options for Z8000
6750 * Z8000 Syntax:: Assembler syntax for the Z8000
6751 * Z8000 Directives:: Special directives for the Z8000
6752 * Z8000 Opcodes:: Opcodes
6758 @cindex Z8000 options
6759 @cindex options, Z8000
6760 @code{@value{AS}} has no additional command-line options for the Zilog
6766 * Z8000-Chars:: Special Characters
6767 * Z8000-Regs:: Register Names
6768 * Z8000-Addressing:: Addressing Modes
6772 @subsection Special Characters
6774 @cindex line comment character, Z8000
6775 @cindex Z8000 line comment character
6776 @samp{!} is the line comment character.
6778 @cindex line separator, Z8000
6779 @cindex statement separator, Z8000
6780 @cindex Z8000 line separator
6781 You can use @samp{;} instead of a newline to separate statements.
6784 @subsection Register Names
6786 @cindex Z8000 registers
6787 @cindex registers, Z8000
6788 The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer
6789 to different sized groups of registers by register number, with the
6790 prefix @samp{r} for 16 bit registers, @samp{rr} for 32 bit registers and
6791 @samp{rq} for 64 bit registers. You can also refer to the contents of
6792 the first eight (of the sixteen 16 bit registers) by bytes. They are
6793 named @samp{r@var{n}h} and @samp{r@var{n}l}.
6796 @exdent @emph{byte registers}
6797 r0l r0h r1h r1l r2h r2l r3h r3l
6798 r4h r4l r5h r5l r6h r6l r7h r7l
6800 @exdent @emph{word registers}
6801 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
6803 @exdent @emph{long word registers}
6804 rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14
6806 @exdent @emph{quad word registers}
6810 @node Z8000-Addressing
6811 @subsection Addressing Modes
6813 @cindex addressing modes, Z8000
6814 @cindex Z800 addressing modes
6815 @value{AS} understands the following addressing modes for the Z8000:
6825 Direct: the 16 bit or 24 bit address (depending on whether the assembler
6826 is in segmented or unsegmented mode) of the operand is in the instruction.
6828 @item address(r@var{n})
6829 Indexed: the 16 or 24 bit address is added to the 16 bit register to produce
6830 the final address in memory of the operand.
6832 @item r@var{n}(#@var{imm})
6833 Base Address: the 16 or 24 bit register is added to the 16 bit sign
6834 extended immediate displacement to produce the final address in memory
6837 @item r@var{n}(r@var{m})
6838 Base Index: the 16 or 24 bit register r@var{n} is added to the sign
6839 extended 16 bit index register r@var{m} to produce the final address in
6840 memory of the operand.
6843 Immediate data @var{xx}.
6846 @node Z8000 Directives
6847 @section Assembler Directives for the Z8000
6849 @cindex Z8000 directives
6850 @cindex directives, Z8000
6851 The Z8000 port of @value{AS} includes these additional assembler directives,
6852 for compatibility with other Z8000 assemblers. As shown, these do not
6853 begin with @samp{.} (unlike the ordinary @value{AS} directives).
6858 Generates code for the segmented Z8001.
6862 Generates code for the unsegmented Z8002.
6866 Synonym for @code{.file}
6870 Synonum for @code{.global}
6874 Synonym for @code{.word}
6878 Synonym for @code{.long}
6882 Synonym for @code{.byte}
6886 Assemble a string. @code{sval} expects one string literal, delimited by
6887 single quotes. It assembles each byte of the string into consecutive
6888 addresses. You can use the escape sequence @samp{%@var{xx}} (where
6889 @var{xx} represents a two-digit hexadecimal number) to represent the
6890 character whose @sc{ascii} value is @var{xx}. Use this feature to
6891 describe single quote and other characters that may not appear in string
6892 literals as themselves. For example, the C statement @w{@samp{char *a =
6893 "he said \"it's 50% off\"";}} is represented in Z8000 assembly language
6894 (shown with the assembler output in hex at the left) as
6898 @let@nonarrowing=@comment
6901 68652073 sval 'he said %22it%27s 50%25 off%22%00'
6914 synonym for @code{.section}
6918 synonym for @code{.space}
6922 synonym for @code{.align 1}
6928 @cindex Z8000 opcode summary
6929 @cindex opcode summary, Z8000
6930 @cindex mnemonics, Z8000
6931 @cindex instruction summary, Z8000
6932 For detailed information on the Z8000 machine instruction set, see
6933 @cite{Z8000 Technical Manual}.
6936 @c this table, due to the multi-col faking and hardcoded order, looks silly
6937 @c except in smallbook. See comments below "@set SMALL" near top of this file.
6939 The following table summarizes the opcodes and their arguments:
6942 @let@nonarrowing=@comment
6946 rs @r{16 bit source register}
6947 rd @r{16 bit destination register}
6948 rbs @r{8 bit source register}
6949 rbd @r{8 bit destination register}
6950 rrs @r{32 bit source register}
6951 rrd @r{32 bit destination register}
6952 rqs @r{64 bit source register}
6953 rqd @r{64 bit destination register}
6954 addr @r{16/24 bit address}
6955 imm @r{immediate data}
6957 adc rd,rs clrb addr cpsir @@rd,@@rs,rr,cc
6958 adcb rbd,rbs clrb addr(rd) cpsirb @@rd,@@rs,rr,cc
6959 add rd,@@rs clrb rbd dab rbd
6960 add rd,addr com @@rd dbjnz rbd,disp7
6961 add rd,addr(rs) com addr dec @@rd,imm4m1
6962 add rd,imm16 com addr(rd) dec addr(rd),imm4m1
6963 add rd,rs com rd dec addr,imm4m1
6964 addb rbd,@@rs comb @@rd dec rd,imm4m1
6965 addb rbd,addr comb addr decb @@rd,imm4m1
6966 addb rbd,addr(rs) comb addr(rd) decb addr(rd),imm4m1
6967 addb rbd,imm8 comb rbd decb addr,imm4m1
6968 addb rbd,rbs comflg flags decb rbd,imm4m1
6969 addl rrd,@@rs cp @@rd,imm16 di i2
6970 addl rrd,addr cp addr(rd),imm16 div rrd,@@rs
6971 addl rrd,addr(rs) cp addr,imm16 div rrd,addr
6972 addl rrd,imm32 cp rd,@@rs div rrd,addr(rs)
6973 addl rrd,rrs cp rd,addr div rrd,imm16
6974 and rd,@@rs cp rd,addr(rs) div rrd,rs
6975 and rd,addr cp rd,imm16 divl rqd,@@rs
6976 and rd,addr(rs) cp rd,rs divl rqd,addr
6977 and rd,imm16 cpb @@rd,imm8 divl rqd,addr(rs)
6978 and rd,rs cpb addr(rd),imm8 divl rqd,imm32
6979 andb rbd,@@rs cpb addr,imm8 divl rqd,rrs
6980 andb rbd,addr cpb rbd,@@rs djnz rd,disp7
6981 andb rbd,addr(rs) cpb rbd,addr ei i2
6982 andb rbd,imm8 cpb rbd,addr(rs) ex rd,@@rs
6983 andb rbd,rbs cpb rbd,imm8 ex rd,addr
6984 bit @@rd,imm4 cpb rbd,rbs ex rd,addr(rs)
6985 bit addr(rd),imm4 cpd rd,@@rs,rr,cc ex rd,rs
6986 bit addr,imm4 cpdb rbd,@@rs,rr,cc exb rbd,@@rs
6987 bit rd,imm4 cpdr rd,@@rs,rr,cc exb rbd,addr
6988 bit rd,rs cpdrb rbd,@@rs,rr,cc exb rbd,addr(rs)
6989 bitb @@rd,imm4 cpi rd,@@rs,rr,cc exb rbd,rbs
6990 bitb addr(rd),imm4 cpib rbd,@@rs,rr,cc ext0e imm8
6991 bitb addr,imm4 cpir rd,@@rs,rr,cc ext0f imm8
6992 bitb rbd,imm4 cpirb rbd,@@rs,rr,cc ext8e imm8
6993 bitb rbd,rs cpl rrd,@@rs ext8f imm8
6994 bpt cpl rrd,addr exts rrd
6995 call @@rd cpl rrd,addr(rs) extsb rd
6996 call addr cpl rrd,imm32 extsl rqd
6997 call addr(rd) cpl rrd,rrs halt
6998 calr disp12 cpsd @@rd,@@rs,rr,cc in rd,@@rs
6999 clr @@rd cpsdb @@rd,@@rs,rr,cc in rd,imm16
7000 clr addr cpsdr @@rd,@@rs,rr,cc inb rbd,@@rs
7001 clr addr(rd) cpsdrb @@rd,@@rs,rr,cc inb rbd,imm16
7002 clr rd cpsi @@rd,@@rs,rr,cc inc @@rd,imm4m1
7003 clrb @@rd cpsib @@rd,@@rs,rr,cc inc addr(rd),imm4m1
7004 inc addr,imm4m1 ldb rbd,rs(rx) mult rrd,addr(rs)
7005 inc rd,imm4m1 ldb rd(imm16),rbs mult rrd,imm16
7006 incb @@rd,imm4m1 ldb rd(rx),rbs mult rrd,rs
7007 incb addr(rd),imm4m1 ldctl ctrl,rs multl rqd,@@rs
7008 incb addr,imm4m1 ldctl rd,ctrl multl rqd,addr
7009 incb rbd,imm4m1 ldd @@rs,@@rd,rr multl rqd,addr(rs)
7010 ind @@rd,@@rs,ra lddb @@rs,@@rd,rr multl rqd,imm32
7011 indb @@rd,@@rs,rba lddr @@rs,@@rd,rr multl rqd,rrs
7012 inib @@rd,@@rs,ra lddrb @@rs,@@rd,rr neg @@rd
7013 inibr @@rd,@@rs,ra ldi @@rd,@@rs,rr neg addr
7014 iret ldib @@rd,@@rs,rr neg addr(rd)
7015 jp cc,@@rd ldir @@rd,@@rs,rr neg rd
7016 jp cc,addr ldirb @@rd,@@rs,rr negb @@rd
7017 jp cc,addr(rd) ldk rd,imm4 negb addr
7018 jr cc,disp8 ldl @@rd,rrs negb addr(rd)
7019 ld @@rd,imm16 ldl addr(rd),rrs negb rbd
7020 ld @@rd,rs ldl addr,rrs nop
7021 ld addr(rd),imm16 ldl rd(imm16),rrs or rd,@@rs
7022 ld addr(rd),rs ldl rd(rx),rrs or rd,addr
7023 ld addr,imm16 ldl rrd,@@rs or rd,addr(rs)
7024 ld addr,rs ldl rrd,addr or rd,imm16
7025 ld rd(imm16),rs ldl rrd,addr(rs) or rd,rs
7026 ld rd(rx),rs ldl rrd,imm32 orb rbd,@@rs
7027 ld rd,@@rs ldl rrd,rrs orb rbd,addr
7028 ld rd,addr ldl rrd,rs(imm16) orb rbd,addr(rs)
7029 ld rd,addr(rs) ldl rrd,rs(rx) orb rbd,imm8
7030 ld rd,imm16 ldm @@rd,rs,n orb rbd,rbs
7031 ld rd,rs ldm addr(rd),rs,n out @@rd,rs
7032 ld rd,rs(imm16) ldm addr,rs,n out imm16,rs
7033 ld rd,rs(rx) ldm rd,@@rs,n outb @@rd,rbs
7034 lda rd,addr ldm rd,addr(rs),n outb imm16,rbs
7035 lda rd,addr(rs) ldm rd,addr,n outd @@rd,@@rs,ra
7036 lda rd,rs(imm16) ldps @@rs outdb @@rd,@@rs,rba
7037 lda rd,rs(rx) ldps addr outib @@rd,@@rs,ra
7038 ldar rd,disp16 ldps addr(rs) outibr @@rd,@@rs,ra
7039 ldb @@rd,imm8 ldr disp16,rs pop @@rd,@@rs
7040 ldb @@rd,rbs ldr rd,disp16 pop addr(rd),@@rs
7041 ldb addr(rd),imm8 ldrb disp16,rbs pop addr,@@rs
7042 ldb addr(rd),rbs ldrb rbd,disp16 pop rd,@@rs
7043 ldb addr,imm8 ldrl disp16,rrs popl @@rd,@@rs
7044 ldb addr,rbs ldrl rrd,disp16 popl addr(rd),@@rs
7045 ldb rbd,@@rs mbit popl addr,@@rs
7046 ldb rbd,addr mreq rd popl rrd,@@rs
7047 ldb rbd,addr(rs) mres push @@rd,@@rs
7048 ldb rbd,imm8 mset push @@rd,addr
7049 ldb rbd,rbs mult rrd,@@rs push @@rd,addr(rs)
7050 ldb rbd,rs(imm16) mult rrd,addr push @@rd,imm16
7051 push @@rd,rs set addr,imm4 subl rrd,imm32
7052 pushl @@rd,@@rs set rd,imm4 subl rrd,rrs
7053 pushl @@rd,addr set rd,rs tcc cc,rd
7054 pushl @@rd,addr(rs) setb @@rd,imm4 tccb cc,rbd
7055 pushl @@rd,rrs setb addr(rd),imm4 test @@rd
7056 res @@rd,imm4 setb addr,imm4 test addr
7057 res addr(rd),imm4 setb rbd,imm4 test addr(rd)
7058 res addr,imm4 setb rbd,rs test rd
7059 res rd,imm4 setflg imm4 testb @@rd
7060 res rd,rs sinb rbd,imm16 testb addr
7061 resb @@rd,imm4 sinb rd,imm16 testb addr(rd)
7062 resb addr(rd),imm4 sind @@rd,@@rs,ra testb rbd
7063 resb addr,imm4 sindb @@rd,@@rs,rba testl @@rd
7064 resb rbd,imm4 sinib @@rd,@@rs,ra testl addr
7065 resb rbd,rs sinibr @@rd,@@rs,ra testl addr(rd)
7066 resflg imm4 sla rd,imm8 testl rrd
7067 ret cc slab rbd,imm8 trdb @@rd,@@rs,rba
7068 rl rd,imm1or2 slal rrd,imm8 trdrb @@rd,@@rs,rba
7069 rlb rbd,imm1or2 sll rd,imm8 trib @@rd,@@rs,rbr
7070 rlc rd,imm1or2 sllb rbd,imm8 trirb @@rd,@@rs,rbr
7071 rlcb rbd,imm1or2 slll rrd,imm8 trtdrb @@ra,@@rb,rbr
7072 rldb rbb,rba sout imm16,rs trtib @@ra,@@rb,rr
7073 rr rd,imm1or2 soutb imm16,rbs trtirb @@ra,@@rb,rbr
7074 rrb rbd,imm1or2 soutd @@rd,@@rs,ra trtrb @@ra,@@rb,rbr
7075 rrc rd,imm1or2 soutdb @@rd,@@rs,rba tset @@rd
7076 rrcb rbd,imm1or2 soutib @@rd,@@rs,ra tset addr
7077 rrdb rbb,rba soutibr @@rd,@@rs,ra tset addr(rd)
7078 rsvd36 sra rd,imm8 tset rd
7079 rsvd38 srab rbd,imm8 tsetb @@rd
7080 rsvd78 sral rrd,imm8 tsetb addr
7081 rsvd7e srl rd,imm8 tsetb addr(rd)
7082 rsvd9d srlb rbd,imm8 tsetb rbd
7083 rsvd9f srll rrd,imm8 xor rd,@@rs
7084 rsvdb9 sub rd,@@rs xor rd,addr
7085 rsvdbf sub rd,addr xor rd,addr(rs)
7086 sbc rd,rs sub rd,addr(rs) xor rd,imm16
7087 sbcb rbd,rbs sub rd,imm16 xor rd,rs
7088 sc imm8 sub rd,rs xorb rbd,@@rs
7089 sda rd,rs subb rbd,@@rs xorb rbd,addr
7090 sdab rbd,rs subb rbd,addr xorb rbd,addr(rs)
7091 sdal rrd,rs subb rbd,addr(rs) xorb rbd,imm8
7092 sdl rd,rs subb rbd,imm8 xorb rbd,rbs
7093 sdlb rbd,rs subb rbd,rbs xorb rbd,rbs
7094 sdll rrd,rs subl rrd,@@rs
7095 set @@rd,imm4 subl rrd,addr
7096 set addr(rd),imm4 subl rrd,addr(rs)
7108 @node MIPS-Dependent
7109 @chapter MIPS Dependent Features
7112 @node Machine Dependencies
7113 @chapter MIPS Dependent Features
7115 The MIPS @value{AS} supports the MIPS R2000 and R3000 processors.
7117 It ignores the @samp{-nocpp} option.
7119 Not all traditional MIPS macro instructions are currently supported.
7120 Specifically, @code{li.d} and @code{li.s} are not currently supported.
7122 Assembling for a MIPS ECOFF target supports some additional sections
7123 besides the usual @code{.text}, @code{.data} and @code{.bss}. The
7124 additional sections are @code{.rdata}, used for read-only data,
7125 @code{.sdata}, used for small data, and @code{.sbss}, used for small
7128 When assembling for ECOFF, the assembler automatically uses the @code{$gp}
7129 (@code{$28}) register when forming the address of a small object. Any object
7130 in the @code{.sdata} or @code{.sbss} sections is considered ``small''. For
7131 external objects or objects in the @code{.bss} section, you may use the
7132 @samp{-G} option to control the size of objects for which the @code{$gp}
7133 register is used; the default value is 8, meaning that a reference to any
7134 object eight bytes or smaller uses @code{$gp}. Passing @samp{-G 0} to
7135 @value{AS} prevents it from using the @code{$gp} register at all. The size of
7136 an object in the @code{.bss} section is set by the @code{.comm} or
7137 @code{.lcomm} directive that defines it. The size of an external object may be
7138 set using the @code{.extern} directive. For example, @samp{.extern sym,4}
7139 declares that the object at @code{sym} is 4 bytes in length, while leaving
7140 @code{sym} otherwise undefined.
7142 Using small ECOFF objects requires linker support, and assumes that the
7143 @code{$gp} register was initialized correctly (normally done automatically
7144 by the startup code). MIPS ECOFF assembly code must avoid modifying the
7145 @code{$gp} register.
7147 MIPS ECOFF @code{@value{AS}} supports several directives used for generating
7148 debugging information which are not support by traditional MIPS
7149 assemblers. These are @code{.def}, @code{.endef}, @code{.dim},
7150 @code{.file}, @code{.scl}, @code{.size}, @code{.tag}, @code{.type},
7151 @code{.val}, @code{.stabd}, @code{.stabn}, and @code{.stabs}. The
7152 debugging information generated by the three @code{.stab} directives can
7153 only be read by GDB, not by traditional MIPS debuggers (this enhancement
7154 is required to fully support C++ debugging). These directives are
7155 primarily used by compilers, not assembly language programmers, and are
7156 described elsewhere in this manual.
7160 @c reverse effect of @down at top of generic Machine-Dep chapter
7164 @node Acknowledgements
7165 @chapter Acknowledgements
7167 If you have contributed to @code{@value{AS}} and your name isn't listed here,
7168 it is not meant as a slight. We just don't know about it. Send mail to the
7169 maintainer, and we'll correct the situation. Currently (January 1994), the
7170 maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
7172 Dean Elsner wrote the original GNU assembler for the VAX.@footnote{Any more
7175 Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug
7176 information and the 68k series machines, most of the preprocessing pass, and
7177 extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}.
7179 K. Richard Pixley maintained GAS for a while, adding various enhancements and
7180 many bug fixes, including merging support for several processors, breaking GAS
7181 up to handle multiple object file format back ends (including heavy rewrite,
7182 testing, an integration of the coff and b.out back ends), adding configuration
7183 including heavy testing and verification of cross assemblers and file splits
7184 and renaming, converted GAS to strictly ANSI C including full prototypes, added
7185 support for m680[34]0 and cpu32, did considerable work on i960 including a COFF
7186 port (including considerable amounts of reverse engineering), a SPARC opcode
7187 file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know''
7188 assertions and made them work, much other reorganization, cleanup, and lint.
7190 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
7191 in format-specific I/O modules.
7193 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
7194 has done much work with it since.
7196 The Intel 80386 machine description was written by Eliot Dresselhaus.
7198 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
7200 The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
7201 University and Torbjorn Granlund of the Swedish Institute of Computer Science.
7203 Keith Knowles at the Open Software Foundation wrote the original MIPS back end
7204 (@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support
7205 (which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to
7206 support a.out format.
7208 Support for the Zilog Z8k and Hitachi H8/300 and H8/500 processors (tc-z8k,
7209 tc-h8300, tc-h8500), and IEEE 695 object file format (obj-ieee), was written by
7210 Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
7211 use BFD for some low-level operations, for use with the H8/300 and AMD 29k
7214 John Gilmore built the AMD 29000 support, added @code{.include} support, and
7215 simplified the configuration of which versions accept which directives. He
7216 updated the 68k machine description so that Motorola's opcodes always produced
7217 fixed-size instructions (e.g. @code{jsr}), while synthetic instructions
7218 remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested
7219 cross-compilation support, and one bug in relaxation that took a week and
7220 required the proverbial one-bit fix.
7222 Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the
7223 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
7224 and made a few other minor patches.
7226 Steve Chamberlain made @code{@value{AS}} able to generate listings.
7228 Hewlett-Packard contributed support for the HP9000/300.
7230 Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM)
7231 along with a fairly extensive HPPA testsuite (for both SOM and ELF object
7232 formats). This work was supported by both the Center for Software Science at
7233 the University of Utah and Cygnus Support.
7235 Support for ELF format files has been worked on by Mark Eichin of Cygnus
7236 Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
7237 Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
7238 Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
7239 and some initial 64-bit support).
7241 Several engineers at Cygnus Support have also provided many small bug fixes and
7242 configuration enhancements.
7244 Many others have contributed large or small bugfixes and enhancements. If
7245 you have contributed significant work and are not mentioned on this list, and
7246 want to be, let us know. Some of the history has been lost; we are not
7247 intentionally leaving anyone out.