* doc/{all.texi,as.texinfo}: Add documentation for HPPA port.
[binutils-gdb.git] / gas / doc / as.texinfo
1 \input texinfo @c -*-Texinfo-*-
2 @c Copyright (c) 1991 1992 1993 Free Software Foundation, Inc.
3 @c %**start of header
4 @setfilename as.info
5 @c ---config---
6 @c defaults, config file may override:
7 @set have-stabs
8 @c ---
9 @include asdoc-config.texi
10 @c ---
11 @c common OR combinations of conditions
12 @ifset AOUT
13 @set aout-bout
14 @end ifset
15 @ifset BOUT
16 @set aout-bout
17 @end ifset
18 @ifset H8/300
19 @set H8
20 @end ifset
21 @ifset H8/500
22 @set H8
23 @end ifset
24 @ifset SH
25 @set H8
26 @end ifset
27 @ifset HPPA
28 @set abnormal-separator
29 @end ifset
30 @c ------------
31 @ifset GENERIC
32 @settitle Using @value{AS}
33 @end ifset
34 @ifclear GENERIC
35 @settitle Using @value{AS} (@value{TARGET})
36 @end ifclear
37 @setchapternewpage odd
38 @c %**end of header
39
40 @ifinfo
41 @format
42 START-INFO-DIR-ENTRY
43 * As:: The GNU assembler.
44 END-INFO-DIR-ENTRY
45 @end format
46 @end ifinfo
47
48 @finalout
49 @syncodeindex ky cp
50
51 @ifinfo
52 This file documents the GNU Assembler "@value{AS}".
53
54 Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
55
56 Permission is granted to make and distribute verbatim copies of
57 this manual provided the copyright notice and this permission notice
58 are preserved on all copies.
59
60 @ignore
61 Permission is granted to process this file through Tex and print the
62 results, provided the printed document carries copying permission
63 notice identical to this one except for the removal of this paragraph
64 (this paragraph not being relevant to the printed manual).
65
66 @end ignore
67 Permission is granted to copy and distribute modified versions of this
68 manual under the conditions for verbatim copying, provided also that the
69 section entitled ``GNU General Public License'' is included exactly as
70 in the original, and provided that the entire resulting derived work is
71 distributed under the terms of a permission notice identical to this
72 one.
73
74 Permission is granted to copy and distribute translations of this manual
75 into another language, under the above conditions for modified versions,
76 except that the section entitled ``GNU General Public License'' may be
77 included in a translation approved by the Free Software Foundation
78 instead of in the original English.
79 @end ifinfo
80
81 @titlepage
82 @title Using @value{AS}
83 @subtitle The GNU Assembler
84 @ifclear GENERIC
85 @subtitle for the @value{TARGET} family
86 @end ifclear
87 @sp 1
88 @subtitle March 1993
89 @sp 1
90 @sp 13
91 The Free Software Foundation Inc. thanks The Nice Computer
92 Company of Australia for loaning Dean Elsner to write the
93 first (Vax) version of @code{as} for Project GNU.
94 The proprietors, management and staff of TNCCA thank FSF for
95 distracting the boss while they got some work
96 done.
97 @sp 3
98 @author Dean Elsner, Jay Fenlason & friends
99 @page
100 @tex
101 {\parskip=0pt
102 \hfill {\it Using {\tt @value{AS}}}\par
103 \hfill Edited by Roland Pesch for Cygnus Support\par
104 }
105 %"boxit" macro for figures:
106 %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
107 \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
108 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
109 #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
110 \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
111 @end tex
112
113 @vskip 0pt plus 1filll
114 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
115
116 Permission is granted to make and distribute verbatim copies of
117 this manual provided the copyright notice and this permission notice
118 are preserved on all copies.
119
120 Permission is granted to copy and distribute modified versions of this
121 manual under the conditions for verbatim copying, provided also that the
122 section entitled ``GNU General Public License'' is included exactly as
123 in the original, and provided that the entire resulting derived work is
124 distributed under the terms of a permission notice identical to this
125 one.
126
127 Permission is granted to copy and distribute translations of this manual
128 into another language, under the above conditions for modified versions,
129 except that the section entitled ``GNU General Public License'' may be
130 included in a translation approved by the Free Software Foundation
131 instead of in the original English.
132 @end titlepage
133
134 @ifinfo
135 @node Top
136 @top Using @value{AS}
137
138 This file is a user guide to the GNU assembler @code{@value{AS}}.
139 @ifclear GENERIC
140 This version of the file describes @code{@value{AS}} configured to generate
141 code for @value{TARGET} architectures.
142 @end ifclear
143 @menu
144 * Overview:: Overview
145 * Invoking:: Command-Line Options
146 * Syntax:: Syntax
147 * Sections:: Sections and Relocation
148 * Symbols:: Symbols
149 * Expressions:: Expressions
150 * Pseudo Ops:: Assembler Directives
151 * Machine Dependencies:: Machine Dependent Features
152 @ifset GENERIC
153 * Copying:: GNU GENERAL PUBLIC LICENSE
154 @end ifset
155
156 * Acknowledgements:: Who Did What
157
158 * Index:: Index
159 @end menu
160 @end ifinfo
161
162 @node Overview
163 @chapter Overview
164 @iftex
165 This manual is a user guide to the GNU assembler @code{@value{AS}}.
166 @ifclear GENERIC
167 This version of the manual describes @code{@value{AS}} configured to generate
168 code for @value{TARGET} architectures.
169 @end ifclear
170 @end iftex
171
172 @cindex invocation summary
173 @cindex option summary
174 @cindex summary of options
175 Here is a brief summary of how to invoke @code{@value{AS}}. For details,
176 @pxref{Invoking,,Comand-Line Options}.
177
178 @c We don't use deffn and friends for the following because they seem
179 @c to be limited to one line for the header.
180 @smallexample
181 @value{AS} [ -a[dhlns] ] [ -D ] [ -f ]
182 [ -I @var{path} ] [ -K ] [ -L ]
183 [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ]
184 @ifset A29K
185 @c am29k has no machine-dependent assembler options
186 @end ifset
187 @ifset H8
188 @c Hitachi family chips have no machine-dependent assembler options
189 @end ifset
190 @ifset HPPA
191 @c HPPA has no machine-dependent assembler options (yet).
192 @end ifset
193 @ifset SPARC
194 [ -Av6 | -Av7 | -Av8 | -Asparclite | -bump ]
195 @end ifset
196 @ifset Z8000
197 @c Z8000 has no machine-dependent assembler options
198 @end ifset
199 @ifset I960
200 @c see md_parse_option in tc-i960.c
201 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
202 [ -b ] [ -norelax ]
203 @end ifset
204 @ifset M680X0
205 [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
206 @end ifset
207 @ifset MIPS
208 [ -nocpp ] [ -EL ] [ -EB ] [ -G @var{num} ]
209 @end ifset
210 [ -- | @var{files} @dots{} ]
211 @end smallexample
212
213 @table @code
214 @item -a[dhlns]
215 Turn on listings;
216 @samp{-ad}, omit debugging pseudo-ops from listing,
217 @samp{-ah}, include high-level source,
218 @samp{-al}, assembly listing,
219 @samp{-an}, no forms processing,
220 @samp{-as}, symbols.
221 These options may be combined; @emph{e.g.}, @samp{-aln} for assembly
222 listing without forms processing. By itself, @samp{-a} defaults to
223 @samp{-ahls} --- that is, all listings turned on.
224
225 @item -D
226 This option is accepted only for script compatibility with calls to
227 other assemblers; it has no effect on @code{@value{AS}}.
228
229 @item -f
230 ``fast''---skip whitespace and comment preprocessing (assume source is
231 compiler output)
232
233 @item -I @var{path}
234 Add @var{path} to the search list for @code{.include} directives
235
236 @item -K
237 @ifclear DIFF-TBL-KLUGE
238 This option is accepted but has no effect on the @value{TARGET} family.
239 @end ifclear
240 @ifset DIFF-TBL-KLUGE
241 Issue warnings when difference tables altered for long displacements.
242 @end ifset
243
244 @item -L
245 Keep (in symbol table) local symbols, starting with @samp{L}
246
247 @item -o @var{objfile}
248 Name the object-file output from @code{@value{AS}}
249
250 @item -R
251 Fold data section into text section
252
253 @item -v
254 Announce @code{as} version
255
256 @item -W
257 Suppress warning messages
258
259 @item -- | @var{files} @dots{}
260 Standard input, or source files to assemble.
261
262 @end table
263
264 @ifset I960
265 The following options are available when @value{AS} is configured for the
266 Intel 80960 processor.
267
268 @table @code
269 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
270 Specify which variant of the 960 architecture is the target.
271
272 @item -b
273 Add code to collect statistics about branches taken.
274
275 @item -norelax
276 Do not alter compare-and-branch instructions for long displacements;
277 error if necessary.
278
279 @end table
280 @end ifset
281
282 @ifset M680X0
283 The following options are available when @value{AS} is configured for the
284 Motorola 68000 series.
285
286 @table @code
287
288 @item -l
289 Shorten references to undefined symbols, to one word instead of two.
290
291 @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040
292 @itemx | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32
293 Specify what processor in the 68000 family is the target. The default
294 is normally the 68020, but this can be changed at configuration time.
295
296 @item -m68881 | -m68882 | -mno-68881 | -mno-68882
297 The target machine does (or does not) have a floating-point coprocessor.
298 The default is to assume a coprocessor for 68020, 68030, and cpu32. Although
299 the basic 68000 is not compatible with the 68881, a combination of the
300 two can be specified, since it's possible to do emulation of the
301 coprocessor instructions with the main processor.
302
303 @item -m68851 | -mno-68851
304 The target machine does (or does not) have a memory-management
305 unit coprocessor. The default is to assume an MMU for 68020 and up.
306
307 @end table
308 @end ifset
309
310 @ifset SPARC
311 The following options are available when @code{@value{AS}} is configured
312 for the SPARC architecture:
313
314 @table @code
315 @item -Av6 | -Av7 | -Av8 | -Asparclite
316 Explicitly select a variant of the SPARC architecture.
317
318 @item -bump
319 Warn when the assembler switches to another architecture.
320 @end table
321 @end ifset
322
323 @ifset MIPS
324 The following options are available when @value{AS} is configured for
325 the MIPS R2000/R3000 processors.
326
327 @table @code
328
329 @item -G @var{num}
330 This option sets the largest size of an object that will be referenced
331 implicitly with the @code{gp} register. It is only accepted for targets
332 that use ECOFF format, such as a DECstation running Ultrix. The default
333 value is 8.
334
335 @item -nocpp
336 @itemx -EB, -EL
337 These options are ignored. They are accepted for compatibility with the
338 native tools.
339
340 @end table
341 @end ifset
342
343 @menu
344 * Manual:: Structure of this Manual
345 * GNU Assembler:: @value{AS}, the GNU Assembler
346 * Object Formats:: Object File Formats
347 * Command Line:: Command Line
348 * Input Files:: Input Files
349 * Object:: Output (Object) File
350 * Errors:: Error and Warning Messages
351 @end menu
352
353 @node Manual
354 @section Structure of this Manual
355
356 @cindex manual, structure and purpose
357 This manual is intended to describe what you need to know to use
358 @sc{gnu} @code{@value{AS}}. We cover the syntax expected in source files, including
359 notation for symbols, constants, and expressions; the directives that
360 @code{@value{AS}} understands; and of course how to invoke @code{@value{AS}}.
361
362 @ifclear GENERIC
363 We also cover special features in the @value{TARGET}
364 configuration of @code{@value{AS}}, including assembler directives.
365 @end ifclear
366 @ifset GENERIC
367 This manual also describes some of the machine-dependent features of
368 various flavors of the assembler.
369 @end ifset
370 @ifset INTERNALS
371 This manual also describes how the assembler works internally, and
372 provides some information that may be useful to people attempting to
373 port the assembler to another machine.
374 @end ifset
375 @refill
376
377 @cindex machine instructions (not covered)
378 On the other hand, this manual is @emph{not} intended as an introduction
379 to programming in assembly language---let alone programming in general!
380 In a similar vein, we make no attempt to introduce the machine
381 architecture; we do @emph{not} describe the instruction set, standard
382 mnemonics, registers or addressing modes that are standard to a
383 particular architecture.
384 @ifset GENERIC
385 You may want to consult the manufacturer's
386 machine architecture manual for this information.
387 @end ifset
388 @ifclear GENERIC
389 @ifset H8/300
390 For information on the H8/300 machine instruction set, see @cite{H8/300
391 Series Programming Manual} (Hitachi ADE--602--025). For the H8/300H,
392 see @cite{H8/300H Series Programming Manual} (Hitachi).
393 @end ifset
394 @ifset H8/500
395 For information on the H8/500 machine instruction set, see @cite{H8/500
396 Series Programming Manual} (Hitachi M21T001).
397 @end ifset
398 @ifset SH
399 For information on the Hitachi SH machine instruction set, see
400 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
401 @end ifset
402 @ifset Z8000
403 For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual}
404 @end ifset
405 @end ifclear
406
407 @c I think this is premature---pesch@cygnus.com, 17jan1991
408 @ignore
409 Throughout this manual, we assume that you are running @dfn{GNU},
410 the portable operating system from the @dfn{Free Software
411 Foundation, Inc.}. This restricts our attention to certain kinds of
412 computer (in particular, the kinds of computers that GNU can run on);
413 once this assumption is granted examples and definitions need less
414 qualification.
415
416 @code{@value{AS}} is part of a team of programs that turn a high-level
417 human-readable series of instructions into a low-level
418 computer-readable series of instructions. Different versions of
419 @code{@value{AS}} are used for different kinds of computer.
420 @end ignore
421
422 @c There used to be a section "Terminology" here, which defined
423 @c "contents", "byte", "word", and "long". Defining "word" to any
424 @c particular size is confusing when the .word directive may generate 16
425 @c bits on one machine and 32 bits on another; in general, for the user
426 @c version of this manual, none of these terms seem essential to define.
427 @c They were used very little even in the former draft of the manual;
428 @c this draft makes an effort to avoid them (except in names of
429 @c directives).
430
431 @node GNU Assembler
432 @section @value{AS}, the GNU Assembler
433
434 GNU @code{as} is really a family of assemblers.
435 @ifclear GENERIC
436 This manual describes @code{@value{AS}}, a member of that family which is
437 configured for the @value{TARGET} architectures.
438 @end ifclear
439 If you use (or have used) the GNU assembler on one architecture, you
440 should find a fairly similar environment when you use it on another
441 architecture. Each version has much in common with the others,
442 including object file formats, most assembler directives (often called
443 @dfn{pseudo-ops}) and assembler syntax.@refill
444
445 @cindex purpose of @sc{gnu} @code{@value{AS}}
446 @code{@value{AS}} is primarily intended to assemble the output of the
447 GNU C compiler @code{@value{GCC}} for use by the linker
448 @code{@value{LD}}. Nevertheless, we've tried to make @code{@value{AS}}
449 assemble correctly everything that other assemblers for the same
450 machine would assemble.
451 @ifset VAX
452 Any exceptions are documented explicitly (@pxref{Machine Dependencies}).
453 @end ifset
454 @ifset M680X0
455 @c This remark should appear in generic version of manual; assumption
456 @c here is that generic version sets M680x0.
457 This doesn't mean @code{@value{AS}} always uses the same syntax as another
458 assembler for the same architecture; for example, we know of several
459 incompatible versions of 680x0 assembly language syntax.
460 @end ifset
461
462 Unlike older assemblers, @code{@value{AS}} is designed to assemble a source
463 program in one pass of the source file. This has a subtle impact on the
464 @kbd{.org} directive (@pxref{Org,,@code{.org}}).
465
466 @node Object Formats
467 @section Object File Formats
468
469 @cindex object file format
470 The GNU assembler can be configured to produce several alternative
471 object file formats. For the most part, this does not affect how you
472 write assembly language programs; but directives for debugging symbols
473 are typically different in different file formats. @xref{Symbol
474 Attributes,,Symbol Attributes}.
475 @ifclear GENERIC
476 @ifclear MULTI-OBJ
477 On the @value{TARGET}, @code{@value{AS}} is configured to produce
478 @value{OBJ-NAME} format object files.
479 @end ifclear
480 @c The following should exhaust all configs that set MULTI-OBJ, ideally
481 @ifset A29K
482 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
483 @code{a.out} or COFF format object files.
484 @end ifset
485 @ifset I960
486 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
487 @code{b.out} or COFF format object files.
488 @end ifset
489 @ifset HPPA
490 On the @value{TARGET}, @code{@value{AS}} can be configured to produce either
491 SOM or ELF format object files.
492 @end ifset
493 @end ifclear
494
495 @node Command Line
496 @section Command Line
497
498 @cindex command line conventions
499 After the program name @code{@value{AS}}, the command line may contain
500 options and file names. Options may appear in any order, and may be
501 before, after, or between file names. The order of file names is
502 significant.
503
504 @cindex standard input, as input file
505 @kindex --
506 @file{--} (two hyphens) by itself names the standard input file
507 explicitly, as one of the files for @code{@value{AS}} to assemble.
508
509 @cindex options, command line
510 Except for @samp{--} any command line argument that begins with a
511 hyphen (@samp{-}) is an option. Each option changes the behavior of
512 @code{@value{AS}}. No option changes the way another option works. An
513 option is a @samp{-} followed by one or more letters; the case of
514 the letter is important. All options are optional.
515
516 Some options expect exactly one file name to follow them. The file
517 name may either immediately follow the option's letter (compatible
518 with older assemblers) or it may be the next command argument (GNU
519 standard). These two command lines are equivalent:
520
521 @smallexample
522 @value{AS} -o my-object-file.o mumble.s
523 @value{AS} -omy-object-file.o mumble.s
524 @end smallexample
525
526 @node Input Files
527 @section Input Files
528
529 @cindex input
530 @cindex source program
531 @cindex files, input
532 We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
533 describe the program input to one run of @code{@value{AS}}. The program may
534 be in one or more files; how the source is partitioned into files
535 doesn't change the meaning of the source.
536
537 @c I added "con" prefix to "catenation" just to prove I can overcome my
538 @c APL training... pesch@cygnus.com
539 The source program is a concatenation of the text in all the files, in the
540 order specified.
541
542 Each time you run @code{@value{AS}} it assembles exactly one source
543 program. The source program is made up of one or more files.
544 (The standard input is also a file.)
545
546 You give @code{@value{AS}} a command line that has zero or more input file
547 names. The input files are read (from left file name to right). A
548 command line argument (in any position) that has no special meaning
549 is taken to be an input file name.
550
551 If you give @code{@value{AS}} no file names it attempts to read one input file
552 from the @code{@value{AS}} standard input, which is normally your terminal. You
553 may have to type @key{ctl-D} to tell @code{@value{AS}} there is no more program
554 to assemble.
555
556 Use @samp{--} if you need to explicitly name the standard input file
557 in your command line.
558
559 If the source is empty, @code{@value{AS}} will produce a small, empty object
560 file.
561
562 @subheading Filenames and Line-numbers
563
564 @cindex input file linenumbers
565 @cindex line numbers, in input files
566 There are two ways of locating a line in the input file (or files) and
567 either may be used in reporting error messages. One way refers to a line
568 number in a physical file; the other refers to a line number in a
569 ``logical'' file. @xref{Errors, ,Error and Warning Messages}.
570
571 @dfn{Physical files} are those files named in the command line given
572 to @code{@value{AS}}.
573
574 @dfn{Logical files} are simply names declared explicitly by assembler
575 directives; they bear no relation to physical files. Logical file names
576 help error messages reflect the original source file, when @code{@value{AS}}
577 source is itself synthesized from other files.
578 @xref{App-File,,@code{.app-file}}.
579
580 @node Object
581 @section Output (Object) File
582
583 @cindex object file
584 @cindex output file
585 @kindex a.out
586 @kindex .o
587 Every time you run @code{@value{AS}} it produces an output file, which is
588 your assembly language program translated into numbers. This file
589 is the object file, named
590 @ifset BOUT
591 @code{b.out},
592 @ifset GENERIC
593 if @code{@value{AS}} is configured for the Intel 80960, or
594 @end ifset
595 @end ifset
596 @ifclear BOUT
597 @code{a.out},
598 @end ifclear
599 unless you tell @code{@value{AS}} to
600 give it another name by using the @code{-o} option. Conventionally,
601 object file names end with @file{.o}. The default name of
602 @file{a.out} is used for historical reasons: older assemblers were
603 capable of assembling self-contained programs directly into a
604 runnable program.
605 (For some formats, this isn't currently possible, but it can be done for
606 @code{a.out} format.)
607
608 @cindex linker
609 @kindex ld
610 The object file is meant for input to the linker @code{@value{LD}}. It contains
611 assembled program code, information to help @code{@value{LD}} integrate
612 the assembled program into a runnable file, and (optionally) symbolic
613 information for the debugger.
614
615 @c link above to some info file(s) like the description of a.out.
616 @c don't forget to describe GNU info as well as Unix lossage.
617
618 @node Errors
619 @section Error and Warning Messages
620
621 @cindex error messsages
622 @cindex warning messages
623 @cindex messages from @code{@value{AS}}
624 @code{@value{AS}} may write warnings and error messages to the standard error
625 file (usually your terminal). This should not happen when a compiler
626 runs @code{@value{AS}} automatically. Warnings report an assumption made so
627 that @code{@value{AS}} could keep assembling a flawed program; errors report a
628 grave problem that stops the assembly.
629
630 @cindex format of warning messages
631 Warning messages have the format
632
633 @smallexample
634 file_name:@b{NNN}:Warning Message Text
635 @end smallexample
636
637 @noindent
638 @cindex line numbers, in warnings/errors
639 (where @b{NNN} is a line number). If a logical file name has been given
640 (@pxref{App-File,,@code{.app-file}}) it is used for the filename,
641 otherwise the name of the current input file is used. If a logical line
642 number was given
643 @ifset GENERIC
644 (@pxref{Line,,@code{.line}})
645 @end ifset
646 @ifclear GENERIC
647 @ifclear A29K
648 (@pxref{Line,,@code{.line}})
649 @end ifclear
650 @ifset A29K
651 (@pxref{Ln,,@code{.ln}})
652 @end ifset
653 @end ifclear
654 then it is used to calculate the number printed,
655 otherwise the actual line in the current source file is printed. The
656 message text is intended to be self explanatory (in the grand Unix
657 tradition).
658
659 @cindex format of error messages
660 Error messages have the format
661 @smallexample
662 file_name:@b{NNN}:FATAL:Error Message Text
663 @end smallexample
664 The file name and line number are derived as for warning
665 messages. The actual message text may be rather less explanatory
666 because many of them aren't supposed to happen.
667
668 @node Invoking
669 @chapter Command-Line Options
670
671 @cindex options, all versions of @code{@value{AS}}
672 This chapter describes command-line options available in @emph{all}
673 versions of the GNU assembler; @pxref{Machine Dependencies}, for options specific
674 @ifclear GENERIC
675 to the @value{TARGET}.
676 @end ifclear
677 @ifset GENERIC
678 to particular machine architectures.
679 @end ifset
680
681 If you are invoking @code{@value{AS}} via the GNU C compiler (version 2), you
682 can use the @samp{-Wa} option to pass arguments through to the
683 assembler. The assembler arguments must be separated from each other
684 (and the @samp{-Wa}) by commas. For example:
685
686 @smallexample
687 gcc -c -g -O -Wa,-alh,-L file.c
688 @end smallexample
689
690 will cause a listing to be emitted to standard output with high-level
691 and assembly source.
692
693 Many compiler command-line options, such as @samp{-R} and many
694 machine-specific options, will be automatically be passed to the
695 assembler by the compiler, so usually you do not need to use this
696 @samp{-Wa} mechanism.
697
698 @menu
699 * a:: -a[dhlns] enable listings
700 * D:: -D for compatibility
701 * f:: -f to work faster
702 * I:: -I for .include search path
703 @ifclear DIFF-TBL-KLUGE
704 * K:: -K for compatibility
705 @end ifclear
706 @ifset DIFF-TBL-KLUGE
707 * K:: -K for difference tables
708 @end ifset
709
710 * L:: -L to retain local labels
711 * o:: -o to name the object file
712 * R:: -R to join data and text sections
713 * v:: -v to announce version
714 * W:: -W to suppress warnings
715 @end menu
716
717 @node a
718 @section Enable Listings: @code{-a[dhlns]}
719
720 @kindex -a
721 @kindex -ad
722 @kindex -ah
723 @kindex -al
724 @kindex -an
725 @kindex -as
726 @cindex listings, enabling
727 @cindex assembly listings, enabling
728
729 These options enable listing output from the assembler. By itself,
730 @samp{-a} requests high-level, assembly, and symbols listing.
731 Other letters may be used to select specific options for the list:
732 @samp{-ah} requests a high-level language listing,
733 @samp{-al} requests an output-program assembly listing, and
734 @samp{-as} requests a symbol table listing.
735 High-level listings require that a compiler debugging option like
736 @samp{-g} be used, and that assembly listings (@samp{-al}) be requested
737 also.
738
739 The @samp{-ad} option may be used to omit debugging pseudo-ops from the
740 listing.
741
742 Once you have specified one of these options, you can further control
743 listing output and its appearance using the directives @code{.list},
744 @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
745 @code{.sbttl}.
746 The @samp{-an} option turns off all forms processing.
747 If you do not request listing output with one of the @samp{-a} options, the
748 listing-control directives have no effect.
749
750 The letters after @samp{-a} may be combined into one option,
751 @emph{e.g.}, @samp{-aln}.
752
753 @node D
754 @section @code{-D}
755
756 @kindex -D
757 This option has no effect whatsoever, but it is accepted to make it more
758 likely that scripts written for other assemblers will also work with
759 @code{@value{AS}}.
760
761 @node f
762 @section Work Faster: @code{-f}
763
764 @kindex -f
765 @cindex trusted compiler
766 @cindex faster processing (@code{-f})
767 @samp{-f} should only be used when assembling programs written by a
768 (trusted) compiler. @samp{-f} stops the assembler from doing whitespace
769 and comment pre-processing on
770 the input file(s) before assembling them. @xref{Pre-processing,
771 ,Pre-processing}.
772
773 @quotation
774 @emph{Warning:} if the files actually need to be pre-processed (if they
775 contain comments, for example), @code{@value{AS}} will not work correctly if
776 @samp{-f} is used.
777 @end quotation
778
779 @node I
780 @section @code{.include} search path: @code{-I} @var{path}
781
782 @kindex -I @var{path}
783 @cindex paths for @code{.include}
784 @cindex search path for @code{.include}
785 @cindex @code{include} directive search path
786 Use this option to add a @var{path} to the list of directories
787 @code{@value{AS}} will search for files specified in @code{.include}
788 directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
789 many times as necessary to include a variety of paths. The current
790 working directory is always searched first; after that, @code{@value{AS}}
791 searches any @samp{-I} directories in the same order as they were
792 specified (left to right) on the command line.
793
794 @node K
795 @section Difference Tables: @code{-K}
796
797 @kindex -K
798 @ifclear DIFF-TBL-KLUGE
799 On the @value{TARGET} family, this option is allowed, but has no effect. It is
800 permitted for compatibility with the GNU assembler on other platforms,
801 where it can be used to warn when the assembler alters the machine code
802 generated for @samp{.word} directives in difference tables. The @value{TARGET}
803 family does not have the addressing limitations that sometimes lead to this
804 alteration on other platforms.
805 @end ifclear
806
807 @ifset DIFF-TBL-KLUGE
808 @cindex difference tables, warning
809 @cindex warning for altered difference tables
810 @code{@value{AS}} sometimes alters the code emitted for directives of the form
811 @samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
812 You can use the @samp{-K} option if you want a warning issued when this
813 is done.
814 @end ifset
815
816 @node L
817 @section Include Local Labels: @code{-L}
818
819 @kindex -L
820 @cindex local labels, retaining in output
821 Labels beginning with @samp{L} (upper case only) are called @dfn{local
822 labels}. @xref{Symbol Names}. Normally you don't see such labels when
823 debugging, because they are intended for the use of programs (like
824 compilers) that compose assembler programs, not for your notice.
825 Normally both @code{@value{AS}} and @code{@value{LD}} discard such labels, so you don't
826 normally debug with them.
827
828 This option tells @code{@value{AS}} to retain those @samp{L@dots{}} symbols
829 in the object file. Usually if you do this you also tell the linker
830 @code{@value{LD}} to preserve symbols whose names begin with @samp{L}.
831
832 By default, a local label is any label beginning with @samp{L}, but each
833 target is allowed to redefine the local label prefix.
834 @ifclear GENERIC
835 On some targets a local label begins with @samp{.L}; on the HPPA local labels
836 begin with @samp{L$}.
837 @end ifclear
838
839 @node o
840 @section Name the Object File: @code{-o}
841
842 @kindex -o
843 @cindex naming object file
844 @cindex object file name
845 There is always one object file output when you run @code{@value{AS}}. By
846 default it has the name
847 @ifset GENERIC
848 @ifset I960
849 @file{a.out} (or @file{b.out}, for Intel 960 targets only).
850 @end ifset
851 @ifclear I960
852 @file{a.out}.
853 @end ifclear
854 @end ifset
855 @ifclear GENERIC
856 @ifset I960
857 @file{b.out}.
858 @end ifset
859 @ifclear I960
860 @file{a.out}.
861 @end ifclear
862 @end ifclear
863 You use this option (which takes exactly one filename) to give the
864 object file a different name.
865
866 Whatever the object file is called, @code{@value{AS}} will overwrite any
867 existing file of the same name.
868
869 @node R
870 @section Join Data and Text Sections: @code{-R}
871
872 @kindex -R
873 @cindex data and text sections, joining
874 @cindex text and data sections, joining
875 @cindex joining text and data sections
876 @cindex merging text and data sections
877 @code{-R} tells @code{@value{AS}} to write the object file as if all
878 data-section data lives in the text section. This is only done at
879 the very last moment: your binary data are the same, but data
880 section parts are relocated differently. The data section part of
881 your object file is zero bytes long because all its bytes are
882 appended to the text section. (@xref{Sections,,Sections and Relocation}.)
883
884 When you specify @code{-R} it would be possible to generate shorter
885 address displacements (because we don't have to cross between text and
886 data section). We refrain from doing this simply for compatibility with
887 older versions of @code{@value{AS}}. In future, @code{-R} may work this way.
888
889 @ifset COFF
890 When @code{@value{AS}} is configured for COFF output,
891 this option is only useful if you use sections named @samp{.text} and
892 @samp{.data}.
893 @end ifset
894
895 @ifset HPPA
896 @code{-R} is not supported for any of the HPPA targets . Using
897 @code{-R} will generate a warning from @code{@value{AS}}.
898 @end ifset
899
900 @node v
901 @section Announce Version: @code{-v}
902
903 @kindex -v
904 @kindex -version
905 @cindex @code{@value{AS}} version
906 @cindex version of @code{@value{AS}}
907 You can find out what version of as is running by including the
908 option @samp{-v} (which you can also spell as @samp{-version}) on the
909 command line.
910
911 @node W
912 @section Suppress Warnings: @code{-W}
913
914 @kindex -W
915 @cindex suppressing warnings
916 @cindex warnings, suppressing
917 @code{@value{AS}} should never give a warning or error message when
918 assembling compiler output. But programs written by people often
919 cause @code{@value{AS}} to give a warning that a particular assumption was
920 made. All such warnings are directed to the standard error file.
921 If you use this option, no warnings are issued. This option only
922 affects the warning messages: it does not change any particular of how
923 @code{@value{AS}} assembles your file. Errors, which stop the assembly, are
924 still reported.
925
926 @node Syntax
927 @chapter Syntax
928
929 @cindex machine-independent syntax
930 @cindex syntax, machine-independent
931 This chapter describes the machine-independent syntax allowed in a
932 source file. @code{@value{AS}} syntax is similar to what many other
933 assemblers use; it is inspired by the BSD 4.2
934 @ifclear VAX
935 assembler.
936 @end ifclear
937 @ifset VAX
938 assembler, except that @code{@value{AS}} does not assemble Vax bit-fields.
939 @end ifset
940
941 @menu
942 * Pre-processing:: Pre-processing
943 * Whitespace:: Whitespace
944 * Comments:: Comments
945 * Symbol Intro:: Symbols
946 * Statements:: Statements
947 * Constants:: Constants
948 @end menu
949
950 @node Pre-processing
951 @section Pre-Processing
952
953 @cindex preprocessing
954 The @code{@value{AS}} internal pre-processor:
955 @itemize @bullet
956 @cindex whitespace, removed by preprocessor
957 @item
958 adjusts and removes extra whitespace. It leaves one space or tab before
959 the keywords on a line, and turns any other whitespace on the line into
960 a single space.
961
962 @cindex comments, removed by preprocessor
963 @item
964 removes all comments, replacing them with a single space, or an
965 appropriate number of newlines.
966
967 @cindex constants, converted by preprocessor
968 @item
969 converts character constants into the appropriate numeric values.
970 @end itemize
971
972 Note that it does not do macro processing, include file handling, or
973 anything else you may get from your C compiler's pre-processor. You can
974 do include file processing with the @code{.include} directive
975 (@pxref{Include,,@code{.include}}). Other ``CPP'' style pre-processing
976 can be done with the @sc{GNU} C compiler, by giving the input file a
977 @code{.S} suffix; see the compiler documentation for details.
978
979 Excess whitespace, comments, and character constants
980 cannot be used in the portions of the input text that are not
981 pre-processed.
982
983 @cindex turning preprocessing on and off
984 @cindex preprocessing, turning on and off
985 @kindex #NO_APP
986 @kindex #APP
987 If the first line of an input file is @code{#NO_APP} or the @samp{-f}
988 option is given, the input file will not be pre-processed. Within such
989 an input file, parts of the file can be pre-processed by putting a line
990 that says @code{#APP} before the text that should be pre-processed, and
991 putting a line that says @code{#NO_APP} after them. This feature is
992 mainly intend to support @code{asm} statements in compilers whose output
993 normally does not need to be pre-processed.
994
995 @node Whitespace
996 @section Whitespace
997
998 @cindex whitespace
999 @dfn{Whitespace} is one or more blanks or tabs, in any order.
1000 Whitespace is used to separate symbols, and to make programs neater for
1001 people to read. Unless within character constants
1002 (@pxref{Characters,,Character Constants}), any whitespace means the same
1003 as exactly one space.
1004
1005 @node Comments
1006 @section Comments
1007
1008 @cindex comments
1009 There are two ways of rendering comments to @code{@value{AS}}. In both
1010 cases the comment is equivalent to one space.
1011
1012 Anything from @samp{/*} through the next @samp{*/} is a comment.
1013 This means you may not nest these comments.
1014
1015 @smallexample
1016 /*
1017 The only way to include a newline ('\n') in a comment
1018 is to use this sort of comment.
1019 */
1020
1021 /* This sort of comment does not nest. */
1022 @end smallexample
1023
1024 @cindex line comment character
1025 Anything from the @dfn{line comment} character to the next newline
1026 is considered a comment and is ignored. The line comment character is
1027 @ifset VAX
1028 @samp{#} on the Vax;
1029 @end ifset
1030 @ifset I960
1031 @samp{#} on the i960;
1032 @end ifset
1033 @ifset SPARC
1034 @samp{!} on the SPARC;
1035 @end ifset
1036 @ifset M680X0
1037 @samp{|} on the 680x0;
1038 @end ifset
1039 @ifset A29K
1040 @samp{;} for the AMD 29K family;
1041 @end ifset
1042 @ifset H8/300
1043 @samp{;} for the H8/300 family;
1044 @end ifset
1045 @ifset H8/500
1046 @samp{!} for the H8/500 family;
1047 @end ifset
1048 @ifset HPPA
1049 @samp{;} for the HPPA;
1050 @end ifset
1051 @ifset SH
1052 @samp{!} for the Hitachi SH;
1053 @end ifset
1054 @ifset Z8000
1055 @samp{!} for the Z8000;
1056 @end ifset
1057 see @ref{Machine Dependencies}. @refill
1058 @c FIXME What about i386, m88k, i860?
1059
1060 @ifset GENERIC
1061 On some machines there are two different line comment characters. One
1062 will only begin a comment if it is the first non-whitespace character on
1063 a line, while the other will always begin a comment.
1064 @end ifset
1065
1066 @kindex #
1067 @cindex lines starting with @code{#}
1068 @cindex logical line numbers
1069 To be compatible with past assemblers, a special interpretation is
1070 given to lines that begin with @samp{#}. Following the @samp{#} an
1071 absolute expression (@pxref{Expressions}) is expected: this will be
1072 the logical line number of the @b{next} line. Then a string
1073 (@xref{Strings}.) is allowed: if present it is a new logical file
1074 name. The rest of the line, if any, should be whitespace.
1075
1076 If the first non-whitespace characters on the line are not numeric,
1077 the line is ignored. (Just like a comment.)
1078 @smallexample
1079 # This is an ordinary comment.
1080 # 42-6 "new_file_name" # New logical file name
1081 # This is logical line # 36.
1082 @end smallexample
1083 This feature is deprecated, and may disappear from future versions
1084 of @code{@value{AS}}.
1085
1086 @node Symbol Intro
1087 @section Symbols
1088
1089 @cindex characters used in symbols
1090 @ifclear SPECIAL-SYMS
1091 A @dfn{symbol} is one or more characters chosen from the set of all
1092 letters (both upper and lower case), digits and the three characters
1093 @samp{_.$}.
1094 @end ifclear
1095 @ifset SPECIAL-SYMS
1096 @ifclear GENERIC
1097 @ifset H8
1098 A @dfn{symbol} is one or more characters chosen from the set of all
1099 letters (both upper and lower case), digits and the three characters
1100 @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in
1101 symbol names.)
1102 @end ifset
1103 @end ifclear
1104 @end ifset
1105 @ifset GENERIC
1106 On most machines, you can also use @code{$} in symbol names; exceptions
1107 are noted in @ref{Machine Dependencies}.
1108 @end ifset
1109 No symbol may begin with a digit. Case is significant.
1110 There is no length limit: all characters are significant. Symbols are
1111 delimited by characters not in that set, or by the beginning of a file
1112 (since the source program must end with a newline, the end of a file is
1113 not a possible symbol delimiter). @xref{Symbols}.
1114 @cindex length of symbols
1115
1116 @node Statements
1117 @section Statements
1118
1119 @cindex statements, structure of
1120 @cindex line separator character
1121 @cindex statement separator character
1122 @ifclear GENERIC
1123 @ifclear abnormal-separator
1124 A @dfn{statement} ends at a newline character (@samp{\n}) or at a
1125 semicolon (@samp{;}). The newline or semicolon is considered part of
1126 the preceding statement. Newlines and semicolons within character
1127 constants are an exception: they don't end statements.
1128 @end ifclear
1129 @ifset abnormal-separator
1130 @ifset A29K
1131 A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at''
1132 sign (@samp{@@}). The newline or at sign is considered part of the
1133 preceding statement. Newlines and at signs within character constants
1134 are an exception: they don't end statements.
1135 @end ifset
1136 @ifset HPPA
1137 A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation
1138 point (@samp{!}). The newline or exclamation point is considered part of the
1139 preceding statement. Newlines and exclamation points within character
1140 constants are an exception: they don't end statements.
1141 @end ifset
1142 @ifset H8
1143 A @dfn{statement} ends at a newline character (@samp{\n}); or (for the
1144 H8/300) a dollar sign (@samp{$}); or (for the
1145 Hitachi-SH or the
1146 H8/500) a semicolon
1147 (@samp{;}). The newline or separator character is considered part of
1148 the preceding statement. Newlines and separators within character
1149 constants are an exception: they don't end statements.
1150 @end ifset
1151 @end ifset
1152 @end ifclear
1153 @ifset GENERIC
1154 A @dfn{statement} ends at a newline character (@samp{\n}) or line
1155 separator character. (The line separator is usually @samp{;}, unless
1156 this conflicts with the comment character; @pxref{Machine Dependencies}.) The
1157 newline or separator character is considered part of the preceding
1158 statement. Newlines and separators within character constants are an
1159 exception: they don't end statements.
1160 @end ifset
1161
1162 @cindex newline, required at file end
1163 @cindex EOF, newline must precede
1164 It is an error to end any statement with end-of-file: the last
1165 character of any input file should be a newline.@refill
1166
1167 @cindex continuing statements
1168 @cindex multi-line statements
1169 @cindex statement on multiple lines
1170 You may write a statement on more than one line if you put a
1171 backslash (@kbd{\}) immediately in front of any newlines within the
1172 statement. When @code{@value{AS}} reads a backslashed newline both
1173 characters are ignored. You can even put backslashed newlines in
1174 the middle of symbol names without changing the meaning of your
1175 source program.
1176
1177 An empty statement is allowed, and may include whitespace. It is ignored.
1178
1179 @cindex instructions and directives
1180 @cindex directives and instructions
1181 @c "key symbol" is not used elsewhere in the document; seems pedantic to
1182 @c @defn{} it in that case, as was done previously... pesch@cygnus.com,
1183 @c 13feb91.
1184 A statement begins with zero or more labels, optionally followed by a
1185 key symbol which determines what kind of statement it is. The key
1186 symbol determines the syntax of the rest of the statement. If the
1187 symbol begins with a dot @samp{.} then the statement is an assembler
1188 directive: typically valid for any computer. If the symbol begins with
1189 a letter the statement is an assembly language @dfn{instruction}: it
1190 will assemble into a machine language instruction.
1191 @ifset GENERIC
1192 Different versions of @code{@value{AS}} for different computers will
1193 recognize different instructions. In fact, the same symbol may
1194 represent a different instruction in a different computer's assembly
1195 language.@refill
1196 @end ifset
1197
1198 @cindex @code{:} (label)
1199 @cindex label (@code{:})
1200 A label is a symbol immediately followed by a colon (@code{:}).
1201 Whitespace before a label or after a colon is permitted, but you may not
1202 have whitespace between a label's symbol and its colon. @xref{Labels}.
1203
1204 @ifset HPPA
1205 For HPPA targets, labels need not be immediately followed by a colon, but
1206 the definition of a label must begin in column zero. This also implies that
1207 only one label may be defined on each line.
1208 @end ifset
1209
1210 @smallexample
1211 label: .directive followed by something
1212 another_label: # This is an empty statement.
1213 instruction operand_1, operand_2, @dots{}
1214 @end smallexample
1215
1216 @node Constants
1217 @section Constants
1218
1219 @cindex constants
1220 A constant is a number, written so that its value is known by
1221 inspection, without knowing any context. Like this:
1222 @smallexample
1223 @group
1224 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
1225 .ascii "Ring the bell\7" # A string constant.
1226 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
1227 .float 0f-314159265358979323846264338327\
1228 95028841971.693993751E-40 # - pi, a flonum.
1229 @end group
1230 @end smallexample
1231
1232 @menu
1233 * Characters:: Character Constants
1234 * Numbers:: Number Constants
1235 @end menu
1236
1237 @node Characters
1238 @subsection Character Constants
1239
1240 @cindex character constants
1241 @cindex constants, character
1242 There are two kinds of character constants. A @dfn{character} stands
1243 for one character in one byte and its value may be used in
1244 numeric expressions. String constants (properly called string
1245 @emph{literals}) are potentially many bytes and their values may not be
1246 used in arithmetic expressions.
1247
1248 @menu
1249 * Strings:: Strings
1250 * Chars:: Characters
1251 @end menu
1252
1253 @node Strings
1254 @subsubsection Strings
1255
1256 @cindex string constants
1257 @cindex constants, string
1258 A @dfn{string} is written between double-quotes. It may contain
1259 double-quotes or null characters. The way to get special characters
1260 into a string is to @dfn{escape} these characters: precede them with
1261 a backslash @samp{\} character. For example @samp{\\} represents
1262 one backslash: the first @code{\} is an escape which tells
1263 @code{@value{AS}} to interpret the second character literally as a backslash
1264 (which prevents @code{@value{AS}} from recognizing the second @code{\} as an
1265 escape character). The complete list of escapes follows.
1266
1267 @cindex escape codes, character
1268 @cindex character escape codes
1269 @table @kbd
1270 @c @item \a
1271 @c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
1272 @c
1273 @item \b
1274 @cindex @code{\b} (backspace character)
1275 @cindex backspace (@code{\b})
1276 Mnemonic for backspace; for ASCII this is octal code 010.
1277
1278 @c @item \e
1279 @c Mnemonic for EOText; for ASCII this is octal code 004.
1280 @c
1281 @item \f
1282 @cindex @code{\f} (formfeed character)
1283 @cindex formfeed (@code{\f})
1284 Mnemonic for FormFeed; for ASCII this is octal code 014.
1285
1286 @item \n
1287 @cindex @code{\n} (newline character)
1288 @cindex newline (@code{\n})
1289 Mnemonic for newline; for ASCII this is octal code 012.
1290
1291 @c @item \p
1292 @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
1293 @c
1294 @item \r
1295 @cindex @code{\r} (carriage return character)
1296 @cindex carriage return (@code{\r})
1297 Mnemonic for carriage-Return; for ASCII this is octal code 015.
1298
1299 @c @item \s
1300 @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
1301 @c other assemblers.
1302 @c
1303 @item \t
1304 @cindex @code{\t} (tab)
1305 @cindex tab (@code{\t})
1306 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
1307
1308 @c @item \v
1309 @c Mnemonic for Vertical tab; for ASCII this is octal code 013.
1310 @c @item \x @var{digit} @var{digit} @var{digit}
1311 @c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
1312 @c
1313 @item \ @var{digit} @var{digit} @var{digit}
1314 @cindex @code{\@var{ddd}} (octal character code)
1315 @cindex octal character code (@code{\@var{ddd}})
1316 An octal character code. The numeric code is 3 octal digits.
1317 For compatibility with other Unix systems, 8 and 9 are accepted as digits:
1318 for example, @code{\008} has the value 010, and @code{\009} the value 011.
1319
1320 @ifset HPPA
1321 @item \@code{x} @var{hex-digit} @var{hex-digit}
1322 @cindex @code{\@var{xdd}} (hex character code)
1323 @cindex hex character code (@code{\@var{xdd}})
1324 A hex character code. The numeric code is 2 hexidecimal digits. Either
1325 an upper or lower case @code{x} may be used.
1326 @end ifset
1327
1328 @item \\
1329 @cindex @code{\\} (@samp{\} character)
1330 @cindex backslash (@code{\\})
1331 Represents one @samp{\} character.
1332
1333 @c @item \'
1334 @c Represents one @samp{'} (accent acute) character.
1335 @c This is needed in single character literals
1336 @c (@xref{Characters,,Character Constants}.) to represent
1337 @c a @samp{'}.
1338 @c
1339 @item \"
1340 @cindex @code{\"} (doublequote character)
1341 @cindex doublequote (@code{\"})
1342 Represents one @samp{"} character. Needed in strings to represent
1343 this character, because an unescaped @samp{"} would end the string.
1344
1345 @item \ @var{anything-else}
1346 Any other character when escaped by @kbd{\} will give a warning, but
1347 assemble as if the @samp{\} was not present. The idea is that if
1348 you used an escape sequence you clearly didn't want the literal
1349 interpretation of the following character. However @code{@value{AS}} has no
1350 other interpretation, so @code{@value{AS}} knows it is giving you the wrong
1351 code and warns you of the fact.
1352 @end table
1353
1354 Which characters are escapable, and what those escapes represent,
1355 varies widely among assemblers. The current set is what we think
1356 the BSD 4.2 assembler recognizes, and is a subset of what most C
1357 compilers recognize. If you are in doubt, don't use an escape
1358 sequence.
1359
1360 @node Chars
1361 @subsubsection Characters
1362
1363 @cindex single character constant
1364 @cindex character, single
1365 @cindex constant, single character
1366 A single character may be written as a single quote immediately
1367 followed by that character. The same escapes apply to characters as
1368 to strings. So if you want to write the character backslash, you
1369 must write @kbd{'\\} where the first @code{\} escapes the second
1370 @code{\}. As you can see, the quote is an acute accent, not a
1371 grave accent. A newline
1372 @ifclear GENERIC
1373 @ifclear abnormal-separator
1374 (or semicolon @samp{;})
1375 @end ifclear
1376 @ifset abnormal-separator
1377 @ifset A29K
1378 (or at sign @samp{@@})
1379 @end ifset
1380 @ifset H8
1381 (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the
1382 Hitachi SH or
1383 H8/500)
1384 @end ifset
1385 @end ifset
1386 @end ifclear
1387 immediately following an acute accent is taken as a literal character
1388 and does not count as the end of a statement. The value of a character
1389 constant in a numeric expression is the machine's byte-wide code for
1390 that character. @code{@value{AS}} assumes your character code is ASCII:
1391 @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
1392
1393 @node Numbers
1394 @subsection Number Constants
1395
1396 @cindex constants, number
1397 @cindex number constants
1398 @code{@value{AS}} distinguishes three kinds of numbers according to how they
1399 are stored in the target machine. @emph{Integers} are numbers that
1400 would fit into an @code{int} in the C language. @emph{Bignums} are
1401 integers, but they are stored in more than 32 bits. @emph{Flonums}
1402 are floating point numbers, described below.
1403
1404 @menu
1405 * Integers:: Integers
1406 * Bignums:: Bignums
1407 * Flonums:: Flonums
1408 @ifclear GENERIC
1409 @ifset I960
1410 * Bit Fields:: Bit Fields
1411 @end ifset
1412 @end ifclear
1413 @end menu
1414
1415 @node Integers
1416 @subsubsection Integers
1417 @cindex integers
1418 @cindex constants, integer
1419
1420 @cindex binary integers
1421 @cindex integers, binary
1422 A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
1423 the binary digits @samp{01}.
1424
1425 @cindex octal integers
1426 @cindex integers, octal
1427 An octal integer is @samp{0} followed by zero or more of the octal
1428 digits (@samp{01234567}).
1429
1430 @cindex decimal integers
1431 @cindex integers, decimal
1432 A decimal integer starts with a non-zero digit followed by zero or
1433 more digits (@samp{0123456789}).
1434
1435 @cindex hexadecimal integers
1436 @cindex integers, hexadecimal
1437 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1438 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
1439
1440 Integers have the usual values. To denote a negative integer, use
1441 the prefix operator @samp{-} discussed under expressions
1442 (@pxref{Prefix Ops,,Prefix Operators}).
1443
1444 @node Bignums
1445 @subsubsection Bignums
1446
1447 @cindex bignums
1448 @cindex constants, bignum
1449 A @dfn{bignum} has the same syntax and semantics as an integer
1450 except that the number (or its negative) takes more than 32 bits to
1451 represent in binary. The distinction is made because in some places
1452 integers are permitted while bignums are not.
1453
1454 @node Flonums
1455 @subsubsection Flonums
1456 @cindex flonums
1457 @cindex floating point numbers
1458 @cindex constants, floating point
1459
1460 @cindex precision, floating point
1461 A @dfn{flonum} represents a floating point number. The translation is
1462 indirect: a decimal floating point number from the text is converted by
1463 @code{@value{AS}} to a generic binary floating point number of more than
1464 sufficient precision. This generic floating point number is converted
1465 to a particular computer's floating point format (or formats) by a
1466 portion of @code{@value{AS}} specialized to that computer.
1467
1468 A flonum is written by writing (in order)
1469 @itemize @bullet
1470 @item
1471 The digit @samp{0}.
1472 @ifset HPPA
1473 @samp{0} is optional on the HPPA.
1474 @end ifset
1475
1476 @item
1477 A letter, to tell @code{@value{AS}} the rest of the number is a flonum.
1478 @ifset GENERIC
1479 @kbd{e} is recommended. Case is not important.
1480 @ignore
1481 @c FIXME: verify if flonum syntax really this vague for most cases
1482 (Any otherwise illegal letter
1483 will work here, but that might be changed. Vax BSD 4.2 assembler seems
1484 to allow any of @samp{defghDEFGH}.)
1485 @end ignore
1486
1487 On the H8/300, H8/500,
1488 Hitachi SH,
1489 and AMD 29K architectures, the letter must be
1490 one of the letters @samp{DFPRSX} (in upper or lower case).
1491
1492 On the Intel 960 architecture, the letter must be
1493 one of the letters @samp{DFT} (in upper or lower case).
1494
1495 On the HPPA architecture, the letter must be @samp{E} (upper case only).
1496 @end ifset
1497 @ifclear GENERIC
1498 @ifset A29K
1499 One of the letters @samp{DFPRSX} (in upper or lower case).
1500 @end ifset
1501 @ifset H8
1502 One of the letters @samp{DFPRSX} (in upper or lower case).
1503 @end ifset
1504 @ifset I960
1505 One of the letters @samp{DFT} (in upper or lower case).
1506 @end ifset
1507 @ifset HPPA
1508 On the HPPA architecture, the letter must be @samp{E} (upper case only).
1509 @end ifset
1510 @end ifclear
1511
1512 @item
1513 An optional sign: either @samp{+} or @samp{-}.
1514
1515 @item
1516 An optional @dfn{integer part}: zero or more decimal digits.
1517
1518 @item
1519 An optional @dfn{fractional part}: @samp{.} followed by zero
1520 or more decimal digits.
1521
1522 @item
1523 An optional exponent, consisting of:
1524
1525 @itemize @bullet
1526 @item
1527 An @samp{E} or @samp{e}.
1528 @c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1529 @c principle this can perfectly well be different on different targets.
1530 @item
1531 Optional sign: either @samp{+} or @samp{-}.
1532 @item
1533 One or more decimal digits.
1534 @end itemize
1535
1536 @end itemize
1537
1538 At least one of the integer part or the fractional part must be
1539 present. The floating point number has the usual base-10 value.
1540
1541 @code{@value{AS}} does all processing using integers. Flonums are computed
1542 independently of any floating point hardware in the computer running
1543 @code{@value{AS}}.
1544
1545 @ifclear GENERIC
1546 @ifset I960
1547 @c Bit fields are written as a general facility but are also controlled
1548 @c by a conditional-compilation flag---which is as of now (21mar91)
1549 @c turned on only by the i960 config of GAS.
1550 @node Bit Fields
1551 @subsubsection Bit Fields
1552
1553 @cindex bit fields
1554 @cindex constants, bit field
1555 You can also define numeric constants as @dfn{bit fields}.
1556 specify two numbers separated by a colon---
1557 @example
1558 @var{mask}:@var{value}
1559 @end example
1560 @noindent
1561 the first will act as a mask; @code{@value{AS}} will bitwise-and it with the
1562 second value.
1563
1564 The resulting number is then packed
1565 @ifset GENERIC
1566 @c this conditional paren in case bit fields turned on elsewhere than 960
1567 (in host-dependent byte order)
1568 @end ifset
1569 into a field whose width depends on which assembler directive has the
1570 bit-field as its argument. Overflow (a result from the bitwise and
1571 requiring more binary digits to represent) is not an error; instead,
1572 more constants are generated, of the specified width, beginning with the
1573 least significant digits.@refill
1574
1575 The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long},
1576 @code{.short}, and @code{.word} accept bit-field arguments.
1577 @end ifset
1578 @end ifclear
1579
1580 @node Sections
1581 @chapter Sections and Relocation
1582 @cindex sections
1583 @cindex relocation
1584
1585 @menu
1586 * Secs Background:: Background
1587 * Ld Sections:: @value{LD} Sections
1588 * As Sections:: @value{AS} Internal Sections
1589 * Sub-Sections:: Sub-Sections
1590 * bss:: bss Section
1591 @end menu
1592
1593 @node Secs Background
1594 @section Background
1595
1596 Roughly, a section is a range of addresses, with no gaps; all data
1597 ``in'' those addresses is treated the same for some particular purpose.
1598 For example there may be a ``read only'' section.
1599
1600 @cindex linker, and assembler
1601 @cindex assembler, and linker
1602 The linker @code{@value{LD}} reads many object files (partial programs) and
1603 combines their contents to form a runnable program. When @code{@value{AS}}
1604 emits an object file, the partial program is assumed to start at address
1605 0. @code{@value{LD}} will assign the final addresses the partial program
1606 occupies, so that different partial programs don't overlap. This is
1607 actually an over-simplification, but it will suffice to explain how
1608 @code{@value{AS}} uses sections.
1609
1610 @code{@value{LD}} moves blocks of bytes of your program to their run-time
1611 addresses. These blocks slide to their run-time addresses as rigid
1612 units; their length does not change and neither does the order of bytes
1613 within them. Such a rigid unit is called a @emph{section}. Assigning
1614 run-time addresses to sections is called @dfn{relocation}. It includes
1615 the task of adjusting mentions of object-file addresses so they refer to
1616 the proper run-time addresses.
1617 @ifset H8
1618 For the H8/300 and H8/500,
1619 and for the Hitachi SH,
1620 @code{@value{AS}} pads sections if needed to
1621 ensure they end on a word (sixteen bit) boundary.
1622 @end ifset
1623
1624 @cindex standard @code{@value{AS}} sections
1625 An object file written by @code{@value{AS}} has at least three sections, any
1626 of which may be empty. These are named @dfn{text}, @dfn{data} and
1627 @dfn{bss} sections.
1628
1629 @ifset COFF
1630 @ifset GENERIC
1631 When it generates COFF output,
1632 @end ifset
1633 @code{@value{AS}} can also generate whatever other named sections you specify
1634 using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1635 If you don't use any directives that place output in the @samp{.text}
1636 or @samp{.data} sections, these sections will still exist, but will be empty.
1637 @end ifset
1638
1639 @ifset HPPA
1640 @ifset GENERIC
1641 When @code{@value{AS}} generates SOM or ELF output for the HPPA,
1642 @end ifset
1643 @code{@value{AS}} can also generate whatever other named sections you
1644 specify using the @samp{.space} and @samp{.subspace} directives. See
1645 @cite{HP9000 Series 800 Assembly Language Reference Manual}
1646 (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace}
1647 assembler directives.
1648
1649 @ifset SOM
1650 Additionally, @code{@value{AS}} uses different names for the standard
1651 text, data, and bss sections when generating SOM output. Program text
1652 is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and
1653 BSS into @samp{$BSS$}.
1654 @end ifset
1655 @end ifset
1656
1657 Within the object file, the text section starts at address @code{0}, the
1658 data section follows, and the bss section follows the data section.
1659
1660 @ifset HPPA
1661 When generating either SOM or ELF output files on the HPPA, the text
1662 section starts at address @code{0}, the data section at address
1663 @code{0x4000000}, and the bss section follows the data section.
1664 @end ifset
1665
1666 To let @code{@value{LD}} know which data will change when the sections are
1667 relocated, and how to change that data, @code{@value{AS}} also writes to the
1668 object file details of the relocation needed. To perform relocation
1669 @code{@value{LD}} must know, each time an address in the object
1670 file is mentioned:
1671 @itemize @bullet
1672 @item
1673 Where in the object file is the beginning of this reference to
1674 an address?
1675 @item
1676 How long (in bytes) is this reference?
1677 @item
1678 Which section does the address refer to? What is the numeric value of
1679 @display
1680 (@var{address}) @minus{} (@var{start-address of section})?
1681 @end display
1682 @item
1683 Is the reference to an address ``Program-Counter relative''?
1684 @end itemize
1685
1686 @cindex addresses, format of
1687 @cindex section-relative addressing
1688 In fact, every address @code{@value{AS}} ever uses is expressed as
1689 @display
1690 (@var{section}) + (@var{offset into section})
1691 @end display
1692 @noindent
1693 Further, every expression @code{@value{AS}} computes is of this section-relative
1694 nature. @dfn{Absolute expression} means an expression with section
1695 ``absolute'' (@pxref{Ld Sections}). A @dfn{pass1 expression} means
1696 an expression with section ``pass1'' (@pxref{As Sections,,@value{AS}
1697 Internal Sections}). In this manual we use the notation @{@var{secname}
1698 @var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1699
1700 Apart from text, data and bss sections you need to know about the
1701 @dfn{absolute} section. When @code{@value{LD}} mixes partial programs,
1702 addresses in the absolute section remain unchanged. For example, address
1703 @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{@value{LD}}.
1704 Although two partial programs' data sections will not overlap addresses
1705 after linking, @emph{by definition} their absolute sections will overlap.
1706 Address @code{@{absolute@ 239@}} in one partial program will always be the same
1707 address when the program is running as address @code{@{absolute@ 239@}} in any
1708 other partial program.
1709
1710 The idea of sections is extended to the @dfn{undefined} section. Any
1711 address whose section is unknown at assembly time is by definition
1712 rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
1713 Since numbers are always defined, the only way to generate an undefined
1714 address is to mention an undefined symbol. A reference to a named
1715 common block would be such a symbol: its value is unknown at assembly
1716 time so it has section @emph{undefined}.
1717
1718 By analogy the word @emph{section} is used to describe groups of sections in
1719 the linked program. @code{@value{LD}} puts all partial programs' text
1720 sections in contiguous addresses in the linked program. It is
1721 customary to refer to the @emph{text section} of a program, meaning all
1722 the addresses of all partial program's text sections. Likewise for
1723 data and bss sections.
1724
1725 Some sections are manipulated by @code{@value{LD}}; others are invented for
1726 use of @code{@value{AS}} and have no meaning except during assembly.
1727
1728 @node Ld Sections
1729 @section @value{LD} Sections
1730 @code{@value{LD}} deals with just four kinds of sections, summarized below.
1731
1732 @table @strong
1733
1734 @ifset COFF
1735 @cindex named sections
1736 @cindex sections, named
1737 @item named sections
1738 @end ifset
1739 @ifset aout-bout
1740 @cindex text section
1741 @cindex data section
1742 @itemx text section
1743 @itemx data section
1744 @end ifset
1745 These sections hold your program. @code{@value{AS}} and @code{@value{LD}} treat them as
1746 separate but equal sections. Anything you can say of one section is
1747 true another.
1748 @ifset aout-bout
1749 When the program is running, however, it is
1750 customary for the text section to be unalterable. The
1751 text section is often shared among processes: it will contain
1752 instructions, constants and the like. The data section of a running
1753 program is usually alterable: for example, C variables would be stored
1754 in the data section.
1755 @end ifset
1756
1757 @cindex bss section
1758 @item bss section
1759 This section contains zeroed bytes when your program begins running. It
1760 is used to hold unitialized variables or common storage. The length of
1761 each partial program's bss section is important, but because it starts
1762 out containing zeroed bytes there is no need to store explicit zero
1763 bytes in the object file. The bss section was invented to eliminate
1764 those explicit zeros from object files.
1765
1766 @cindex absolute section
1767 @item absolute section
1768 Address 0 of this section is always ``relocated'' to runtime address 0.
1769 This is useful if you want to refer to an address that @code{@value{LD}} must
1770 not change when relocating. In this sense we speak of absolute
1771 addresses being ``unrelocatable'': they don't change during relocation.
1772
1773 @cindex undefined section
1774 @item undefined section
1775 This ``section'' is a catch-all for address references to objects not in
1776 the preceding sections.
1777 @c FIXME: ref to some other doc on obj-file formats could go here.
1778 @end table
1779
1780 @cindex relocation example
1781 An idealized example of three relocatable sections follows.
1782 @ifset COFF
1783 The example uses the traditional section names @samp{.text} and @samp{.data}.
1784 @end ifset
1785 Memory addresses are on the horizontal axis.
1786
1787 @c TEXI2ROFF-KILL
1788 @ifinfo
1789 @c END TEXI2ROFF-KILL
1790 @smallexample
1791 +-----+----+--+
1792 partial program # 1: |ttttt|dddd|00|
1793 +-----+----+--+
1794
1795 text data bss
1796 seg. seg. seg.
1797
1798 +---+---+---+
1799 partial program # 2: |TTT|DDD|000|
1800 +---+---+---+
1801
1802 +--+---+-----+--+----+---+-----+~~
1803 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1804 +--+---+-----+--+----+---+-----+~~
1805
1806 addresses: 0 @dots{}
1807 @end smallexample
1808 @c TEXI2ROFF-KILL
1809 @end ifinfo
1810 @c FIXME make sure no page breaks inside figure!!
1811 @tex
1812
1813 \line{\it Partial program \#1: \hfil}
1814 \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1815 \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1816
1817 \line{\it Partial program \#2: \hfil}
1818 \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1819 \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
1820
1821 \line{\it linked program: \hfil}
1822 \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
1823 \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
1824 ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1825 DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1826
1827 \line{\it addresses: \hfil}
1828 \line{0\dots\hfil}
1829
1830 @end tex
1831 @c END TEXI2ROFF-KILL
1832
1833 @node As Sections
1834 @section @value{AS} Internal Sections
1835
1836 @cindex internal @code{@value{AS}} sections
1837 @cindex sections in messages, internal
1838 These sections are meant only for the internal use of @code{@value{AS}}. They
1839 have no meaning at run-time. You don't really need to know about these
1840 sections for most purposes; but they can be mentioned in @code{@value{AS}}
1841 warning messages, so it might be helpful to have an idea of their
1842 meanings to @code{@value{AS}}. These sections are used to permit the
1843 value of every expression in your assembly language program to be a
1844 section-relative address.
1845
1846 @table @b
1847 @item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1848 @cindex assembler internal logic error
1849 An internal assembler logic error has been found. This means there is a
1850 bug in the assembler.
1851
1852 @item expr section
1853 @cindex expr (internal section)
1854 The assembler stores complex expression internally as combinations of
1855 symbols. When it needs to represent an expression as a symbol, it puts
1856 it in the expr section.
1857 @c FIXME item debug
1858 @c FIXME item transfer[t] vector preload
1859 @c FIXME item transfer[t] vector postload
1860 @c FIXME item register
1861 @end table
1862
1863 @node Sub-Sections
1864 @section Sub-Sections
1865
1866 @cindex numbered subsections
1867 @cindex grouping data
1868 @ifset aout-bout
1869 Assembled bytes
1870 @ifset COFF
1871 conventionally
1872 @end ifset
1873 fall into two sections: text and data.
1874 @end ifset
1875 You may have separate groups of
1876 @ifset GENERIC
1877 data in named sections
1878 @end ifset
1879 @ifclear GENERIC
1880 @ifclear aout-bout
1881 data in named sections
1882 @end ifclear
1883 @ifset aout-bout
1884 text or data
1885 @end ifset
1886 @end ifclear
1887 that you want to end up near to each other in the object file, even
1888 though they are not contiguous in the assembler source.
1889 @code{@value{AS}} allows you to use @dfn{subsections} for this purpose.
1890 Within each section, there can be numbered subsections with values from
1891 0 to 8192. Objects assembled into the same subsection will be grouped
1892 with other objects in the same subsection when they are all put into the
1893 object file. For example, a compiler might want to store constants in
1894 the text section, but might not want to have them interspersed with the
1895 program being assembled. In this case, the compiler could issue a
1896 @samp{.text 0} before each section of code being output, and a
1897 @samp{.text 1} before each group of constants being output.
1898
1899 Subsections are optional. If you don't use subsections, everything
1900 will be stored in subsection number zero.
1901
1902 @ifset GENERIC
1903 Each subsection is zero-padded up to a multiple of four bytes.
1904 (Subsections may be padded a different amount on different flavors
1905 of @code{@value{AS}}.)
1906 @end ifset
1907 @ifclear GENERIC
1908 @ifset H8
1909 On the H8/300 and H8/500 platforms, each subsection is zero-padded to a word
1910 boundary (two bytes).
1911 The same is true on the Hitachi SH.
1912 @end ifset
1913 @ifset I960
1914 @c FIXME section padding (alignment)?
1915 @c Rich Pixley says padding here depends on target obj code format; that
1916 @c doesn't seem particularly useful to say without further elaboration,
1917 @c so for now I say nothing about it. If this is a generic BFD issue,
1918 @c these paragraphs might need to vanish from this manual, and be
1919 @c discussed in BFD chapter of binutils (or some such).
1920 @end ifset
1921 @ifset A29K
1922 On the AMD 29K family, no particular padding is added to section or
1923 subsection sizes; @value{AS} forces no alignment on this platform.
1924 @end ifset
1925 @end ifclear
1926
1927 Subsections appear in your object file in numeric order, lowest numbered
1928 to highest. (All this to be compatible with other people's assemblers.)
1929 The object file contains no representation of subsections; @code{@value{LD}} and
1930 other programs that manipulate object files will see no trace of them.
1931 They just see all your text subsections as a text section, and all your
1932 data subsections as a data section.
1933
1934 To specify which subsection you want subsequent statements assembled
1935 into, use a numeric argument to specify it, in a @samp{.text
1936 @var{expression}} or a @samp{.data @var{expression}} statement.
1937 @ifset COFF
1938 @ifset GENERIC
1939 When generating COFF output, you
1940 @end ifset
1941 @ifclear GENERIC
1942 You
1943 @end ifclear
1944 can also use an extra subsection
1945 argument with arbitrary named sections: @samp{.section @var{name},
1946 @var{expression}}.
1947 @end ifset
1948 @var{Expression} should be an absolute expression.
1949 (@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
1950 is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
1951 begins in @code{text 0}. For instance:
1952 @smallexample
1953 .text 0 # The default subsection is text 0 anyway.
1954 .ascii "This lives in the first text subsection. *"
1955 .text 1
1956 .ascii "But this lives in the second text subsection."
1957 .data 0
1958 .ascii "This lives in the data section,"
1959 .ascii "in the first data subsection."
1960 .text 0
1961 .ascii "This lives in the first text section,"
1962 .ascii "immediately following the asterisk (*)."
1963 @end smallexample
1964
1965 Each section has a @dfn{location counter} incremented by one for every
1966 byte assembled into that section. Because subsections are merely a
1967 convenience restricted to @code{@value{AS}} there is no concept of a subsection
1968 location counter. There is no way to directly manipulate a location
1969 counter---but the @code{.align} directive will change it, and any label
1970 definition will capture its current value. The location counter of the
1971 section that statements are being assembled into is said to be the
1972 @dfn{active} location counter.
1973
1974 @node bss
1975 @section bss Section
1976
1977 @cindex bss section
1978 @cindex common variable storage
1979 The bss section is used for local common variable storage.
1980 You may allocate address space in the bss section, but you may
1981 not dictate data to load into it before your program executes. When
1982 your program starts running, all the contents of the bss
1983 section are zeroed bytes.
1984
1985 Addresses in the bss section are allocated with special directives; you
1986 may not assemble anything directly into the bss section. Hence there
1987 are no bss subsections. @xref{Comm,,@code{.comm}},
1988 @pxref{Lcomm,,@code{.lcomm}}.
1989
1990 @node Symbols
1991 @chapter Symbols
1992
1993 @cindex symbols
1994 Symbols are a central concept: the programmer uses symbols to name
1995 things, the linker uses symbols to link, and the debugger uses symbols
1996 to debug.
1997
1998 @quotation
1999 @cindex debuggers, and symbol order
2000 @emph{Warning:} @code{@value{AS}} does not place symbols in the object file in
2001 the same order they were declared. This may break some debuggers.
2002 @end quotation
2003
2004 @menu
2005 * Labels:: Labels
2006 * Setting Symbols:: Giving Symbols Other Values
2007 * Symbol Names:: Symbol Names
2008 * Dot:: The Special Dot Symbol
2009 * Symbol Attributes:: Symbol Attributes
2010 @end menu
2011
2012 @node Labels
2013 @section Labels
2014
2015 @cindex labels
2016 A @dfn{label} is written as a symbol immediately followed by a colon
2017 @samp{:}. The symbol then represents the current value of the
2018 active location counter, and is, for example, a suitable instruction
2019 operand. You are warned if you use the same symbol to represent two
2020 different locations: the first definition overrides any other
2021 definitions.
2022
2023 @ifset HPPA
2024 On the HPPA, a @dfn{label} need not be immediately followed by a colon,
2025 but instead must start in column zero. Only one @dfn{label} may be
2026 defined on a single line.
2027 @end ifset
2028
2029 @node Setting Symbols
2030 @section Giving Symbols Other Values
2031
2032 @cindex assigning values to symbols
2033 @cindex symbol values, assigning
2034 A symbol can be given an arbitrary value by writing a symbol, followed
2035 by an equals sign @samp{=}, followed by an expression
2036 (@pxref{Expressions}). This is equivalent to using the @code{.set}
2037 directive. @xref{Set,,@code{.set}}.
2038
2039 @node Symbol Names
2040 @section Symbol Names
2041
2042 @cindex symbol names
2043 @cindex names, symbol
2044 @ifclear SPECIAL-SYMS
2045 Symbol names begin with a letter or with one of @samp{._}. On most
2046 machines, you can also use @code{$} in symbol names; exceptions are
2047 noted in @ref{Machine Dependencies}. That character may be followed by any
2048 string of digits, letters, dollar signs (unless otherwise noted in
2049 @ref{Machine Dependencies}), and underscores.
2050 @end ifclear
2051 @ifset A29K
2052 For the AMD 29K family, @samp{?} is also allowed in the
2053 body of a symbol name, though not at its beginning.
2054 @end ifset
2055
2056 @ifset SPECIAL-SYMS
2057 @ifset H8
2058 Symbol names begin with a letter or with one of @samp{._}. On the
2059 Hitachi SH or the
2060 H8/500, you can also use @code{$} in symbol names. That character may
2061 be followed by any string of digits, letters, dollar signs (save on the
2062 H8/300), and underscores.
2063 @end ifset
2064 @end ifset
2065
2066 Case of letters is significant: @code{foo} is a different symbol name
2067 than @code{Foo}.
2068
2069 Each symbol has exactly one name. Each name in an assembly language
2070 program refers to exactly one symbol. You may use that symbol name any
2071 number of times in a program.
2072
2073 @subheading Local Symbol Names
2074
2075 @cindex local symbol names
2076 @cindex symbol names, local
2077 @cindex temporary symbol names
2078 @cindex symbol names, temporary
2079 Local symbols help compilers and programmers use names temporarily.
2080 There are ten local symbol names, which are re-used throughout the
2081 program. You may refer to them using the names @samp{0} @samp{1}
2082 @dots{} @samp{9}. To define a local symbol, write a label of the form
2083 @samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
2084 recent previous definition of that symbol write @samp{@b{N}b}, using the
2085 same digit as when you defined the label. To refer to the next
2086 definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
2087 a choice of 10 forward references. The @samp{b} stands for
2088 ``backwards'' and the @samp{f} stands for ``forwards''.
2089
2090 Local symbols are not emitted by the current GNU C compiler.
2091
2092 There is no restriction on how you can use these labels, but
2093 remember that at any point in the assembly you can refer to at most
2094 10 prior local labels and to at most 10 forward local labels.
2095
2096 Local symbol names are only a notation device. They are immediately
2097 transformed into more conventional symbol names before the assembler
2098 uses them. The symbol names stored in the symbol table, appearing in
2099 error messages and optionally emitted to the object file have these
2100 parts:
2101
2102 @table @code
2103 @item L
2104 All local labels begin with @samp{L}. Normally both @code{@value{AS}} and
2105 @code{@value{LD}} forget symbols that start with @samp{L}. These labels are
2106 used for symbols you are never intended to see. If you give the
2107 @samp{-L} option then @code{@value{AS}} will retain these symbols in the
2108 object file. If you also instruct @code{@value{LD}} to retain these symbols,
2109 you may use them in debugging.
2110
2111 @item @var{digit}
2112 If the label is written @samp{0:} then the digit is @samp{0}.
2113 If the label is written @samp{1:} then the digit is @samp{1}.
2114 And so on up through @samp{9:}.
2115
2116 @item @ctrl{A}
2117 This unusual character is included so you don't accidentally invent
2118 a symbol of the same name. The character has ASCII value
2119 @samp{\001}.
2120
2121 @item @emph{ordinal number}
2122 This is a serial number to keep the labels distinct. The first
2123 @samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
2124 number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
2125 through @samp{9:}.
2126 @end table
2127
2128 For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
2129 @code{3:} is named @code{L3@ctrl{A}44}.
2130
2131 @node Dot
2132 @section The Special Dot Symbol
2133
2134 @cindex dot (symbol)
2135 @cindex @code{.} (symbol)
2136 @cindex current address
2137 @cindex location counter
2138 The special symbol @samp{.} refers to the current address that
2139 @code{@value{AS}} is assembling into. Thus, the expression @samp{melvin:
2140 .long .} will cause @code{melvin} to contain its own address.
2141 Assigning a value to @code{.} is treated the same as a @code{.org}
2142 directive. Thus, the expression @samp{.=.+4} is the same as saying
2143 @ifclear no-space-dir
2144 @samp{.space 4}.
2145 @end ifclear
2146 @ifset no-space-dir
2147 @ifset A29K
2148 @samp{.block 4}.
2149 @end ifset
2150 @end ifset
2151
2152 @node Symbol Attributes
2153 @section Symbol Attributes
2154
2155 @cindex symbol attributes
2156 @cindex attributes, symbol
2157 Every symbol has, as well as its name, the attributes ``Value'' and
2158 ``Type''. Depending on output format, symbols can also have auxiliary
2159 attributes.
2160 @ifset INTERNALS
2161 The detailed definitions are in @file{a.out.h}.
2162 @end ifset
2163
2164 If you use a symbol without defining it, @code{@value{AS}} assumes zero for
2165 all these attributes, and probably won't warn you. This makes the
2166 symbol an externally defined symbol, which is generally what you
2167 would want.
2168
2169 @menu
2170 * Symbol Value:: Value
2171 * Symbol Type:: Type
2172 @ifset aout-bout
2173 @ifset GENERIC
2174 * a.out Symbols:: Symbol Attributes: @code{a.out}
2175 @end ifset
2176 @ifclear GENERIC
2177 @ifclear BOUT
2178 * a.out Symbols:: Symbol Attributes: @code{a.out}
2179 @end ifclear
2180 @ifset BOUT
2181 * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out}
2182 @end ifset
2183 @end ifclear
2184 @end ifset
2185 @ifset COFF
2186 * COFF Symbols:: Symbol Attributes for COFF
2187 @end ifset
2188 @ifset SOM
2189 * SOM Symbols:: Symbol Attributes for SOM
2190 @end ifset
2191 @end menu
2192
2193 @node Symbol Value
2194 @subsection Value
2195
2196 @cindex value of a symbol
2197 @cindex symbol value
2198 The value of a symbol is (usually) 32 bits. For a symbol which labels a
2199 location in the text, data, bss or absolute sections the value is the
2200 number of addresses from the start of that section to the label.
2201 Naturally for text, data and bss sections the value of a symbol changes
2202 as @code{@value{LD}} changes section base addresses during linking. Absolute
2203 symbols' values do not change during linking: that is why they are
2204 called absolute.
2205
2206 The value of an undefined symbol is treated in a special way. If it is
2207 0 then the symbol is not defined in this assembler source program, and
2208 @code{@value{LD}} will try to determine its value from other programs it is
2209 linked with. You make this kind of symbol simply by mentioning a symbol
2210 name without defining it. A non-zero value represents a @code{.comm}
2211 common declaration. The value is how much common storage to reserve, in
2212 bytes (addresses). The symbol refers to the first address of the
2213 allocated storage.
2214
2215 @node Symbol Type
2216 @subsection Type
2217
2218 @cindex type of a symbol
2219 @cindex symbol type
2220 The type attribute of a symbol contains relocation (section)
2221 information, any flag settings indicating that a symbol is external, and
2222 (optionally), other information for linkers and debuggers. The exact
2223 format depends on the object-code output format in use.
2224
2225 @ifset aout-bout
2226 @ifclear GENERIC
2227 @ifset BOUT
2228 @c The following avoids a "widow" subsection title. @group would be
2229 @c better if it were available outside examples.
2230 @need 1000
2231 @node a.out Symbols
2232 @subsection Symbol Attributes: @code{a.out}, @code{b.out}
2233
2234 @cindex @code{b.out} symbol attributes
2235 @cindex symbol attributes, @code{b.out}
2236 These symbol attributes appear only when @code{@value{AS}} is configured for
2237 one of the Berkeley-descended object output formats---@code{a.out} or
2238 @code{b.out}.
2239
2240 @end ifset
2241 @ifclear BOUT
2242 @node a.out Symbols
2243 @subsection Symbol Attributes: @code{a.out}
2244
2245 @cindex @code{a.out} symbol attributes
2246 @cindex symbol attributes, @code{a.out}
2247
2248 @end ifclear
2249 @end ifclear
2250 @ifset GENERIC
2251 @node a.out Symbols
2252 @subsection Symbol Attributes: @code{a.out}
2253
2254 @cindex @code{a.out} symbol attributes
2255 @cindex symbol attributes, @code{a.out}
2256
2257 @end ifset
2258 @menu
2259 * Symbol Desc:: Descriptor
2260 * Symbol Other:: Other
2261 @end menu
2262
2263 @node Symbol Desc
2264 @subsubsection Descriptor
2265
2266 @cindex descriptor, of @code{a.out} symbol
2267 This is an arbitrary 16-bit value. You may establish a symbol's
2268 descriptor value by using a @code{.desc} statement
2269 (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
2270 @code{@value{AS}}.
2271
2272 @node Symbol Other
2273 @subsubsection Other
2274
2275 @cindex other attribute, of @code{a.out} symbol
2276 This is an arbitrary 8-bit value. It means nothing to @code{@value{AS}}.
2277 @end ifset
2278
2279 @ifset COFF
2280 @node COFF Symbols
2281 @subsection Symbol Attributes for COFF
2282
2283 @cindex COFF symbol attributes
2284 @cindex symbol attributes, COFF
2285
2286 The COFF format supports a multitude of auxiliary symbol attributes;
2287 like the primary symbol attributes, they are set between @code{.def} and
2288 @code{.endef} directives.
2289
2290 @subsubsection Primary Attributes
2291
2292 @cindex primary attributes, COFF symbols
2293 The symbol name is set with @code{.def}; the value and type,
2294 respectively, with @code{.val} and @code{.type}.
2295
2296 @subsubsection Auxiliary Attributes
2297
2298 @cindex auxiliary attributes, COFF symbols
2299 The @code{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl},
2300 @code{.size}, and @code{.tag} can generate auxiliary symbol table
2301 information for COFF.
2302 @end ifset
2303
2304 @ifset SOM
2305 @node SOM Symbols
2306 @subsection Symbol Attributes for SOM
2307
2308 @cindex SOM symbol attributes
2309 @cindex symbol attributes, SOM
2310
2311 The SOM format supports a multitude of symbol attributes set with the
2312 with the @code{.EXPORT} and @code{.IMPORT} directives.
2313
2314 The attributes are described in @cite{HP9000 Series 800 Assembly
2315 Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and
2316 @code{EXPORT} assembler directive documentation.
2317 @end ifset
2318
2319 @node Expressions
2320 @chapter Expressions
2321
2322 @cindex expressions
2323 @cindex addresses
2324 @cindex numeric values
2325 An @dfn{expression} specifies an address or numeric value.
2326 Whitespace may precede and/or follow an expression.
2327
2328 @menu
2329 * Empty Exprs:: Empty Expressions
2330 * Integer Exprs:: Integer Expressions
2331 @end menu
2332
2333 @node Empty Exprs
2334 @section Empty Expressions
2335
2336 @cindex empty expressions
2337 @cindex expressions, empty
2338 An empty expression has no value: it is just whitespace or null.
2339 Wherever an absolute expression is required, you may omit the
2340 expression and @code{@value{AS}} will assume a value of (absolute) 0. This
2341 is compatible with other assemblers.
2342
2343 @node Integer Exprs
2344 @section Integer Expressions
2345
2346 @cindex integer expressions
2347 @cindex expressions, integer
2348 An @dfn{integer expression} is one or more @emph{arguments} delimited
2349 by @emph{operators}.
2350
2351 @menu
2352 * Arguments:: Arguments
2353 * Operators:: Operators
2354 * Prefix Ops:: Prefix Operators
2355 * Infix Ops:: Infix Operators
2356 @end menu
2357
2358 @node Arguments
2359 @subsection Arguments
2360
2361 @cindex expression arguments
2362 @cindex arguments in expressions
2363 @cindex operands in expressions
2364 @cindex arithmetic operands
2365 @dfn{Arguments} are symbols, numbers or subexpressions. In other
2366 contexts arguments are sometimes called ``arithmetic operands''. In
2367 this manual, to avoid confusing them with the ``instruction operands'' of
2368 the machine language, we use the term ``argument'' to refer to parts of
2369 expressions only, reserving the word ``operand'' to refer only to machine
2370 instruction operands.
2371
2372 Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
2373 @var{section} is one of text, data, bss, absolute,
2374 or undefined. @var{NNN} is a signed, 2's complement 32 bit
2375 integer.
2376
2377 Numbers are usually integers.
2378
2379 A number can be a flonum or bignum. In this case, you are warned
2380 that only the low order 32 bits are used, and @code{@value{AS}} pretends
2381 these 32 bits are an integer. You may write integer-manipulating
2382 instructions that act on exotic constants, compatible with other
2383 assemblers.
2384
2385 @cindex subexpressions
2386 Subexpressions are a left parenthesis @samp{(} followed by an integer
2387 expression, followed by a right parenthesis @samp{)}; or a prefix
2388 operator followed by an argument.
2389
2390 @node Operators
2391 @subsection Operators
2392
2393 @cindex operators, in expressions
2394 @cindex arithmetic functions
2395 @cindex functions, in expressions
2396 @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
2397 operators are followed by an argument. Infix operators appear
2398 between their arguments. Operators may be preceded and/or followed by
2399 whitespace.
2400
2401 @node Prefix Ops
2402 @subsection Prefix Operator
2403
2404 @cindex prefix operators
2405 @code{@value{AS}} has the following @dfn{prefix operators}. They each take
2406 one argument, which must be absolute.
2407
2408 @c the tex/end tex stuff surrounding this small table is meant to make
2409 @c it align, on the printed page, with the similar table in the next
2410 @c section (which is inside an enumerate).
2411 @tex
2412 \global\advance\leftskip by \itemindent
2413 @end tex
2414
2415 @table @code
2416 @item -
2417 @dfn{Negation}. Two's complement negation.
2418 @item ~
2419 @dfn{Complementation}. Bitwise not.
2420 @end table
2421
2422 @tex
2423 \global\advance\leftskip by -\itemindent
2424 @end tex
2425
2426 @node Infix Ops
2427 @subsection Infix Operators
2428
2429 @cindex infix operators
2430 @cindex operators, permitted arguments
2431 @dfn{Infix operators} take two arguments, one on either side. Operators
2432 have precedence, but operations with equal precedence are performed left
2433 to right. Apart from @code{+} or @code{-}, both arguments must be
2434 absolute, and the result is absolute.
2435
2436 @enumerate
2437 @cindex operator precedence
2438 @cindex precedence of operators
2439
2440 @item
2441 Highest Precedence
2442
2443 @table @code
2444 @item *
2445 @dfn{Multiplication}.
2446
2447 @item /
2448 @dfn{Division}. Truncation is the same as the C operator @samp{/}
2449
2450 @item %
2451 @dfn{Remainder}.
2452
2453 @item <
2454 @itemx <<
2455 @dfn{Shift Left}. Same as the C operator @samp{<<}.
2456
2457 @item >
2458 @itemx >>
2459 @dfn{Shift Right}. Same as the C operator @samp{>>}.
2460 @end table
2461
2462 @item
2463 Intermediate precedence
2464
2465 @table @code
2466 @item |
2467
2468 @dfn{Bitwise Inclusive Or}.
2469
2470 @item &
2471 @dfn{Bitwise And}.
2472
2473 @item ^
2474 @dfn{Bitwise Exclusive Or}.
2475
2476 @item !
2477 @dfn{Bitwise Or Not}.
2478 @end table
2479
2480 @item
2481 Lowest Precedence
2482
2483 @table @code
2484 @item +
2485 @cindex addition, permitted arguments
2486 @cindex plus, permitted arguments
2487 @cindex arguments for addition
2488 @dfn{Addition}. If either argument is absolute, the result
2489 has the section of the other argument.
2490 If either argument is pass1 or undefined, the result is pass1.
2491 Otherwise @code{+} is illegal.
2492
2493 @item -
2494 @cindex subtraction, permitted arguments
2495 @cindex minus, permitted arguments
2496 @cindex arguments for subtraction
2497 @dfn{Subtraction}. If the right argument is absolute, the
2498 result has the section of the left argument.
2499 If either argument is pass1 the result is pass1.
2500 If either argument is undefined the result is difference section.
2501 If both arguments are in the same section, the result is absolute---provided
2502 that section is one of text, data or bss.
2503 Otherwise subtraction is illegal.
2504 @end table
2505 @end enumerate
2506
2507 The sense of the rule for addition is that it's only meaningful to add
2508 the @emph{offsets} in an address; you can only have a defined section in
2509 one of the two arguments.
2510
2511 Similarly, you can't subtract quantities from two different sections.
2512
2513 @node Pseudo Ops
2514 @chapter Assembler Directives
2515
2516 @cindex directives, machine independent
2517 @cindex pseudo-ops, machine independent
2518 @cindex machine independent directives
2519 All assembler directives have names that begin with a period (@samp{.}).
2520 The rest of the name is letters, usually in lower case.
2521
2522 This chapter discusses directives that are available regardless of the
2523 target machine configuration for the GNU assembler.
2524 @ifset GENERIC
2525 Some machine configurations provide additional directives.
2526 @xref{Machine Dependencies}.
2527 @end ifset
2528 @ifclear GENERIC
2529 @ifset machine-directives
2530 @xref{Machine Dependencies} for additional directives.
2531 @end ifset
2532 @end ifclear
2533
2534 @menu
2535 * Abort:: @code{.abort}
2536 @ifset COFF
2537 * ABORT:: @code{.ABORT}
2538 @end ifset
2539
2540 * Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
2541 * App-File:: @code{.app-file @var{string}}
2542 * Ascii:: @code{.ascii "@var{string}"}@dots{}
2543 * Asciz:: @code{.asciz "@var{string}"}@dots{}
2544 * Byte:: @code{.byte @var{expressions}}
2545 * Comm:: @code{.comm @var{symbol} , @var{length} }
2546 * Data:: @code{.data @var{subsection}}
2547 @ifset COFF
2548 * Def:: @code{.def @var{name}}
2549 @end ifset
2550 @ifset aout-bout
2551 * Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
2552 @end ifset
2553 @ifset COFF
2554 * Dim:: @code{.dim}
2555 @end ifset
2556
2557 * Double:: @code{.double @var{flonums}}
2558 * Eject:: @code{.eject}
2559 * Else:: @code{.else}
2560 @ifset COFF
2561 * Endef:: @code{.endef}
2562 @end ifset
2563
2564 * Endif:: @code{.endif}
2565 * Equ:: @code{.equ @var{symbol}, @var{expression}}
2566 * Extern:: @code{.extern}
2567 @ifclear no-file-dir
2568 * File:: @code{.file @var{string}}
2569 @end ifclear
2570
2571 * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
2572 * Float:: @code{.float @var{flonums}}
2573 * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2574 * hword:: @code{.hword @var{expressions}}
2575 * Ident:: @code{.ident}
2576 * If:: @code{.if @var{absolute expression}}
2577 * Include:: @code{.include "@var{file}"}
2578 * Int:: @code{.int @var{expressions}}
2579 * Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
2580 * Lflags:: @code{.lflags}
2581 @ifclear no-line-dir
2582 * Line:: @code{.line @var{line-number}}
2583 @end ifclear
2584
2585 * Ln:: @code{.ln @var{line-number}}
2586 * List:: @code{.list}
2587 * Long:: @code{.long @var{expressions}}
2588 @ignore
2589 * Lsym:: @code{.lsym @var{symbol}, @var{expression}}
2590 @end ignore
2591
2592 * Nolist:: @code{.nolist}
2593 * Octa:: @code{.octa @var{bignums}}
2594 * Org:: @code{.org @var{new-lc} , @var{fill}}
2595 * Psize:: @code{.psize @var{lines}, @var{columns}}
2596 * Quad:: @code{.quad @var{bignums}}
2597 * Sbttl:: @code{.sbttl "@var{subheading}"}
2598 @ifset COFF
2599 * Scl:: @code{.scl @var{class}}
2600 @end ifset
2601 @ifset COFF
2602 * Section:: @code{.section @var{name}, @var{subsection}}
2603 @end ifset
2604
2605 * Set:: @code{.set @var{symbol}, @var{expression}}
2606 * Short:: @code{.short @var{expressions}}
2607 * Single:: @code{.single @var{flonums}}
2608 @ifset COFF
2609 * Size:: @code{.size}
2610 @end ifset
2611
2612 * Space:: @code{.space @var{size} , @var{fill}}
2613 @ifset have-stabs
2614 * Stab:: @code{.stabd, .stabn, .stabs}
2615 @end ifset
2616 @ifset COFF
2617 * Tag:: @code{.tag @var{structname}}
2618 @end ifset
2619
2620 * Text:: @code{.text @var{subsection}}
2621 * Title:: @code{.title "@var{heading}"}
2622 @ifset COFF
2623 * Type:: @code{.type @var{int}}
2624 * Val:: @code{.val @var{addr}}
2625 @end ifset
2626
2627 * Word:: @code{.word @var{expressions}}
2628 * Deprecated:: Deprecated Directives
2629 @end menu
2630
2631 @node Abort
2632 @section @code{.abort}
2633
2634 @cindex @code{abort} directive
2635 @cindex stopping the assembly
2636 This directive stops the assembly immediately. It is for
2637 compatibility with other assemblers. The original idea was that the
2638 assembly language source would be piped into the assembler. If the sender
2639 of the source quit, it could use this directive tells @code{@value{AS}} to
2640 quit also. One day @code{.abort} will not be supported.
2641
2642 @ifset COFF
2643 @node ABORT
2644 @section @code{.ABORT}
2645
2646 @cindex @code{ABORT} directive
2647 When producing COFF output, @code{@value{AS}} accepts this directive as a
2648 synonym for @samp{.abort}.
2649
2650 @ifset BOUT
2651 When producing @code{b.out} output, @code{@value{AS}} accepts this directive,
2652 but ignores it.
2653 @end ifset
2654 @end ifset
2655
2656 @node Align
2657 @section @code{.align @var{abs-expr} , @var{abs-expr}}
2658
2659 @cindex padding the location counter
2660 @cindex @code{align} directive
2661 Pad the location counter (in the current subsection) to a particular
2662 storage boundary. The first expression (which must be absolute) is the
2663 number of low-order zero bits the location counter will have after
2664 advancement. For example @samp{.align 3} will advance the location
2665 counter until it a multiple of 8. If the location counter is already a
2666 multiple of 8, no change is needed.
2667
2668 @ifset HPPA
2669 For the HPPA, the first expression (which must be absolute) is the
2670 alignment request in bytes. For example @samp{.align 8} will advance
2671 the location counter until it is a multiple of 8. If the location counter
2672 is already a multiple of 8, no change is needed.
2673 @end ifset
2674
2675 The second expression (also absolute) gives the value to be stored in
2676 the padding bytes. It (and the comma) may be omitted. If it is
2677 omitted, the padding bytes are zero.
2678
2679 @node App-File
2680 @section @code{.app-file @var{string}}
2681
2682 @cindex logical file name
2683 @cindex file name, logical
2684 @cindex @code{app-file} directive
2685 @code{.app-file}
2686 @ifclear no-file-dir
2687 (which may also be spelled @samp{.file})
2688 @end ifclear
2689 tells @code{@value{AS}} that we are about to start a new
2690 logical file. @var{string} is the new file name. In general, the
2691 filename is recognized whether or not it is surrounded by quotes @samp{"};
2692 but if you wish to specify an empty file name is permitted,
2693 you must give the quotes--@code{""}. This statement may go away in
2694 future: it is only recognized to be compatible with old @code{@value{AS}}
2695 programs.@refill
2696
2697 @node Ascii
2698 @section @code{.ascii "@var{string}"}@dots{}
2699
2700 @cindex @code{ascii} directive
2701 @cindex string literals
2702 @code{.ascii} expects zero or more string literals (@pxref{Strings})
2703 separated by commas. It assembles each string (with no automatic
2704 trailing zero byte) into consecutive addresses.
2705
2706 @node Asciz
2707 @section @code{.asciz "@var{string}"}@dots{}
2708
2709 @cindex @code{asciz} directive
2710 @cindex zero-terminated strings
2711 @cindex null-terminated strings
2712 @code{.asciz} is just like @code{.ascii}, but each string is followed by
2713 a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2714
2715 @node Byte
2716 @section @code{.byte @var{expressions}}
2717
2718 @cindex @code{byte} directive
2719 @cindex integers, one byte
2720 @code{.byte} expects zero or more expressions, separated by commas.
2721 Each expression is assembled into the next byte.
2722
2723 @node Comm
2724 @section @code{.comm @var{symbol} , @var{length} }
2725
2726 @cindex @code{comm} directive
2727 @cindex symbol, common
2728 @code{.comm} declares a named common area in the bss section. Normally
2729 @code{@value{LD}} reserves memory addresses for it during linking, so no partial
2730 program defines the location of the symbol. Use @code{.comm} to tell
2731 @code{@value{LD}} that it must be at least @var{length} bytes long. @code{@value{LD}}
2732 will allocate space for each @code{.comm} symbol that is at least as
2733 long as the longest @code{.comm} request in any of the partial programs
2734 linked. @var{length} is an absolute expression.
2735
2736 @ifset HPPA
2737 The syntax for @code{.comm} differs slightly on the HPPA. The syntax is
2738 @code{@var{symbol} .comm, @var{length}}; @var{symbol} is optional.
2739 @end ifset
2740
2741 @node Data
2742 @section @code{.data @var{subsection}}
2743
2744 @cindex @code{data} directive
2745 @code{.data} tells @code{@value{AS}} to assemble the following statements onto the
2746 end of the data subsection numbered @var{subsection} (which is an
2747 absolute expression). If @var{subsection} is omitted, it defaults
2748 to zero.
2749
2750 @ifset COFF
2751 @node Def
2752 @section @code{.def @var{name}}
2753
2754 @cindex @code{def} directive
2755 @cindex COFF symbols, debugging
2756 @cindex debugging COFF symbols
2757 Begin defining debugging information for a symbol @var{name}; the
2758 definition extends until the @code{.endef} directive is encountered.
2759 @ifset BOUT
2760
2761 This directive is only observed when @code{@value{AS}} is configured for COFF
2762 format output; when producing @code{b.out}, @samp{.def} is recognized,
2763 but ignored.
2764 @end ifset
2765 @end ifset
2766
2767 @ifset aout-bout
2768 @node Desc
2769 @section @code{.desc @var{symbol}, @var{abs-expression}}
2770
2771 @cindex @code{desc} directive
2772 @cindex COFF symbol descriptor
2773 @cindex symbol descriptor, COFF
2774 This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2775 to the low 16 bits of an absolute expression.
2776
2777 @ifset COFF
2778 The @samp{.desc} directive is not available when @code{@value{AS}} is
2779 configured for COFF output; it is only for @code{a.out} or @code{b.out}
2780 object format. For the sake of compatibility, @code{@value{AS}} will accept
2781 it, but produce no output, when configured for COFF.
2782 @end ifset
2783 @end ifset
2784
2785 @ifset COFF
2786 @node Dim
2787 @section @code{.dim}
2788
2789 @cindex @code{dim} directive
2790 @cindex COFF auxiliary symbol information
2791 @cindex auxiliary symbol information, COFF
2792 This directive is generated by compilers to include auxiliary debugging
2793 information in the symbol table. It is only permitted inside
2794 @code{.def}/@code{.endef} pairs.
2795 @ifset BOUT
2796
2797 @samp{.dim} is only meaningful when generating COFF format output; when
2798 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
2799 ignores it.
2800 @end ifset
2801 @end ifset
2802
2803 @node Double
2804 @section @code{.double @var{flonums}}
2805
2806 @cindex @code{double} directive
2807 @cindex floating point numbers (double)
2808 @code{.double} expects zero or more flonums, separated by commas. It
2809 assembles floating point numbers.
2810 @ifset GENERIC
2811 The exact kind of floating point numbers emitted depends on how
2812 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
2813 @end ifset
2814 @ifclear GENERIC
2815 @ifset IEEEFLOAT
2816 On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers
2817 in @sc{ieee} format.
2818 @end ifset
2819 @end ifclear
2820
2821 @node Eject
2822 @section @code{.eject}
2823
2824 @cindex @code{eject} directive
2825 @cindex new page, in listings
2826 @cindex page, in listings
2827 @cindex listing control: new page
2828 Force a page break at this point, when generating assembly listings.
2829
2830 @node Else
2831 @section @code{.else}
2832
2833 @cindex @code{else} directive
2834 @code{.else} is part of the @code{@value{AS}} support for conditional
2835 assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2836 of code to be assembled if the condition for the preceding @code{.if}
2837 was false.
2838
2839 @ignore
2840 @node End, Endef, Else, Pseudo Ops
2841 @section @code{.end}
2842
2843 @cindex @code{end} directive
2844 This doesn't do anything---but isn't an s_ignore, so I suspect it's
2845 meant to do something eventually (which is why it isn't documented here
2846 as "for compatibility with blah").
2847 @end ignore
2848
2849 @ifset COFF
2850 @node Endef
2851 @section @code{.endef}
2852
2853 @cindex @code{endef} directive
2854 This directive flags the end of a symbol definition begun with
2855 @code{.def}.
2856 @ifset BOUT
2857
2858 @samp{.endef} is only meaningful when generating COFF format output; if
2859 @code{@value{AS}} is configured to generate @code{b.out}, it accepts this
2860 directive but ignores it.
2861 @end ifset
2862 @end ifset
2863
2864 @node Endif
2865 @section @code{.endif}
2866
2867 @cindex @code{endif} directive
2868 @code{.endif} is part of the @code{@value{AS}} support for conditional assembly;
2869 it marks the end of a block of code that is only assembled
2870 conditionally. @xref{If,,@code{.if}}.
2871
2872 @node Equ
2873 @section @code{.equ @var{symbol}, @var{expression}}
2874
2875 @cindex @code{equ} directive
2876 @cindex assigning values to symbols
2877 @cindex symbols, assigning values to
2878 This directive sets the value of @var{symbol} to @var{expression}.
2879 It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2880
2881 @ifset HPPA
2882 The syntax for @code{equ} on the HPPA is
2883 @code{@var{symbol} .equ @var{expression}}.
2884 @end ifset
2885
2886 @node Extern
2887 @section @code{.extern}
2888
2889 @cindex @code{extern} directive
2890 @code{.extern} is accepted in the source program---for compatibility
2891 with other assemblers---but it is ignored. @code{@value{AS}} treats
2892 all undefined symbols as external.
2893
2894 @ifclear no-file-dir
2895 @node File
2896 @section @code{.file @var{string}}
2897
2898 @cindex @code{file} directive
2899 @cindex logical file name
2900 @cindex file name, logical
2901 @code{.file} (which may also be spelled @samp{.app-file}) tells
2902 @code{@value{AS}} that we are about to start a new logical file.
2903 @var{string} is the new file name. In general, the filename is
2904 recognized whether or not it is surrounded by quotes @samp{"}; but if
2905 you wish to specify an empty file name, you must give the
2906 quotes--@code{""}. This statement may go away in future: it is only
2907 recognized to be compatible with old @code{@value{AS}} programs.
2908 @ifset A29K
2909 In some configurations of @code{@value{AS}}, @code{.file} has already been
2910 removed to avoid conflicts with other assemblers. @xref{Machine Dependencies}.
2911 @end ifset
2912 @end ifclear
2913
2914 @node Fill
2915 @section @code{.fill @var{repeat} , @var{size} , @var{value}}
2916
2917 @cindex @code{fill} directive
2918 @cindex writing patterns in memory
2919 @cindex patterns, writing in memory
2920 @var{result}, @var{size} and @var{value} are absolute expressions.
2921 This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2922 may be zero or more. @var{Size} may be zero or more, but if it is
2923 more than 8, then it is deemed to have the value 8, compatible with
2924 other people's assemblers. The contents of each @var{repeat} bytes
2925 is taken from an 8-byte number. The highest order 4 bytes are
2926 zero. The lowest order 4 bytes are @var{value} rendered in the
2927 byte-order of an integer on the computer @code{@value{AS}} is assembling for.
2928 Each @var{size} bytes in a repetition is taken from the lowest order
2929 @var{size} bytes of this number. Again, this bizarre behavior is
2930 compatible with other people's assemblers.
2931
2932 @var{size} and @var{value} are optional.
2933 If the second comma and @var{value} are absent, @var{value} is
2934 assumed zero. If the first comma and following tokens are absent,
2935 @var{size} is assumed to be 1.
2936
2937 @node Float
2938 @section @code{.float @var{flonums}}
2939
2940 @cindex floating point numbers (single)
2941 @cindex @code{float} directive
2942 This directive assembles zero or more flonums, separated by commas. It
2943 has the same effect as @code{.single}.
2944 @ifset GENERIC
2945 The exact kind of floating point numbers emitted depends on how
2946 @code{@value{AS}} is configured.
2947 @xref{Machine Dependencies}.
2948 @end ifset
2949 @ifclear GENERIC
2950 @ifset IEEEFLOAT
2951 On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers
2952 in @sc{ieee} format.
2953 @end ifset
2954 @end ifclear
2955
2956 @node Global
2957 @section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2958
2959 @cindex @code{global} directive
2960 @cindex symbol, making visible to linker
2961 @code{.global} makes the symbol visible to @code{@value{LD}}. If you define
2962 @var{symbol} in your partial program, its value is made available to
2963 other partial programs that are linked with it. Otherwise,
2964 @var{symbol} will take its attributes from a symbol of the same name
2965 from another partial program it is linked with.
2966
2967 Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
2968 compatibility with other assemblers.
2969
2970 @ifset HPPA
2971 On the HPPA symbols are made visible to @code{@value{LD}} with the
2972 @code{.EXPORT} directive. Using @code{.EXPORT} is necessary to provide
2973 the linker with the correct symbol type information necessary for linking
2974 in SOM
2975 @end ifset
2976
2977 @node hword
2978 @section @code{.hword @var{expressions}}
2979
2980 @cindex @code{hword} directive
2981 @cindex integers, 16-bit
2982 @cindex numbers, 16-bit
2983 @cindex sixteen bit integers
2984 This expects zero or more @var{expressions}, and emits
2985 a 16 bit number for each.
2986
2987 @ifset GENERIC
2988 This directive is a synonym for @samp{.short}; depending on the target
2989 architecture, it may also be a synonym for @samp{.word}.
2990 @end ifset
2991 @ifclear GENERIC
2992 @ifset W32
2993 This directive is a synonym for @samp{.short}.
2994 @end ifset
2995 @ifset W16
2996 This directive is a synonym for both @samp{.short} and @samp{.word}.
2997 @end ifset
2998 @end ifclear
2999
3000 @node Ident
3001 @section @code{.ident}
3002
3003 @cindex @code{ident} directive
3004 This directive is used by some assemblers to place tags in object files.
3005 @code{@value{AS}} simply accepts the directive for source-file
3006 compatibility with such assemblers, but does not actually emit anything
3007 for it.
3008
3009 @node If
3010 @section @code{.if @var{absolute expression}}
3011
3012 @cindex conditional assembly
3013 @cindex @code{if} directive
3014 @code{.if} marks the beginning of a section of code which is only
3015 considered part of the source program being assembled if the argument
3016 (which must be an @var{absolute expression}) is non-zero. The end of
3017 the conditional section of code must be marked by @code{.endif}
3018 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
3019 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
3020
3021 The following variants of @code{.if} are also supported:
3022 @table @code
3023 @item .ifdef @var{symbol}
3024 @cindex @code{ifdef} directive
3025 Assembles the following section of code if the specified @var{symbol}
3026 has been defined.
3027
3028 @ignore
3029 @item .ifeqs
3030 @cindex @code{ifeqs} directive
3031 Not yet implemented.
3032 @end ignore
3033
3034 @item .ifndef @var{symbol}
3035 @itemx ifnotdef @var{symbol}
3036 @cindex @code{ifndef} directive
3037 @cindex @code{ifnotdef} directive
3038 Assembles the following section of code if the specified @var{symbol}
3039 has not been defined. Both spelling variants are equivalent.
3040
3041 @ignore
3042 @item ifnes
3043 Not yet implemented.
3044 @end ignore
3045 @end table
3046
3047 @node Include
3048 @section @code{.include "@var{file}"}
3049
3050 @cindex @code{include} directive
3051 @cindex supporting files, including
3052 @cindex files, including
3053 This directive provides a way to include supporting files at specified
3054 points in your source program. The code from @var{file} is assembled as
3055 if it followed the point of the @code{.include}; when the end of the
3056 included file is reached, assembly of the original file continues. You
3057 can control the search paths used with the @samp{-I} command-line option
3058 (@pxref{Invoking,,Command-Line Options}). Quotation marks are required
3059 around @var{file}.
3060
3061 @node Int
3062 @section @code{.int @var{expressions}}
3063
3064 @cindex @code{int} directive
3065 @ifset GENERIC
3066 @cindex integers, 32-bit
3067 Expect zero or more @var{expressions}, of any section, separated by
3068 commas. For each expression, emit a 32-bit
3069 @end ifset
3070 @ifclear GENERIC
3071 @ifclear H8
3072 @cindex integers, 32-bit
3073 Expect zero or more @var{expressions}, of any section, separated by
3074 commas. For each expression, emit a 32-bit
3075 @end ifclear
3076 @ifset H8
3077 @cindex integers
3078 Expect zero or more @var{expressions}, of any section, separated by
3079 commas. For each expression, emit a
3080 @end ifset
3081 @end ifclear
3082 number that will, at run time, be the value of that expression. The
3083 byte order of the expression depends on what kind of computer will run
3084 the program.
3085
3086 @ifclear GENERIC
3087 @ifset H8
3088 On the H8/500 and most forms of the H8/300, @code{.int} emits 16-bit
3089 integers. On the H8/300H and the Hitachi SH, however, @code{.int} emits
3090 32-bit integers.
3091 @end ifset
3092 @end ifclear
3093
3094 @node Lcomm
3095 @section @code{.lcomm @var{symbol} , @var{length}}
3096
3097 @cindex @code{lcomm} directive
3098 @cindex local common symbols
3099 @cindex symbols, local common
3100 Reserve @var{length} (an absolute expression) bytes for a local common
3101 denoted by @var{symbol}. The section and value of @var{symbol} are
3102 those of the new local common. The addresses are allocated in the bss
3103 section, so at run-time the bytes will start off zeroed. @var{Symbol}
3104 is not declared global (@pxref{Global,,@code{.global}}), so is normally
3105 not visible to @code{@value{LD}}.
3106
3107 @ifset HPPA
3108 The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is
3109 @code{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional.
3110 @end ifset
3111
3112 @node Lflags
3113 @section @code{.lflags}
3114
3115 @cindex @code{lflags} directive (ignored)
3116 @code{@value{AS}} accepts this directive, for compatibility with other
3117 assemblers, but ignores it.
3118
3119 @ifclear no-line-dir
3120 @node Line
3121 @section @code{.line @var{line-number}}
3122
3123 @cindex @code{line} directive
3124 @end ifclear
3125 @ifset no-line-dir
3126 @node Ln
3127 @section @code{.ln @var{line-number}}
3128
3129 @cindex @code{ln} directive
3130 @end ifset
3131 @cindex logical line number
3132 @ifset aout-bout
3133 Tell @code{@value{AS}} to change the logical line number. @var{line-number} must be
3134 an absolute expression. The next line will have that logical line
3135 number. So any other statements on the current line (after a statement
3136 separator character)
3137 will be reported as on logical line number
3138 @var{line-number} @minus{} 1.
3139 One day this directive will be unsupported: it is used only
3140 for compatibility with existing assembler programs.
3141
3142 @ifset GENERIC
3143 @ifset A29K
3144 @emph{Warning:} In the AMD29K configuration of @value{AS}, this command is
3145 only available with the name @code{.ln}, rather than as either
3146 @code{.line} or @code{.ln}.
3147 @end ifset
3148 @end ifset
3149 @end ifset
3150
3151 @ifclear no-line-dir
3152 Even though this is a directive associated with the @code{a.out} or
3153 @code{b.out} object-code formats, @code{@value{AS}} will still recognize it
3154 when producing COFF output, and will treat @samp{.line} as though it
3155 were the COFF @samp{.ln} @emph{if} it is found outside a
3156 @code{.def}/@code{.endef} pair.
3157
3158 Inside a @code{.def}, @samp{.line} is, instead, one of the directives
3159 used by compilers to generate auxiliary symbol information for
3160 debugging.
3161 @end ifclear
3162
3163 @node Ln
3164 @section @code{.ln @var{line-number}}
3165
3166 @cindex @code{ln} directive
3167 @ifclear no-line-dir
3168 @samp{.ln} is a synonym for @samp{.line}.
3169 @end ifclear
3170 @ifset no-line-dir
3171 Tell @code{@value{AS}} to change the logical line number. @var{line-number}
3172 must be an absolute expression. The next line will have that logical
3173 line number, so any other statements on the current line (after a
3174 statement separator character @code{;}) will be reported as on logical
3175 line number @var{line-number} @minus{} 1.
3176 @ifset BOUT
3177
3178 This directive is accepted, but ignored, when @code{@value{AS}} is
3179 configured for @code{b.out}; its effect is only associated with COFF
3180 output format.
3181 @end ifset
3182 @end ifset
3183
3184 @node List
3185 @section @code{.list}
3186
3187 @cindex @code{list} directive
3188 @cindex listing control, turning on
3189 Control (in conjunction with the @code{.nolist} directive) whether or
3190 not assembly listings are generated. These two directives maintain an
3191 internal counter (which is zero initially). @code{.list} increments the
3192 counter, and @code{.nolist} decrements it. Assembly listings are
3193 generated whenever the counter is greater than zero.
3194
3195 By default, listings are disabled. When you enable them (with the
3196 @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
3197 the initial value of the listing counter is one.
3198
3199 @node Long
3200 @section @code{.long @var{expressions}}
3201
3202 @cindex @code{long} directive
3203 @code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
3204
3205 @ignore
3206 @c no one seems to know what this is for or whether this description is
3207 @c what it really ought to do
3208 @node Lsym
3209 @section @code{.lsym @var{symbol}, @var{expression}}
3210
3211 @cindex @code{lsym} directive
3212 @cindex symbol, not referenced in assembly
3213 @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
3214 the hash table, ensuring it cannot be referenced by name during the
3215 rest of the assembly. This sets the attributes of the symbol to be
3216 the same as the expression value:
3217 @smallexample
3218 @var{other} = @var{descriptor} = 0
3219 @var{type} = @r{(section of @var{expression})}
3220 @var{value} = @var{expression}
3221 @end smallexample
3222 @noindent
3223 The new symbol is not flagged as external.
3224 @end ignore
3225
3226 @node Nolist
3227 @section @code{.nolist}
3228
3229 @cindex @code{nolist} directive
3230 @cindex listing control, turning off
3231 Control (in conjunction with the @code{.list} directive) whether or
3232 not assembly listings are generated. These two directives maintain an
3233 internal counter (which is zero initially). @code{.list} increments the
3234 counter, and @code{.nolist} decrements it. Assembly listings are
3235 generated whenever the counter is greater than zero.
3236
3237 @node Octa
3238 @section @code{.octa @var{bignums}}
3239
3240 @c FIXME: double size emitted for "octa" on i960, others? Or warn?
3241 @cindex @code{octa} directive
3242 @cindex integer, 16-byte
3243 @cindex sixteen byte integer
3244 This directive expects zero or more bignums, separated by commas. For each
3245 bignum, it emits a 16-byte integer.
3246
3247 The term ``octa'' comes from contexts in which a ``word'' is two bytes;
3248 hence @emph{octa}-word for 16 bytes.
3249
3250 @node Org
3251 @section @code{.org @var{new-lc} , @var{fill}}
3252
3253 @cindex @code{org} directive
3254 @cindex location counter, advancing
3255 @cindex advancing location counter
3256 @cindex current address, advancing
3257 @code{.org} will advance the location counter of the current section to
3258 @var{new-lc}. @var{new-lc} is either an absolute expression or an
3259 expression with the same section as the current subsection. That is,
3260 you can't use @code{.org} to cross sections: if @var{new-lc} has the
3261 wrong section, the @code{.org} directive is ignored. To be compatible
3262 with former assemblers, if the section of @var{new-lc} is absolute,
3263 @code{@value{AS}} will issue a warning, then pretend the section of @var{new-lc}
3264 is the same as the current subsection.
3265
3266 @code{.org} may only increase the location counter, or leave it
3267 unchanged; you cannot use @code{.org} to move the location counter
3268 backwards.
3269
3270 @c double negative used below "not undefined" because this is a specific
3271 @c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
3272 @c section. pesch@cygnus.com 18feb91
3273 Because @code{@value{AS}} tries to assemble programs in one pass @var{new-lc}
3274 may not be undefined. If you really detest this restriction we eagerly await
3275 a chance to share your improved assembler.
3276
3277 Beware that the origin is relative to the start of the section, not
3278 to the start of the subsection. This is compatible with other
3279 people's assemblers.
3280
3281 When the location counter (of the current subsection) is advanced, the
3282 intervening bytes are filled with @var{fill} which should be an
3283 absolute expression. If the comma and @var{fill} are omitted,
3284 @var{fill} defaults to zero.
3285
3286 @node Psize
3287 @section @code{.psize @var{lines} , @var{columns}}
3288
3289 @cindex @code{psize} directive
3290 @cindex listing control: paper size
3291 @cindex paper size, for listings
3292 Use this directive to declare the number of lines---and, optionally, the
3293 number of columns---to use for each page, when generating listings.
3294
3295 If you don't use @code{.psize}, listings will use a default line-count
3296 of 60. You may omit the comma and @var{columns} specification; the
3297 default width is 200 columns.
3298
3299 @code{@value{AS}} will generate formfeeds whenever the specified number of
3300 lines is exceeded (or whenever you explicitly request one, using
3301 @code{.eject}).
3302
3303 If you specify @var{lines} as @code{0}, no formfeeds are generated save
3304 those explicitly specified with @code{.eject}.
3305
3306 @node Quad
3307 @section @code{.quad @var{bignums}}
3308
3309 @cindex @code{quad} directive
3310 @code{.quad} expects zero or more bignums, separated by commas. For
3311 each bignum, it emits
3312 @ifclear bignum-16
3313 an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a
3314 warning message; and just takes the lowest order 8 bytes of the bignum.
3315 @cindex eight-byte integer
3316 @cindex integer, 8-byte
3317
3318 The term ``quad'' comes from contexts in which a ``word'' is two bytes;
3319 hence @emph{quad}-word for 8 bytes.
3320 @end ifclear
3321 @ifset bignum-16
3322 a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a
3323 warning message; and just takes the lowest order 16 bytes of the bignum.
3324 @cindex sixteen-byte integer
3325 @cindex integer, 16-byte
3326 @end ifset
3327
3328 @node Sbttl
3329 @section @code{.sbttl "@var{subheading}"}
3330
3331 @cindex @code{sbttl} directive
3332 @cindex subtitles for listings
3333 @cindex listing control: subtitle
3334 Use @var{subheading} as the title (third line, immediately after the
3335 title line) when generating assembly listings.
3336
3337 This directive affects subsequent pages, as well as the current page if
3338 it appears within ten lines of the top of a page.
3339
3340 @ifset COFF
3341 @node Scl
3342 @section @code{.scl @var{class}}
3343
3344 @cindex @code{scl} directive
3345 @cindex symbol storage class (COFF)
3346 @cindex COFF symbol storage class
3347 Set the storage-class value for a symbol. This directive may only be
3348 used inside a @code{.def}/@code{.endef} pair. Storage class may flag
3349 whether a symbol is static or external, or it may record further
3350 symbolic debugging information.
3351 @ifset BOUT
3352
3353 The @samp{.scl} directive is primarily associated with COFF output; when
3354 configured to generate @code{b.out} output format, @code{@value{AS}} will
3355 accept this directive but ignore it.
3356 @end ifset
3357 @end ifset
3358
3359 @ifset COFF
3360 @node Section
3361 @section @code{.section @var{name}, @var{subsection}}
3362
3363 @cindex @code{section} directive
3364 @cindex named section (COFF)
3365 @cindex COFF named section
3366 Assemble the following code into end of subsection numbered
3367 @var{subsection} in the COFF named section @var{name}. If you omit
3368 @var{subsection}, @code{@value{AS}} uses subsection number zero.
3369 @samp{.section .text} is equivalent to the @code{.text} directive;
3370 @samp{.section .data} is equivalent to the @code{.data} directive.
3371 @end ifset
3372
3373 @node Set
3374 @section @code{.set @var{symbol}, @var{expression}}
3375
3376 @cindex @code{set} directive
3377 @cindex symbol value, setting
3378 This directive sets the value of @var{symbol} to @var{expression}. This
3379 will change @var{symbol}'s value and type to conform to
3380 @var{expression}. If @var{symbol} was flagged as external, it remains
3381 flagged. (@xref{Symbol Attributes}.)
3382
3383 You may @code{.set} a symbol many times in the same assembly.
3384 If the expression's section is unknowable during pass 1, a second
3385 pass over the source program will be forced. The second pass is
3386 currently not implemented. @code{@value{AS}} will abort with an error
3387 message if one is required.
3388
3389 If you @code{.set} a global symbol, the value stored in the object
3390 file is the last value stored into it.
3391
3392 @ifset HPPA
3393 The syntax for @code{set} on the HPPA is
3394 @code{@var{symbol} .set @var{expression}}.
3395 @end ifset
3396
3397 @node Short
3398 @section @code{.short @var{expressions}}
3399
3400 @cindex @code{short} directive
3401 @ifset GENERIC
3402 @code{.short} is normally the same as @samp{.word}.
3403 @xref{Word,,@code{.word}}.
3404
3405 In some configurations, however, @code{.short} and @code{.word} generate
3406 numbers of different lengths; @pxref{Machine Dependencies}.
3407 @end ifset
3408 @ifclear GENERIC
3409 @ifset W16
3410 @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
3411 @end ifset
3412 @ifset W32
3413 This expects zero or more @var{expressions}, and emits
3414 a 16 bit number for each.
3415 @end ifset
3416 @end ifclear
3417
3418 @node Single
3419 @section @code{.single @var{flonums}}
3420
3421 @cindex @code{single} directive
3422 @cindex floating point numbers (single)
3423 This directive assembles zero or more flonums, separated by commas. It
3424 has the same effect as @code{.float}.
3425 @ifset GENERIC
3426 The exact kind of floating point numbers emitted depends on how
3427 @code{@value{AS}} is configured. @xref{Machine Dependencies}.
3428 @end ifset
3429 @ifclear GENERIC
3430 @ifset IEEEFLOAT
3431 On the @value{TARGET} family, @code{.single} emits 32-bit floating point
3432 numbers in @sc{ieee} format.
3433 @end ifset
3434 @end ifclear
3435
3436 @ifset COFF
3437 @node Size
3438 @section @code{.size}
3439
3440 @cindex @code{size} directive
3441 This directive is generated by compilers to include auxiliary debugging
3442 information in the symbol table. It is only permitted inside
3443 @code{.def}/@code{.endef} pairs.
3444 @ifset BOUT
3445
3446 @samp{.size} is only meaningful when generating COFF format output; when
3447 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3448 ignores it.
3449 @end ifset
3450 @end ifset
3451
3452 @ifclear no-space-dir
3453 @node Space
3454 @section @code{.space @var{size} , @var{fill}}
3455
3456 @cindex @code{space} directive
3457 @cindex filling memory
3458 This directive emits @var{size} bytes, each of value @var{fill}. Both
3459 @var{size} and @var{fill} are absolute expressions. If the comma
3460 and @var{fill} are omitted, @var{fill} is assumed to be zero.
3461 @end ifclear
3462
3463 @ifset A29K
3464 @ifclear GENERIC
3465 @node Space
3466 @section @code{.space}
3467 @cindex @code{space} directive
3468 @end ifclear
3469 On the AMD 29K, this directive is ignored; it is accepted for
3470 compatibility with other AMD 29K assemblers.
3471
3472 @ifset HPPA
3473 @emph{Warning:} @code{.space} has a completely different meaning for HPPA
3474 targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800
3475 Assembly Language Reference Manual} (HP 92432-90001) for the meaning of
3476 the @code{.space} directive.
3477 @end ifset
3478
3479 @quotation
3480 @emph{Warning:} In most versions of the GNU assembler, the directive
3481 @code{.space} has the effect of @code{.block} @xref{Machine Dependencies}.
3482 @end quotation
3483 @end ifset
3484
3485 @ifset have-stabs
3486 @node Stab
3487 @section @code{.stabd, .stabn, .stabs}
3488
3489 @cindex symbolic debuggers, information for
3490 @cindex @code{stab@var{x}} directives
3491 There are three directives that begin @samp{.stab}.
3492 All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
3493 The symbols are not entered in the @code{@value{AS}} hash table: they
3494 cannot be referenced elsewhere in the source file.
3495 Up to five fields are required:
3496
3497 @table @var
3498 @item string
3499 This is the symbol's name. It may contain any character except
3500 @samp{\000}, so is more general than ordinary symbol names. Some
3501 debuggers used to code arbitrarily complex structures into symbol names
3502 using this field.
3503
3504 @item type
3505 An absolute expression. The symbol's type is set to the low 8 bits of
3506 this expression. Any bit pattern is permitted, but @code{@value{LD}}
3507 and debuggers will choke on silly bit patterns.
3508
3509 @item other
3510 An absolute expression. The symbol's ``other'' attribute is set to the
3511 low 8 bits of this expression.
3512
3513 @item desc
3514 An absolute expression. The symbol's descriptor is set to the low 16
3515 bits of this expression.
3516
3517 @item value
3518 An absolute expression which becomes the symbol's value.
3519 @end table
3520
3521 If a warning is detected while reading a @code{.stabd}, @code{.stabn},
3522 or @code{.stabs} statement, the symbol has probably already been created
3523 and you will get a half-formed symbol in your object file. This is
3524 compatible with earlier assemblers!
3525
3526 @table @code
3527 @cindex @code{stabd} directive
3528 @item .stabd @var{type} , @var{other} , @var{desc}
3529
3530 The ``name'' of the symbol generated is not even an empty string.
3531 It is a null pointer, for compatibility. Older assemblers used a
3532 null pointer so they didn't waste space in object files with empty
3533 strings.
3534
3535 The symbol's value is set to the location counter,
3536 relocatably. When your program is linked, the value of this symbol
3537 will be where the location counter was when the @code{.stabd} was
3538 assembled.
3539
3540 @item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
3541 @cindex @code{stabn} directive
3542 The name of the symbol is set to the empty string @code{""}.
3543
3544 @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
3545 @cindex @code{stabs} directive
3546 All five fields are specified.
3547 @end table
3548 @end ifset
3549 @c end have-stabs
3550
3551 @ifset COFF
3552 @node Tag
3553 @section @code{.tag @var{structname}}
3554
3555 @cindex COFF structure debugging
3556 @cindex structure debugging, COFF
3557 @cindex @code{tag} directive
3558 This directive is generated by compilers to include auxiliary debugging
3559 information in the symbol table. It is only permitted inside
3560 @code{.def}/@code{.endef} pairs. Tags are used to link structure
3561 definitions in the symbol table with instances of those structures.
3562 @ifset BOUT
3563
3564 @samp{.tag} is only used when generating COFF format output; when
3565 @code{@value{AS}} is generating @code{b.out}, it accepts this directive but
3566 ignores it.
3567 @end ifset
3568 @end ifset
3569
3570 @node Text
3571 @section @code{.text @var{subsection}}
3572
3573 @cindex @code{text} directive
3574 Tells @code{@value{AS}} to assemble the following statements onto the end of
3575 the text subsection numbered @var{subsection}, which is an absolute
3576 expression. If @var{subsection} is omitted, subsection number zero
3577 is used.
3578
3579 @node Title
3580 @section @code{.title "@var{heading}"}
3581
3582 @cindex @code{title} directive
3583 @cindex listing control: title line
3584 Use @var{heading} as the title (second line, immediately after the
3585 source file name and pagenumber) when generating assembly listings.
3586
3587 This directive affects subsequent pages, as well as the current page if
3588 it appears within ten lines of the top of a page.
3589
3590 @ifset COFF
3591 @node Type
3592 @section @code{.type @var{int}}
3593
3594 @cindex COFF symbol type
3595 @cindex symbol type, COFF
3596 @cindex @code{type} directive
3597 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3598 records the integer @var{int} as the type attribute of a symbol table entry.
3599 @ifset BOUT
3600
3601 @samp{.type} is associated only with COFF format output; when
3602 @code{@value{AS}} is configured for @code{b.out} output, it accepts this
3603 directive but ignores it.
3604 @end ifset
3605 @end ifset
3606
3607 @ifset COFF
3608 @node Val
3609 @section @code{.val @var{addr}}
3610
3611 @cindex @code{val} directive
3612 @cindex COFF value attribute
3613 @cindex value attribute, COFF
3614 This directive, permitted only within @code{.def}/@code{.endef} pairs,
3615 records the address @var{addr} as the value attribute of a symbol table
3616 entry.
3617 @ifset BOUT
3618
3619 @samp{.val} is used only for COFF output; when @code{@value{AS}} is
3620 configured for @code{b.out}, it accepts this directive but ignores it.
3621 @end ifset
3622 @end ifset
3623
3624 @node Word
3625 @section @code{.word @var{expressions}}
3626
3627 @cindex @code{word} directive
3628 This directive expects zero or more @var{expressions}, of any section,
3629 separated by commas.
3630 @ifclear GENERIC
3631 @ifset W32
3632 For each expression, @code{@value{AS}} emits a 32-bit number.
3633 @end ifset
3634 @ifset W16
3635 For each expression, @code{@value{AS}} emits a 16-bit number.
3636 @end ifset
3637 @end ifclear
3638 @ifset GENERIC
3639
3640 The size of the number emitted, and its byte order,
3641 depends on what kind of computer will run the program.
3642 @end ifset
3643
3644 @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
3645 @c happen---32-bit addressability, period; no long/short jumps.
3646 @ifset DIFF-TBL-KLUGE
3647 @cindex difference tables altered
3648 @cindex altered difference tables
3649 @quotation
3650 @emph{Warning: Special Treatment to support Compilers}
3651 @end quotation
3652
3653 @ifset GENERIC
3654 Machines with a 32-bit address space, but that do less than 32-bit
3655 addressing, require the following special treatment. If the machine of
3656 interest to you does 32-bit addressing (or doesn't require it;
3657 @pxref{Machine Dependencies}), you can ignore this issue.
3658
3659 @end ifset
3660 In order to assemble compiler output into something that will work,
3661 @code{@value{AS}} will occasionlly do strange things to @samp{.word} directives.
3662 Directives of the form @samp{.word sym1-sym2} are often emitted by
3663 compilers as part of jump tables. Therefore, when @code{@value{AS}} assembles a
3664 directive of the form @samp{.word sym1-sym2}, and the difference between
3665 @code{sym1} and @code{sym2} does not fit in 16 bits, @code{@value{AS}} will
3666 create a @dfn{secondary jump table}, immediately before the next label.
3667 This secondary jump table will be preceded by a short-jump to the
3668 first byte after the secondary table. This short-jump prevents the flow
3669 of control from accidentally falling into the new table. Inside the
3670 table will be a long-jump to @code{sym2}. The original @samp{.word}
3671 will contain @code{sym1} minus the address of the long-jump to
3672 @code{sym2}.
3673
3674 If there were several occurrences of @samp{.word sym1-sym2} before the
3675 secondary jump table, all of them will be adjusted. If there was a
3676 @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
3677 long-jump to @code{sym4} will be included in the secondary jump table,
3678 and the @code{.word} directives will be adjusted to contain @code{sym3}
3679 minus the address of the long-jump to @code{sym4}; and so on, for as many
3680 entries in the original jump table as necessary.
3681
3682 @ifset INTERNALS
3683 @emph{This feature may be disabled by compiling @code{@value{AS}} with the
3684 @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse
3685 assembly language programmers.
3686 @end ifset
3687 @end ifset
3688 @c end DIFF-TBL-KLUGE
3689
3690 @node Deprecated
3691 @section Deprecated Directives
3692
3693 @cindex deprecated directives
3694 @cindex obsolescent directives
3695 One day these directives won't work.
3696 They are included for compatibility with older assemblers.
3697 @table @t
3698 @item .abort
3699 @item .app-file
3700 @item .line
3701 @end table
3702
3703 @ifset GENERIC
3704 @node Machine Dependencies
3705 @chapter Machine Dependent Features
3706
3707 @cindex machine dependencies
3708 The machine instruction sets are (almost by definition) different on
3709 each machine where @code{@value{AS}} runs. Floating point representations
3710 vary as well, and @code{@value{AS}} often supports a few additional
3711 directives or command-line options for compatibility with other
3712 assemblers on a particular platform. Finally, some versions of
3713 @code{@value{AS}} support special pseudo-instructions for branch
3714 optimization.
3715
3716 This chapter discusses most of these differences, though it does not
3717 include details on any machine's instruction set. For details on that
3718 subject, see the hardware manufacturer's manual.
3719
3720 @menu
3721 @ifset VAX
3722 * Vax-Dependent:: VAX Dependent Features
3723 @end ifset
3724 @ifset A29K
3725 * AMD29K-Dependent:: AMD 29K Dependent Features
3726 @end ifset
3727 @ifset H8/300
3728 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
3729 @end ifset
3730 @ifset H8/500
3731 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
3732 @end ifset
3733 @ifset HPPA
3734 * HPPA-Dependent:: HPPA Dependent Features
3735 @end ifset
3736 @ifset SH
3737 * SH-Dependent:: Hitachi SH Dependent Features
3738 @end ifset
3739 @ifset I960
3740 * i960-Dependent:: Intel 80960 Dependent Features
3741 @end ifset
3742 @ifset M680X0
3743 * M68K-Dependent:: M680x0 Dependent Features
3744 @end ifset
3745 @ifset SPARC
3746 * Sparc-Dependent:: SPARC Dependent Features
3747 @end ifset
3748 @ifset Z8000
3749 * Z8000-Dependent:: Z8000 Dependent Features
3750 @end ifset
3751 @ifset I80386
3752 * i386-Dependent:: 80386 Dependent Features
3753 @end ifset
3754 @end menu
3755
3756 @lowersections
3757 @end ifset
3758
3759 @c The following major nodes are *sections* in the GENERIC version, *chapters*
3760 @c in single-cpu versions. This is mainly achieved by @lowersections. There is a
3761 @c peculiarity: to preserve cross-references, there must be a node called
3762 @c "Machine Dependencies". Hence the conditional nodenames in each
3763 @c major node below. Node defaulting in makeinfo requires adjacency of
3764 @c node and sectioning commands; hence the repetition of @chapter BLAH
3765 @c in both conditional blocks.
3766 @c
3767 @ifset VAX
3768 @ifset GENERIC
3769 @node Vax-Dependent
3770 @chapter VAX Dependent Features
3771 @cindex VAX support
3772
3773 @end ifset
3774 @ifclear GENERIC
3775 @node Machine Dependencies
3776 @chapter VAX Dependent Features
3777 @cindex VAX support
3778
3779 @end ifclear
3780
3781 @menu
3782 * Vax-Opts:: VAX Command-Line Options
3783 * VAX-float:: VAX Floating Point
3784 * VAX-directives:: Vax Machine Directives
3785 * VAX-opcodes:: VAX Opcodes
3786 * VAX-branch:: VAX Branch Improvement
3787 * VAX-operands:: VAX Operands
3788 * VAX-no:: Not Supported on VAX
3789 @end menu
3790
3791
3792 @node Vax-Opts
3793 @section VAX Command-Line Options
3794
3795 @cindex command-line options ignored, VAX
3796 @cindex VAX command-line options ignored
3797 The Vax version of @code{@value{AS}} accepts any of the following options,
3798 gives a warning message that the option was ignored and proceeds.
3799 These options are for compatibility with scripts designed for other
3800 people's assemblers.
3801
3802 @table @asis
3803 @item @kbd{-D} (Debug)
3804 @itemx @kbd{-S} (Symbol Table)
3805 @itemx @kbd{-T} (Token Trace)
3806 @cindex @code{-D}, ignored on VAX
3807 @cindex @code{-S}, ignored on VAX
3808 @cindex @code{-T}, ignored on VAX
3809 These are obsolete options used to debug old assemblers.
3810
3811 @item @kbd{-d} (Displacement size for JUMPs)
3812 @cindex @code{-d}, VAX option
3813 This option expects a number following the @kbd{-d}. Like options
3814 that expect filenames, the number may immediately follow the
3815 @kbd{-d} (old standard) or constitute the whole of the command line
3816 argument that follows @kbd{-d} (GNU standard).
3817
3818 @item @kbd{-V} (Virtualize Interpass Temporary File)
3819 @cindex @code{-V}, redundant on VAX
3820 Some other assemblers use a temporary file. This option
3821 commanded them to keep the information in active memory rather
3822 than in a disk file. @code{@value{AS}} always does this, so this
3823 option is redundant.
3824
3825 @item @kbd{-J} (JUMPify Longer Branches)
3826 @cindex @code{-J}, ignored on VAX
3827 Many 32-bit computers permit a variety of branch instructions
3828 to do the same job. Some of these instructions are short (and
3829 fast) but have a limited range; others are long (and slow) but
3830 can branch anywhere in virtual memory. Often there are 3
3831 flavors of branch: short, medium and long. Some other
3832 assemblers would emit short and medium branches, unless told by
3833 this option to emit short and long branches.
3834
3835 @item @kbd{-t} (Temporary File Directory)
3836 @cindex @code{-t}, ignored on VAX
3837 Some other assemblers may use a temporary file, and this option
3838 takes a filename being the directory to site the temporary
3839 file. Since @code{@value{AS}} does not use a temporary disk file, this
3840 option makes no difference. @kbd{-t} needs exactly one
3841 filename.
3842 @end table
3843
3844 @cindex VMS (VAX) options
3845 @cindex options for VAX/VMS
3846 @cindex VAX/VMS options
3847 @cindex @code{-h} option, VAX/VMS
3848 @cindex @code{-+} option, VAX/VMS
3849 @cindex Vax-11 C compatibility
3850 @cindex symbols with lowercase, VAX/VMS
3851 @c FIXME! look into "I think" below, correct if needed, delete.
3852 The Vax version of the assembler accepts two options when
3853 compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
3854 @kbd{-h} option prevents @code{@value{AS}} from modifying the
3855 symbol-table entries for symbols that contain lowercase
3856 characters (I think). The @kbd{-+} option causes @code{@value{AS}} to
3857 print warning messages if the FILENAME part of the object file,
3858 or any symbol name is larger than 31 characters. The @kbd{-+}
3859 option also insertes some code following the @samp{_main}
3860 symbol so that the object file will be compatible with Vax-11
3861 "C".
3862
3863 @node VAX-float
3864 @section VAX Floating Point
3865
3866 @cindex VAX floating point
3867 @cindex floating point, VAX
3868 Conversion of flonums to floating point is correct, and
3869 compatible with previous assemblers. Rounding is
3870 towards zero if the remainder is exactly half the least significant bit.
3871
3872 @code{D}, @code{F}, @code{G} and @code{H} floating point formats
3873 are understood.
3874
3875 Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
3876 are rendered correctly. Again, rounding is towards zero in the
3877 boundary case.
3878
3879 @cindex @code{float} directive, VAX
3880 @cindex @code{double} directive, VAX
3881 The @code{.float} directive produces @code{f} format numbers.
3882 The @code{.double} directive produces @code{d} format numbers.
3883
3884 @node VAX-directives
3885 @section Vax Machine Directives
3886
3887 @cindex machine directives, VAX
3888 @cindex VAX machine directives
3889 The Vax version of the assembler supports four directives for
3890 generating Vax floating point constants. They are described in the
3891 table below.
3892
3893 @cindex wide floating point directives, VAX
3894 @table @code
3895 @item .dfloat
3896 @cindex @code{dfloat} directive, VAX
3897 This expects zero or more flonums, separated by commas, and
3898 assembles Vax @code{d} format 64-bit floating point constants.
3899
3900 @item .ffloat
3901 @cindex @code{ffloat} directive, VAX
3902 This expects zero or more flonums, separated by commas, and
3903 assembles Vax @code{f} format 32-bit floating point constants.
3904
3905 @item .gfloat
3906 @cindex @code{gfloat} directive, VAX
3907 This expects zero or more flonums, separated by commas, and
3908 assembles Vax @code{g} format 64-bit floating point constants.
3909
3910 @item .hfloat
3911 @cindex @code{hfloat} directive, VAX
3912 This expects zero or more flonums, separated by commas, and
3913 assembles Vax @code{h} format 128-bit floating point constants.
3914
3915 @end table
3916
3917 @node VAX-opcodes
3918 @section VAX Opcodes
3919
3920 @cindex VAX opcode mnemonics
3921 @cindex opcode mnemonics, VAX
3922 @cindex mnemonics for opcodes, VAX
3923 All DEC mnemonics are supported. Beware that @code{case@dots{}}
3924 instructions have exactly 3 operands. The dispatch table that
3925 follows the @code{case@dots{}} instruction should be made with
3926 @code{.word} statements. This is compatible with all unix
3927 assemblers we know of.
3928
3929 @node VAX-branch
3930 @section VAX Branch Improvement
3931
3932 @cindex VAX branch improvement
3933 @cindex branch improvement, VAX
3934 @cindex pseudo-ops for branch, VAX
3935 Certain pseudo opcodes are permitted. They are for branch
3936 instructions. They expand to the shortest branch instruction that
3937 will reach the target. Generally these mnemonics are made by
3938 substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
3939 This feature is included both for compatibility and to help
3940 compilers. If you don't need this feature, don't use these
3941 opcodes. Here are the mnemonics, and the code they can expand into.
3942
3943 @table @code
3944 @item jbsb
3945 @samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
3946 @table @asis
3947 @item (byte displacement)
3948 @kbd{bsbb @dots{}}
3949 @item (word displacement)
3950 @kbd{bsbw @dots{}}
3951 @item (long displacement)
3952 @kbd{jsb @dots{}}
3953 @end table
3954 @item jbr
3955 @itemx jr
3956 Unconditional branch.
3957 @table @asis
3958 @item (byte displacement)
3959 @kbd{brb @dots{}}
3960 @item (word displacement)
3961 @kbd{brw @dots{}}
3962 @item (long displacement)
3963 @kbd{jmp @dots{}}
3964 @end table
3965 @item j@var{COND}
3966 @var{COND} may be any one of the conditional branches
3967 @code{neq}, @code{nequ}, @code{eql}, @code{eqlu}, @code{gtr},
3968 @code{geq}, @code{lss}, @code{gtru}, @code{lequ}, @code{vc}, @code{vs},
3969 @code{gequ}, @code{cc}, @code{lssu}, @code{cs}.
3970 @var{COND} may also be one of the bit tests
3971 @code{bs}, @code{bc}, @code{bss}, @code{bcs}, @code{bsc}, @code{bcc},
3972 @code{bssi}, @code{bcci}, @code{lbs}, @code{lbc}.
3973 @var{NOTCOND} is the opposite condition to @var{COND}.
3974 @table @asis
3975 @item (byte displacement)
3976 @kbd{b@var{COND} @dots{}}
3977 @item (word displacement)
3978 @kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
3979 @item (long displacement)
3980 @kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
3981 @end table
3982 @item jacb@var{X}
3983 @var{X} may be one of @code{b d f g h l w}.
3984 @table @asis
3985 @item (word displacement)
3986 @kbd{@var{OPCODE} @dots{}}
3987 @item (long displacement)
3988 @example
3989 @var{OPCODE} @dots{}, foo ;
3990 brb bar ;
3991 foo: jmp @dots{} ;
3992 bar:
3993 @end example
3994 @end table
3995 @item jaob@var{YYY}
3996 @var{YYY} may be one of @code{lss leq}.
3997 @item jsob@var{ZZZ}
3998 @var{ZZZ} may be one of @code{geq gtr}.
3999 @table @asis
4000 @item (byte displacement)
4001 @kbd{@var{OPCODE} @dots{}}
4002 @item (word displacement)
4003 @example
4004 @var{OPCODE} @dots{}, foo ;
4005 brb bar ;
4006 foo: brw @var{destination} ;
4007 bar:
4008 @end example
4009 @item (long displacement)
4010 @example
4011 @var{OPCODE} @dots{}, foo ;
4012 brb bar ;
4013 foo: jmp @var{destination} ;
4014 bar:
4015 @end example
4016 @end table
4017 @item aobleq
4018 @itemx aoblss
4019 @itemx sobgeq
4020 @itemx sobgtr
4021 @table @asis
4022 @item (byte displacement)
4023 @kbd{@var{OPCODE} @dots{}}
4024 @item (word displacement)
4025 @example
4026 @var{OPCODE} @dots{}, foo ;
4027 brb bar ;
4028 foo: brw @var{destination} ;
4029 bar:
4030 @end example
4031 @item (long displacement)
4032 @example
4033 @var{OPCODE} @dots{}, foo ;
4034 brb bar ;
4035 foo: jmp @var{destination} ;
4036 bar:
4037 @end example
4038 @end table
4039 @end table
4040
4041 @node VAX-operands
4042 @section VAX Operands
4043
4044 @cindex VAX operand notation
4045 @cindex operand notation, VAX
4046 @cindex immediate character, VAX
4047 @cindex VAX immediate character
4048 The immediate character is @samp{$} for Unix compatibility, not
4049 @samp{#} as DEC writes it.
4050
4051 @cindex indirect character, VAX
4052 @cindex VAX indirect character
4053 The indirect character is @samp{*} for Unix compatibility, not
4054 @samp{@@} as DEC writes it.
4055
4056 @cindex displacement sizing character, VAX
4057 @cindex VAX displacement sizing character
4058 The displacement sizing character is @samp{`} (an accent grave) for
4059 Unix compatibility, not @samp{^} as DEC writes it. The letter
4060 preceding @samp{`} may have either case. @samp{G} is not
4061 understood, but all other letters (@code{b i l s w}) are understood.
4062
4063 @cindex register names, VAX
4064 @cindex VAX register names
4065 Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
4066 pc}. Any case of letters will do.
4067
4068 For instance
4069 @smallexample
4070 tstb *w`$4(r5)
4071 @end smallexample
4072
4073 Any expression is permitted in an operand. Operands are comma
4074 separated.
4075
4076 @c There is some bug to do with recognizing expressions
4077 @c in operands, but I forget what it is. It is
4078 @c a syntax clash because () is used as an address mode
4079 @c and to encapsulate sub-expressions.
4080
4081 @node VAX-no
4082 @section Not Supported on VAX
4083
4084 @cindex VAX bitfields not supported
4085 @cindex bitfields, not supported on VAX
4086 Vax bit fields can not be assembled with @code{@value{AS}}. Someone
4087 can add the required code if they really need it.
4088
4089 @end ifset
4090 @ifset A29K
4091 @ifset GENERIC
4092 @page
4093 @node AMD29K-Dependent
4094 @chapter AMD 29K Dependent Features
4095 @end ifset
4096 @ifclear GENERIC
4097 @node Machine Dependencies
4098 @chapter AMD 29K Dependent Features
4099 @end ifclear
4100
4101 @cindex AMD 29K support
4102 @cindex 29K support
4103 @menu
4104 * AMD29K Options:: Options
4105 * AMD29K Syntax:: Syntax
4106 * AMD29K Floating Point:: Floating Point
4107 * AMD29K Directives:: AMD 29K Machine Directives
4108 * AMD29K Opcodes:: Opcodes
4109 @end menu
4110
4111 @node AMD29K Options
4112 @section Options
4113 @cindex AMD 29K options (none)
4114 @cindex options for AMD29K (none)
4115 @code{@value{AS}} has no additional command-line options for the AMD
4116 29K family.
4117
4118 @node AMD29K Syntax
4119 @section Syntax
4120 @menu
4121 * AMD29K-Chars:: Special Characters
4122 * AMD29K-Regs:: Register Names
4123 @end menu
4124
4125 @node AMD29K-Chars
4126 @subsection Special Characters
4127
4128 @cindex line comment character, AMD 29K
4129 @cindex AMD 29K line comment character
4130 @samp{;} is the line comment character.
4131
4132 @cindex line separator, AMD 29K
4133 @cindex AMD 29K line separator
4134 @cindex statement separator, AMD 29K
4135 @cindex AMD 29K statement separator
4136 @samp{@@} can be used instead of a newline to separate statements.
4137
4138 @cindex identifiers, AMD 29K
4139 @cindex AMD 29K identifiers
4140 The character @samp{?} is permitted in identifiers (but may not begin
4141 an identifier).
4142
4143 @node AMD29K-Regs
4144 @subsection Register Names
4145
4146 @cindex AMD 29K register names
4147 @cindex register names, AMD 29K
4148 General-purpose registers are represented by predefined symbols of the
4149 form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
4150 (for local registers), where @var{nnn} represents a number between
4151 @code{0} and @code{127}, written with no leading zeros. The leading
4152 letters may be in either upper or lower case; for example, @samp{gr13}
4153 and @samp{LR7} are both valid register names.
4154
4155 You may also refer to general-purpose registers by specifying the
4156 register number as the result of an expression (prefixed with @samp{%%}
4157 to flag the expression as a register number):
4158 @smallexample
4159 %%@var{expression}
4160 @end smallexample
4161 @noindent
4162 ---where @var{expression} must be an absolute expression evaluating to a
4163 number between @code{0} and @code{255}. The range [0, 127] refers to
4164 global registers, and the range [128, 255] to local registers.
4165
4166 @cindex special purpose registers, AMD 29K
4167 @cindex AMD 29K special purpose registers
4168 @cindex protected registers, AMD 29K
4169 @cindex AMD 29K protected registers
4170 In addition, @code{@value{AS}} understands the following protected
4171 special-purpose register names for the AMD 29K family:
4172
4173 @smallexample
4174 vab chd pc0
4175 ops chc pc1
4176 cps rbp pc2
4177 cfg tmc mmu
4178 cha tmr lru
4179 @end smallexample
4180
4181 These unprotected special-purpose register names are also recognized:
4182 @smallexample
4183 ipc alu fpe
4184 ipa bp inte
4185 ipb fc fps
4186 q cr exop
4187 @end smallexample
4188
4189 @node AMD29K Floating Point
4190 @section Floating Point
4191
4192 @cindex floating point, AMD 29K (@sc{ieee})
4193 @cindex AMD 29K floating point (@sc{ieee})
4194 The AMD 29K family uses @sc{ieee} floating-point numbers.
4195
4196 @node AMD29K Directives
4197 @section AMD 29K Machine Directives
4198
4199 @cindex machine directives, AMD 29K
4200 @cindex AMD 29K machine directives
4201 @table @code
4202 @item .block @var{size} , @var{fill}
4203 @cindex @code{block} directive, AMD 29K
4204 This directive emits @var{size} bytes, each of value @var{fill}. Both
4205 @var{size} and @var{fill} are absolute expressions. If the comma
4206 and @var{fill} are omitted, @var{fill} is assumed to be zero.
4207
4208 In other versions of the GNU assembler, this directive is called
4209 @samp{.space}.
4210 @end table
4211
4212 @table @code
4213 @item .cputype
4214 @cindex @code{cputype} directive, AMD 29K
4215 This directive is ignored; it is accepted for compatibility with other
4216 AMD 29K assemblers.
4217
4218 @item .file
4219 @cindex @code{file} directive, AMD 29K
4220 This directive is ignored; it is accepted for compatibility with other
4221 AMD 29K assemblers.
4222
4223 @quotation
4224 @emph{Warning:} in other versions of the GNU assembler, @code{.file} is
4225 used for the directive called @code{.app-file} in the AMD 29K support.
4226 @end quotation
4227
4228 @item .line
4229 @cindex @code{line} directive, AMD 29K
4230 This directive is ignored; it is accepted for compatibility with other
4231 AMD 29K assemblers.
4232
4233 @ignore
4234 @c since we're ignoring .lsym...
4235 @item .reg @var{symbol}, @var{expression}
4236 @cindex @code{reg} directive, AMD 29K
4237 @code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
4238 @end ignore
4239
4240 @item .sect
4241 @cindex @code{sect} directive, AMD 29K
4242 This directive is ignored; it is accepted for compatibility with other
4243 AMD 29K assemblers.
4244
4245 @item .use @var{section name}
4246 @cindex @code{use} directive, AMD 29K
4247 Establishes the section and subsection for the following code;
4248 @var{section name} may be one of @code{.text}, @code{.data},
4249 @code{.data1}, or @code{.lit}. With one of the first three @var{section
4250 name} options, @samp{.use} is equivalent to the machine directive
4251 @var{section name}; the remaining case, @samp{.use .lit}, is the same as
4252 @samp{.data 200}.
4253 @end table
4254
4255 @node AMD29K Opcodes
4256 @section Opcodes
4257
4258 @cindex AMD 29K opcodes
4259 @cindex opcodes for AMD 29K
4260 @code{@value{AS}} implements all the standard AMD 29K opcodes. No
4261 additional pseudo-instructions are needed on this family.
4262
4263 For information on the 29K machine instruction set, see @cite{Am29000
4264 User's Manual}, Advanced Micro Devices, Inc.
4265
4266 @end ifset
4267 @ifset Hitachi-all
4268 @ifclear GENERIC
4269 @node Machine Dependencies
4270 @chapter Machine Dependent Features
4271
4272 The machine instruction sets are different on each Hitachi chip family,
4273 and there are also some syntax differences among the families. This
4274 chapter describes the specific @code{@value{AS}} features for each
4275 family.
4276
4277 @menu
4278 * H8/300-Dependent:: Hitachi H8/300 Dependent Features
4279 * H8/500-Dependent:: Hitachi H8/500 Dependent Features
4280 * SH-Dependent:: Hitachi SH Dependent Features
4281 @end menu
4282 @lowersections
4283 @end ifclear
4284 @end ifset
4285
4286 @ifset H8/300
4287 @ifset GENERIC
4288 @page
4289 @end ifset
4290 @node H8/300-Dependent
4291 @chapter H8/300 Dependent Features
4292
4293 @cindex H8/300 support
4294 @menu
4295 * H8/300 Options:: Options
4296 * H8/300 Syntax:: Syntax
4297 * H8/300 Floating Point:: Floating Point
4298 * H8/300 Directives:: H8/300 Machine Directives
4299 * H8/300 Opcodes:: Opcodes
4300 @end menu
4301
4302 @node H8/300 Options
4303 @section Options
4304
4305 @cindex H8/300 options (none)
4306 @cindex options, H8/300 (none)
4307 @code{@value{AS}} has no additional command-line options for the Hitachi
4308 H8/300 family.
4309
4310 @node H8/300 Syntax
4311 @section Syntax
4312 @menu
4313 * H8/300-Chars:: Special Characters
4314 * H8/300-Regs:: Register Names
4315 * H8/300-Addressing:: Addressing Modes
4316 @end menu
4317
4318 @node H8/300-Chars
4319 @subsection Special Characters
4320
4321 @cindex line comment character, H8/300
4322 @cindex H8/300 line comment character
4323 @samp{;} is the line comment character.
4324
4325 @cindex line separator, H8/300
4326 @cindex statement separator, H8/300
4327 @cindex H8/300 line separator
4328 @samp{$} can be used instead of a newline to separate statements.
4329 Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
4330
4331 @node H8/300-Regs
4332 @subsection Register Names
4333
4334 @cindex H8/300 registers
4335 @cindex register names, H8/300
4336 You can use predefined symbols of the form @samp{r@var{n}h} and
4337 @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
4338 general-purpose registers. @var{n} is a digit from @samp{0} to
4339 @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
4340 register names.
4341
4342 You can also use the eight predefined symbols @samp{r@var{n}} to refer
4343 to the H8/300 registers as 16-bit registers (you must use this form for
4344 addressing).
4345
4346 On the H8/300H, you can also use the eight predefined symbols
4347 @samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit
4348 general purpose registers.
4349
4350 The two control registers are called @code{pc} (program counter; a
4351 16-bit register, except on the H8/300H where it is 24 bits) and
4352 @code{ccr} (condition code register; an 8-bit register). @code{r7} is
4353 used as the stack pointer, and can also be called @code{sp}.
4354
4355 @node H8/300-Addressing
4356 @subsection Addressing Modes
4357
4358 @cindex addressing modes, H8/300
4359 @cindex H8/300 addressing modes
4360 @value{AS} understands the following addressing modes for the H8/300:
4361 @table @code
4362 @item r@var{n}
4363 Register direct
4364
4365 @item @@r@var{n}
4366 Register indirect
4367
4368 @item @@(@var{d}, r@var{n})
4369 @itemx @@(@var{d}:16, r@var{n})
4370 @itemx @@(@var{d}:24, r@var{n})
4371 Register indirect: 16-bit or 24-bit displacement @var{d} from register
4372 @var{n}. (24-bit displacements are only meaningful on the H8/300H.)
4373
4374 @item @@r@var{n}+
4375 Register indirect with post-increment
4376
4377 @item @@-r@var{n}
4378 Register indirect with pre-decrement
4379
4380 @item @code{@@}@var{aa}
4381 @itemx @code{@@}@var{aa}:8
4382 @itemx @code{@@}@var{aa}:16
4383 @itemx @code{@@}@var{aa}:24
4384 Absolute address @code{aa}. (The address size @samp{:24} only makes
4385 sense on the H8/300H.)
4386
4387 @item #@var{xx}
4388 @itemx #@var{xx}:8
4389 @itemx #@var{xx}:16
4390 @itemx #@var{xx}:32
4391 Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or
4392 @samp{:32} for clarity, if you wish; but @code{@value{AS}} neither
4393 requires this nor uses it---the data size required is taken from
4394 context.
4395
4396 @item @code{@@}@code{@@}@var{aa}
4397 @itemx @code{@@}@code{@@}@var{aa}:8
4398 Memory indirect. You may specify the @samp{:8} for clarity, if you
4399 wish; but @code{@value{AS}} neither requires this nor uses it.
4400 @end table
4401
4402 @node H8/300 Floating Point
4403 @section Floating Point
4404
4405 @cindex floating point, H8/300 (@sc{ieee})
4406 @cindex H8/300 floating point (@sc{ieee})
4407 The H8/300 family has no hardware floating point, but the @code{.float}
4408 directive generates @sc{ieee} floating-point numbers for compatibility
4409 with other development tools.
4410
4411 @page
4412 @node H8/300 Directives
4413 @section H8/300 Machine Directives
4414
4415 @cindex H8/300 machine directives (none)
4416 @cindex machine directives, H8/300 (none)
4417 @cindex @code{word} directive, H8/300
4418 @cindex @code{int} directive, H8/300
4419 @code{@value{AS}} has only one machine-dependent directive for the
4420 H8/300:
4421
4422 @table @code
4423 @item .h300h
4424 @cindex H8/300H, assembling for
4425 Recognize and emit additional instructions for the H8/300H variant, and
4426 also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
4427 for the H8/300 family.
4428 @end table
4429
4430 On the H8/300 family (including the H8/300H) @samp{.word} directives
4431 generate 16-bit numbers.
4432
4433 @node H8/300 Opcodes
4434 @section Opcodes
4435
4436 @cindex H8/300 opcode summary
4437 @cindex opcode summary, H8/300
4438 @cindex mnemonics, H8/300
4439 @cindex instruction summary, H8/300
4440 For detailed information on the H8/300 machine instruction set, see
4441 @cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025). For
4442 information specific to the H8/300H, see @cite{H8/300H Series
4443 Programming Manual} (Hitachi).
4444
4445 @code{@value{AS}} implements all the standard H8/300 opcodes. No additional
4446 pseudo-instructions are needed on this family.
4447
4448 The following table summarizes the H8/300 opcodes, and their arguments.
4449 Entries marked @samp{*} are opcodes used only on the H8/300H.
4450
4451 @smallexample
4452 @c Using @group seems to use the normal baselineskip, not the smallexample
4453 @c baselineskip; looks approx doublespaced.
4454 @i{Legend:}
4455 Rs @r{source register}
4456 Rd @r{destination register}
4457 abs @r{absolute address}
4458 imm @r{immediate data}
4459 disp:N @r{N-bit displacement from a register}
4460 pcrel:N @r{N-bit displacement relative to program counter}
4461
4462 add.b #imm,rd * andc #imm,ccr
4463 add.b rs,rd band #imm,rd
4464 add.w rs,rd band #imm,@@rd
4465 * add.w #imm,rd band #imm,@@abs:8
4466 * add.l rs,rd bra pcrel:8
4467 * add.l #imm,rd * bra pcrel:16
4468 adds #imm,rd bt pcrel:8
4469 addx #imm,rd * bt pcrel:16
4470 addx rs,rd brn pcrel:8
4471 and.b #imm,rd * brn pcrel:16
4472 and.b rs,rd bf pcrel:8
4473 * and.w rs,rd * bf pcrel:16
4474 * and.w #imm,rd bhi pcrel:8
4475 * and.l #imm,rd * bhi pcrel:16
4476 * and.l rs,rd bls pcrel:8
4477 @page
4478 * bls pcrel:16 bld #imm,rd
4479 bcc pcrel:8 bld #imm,@@rd
4480 * bcc pcrel:16 bld #imm,@@abs:8
4481 bhs pcrel:8 bnot #imm,rd
4482 * bhs pcrel:16 bnot #imm,@@rd
4483 bcs pcrel:8 bnot #imm,@@abs:8
4484 * bcs pcrel:16 bnot rs,rd
4485 blo pcrel:8 bnot rs,@@rd
4486 * blo pcrel:16 bnot rs,@@abs:8
4487 bne pcrel:8 bor #imm,rd
4488 * bne pcrel:16 bor #imm,@@rd
4489 beq pcrel:8 bor #imm,@@abs:8
4490 * beq pcrel:16 bset #imm,rd
4491 bvc pcrel:8 bset #imm,@@rd
4492 * bvc pcrel:16 bset #imm,@@abs:8
4493 bvs pcrel:8 bset rs,rd
4494 * bvs pcrel:16 bset rs,@@rd
4495 bpl pcrel:8 bset rs,@@abs:8
4496 * bpl pcrel:16 bsr pcrel:8
4497 bmi pcrel:8 bsr pcrel:16
4498 * bmi pcrel:16 bst #imm,rd
4499 bge pcrel:8 bst #imm,@@rd
4500 * bge pcrel:16 bst #imm,@@abs:8
4501 blt pcrel:8 btst #imm,rd
4502 * blt pcrel:16 btst #imm,@@rd
4503 bgt pcrel:8 btst #imm,@@abs:8
4504 * bgt pcrel:16 btst rs,rd
4505 ble pcrel:8 btst rs,@@rd
4506 * ble pcrel:16 btst rs,@@abs:8
4507 bclr #imm,rd bxor #imm,rd
4508 bclr #imm,@@rd bxor #imm,@@rd
4509 bclr #imm,@@abs:8 bxor #imm,@@abs:8
4510 bclr rs,rd cmp.b #imm,rd
4511 bclr rs,@@rd cmp.b rs,rd
4512 bclr rs,@@abs:8 cmp.w rs,rd
4513 biand #imm,rd cmp.w rs,rd
4514 biand #imm,@@rd * cmp.w #imm,rd
4515 biand #imm,@@abs:8 * cmp.l #imm,rd
4516 bild #imm,rd * cmp.l rs,rd
4517 bild #imm,@@rd daa rs
4518 bild #imm,@@abs:8 das rs
4519 bior #imm,rd dec.b rs
4520 bior #imm,@@rd * dec.w #imm,rd
4521 bior #imm,@@abs:8 * dec.l #imm,rd
4522 bist #imm,rd divxu.b rs,rd
4523 bist #imm,@@rd * divxu.w rs,rd
4524 bist #imm,@@abs:8 * divxs.b rs,rd
4525 bixor #imm,rd * divxs.w rs,rd
4526 bixor #imm,@@rd eepmov
4527 bixor #imm,@@abs:8 * eepmovw
4528 @page
4529 * exts.w rd mov.w rs,@@abs:16
4530 * exts.l rd * mov.l #imm,rd
4531 * extu.w rd * mov.l rs,rd
4532 * extu.l rd * mov.l @@rs,rd
4533 inc rs * mov.l @@(disp:16,rs),rd
4534 * inc.w #imm,rd * mov.l @@(disp:24,rs),rd
4535 * inc.l #imm,rd * mov.l @@rs+,rd
4536 jmp @@rs * mov.l @@abs:16,rd
4537 jmp abs * mov.l @@abs:24,rd
4538 jmp @@@@abs:8 * mov.l rs,@@rd
4539 jsr @@rs * mov.l rs,@@(disp:16,rd)
4540 jsr abs * mov.l rs,@@(disp:24,rd)
4541 jsr @@@@abs:8 * mov.l rs,@@-rd
4542 ldc #imm,ccr * mov.l rs,@@abs:16
4543 ldc rs,ccr * mov.l rs,@@abs:24
4544 * ldc @@abs:16,ccr movfpe @@abs:16,rd
4545 * ldc @@abs:24,ccr movtpe rs,@@abs:16
4546 * ldc @@(disp:16,rs),ccr mulxu.b rs,rd
4547 * ldc @@(disp:24,rs),ccr * mulxu.w rs,rd
4548 * ldc @@rs+,ccr * mulxs.b rs,rd
4549 * ldc @@rs,ccr * mulxs.w rs,rd
4550 * mov.b @@(disp:24,rs),rd neg.b rs
4551 * mov.b rs,@@(disp:24,rd) * neg.w rs
4552 mov.b @@abs:16,rd * neg.l rs
4553 mov.b rs,rd nop
4554 mov.b @@abs:8,rd not.b rs
4555 mov.b rs,@@abs:8 * not.w rs
4556 mov.b rs,rd * not.l rs
4557 mov.b #imm,rd or.b #imm,rd
4558 mov.b @@rs,rd or.b rs,rd
4559 mov.b @@(disp:16,rs),rd * or.w #imm,rd
4560 mov.b @@rs+,rd * or.w rs,rd
4561 mov.b @@abs:8,rd * or.l #imm,rd
4562 mov.b rs,@@rd * or.l rs,rd
4563 mov.b rs,@@(disp:16,rd) orc #imm,ccr
4564 mov.b rs,@@-rd pop.w rs
4565 mov.b rs,@@abs:8 * pop.l rs
4566 mov.w rs,@@rd push.w rs
4567 * mov.w @@(disp:24,rs),rd * push.l rs
4568 * mov.w rs,@@(disp:24,rd) rotl.b rs
4569 * mov.w @@abs:24,rd * rotl.w rs
4570 * mov.w rs,@@abs:24 * rotl.l rs
4571 mov.w rs,rd rotr.b rs
4572 mov.w #imm,rd * rotr.w rs
4573 mov.w @@rs,rd * rotr.l rs
4574 mov.w @@(disp:16,rs),rd rotxl.b rs
4575 mov.w @@rs+,rd * rotxl.w rs
4576 mov.w @@abs:16,rd * rotxl.l rs
4577 mov.w rs,@@(disp:16,rd) rotxr.b rs
4578 mov.w rs,@@-rd * rotxr.w rs
4579 @page
4580 * rotxr.l rs * stc ccr,@@(disp:24,rd)
4581 bpt * stc ccr,@@-rd
4582 rte * stc ccr,@@abs:16
4583 rts * stc ccr,@@abs:24
4584 shal.b rs sub.b rs,rd
4585 * shal.w rs sub.w rs,rd
4586 * shal.l rs * sub.w #imm,rd
4587 shar.b rs * sub.l rs,rd
4588 * shar.w rs * sub.l #imm,rd
4589 * shar.l rs subs #imm,rd
4590 shll.b rs subx #imm,rd
4591 * shll.w rs subx rs,rd
4592 * shll.l rs * trapa #imm
4593 shlr.b rs xor #imm,rd
4594 * shlr.w rs xor rs,rd
4595 * shlr.l rs * xor.w #imm,rd
4596 sleep * xor.w rs,rd
4597 stc ccr,rd * xor.l #imm,rd
4598 * stc ccr,@@rs * xor.l rs,rd
4599 * stc ccr,@@(disp:16,rd) xorc #imm,ccr
4600 @end smallexample
4601
4602 @cindex size suffixes, H8/300
4603 @cindex H8/300 size suffixes
4604 Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
4605 @code{sub}) are defined with variants using the suffixes @samp{.b},
4606 @samp{.w}, and @samp{.l} to specify the size of a memory operand.
4607 @code{@value{AS}} supports these suffixes, but does not require them;
4608 since one of the operands is always a register, @code{@value{AS}} can
4609 deduce the correct size.
4610
4611 For example, since @code{r0} refers to a 16-bit register,
4612 @example
4613 mov r0,@@foo
4614 @exdent is equivalent to
4615 mov.w r0,@@foo
4616 @end example
4617
4618 If you use the size suffixes, @code{@value{AS}} issues a warning when
4619 the suffix and the register size do not match.
4620 @end ifset
4621
4622 @ifset H8/500
4623 @page
4624 @node H8/500-Dependent
4625 @chapter H8/500 Dependent Features
4626
4627 @cindex H8/500 support
4628 @menu
4629 * H8/500 Options:: Options
4630 * H8/500 Syntax:: Syntax
4631 * H8/500 Floating Point:: Floating Point
4632 * H8/500 Directives:: H8/500 Machine Directives
4633 * H8/500 Opcodes:: Opcodes
4634 @end menu
4635
4636 @node H8/500 Options
4637 @section Options
4638
4639 @cindex H8/500 options (none)
4640 @cindex options, H8/500 (none)
4641 @code{@value{AS}} has no additional command-line options for the Hitachi
4642 H8/500 family.
4643
4644 @node H8/500 Syntax
4645 @section Syntax
4646
4647 @menu
4648 * H8/500-Chars:: Special Characters
4649 * H8/500-Regs:: Register Names
4650 * H8/500-Addressing:: Addressing Modes
4651 @end menu
4652
4653 @node H8/500-Chars
4654 @subsection Special Characters
4655
4656 @cindex line comment character, H8/500
4657 @cindex H8/500 line comment character
4658 @samp{!} is the line comment character.
4659
4660 @cindex line separator, H8/500
4661 @cindex statement separator, H8/500
4662 @cindex H8/500 line separator
4663 @samp{;} can be used instead of a newline to separate statements.
4664
4665 @cindex symbol names, @samp{$} in
4666 @cindex @code{$} in symbol names
4667 Since @samp{$} has no special meaning, you may use it in symbol names.
4668
4669 @node H8/500-Regs
4670 @subsection Register Names
4671
4672 @cindex H8/500 registers
4673 @cindex registers, H8/500
4674 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
4675 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, and @samp{r7} to refer to
4676 the H8/500 registers.
4677
4678 The H8/500 also has these control registers:
4679
4680 @table @code
4681 @item cp
4682 code pointer
4683
4684 @item dp
4685 data pointer
4686
4687 @item bp
4688 base pointer
4689
4690 @item tp
4691 stack top pointer
4692
4693 @item ep
4694 extra pointer
4695
4696 @item sr
4697 status register
4698
4699 @item ccr
4700 condition code register
4701 @end table
4702
4703 All registers are 16 bits long. To represent 32 bit numbers, use two
4704 adjacent registers; for distant memory addresses, use one of the segment
4705 pointers (@code{cp} for the program counter; @code{dp} for
4706 @code{r0}--@code{r3}; @code{ep} for @code{r4} and @code{r5}; and
4707 @code{tp} for @code{r6} and @code{r7}.
4708
4709 @node H8/500-Addressing
4710 @subsection Addressing Modes
4711
4712 @cindex addressing modes, H8/500
4713 @cindex H8/500 addressing modes
4714 @value{AS} understands the following addressing modes for the H8/500:
4715 @table @code
4716 @item R@var{n}
4717 Register direct
4718
4719 @item @@R@var{n}
4720 Register indirect
4721
4722 @item @@(d:8, R@var{n})
4723 Register indirect with 8 bit signed displacement
4724
4725 @item @@(d:16, R@var{n})
4726 Register indirect with 16 bit signed displacement
4727
4728 @item @@-R@var{n}
4729 Register indirect with pre-decrement
4730
4731 @item @@R@var{n}+
4732 Register indirect with post-increment
4733
4734 @item @@@var{aa}:8
4735 8 bit absolute address
4736
4737 @item @@@var{aa}:16
4738 16 bit absolute address
4739
4740 @item #@var{xx}:8
4741 8 bit immediate
4742
4743 @item #@var{xx}:16
4744 16 bit immediate
4745 @end table
4746
4747 @node H8/500 Floating Point
4748 @section Floating Point
4749
4750 @cindex floating point, H8/500 (@sc{ieee})
4751 @cindex H8/500 floating point (@sc{ieee})
4752 The H8/500 family uses @sc{ieee} floating-point numbers.
4753
4754 @node H8/500 Directives
4755 @section H8/500 Machine Directives
4756
4757 @cindex H8/500 machine directives (none)
4758 @cindex machine directives, H8/500 (none)
4759 @cindex @code{word} directive, H8/500
4760 @cindex @code{int} directive, H8/500
4761 @code{@value{AS}} has no machine-dependent directives for the H8/500.
4762 However, on this platform the @samp{.int} and @samp{.word} directives
4763 generate 16-bit numbers.
4764
4765 @node H8/500 Opcodes
4766 @section Opcodes
4767
4768 @cindex H8/500 opcode summary
4769 @cindex opcode summary, H8/500
4770 @cindex mnemonics, H8/500
4771 @cindex instruction summary, H8/500
4772 For detailed information on the H8/500 machine instruction set, see
4773 @cite{H8/500 Series Programming Manual} (Hitachi M21T001).
4774
4775 @code{@value{AS}} implements all the standard H8/500 opcodes. No additional
4776 pseudo-instructions are needed on this family.
4777
4778 The following table summarizes H8/500 opcodes and their operands:
4779
4780 @c Use @group if it ever works, instead of @page
4781 @page
4782 @smallexample
4783 @i{Legend:}
4784 abs8 @r{8-bit absolute address}
4785 abs16 @r{16-bit absolute address}
4786 abs24 @r{24-bit absolute address}
4787 crb @r{@code{ccr}, @code{br}, @code{ep}, @code{dp}, @code{tp}, @code{dp}}
4788 disp8 @r{8-bit displacement}
4789 ea @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4790 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16},}
4791 @r{@code{#xx:8}, @code{#xx:16}}
4792 ea_mem @r{@code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4793 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4794 ea_noimm @r{@code{rn}, @code{@@rn}, @code{@@(d:8, rn)}, @code{@@(d:16, rn)},}
4795 @r{@code{@@-rn}, @code{@@rn+}, @code{@@aa:8}, @code{@@aa:16}}
4796 fp r6
4797 imm4 @r{4-bit immediate data}
4798 imm8 @r{8-bit immediate data}
4799 imm16 @r{16-bit immediate data}
4800 pcrel8 @r{8-bit offset from program counter}
4801 pcrel16 @r{16-bit offset from program counter}
4802 qim @r{@code{-2}, @code{-1}, @code{1}, @code{2}}
4803 rd @r{any register}
4804 rs @r{a register distinct from rd}
4805 rlist @r{comma-separated list of registers in parentheses;}
4806 @r{register ranges @code{rd-rs} are allowed}
4807 sp @r{stack pointer (@code{r7})}
4808 sr @r{status register}
4809 sz @r{size; @samp{.b} or @samp{.w}. If omitted, default @samp{.w}}
4810
4811 ldc[.b] ea,crb bcc[.w] pcrel16
4812 ldc[.w] ea,sr bcc[.b] pcrel8
4813 add[:q] sz qim,ea_noimm bhs[.w] pcrel16
4814 add[:g] sz ea,rd bhs[.b] pcrel8
4815 adds sz ea,rd bcs[.w] pcrel16
4816 addx sz ea,rd bcs[.b] pcrel8
4817 and sz ea,rd blo[.w] pcrel16
4818 andc[.b] imm8,crb blo[.b] pcrel8
4819 andc[.w] imm16,sr bne[.w] pcrel16
4820 bpt bne[.b] pcrel8
4821 bra[.w] pcrel16 beq[.w] pcrel16
4822 bra[.b] pcrel8 beq[.b] pcrel8
4823 bt[.w] pcrel16 bvc[.w] pcrel16
4824 bt[.b] pcrel8 bvc[.b] pcrel8
4825 brn[.w] pcrel16 bvs[.w] pcrel16
4826 brn[.b] pcrel8 bvs[.b] pcrel8
4827 bf[.w] pcrel16 bpl[.w] pcrel16
4828 bf[.b] pcrel8 bpl[.b] pcrel8
4829 bhi[.w] pcrel16 bmi[.w] pcrel16
4830 bhi[.b] pcrel8 bmi[.b] pcrel8
4831 bls[.w] pcrel16 bge[.w] pcrel16
4832 bls[.b] pcrel8 bge[.b] pcrel8
4833 @page
4834 blt[.w] pcrel16 mov[:g][.b] imm8,ea_mem
4835 blt[.b] pcrel8 mov[:g][.w] imm16,ea_mem
4836 bgt[.w] pcrel16 movfpe[.b] ea,rd
4837 bgt[.b] pcrel8 movtpe[.b] rs,ea_noimm
4838 ble[.w] pcrel16 mulxu sz ea,rd
4839 ble[.b] pcrel8 neg sz ea
4840 bclr sz imm4,ea_noimm nop
4841 bclr sz rs,ea_noimm not sz ea
4842 bnot sz imm4,ea_noimm or sz ea,rd
4843 bnot sz rs,ea_noimm orc[.b] imm8,crb
4844 bset sz imm4,ea_noimm orc[.w] imm16,sr
4845 bset sz rs,ea_noimm pjmp abs24
4846 bsr[.b] pcrel8 pjmp @@rd
4847 bsr[.w] pcrel16 pjsr abs24
4848 btst sz imm4,ea_noimm pjsr @@rd
4849 btst sz rs,ea_noimm prtd imm8
4850 clr sz ea prtd imm16
4851 cmp[:e][.b] imm8,rd prts
4852 cmp[:i][.w] imm16,rd rotl sz ea
4853 cmp[:g].b imm8,ea_noimm rotr sz ea
4854 cmp[:g][.w] imm16,ea_noimm rotxl sz ea
4855 Cmp[:g] sz ea,rd rotxr sz ea
4856 dadd rs,rd rtd imm8
4857 divxu sz ea,rd rtd imm16
4858 dsub rs,rd rts
4859 exts[.b] rd scb/f rs,pcrel8
4860 extu[.b] rd scb/ne rs,pcrel8
4861 jmp @@rd scb/eq rs,pcrel8
4862 jmp @@(imm8,rd) shal sz ea
4863 jmp @@(imm16,rd) shar sz ea
4864 jmp abs16 shll sz ea
4865 jsr @@rd shlr sz ea
4866 jsr @@(imm8,rd) sleep
4867 jsr @@(imm16,rd) stc[.b] crb,ea_noimm
4868 jsr abs16 stc[.w] sr,ea_noimm
4869 ldm @@sp+,(rlist) stm (rlist),@@-sp
4870 link fp,imm8 sub sz ea,rd
4871 link fp,imm16 subs sz ea,rd
4872 mov[:e][.b] imm8,rd subx sz ea,rd
4873 mov[:i][.w] imm16,rd swap[.b] rd
4874 mov[:l][.w] abs8,rd tas[.b] ea
4875 mov[:l].b abs8,rd trapa imm4
4876 mov[:s][.w] rs,abs8 trap/vs
4877 mov[:s].b rs,abs8 tst sz ea
4878 mov[:f][.w] @@(disp8,fp),rd unlk fp
4879 mov[:f][.w] rs,@@(disp8,fp) xch[.w] rs,rd
4880 mov[:f].b @@(disp8,fp),rd xor sz ea,rd
4881 mov[:f].b rs,@@(disp8,fp) xorc.b imm8,crb
4882 mov[:g] sz rs,ea_mem xorc.w imm16,sr
4883 mov[:g] sz ea,rd
4884 @end smallexample
4885
4886 @end ifset
4887
4888 @ifset HPPA
4889 @page
4890 @node HPPA-Dependent
4891 @chapter HPPA Dependent Features
4892
4893 @cindex support
4894 @menu
4895 * HPPA Notes:: Notes
4896 * HPPA Options:: Options
4897 * HPPA Syntax:: Syntax
4898 * HPPA Floating Point:: Floating Point
4899 * HPPA Directives:: HPPA Machine Directives
4900 * HPPA Opcodes:: Opcodes
4901 @end menu
4902
4903 @node HPPA Notes
4904 @section Notes
4905 As a backend for GNU CC @code{@value{AS}} has been throughly tested and should
4906 work extremely well. We have tested it only minimally on hand written assembly
4907 code and no one has tested it much on the assembly output from the HP
4908 compilers.
4909
4910 The format of the debugging sections has changed since the original
4911 @code{@value{AS}} port (version 1.3X) was released; therefore,
4912 you must rebuild all objects and libraries with the new
4913 assembler so that you can debug the final executable.
4914
4915 The HPPA @code{@value{AS}} port generates a small subset of the relocations
4916 available in the SOM and ELF object file formats. Additional relocation
4917 support will be added as it becomes necessary.
4918
4919 @node HPPA Options
4920 @section Options
4921 @code{@value{AS}} has no machine-dependent directives for the HPPA.
4922
4923 @cindex HPPA Syntax
4924 @section HPPA Syntax
4925 @node HPPA Syntax
4926 The assembler syntax closely follows the HPPA instruction set
4927 reference manual; assembler directives and general syntax closely follow the
4928 HPPA assembly language reference manual with a few noteworthy differences.
4929
4930 First a colon may immediately follow a label definition. This is
4931 simply for compatability with how most assembly language programmers
4932 write code.
4933
4934 Some obscure expression parsing problems may affect hand written code which
4935 uses the @code{spop} instructions, or code which makes significant
4936 use of the @code{!} line separator.
4937
4938 @code{@value{AS} is much less forgiving about missing arguments and other
4939 similar oversights. @code{@value{AS}} will flag missing arguments as
4940 syntax errors; this is regarded as a feature, not a bug.
4941
4942 Finally, @code{@value{AS}} allows you to use an external symbol without
4943 explicitly importing the symbol. @emph{Warning:} in the future this will be
4944 an error for HPPA targets.
4945
4946 Special characters for HPPA targets include:
4947
4948 @samp{;} is the line comment character.
4949
4950 @samp{!} can be used instead of a newline to separate statements.
4951
4952 Since @samp{$} has no special meaning, you may use it in symbol names.
4953
4954 @node HPPA Floating Point
4955 @section Floating Point
4956 @cindex floating point, HPPA (@sc{ieee})
4957 @cindex HPPA floating point (@sc{ieee})
4958 The HPPA family uses @sc{ieee} floating-point numbers.
4959
4960 @node HPPA Directives
4961 @section HPPA Machine Directives
4962 For detailed information on the HPPA machine instruction set, see
4963 @cite{HP9000 Series 800 Assembly Language Reference Manual}
4964 (HP 92432-90001).
4965
4966 @code{@value{AS}} does not support the following assembler directives
4967 found in the HP manual:
4968 @itemize @bullet
4969 @item endm
4970 @item enter
4971 @item leave
4972 @item listoff
4973 @item liston
4974 @item locct
4975 @item macro
4976 @end itemize
4977
4978 @code{@value{AS}} supports one additional assembler directive for the
4979 HPPA: @code{.PARAM}. It conveys register argument locations for
4980 static functions. Its syntax closely follows the @code{.EXPORT} directive.
4981
4982 @node HPPA Opcodes
4983 @section Opcodes
4984 For detailed information on the HPPA machine instruction set, see
4985 @cite{PA-RISC Architecture and Instruction Set Reference Manual}
4986 (HP 09740-90039).
4987 @end ifset
4988
4989 @ifset SH
4990 @page
4991 @node SH-Dependent
4992 @chapter Hitachi SH Dependent Features
4993
4994 @cindex SH support
4995 @menu
4996 * SH Options:: Options
4997 * SH Syntax:: Syntax
4998 * SH Floating Point:: Floating Point
4999 * SH Directives:: SH Machine Directives
5000 * SH Opcodes:: Opcodes
5001 @end menu
5002
5003 @node SH Options
5004 @section Options
5005
5006 @cindex SH options (none)
5007 @cindex options, SH (none)
5008 @code{@value{AS}} has no additional command-line options for the Hitachi
5009 SH family.
5010
5011 @node SH Syntax
5012 @section Syntax
5013
5014 @menu
5015 * SH-Chars:: Special Characters
5016 * SH-Regs:: Register Names
5017 * SH-Addressing:: Addressing Modes
5018 @end menu
5019
5020 @node SH-Chars
5021 @subsection Special Characters
5022
5023 @cindex line comment character, SH
5024 @cindex SH line comment character
5025 @samp{!} is the line comment character.
5026
5027 @cindex line separator, SH
5028 @cindex statement separator, SH
5029 @cindex SH line separator
5030 You can use @samp{;} instead of a newline to separate statements.
5031
5032 @cindex symbol names, @samp{$} in
5033 @cindex @code{$} in symbol names
5034 Since @samp{$} has no special meaning, you may use it in symbol names.
5035
5036 @node SH-Regs
5037 @subsection Register Names
5038
5039 @cindex SH registers
5040 @cindex registers, SH
5041 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
5042 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
5043 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
5044 and @samp{r15} to refer to the SH registers.
5045
5046 The SH also has these control registers:
5047
5048 @table @code
5049 @item pr
5050 procedure register (holds return address)
5051
5052 @item pc
5053 program counter
5054
5055 @item mach
5056 @itemx macl
5057 high and low multiply accumulator registers
5058
5059 @item sr
5060 status register
5061
5062 @item gbr
5063 global base register
5064
5065 @item vbr
5066 vector base register (for interrupt vectors)
5067 @end table
5068
5069 @node SH-Addressing
5070 @subsection Addressing Modes
5071
5072 @cindex addressing modes, SH
5073 @cindex SH addressing modes
5074 @code{@value{AS}} understands the following addressing modes for the SH.
5075 @code{R@var{n}} in the following refers to any of the numbered
5076 registers, but @emph{not} the control registers.
5077
5078 @table @code
5079 @item R@var{n}
5080 Register direct
5081
5082 @item @@R@var{n}
5083 Register indirect
5084
5085 @item @@-R@var{n}
5086 Register indirect with pre-decrement
5087
5088 @item @@R@var{n}+
5089 Register indirect with post-increment
5090
5091 @item @@(@var{disp}, R@var{n})
5092 Register indirect with displacement
5093
5094 @item @@(R0, R@var{n})
5095 Register indexed
5096
5097 @item @@(@var{disp}, GBR)
5098 @code{GBR} offset
5099
5100 @item @@(R0, GBR)
5101 GBR indexed
5102
5103 @item @var{addr}
5104 @itemx @@(@var{disp}, PC)
5105 PC relative address (for branch or for addressing memory). The
5106 @code{@value{AS}} implementation allows you to use the simpler form
5107 @var{addr} anywhere a PC relative address is called for; the alternate
5108 form is supported for compatibility with other assemblers.
5109
5110 @item #@var{imm}
5111 Immediate data
5112 @end table
5113
5114 @node SH Floating Point
5115 @section Floating Point
5116
5117 @cindex floating point, SH (@sc{ieee})
5118 @cindex SH floating point (@sc{ieee})
5119 The SH family uses @sc{ieee} floating-point numbers.
5120
5121 @node SH Directives
5122 @section SH Machine Directives
5123
5124 @cindex SH machine directives (none)
5125 @cindex machine directives, SH (none)
5126 @cindex @code{word} directive, SH
5127 @cindex @code{int} directive, SH
5128 @code{@value{AS}} has no machine-dependent directives for the SH.
5129
5130 @node SH Opcodes
5131 @section Opcodes
5132
5133 @cindex SH opcode summary
5134 @cindex opcode summary, SH
5135 @cindex mnemonics, SH
5136 @cindex instruction summary, SH
5137 For detailed information on the SH machine instruction set, see
5138 @cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.).
5139
5140 @code{@value{AS}} implements all the standard SH opcodes. No additional
5141 pseudo-instructions are needed on this family. Note, however, that
5142 because @code{@value{AS}} supports a simpler form of PC-relative
5143 addressing, you may simply write (for example)
5144
5145 @example
5146 mov.l bar,r0
5147 @end example
5148
5149 @noindent
5150 where other assemblers might require an explicit displacement to
5151 @code{bar} from the program counter:
5152
5153 @example
5154 mov.l @@(@var{disp}, PC)
5155 @end example
5156
5157 Here is a summary of SH opcodes:
5158
5159 @page
5160 @smallexample
5161 @i{Legend:}
5162 Rn @r{a numbered register}
5163 Rm @r{another numbered register}
5164 #imm @r{immediate data}
5165 disp @r{displacement}
5166 disp8 @r{8-bit displacement}
5167 disp12 @r{12-bit displacement}
5168
5169 add #imm,Rn lds.l @@Rn+,PR
5170 add Rm,Rn mac.w @@Rm+,@@Rn+
5171 addc Rm,Rn mov #imm,Rn
5172 addv Rm,Rn mov Rm,Rn
5173 and #imm,R0 mov.b Rm,@@(R0,Rn)
5174 and Rm,Rn mov.b Rm,@@-Rn
5175 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
5176 bf disp8 mov.b @@(disp,Rm),R0
5177 bra disp12 mov.b @@(disp,GBR),R0
5178 bsr disp12 mov.b @@(R0,Rm),Rn
5179 bt disp8 mov.b @@Rm+,Rn
5180 clrm mov.b @@Rm,Rn
5181 clrt mov.b R0,@@(disp,Rm)
5182 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
5183 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
5184 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
5185 cmp/gt Rm,Rn mov.l Rm,@@-Rn
5186 cmp/hi Rm,Rn mov.l Rm,@@Rn
5187 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
5188 cmp/pl Rn mov.l @@(disp,GBR),R0
5189 cmp/pz Rn mov.l @@(disp,PC),Rn
5190 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
5191 div0s Rm,Rn mov.l @@Rm+,Rn
5192 div0u mov.l @@Rm,Rn
5193 div1 Rm,Rn mov.l R0,@@(disp,GBR)
5194 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
5195 exts.w Rm,Rn mov.w Rm,@@-Rn
5196 extu.b Rm,Rn mov.w Rm,@@Rn
5197 extu.w Rm,Rn mov.w @@(disp,Rm),R0
5198 jmp @@Rn mov.w @@(disp,GBR),R0
5199 jsr @@Rn mov.w @@(disp,PC),Rn
5200 ldc Rn,GBR mov.w @@(R0,Rm),Rn
5201 ldc Rn,SR mov.w @@Rm+,Rn
5202 ldc Rn,VBR mov.w @@Rm,Rn
5203 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
5204 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
5205 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
5206 lds Rn,MACH movt Rn
5207 lds Rn,MACL muls Rm,Rn
5208 lds Rn,PR mulu Rm,Rn
5209 lds.l @@Rn+,MACH neg Rm,Rn
5210 lds.l @@Rn+,MACL negc Rm,Rn
5211 @page
5212 nop stc VBR,Rn
5213 not Rm,Rn stc.l GBR,@@-Rn
5214 or #imm,R0 stc.l SR,@@-Rn
5215 or Rm,Rn stc.l VBR,@@-Rn
5216 or.b #imm,@@(R0,GBR) sts MACH,Rn
5217 rotcl Rn sts MACL,Rn
5218 rotcr Rn sts PR,Rn
5219 rotl Rn sts.l MACH,@@-Rn
5220 rotr Rn sts.l MACL,@@-Rn
5221 rte sts.l PR,@@-Rn
5222 rts sub Rm,Rn
5223 sett subc Rm,Rn
5224 shal Rn subv Rm,Rn
5225 shar Rn swap.b Rm,Rn
5226 shll Rn swap.w Rm,Rn
5227 shll16 Rn tas.b @@Rn
5228 shll2 Rn trapa #imm
5229 shll8 Rn tst #imm,R0
5230 shlr Rn tst Rm,Rn
5231 shlr16 Rn tst.b #imm,@@(R0,GBR)
5232 shlr2 Rn xor #imm,R0
5233 shlr8 Rn xor Rm,Rn
5234 sleep xor.b #imm,@@(R0,GBR)
5235 stc GBR,Rn xtrct Rm,Rn
5236 stc SR,Rn
5237 @end smallexample
5238
5239 @ifset Hitachi-all
5240 @ifclear GENERIC
5241 @raisesections
5242 @end ifclear
5243 @end ifset
5244
5245 @end ifset
5246 @ifset I960
5247 @ifset GENERIC
5248 @page
5249 @node i960-Dependent
5250 @chapter Intel 80960 Dependent Features
5251 @end ifset
5252 @ifclear GENERIC
5253 @node Machine Dependencies
5254 @chapter Intel 80960 Dependent Features
5255 @end ifclear
5256
5257 @cindex i960 support
5258 @menu
5259 * Options-i960:: i960 Command-line Options
5260 * Floating Point-i960:: Floating Point
5261 * Directives-i960:: i960 Machine Directives
5262 * Opcodes for i960:: i960 Opcodes
5263 @end menu
5264
5265 @c FIXME! Add Syntax sec with discussion of bitfields here, at least so
5266 @c long as they're not turned on for other machines than 960.
5267
5268 @node Options-i960
5269
5270 @section i960 Command-line Options
5271
5272 @cindex i960 options
5273 @cindex options, i960
5274 @table @code
5275
5276 @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
5277 @cindex i960 architecture options
5278 @cindex architecture options, i960
5279 @cindex @code{-A} options, i960
5280 Select the 80960 architecture. Instructions or features not supported
5281 by the selected architecture cause fatal errors.
5282
5283 @samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
5284 @samp{-AMC}. Synonyms are provided for compatibility with other tools.
5285
5286 If none of these options is specified, @code{@value{AS}} will generate code for any
5287 instruction or feature that is supported by @emph{some} version of the
5288 960 (even if this means mixing architectures!). In principle,
5289 @code{@value{AS}} will attempt to deduce the minimal sufficient processor
5290 type if none is specified; depending on the object code format, the
5291 processor type may be recorded in the object file. If it is critical
5292 that the @code{@value{AS}} output match a specific architecture, specify that
5293 architecture explicitly.
5294
5295 @item -b
5296 @cindex @code{-b} option, i960
5297 @cindex branch recording, i960
5298 @cindex i960 branch recording
5299 Add code to collect information about conditional branches taken, for
5300 later optimization using branch prediction bits. (The conditional branch
5301 instructions have branch prediction bits in the CA, CB, and CC
5302 architectures.) If @var{BR} represents a conditional branch instruction,
5303 the following represents the code generated by the assembler when
5304 @samp{-b} is specified:
5305
5306 @smallexample
5307 call @var{increment routine}
5308 .word 0 # pre-counter
5309 Label: @var{BR}
5310 call @var{increment routine}
5311 .word 0 # post-counter
5312 @end smallexample
5313
5314 The counter following a branch records the number of times that branch
5315 was @emph{not} taken; the differenc between the two counters is the
5316 number of times the branch @emph{was} taken.
5317
5318 @cindex @code{gbr960}, i960 postprocessor
5319 @cindex branch statistics table, i960
5320 A table of every such @code{Label} is also generated, so that the
5321 external postprocessor @code{gbr960} (supplied by Intel) can locate all
5322 the counters. This table is always labelled @samp{__BRANCH_TABLE__};
5323 this is a local symbol to permit collecting statistics for many separate
5324 object files. The table is word aligned, and begins with a two-word
5325 header. The first word, initialized to 0, is used in maintaining linked
5326 lists of branch tables. The second word is a count of the number of
5327 entries in the table, which follow immediately: each is a word, pointing
5328 to one of the labels illustrated above.
5329
5330 @c TEXI2ROFF-KILL
5331 @ifinfo
5332 @c END TEXI2ROFF-KILL
5333 @example
5334 +------------+------------+------------+ ... +------------+
5335 | | | | | |
5336 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
5337 | | | | | |
5338 +------------+------------+------------+ ... +------------+
5339
5340 __BRANCH_TABLE__ layout
5341 @end example
5342 @c TEXI2ROFF-KILL
5343 @end ifinfo
5344 @tex
5345 \vskip 1pc
5346 \line{\leftskip=0pt\hskip\tableindent
5347 \boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
5348 *BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
5349 \centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
5350 @end tex
5351 @c END TEXI2ROFF-KILL
5352
5353 The first word of the header is used to locate multiple branch tables,
5354 since each object file may contain one. Normally the links are
5355 maintained with a call to an initialization routine, placed at the
5356 beginning of each function in the file. The GNU C compiler will
5357 generate these calls automatically when you give it a @samp{-b} option.
5358 For further details, see the documentation of @samp{gbr960}.
5359
5360 @item -norelax
5361 @cindex @code{-norelax} option, i960
5362 Normally, Compare-and-Branch instructions with targets that require
5363 displacements greater than 13 bits (or that have external targets) are
5364 replaced with the corresponding compare (or @samp{chkbit}) and branch
5365 instructions. You can use the @samp{-norelax} option to specify that
5366 @code{@value{AS}} should generate errors instead, if the target displacement
5367 is larger than 13 bits.
5368
5369 This option does not affect the Compare-and-Jump instructions; the code
5370 emitted for them is @emph{always} adjusted when necessary (depending on
5371 displacement size), regardless of whether you use @samp{-norelax}.
5372 @end table
5373
5374 @node Floating Point-i960
5375 @section Floating Point
5376
5377 @cindex floating point, i960 (@sc{ieee})
5378 @cindex i960 floating point (@sc{ieee})
5379 @code{@value{AS}} generates @sc{ieee} floating-point numbers for the directives
5380 @samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
5381
5382 @node Directives-i960
5383 @section i960 Machine Directives
5384
5385 @cindex machine directives, i960
5386 @cindex i960 machine directives
5387
5388 @table @code
5389 @cindex @code{bss} directive, i960
5390 @item .bss @var{symbol}, @var{length}, @var{align}
5391 Reserve @var{length} bytes in the bss section for a local @var{symbol},
5392 aligned to the power of two specified by @var{align}. @var{length} and
5393 @var{align} must be positive absolute expressions. This directive
5394 differs from @samp{.lcomm} only in that it permits you to specify
5395 an alignment. @xref{Lcomm,,@code{.lcomm}}.
5396 @end table
5397
5398 @table @code
5399 @item .extended @var{flonums}
5400 @cindex @code{extended} directive, i960
5401 @code{.extended} expects zero or more flonums, separated by commas; for
5402 each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
5403 floating-point number.
5404
5405 @item .leafproc @var{call-lab}, @var{bal-lab}
5406 @cindex @code{leafproc} directive, i960
5407 You can use the @samp{.leafproc} directive in conjunction with the
5408 optimized @code{callj} instruction to enable faster calls of leaf
5409 procedures. If a procedure is known to call no other procedures, you
5410 may define an entry point that skips procedure prolog code (and that does
5411 not depend on system-supplied saved context), and declare it as the
5412 @var{bal-lab} using @samp{.leafproc}. If the procedure also has an
5413 entry point that goes through the normal prolog, you can specify that
5414 entry point as @var{call-lab}.
5415
5416 A @samp{.leafproc} declaration is meant for use in conjunction with the
5417 optimized call instruction @samp{callj}; the directive records the data
5418 needed later to choose between converting the @samp{callj} into a
5419 @code{bal} or a @code{call}.
5420
5421 @var{call-lab} is optional; if only one argument is present, or if the
5422 two arguments are identical, the single argument is assumed to be the
5423 @code{bal} entry point.
5424
5425 @item .sysproc @var{name}, @var{index}
5426 @cindex @code{sysproc} directive, i960
5427 The @samp{.sysproc} directive defines a name for a system procedure.
5428 After you define it using @samp{.sysproc}, you can use @var{name} to
5429 refer to the system procedure identified by @var{index} when calling
5430 procedures with the optimized call instruction @samp{callj}.
5431
5432 Both arguments are required; @var{index} must be between 0 and 31
5433 (inclusive).
5434 @end table
5435
5436 @node Opcodes for i960
5437 @section i960 Opcodes
5438
5439 @cindex opcodes, i960
5440 @cindex i960 opcodes
5441 All Intel 960 machine instructions are supported;
5442 @pxref{Options-i960,,i960 Command-line Options} for a discussion of
5443 selecting the instruction subset for a particular 960
5444 architecture.@refill
5445
5446 Some opcodes are processed beyond simply emitting a single corresponding
5447 instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
5448 instructions with target displacements larger than 13 bits.
5449
5450 @menu
5451 * callj-i960:: @code{callj}
5452 * Compare-and-branch-i960:: Compare-and-Branch
5453 @end menu
5454
5455 @node callj-i960
5456 @subsection @code{callj}
5457
5458 @cindex @code{callj}, i960 pseudo-opcode
5459 @cindex i960 @code{callj} pseudo-opcode
5460 You can write @code{callj} to have the assembler or the linker determine
5461 the most appropriate form of subroutine call: @samp{call},
5462 @samp{bal}, or @samp{calls}. If the assembly source contains
5463 enough information---a @samp{.leafproc} or @samp{.sysproc} directive
5464 defining the operand---then @code{@value{AS}} will translate the
5465 @code{callj}; if not, it will simply emit the @code{callj}, leaving it
5466 for the linker to resolve.
5467
5468 @node Compare-and-branch-i960
5469 @subsection Compare-and-Branch
5470
5471 @cindex i960 compare/branch instructions
5472 @cindex compare/branch instructions, i960
5473 The 960 architectures provide combined Compare-and-Branch instructions
5474 that permit you to store the branch target in the lower 13 bits of the
5475 instruction word itself. However, if you specify a branch target far
5476 enough away that its address won't fit in 13 bits, the assembler can
5477 either issue an error, or convert your Compare-and-Branch instruction
5478 into separate instructions to do the compare and the branch.
5479
5480 @cindex compare and jump expansions, i960
5481 @cindex i960 compare and jump expansions
5482 Whether @code{@value{AS}} gives an error or expands the instruction depends
5483 on two choices you can make: whether you use the @samp{-norelax} option,
5484 and whether you use a ``Compare and Branch'' instruction or a ``Compare
5485 and Jump'' instruction. The ``Jump'' instructions are @emph{always}
5486 expanded if necessary; the ``Branch'' instructions are expanded when
5487 necessary @emph{unless} you specify @code{-norelax}---in which case
5488 @code{@value{AS}} gives an error instead.
5489
5490 These are the Compare-and-Branch instructions, their ``Jump'' variants,
5491 and the instruction pairs they may expand into:
5492
5493 @c TEXI2ROFF-KILL
5494 @ifinfo
5495 @c END TEXI2ROFF-KILL
5496 @example
5497 Compare and
5498 Branch Jump Expanded to
5499 ------ ------ ------------
5500 bbc chkbit; bno
5501 bbs chkbit; bo
5502 cmpibe cmpije cmpi; be
5503 cmpibg cmpijg cmpi; bg
5504 cmpibge cmpijge cmpi; bge
5505 cmpibl cmpijl cmpi; bl
5506 cmpible cmpijle cmpi; ble
5507 cmpibno cmpijno cmpi; bno
5508 cmpibne cmpijne cmpi; bne
5509 cmpibo cmpijo cmpi; bo
5510 cmpobe cmpoje cmpo; be
5511 cmpobg cmpojg cmpo; bg
5512 cmpobge cmpojge cmpo; bge
5513 cmpobl cmpojl cmpo; bl
5514 cmpoble cmpojle cmpo; ble
5515 cmpobne cmpojne cmpo; bne
5516 @end example
5517 @c TEXI2ROFF-KILL
5518 @end ifinfo
5519 @tex
5520 \hskip\tableindent
5521 \halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
5522 \omit{\hfil\it Compare and\hfil}\span\omit&\cr
5523 {\it Branch}&{\it Jump}&{\it Expanded to}\cr
5524 bbc& & chkbit; bno\cr
5525 bbs& & chkbit; bo\cr
5526 cmpibe& cmpije& cmpi; be\cr
5527 cmpibg& cmpijg& cmpi; bg\cr
5528 cmpibge& cmpijge& cmpi; bge\cr
5529 cmpibl& cmpijl& cmpi; bl\cr
5530 cmpible& cmpijle& cmpi; ble\cr
5531 cmpibno& cmpijno& cmpi; bno\cr
5532 cmpibne& cmpijne& cmpi; bne\cr
5533 cmpibo& cmpijo& cmpi; bo\cr
5534 cmpobe& cmpoje& cmpo; be\cr
5535 cmpobg& cmpojg& cmpo; bg\cr
5536 cmpobge& cmpojge& cmpo; bge\cr
5537 cmpobl& cmpojl& cmpo; bl\cr
5538 cmpoble& cmpojle& cmpo; ble\cr
5539 cmpobne& cmpojne& cmpo; bne\cr}
5540 @end tex
5541 @c END TEXI2ROFF-KILL
5542 @end ifset
5543
5544 @ifset M680X0
5545 @ifset GENERIC
5546 @page
5547 @node M68K-Dependent
5548 @chapter M680x0 Dependent Features
5549 @end ifset
5550 @ifclear GENERIC
5551 @node Machine Dependencies
5552 @chapter M680x0 Dependent Features
5553 @end ifclear
5554
5555 @cindex M680x0 support
5556 @menu
5557 * M68K-Opts:: M680x0 Options
5558 * M68K-Syntax:: Syntax
5559 * M68K-Moto-Syntax:: Motorola Syntax
5560 * M68K-Float:: Floating Point
5561 * M68K-Directives:: 680x0 Machine Directives
5562 * M68K-opcodes:: Opcodes
5563 @end menu
5564
5565 @node M68K-Opts
5566 @section M680x0 Options
5567
5568 @cindex options, M680x0
5569 @cindex M680x0 options
5570 The Motorola 680x0 version of @code{@value{AS}} has two machine dependent options.
5571 One shortens undefined references from 32 to 16 bits, while the
5572 other is used to tell @code{@value{AS}} what kind of machine it is
5573 assembling for.
5574
5575 @cindex @code{-l} option, M680x0
5576 You can use the @kbd{-l} option to shorten the size of references to
5577 undefined symbols. If the @kbd{-l} option is not given, references to
5578 undefined symbols will be a full long (32 bits) wide. (Since @code{@value{AS}}
5579 cannot know where these symbols will end up, @code{@value{AS}} can only allocate
5580 space for the linker to fill in later. Since @code{@value{AS}} doesn't know how
5581 far away these symbols will be, it allocates as much space as it can.)
5582 If this option is given, the references will only be one word wide (16
5583 bits). This may be useful if you want the object file to be as small as
5584 possible, and you know that the relevant symbols will be less than 17
5585 bits away.
5586
5587 @cindex @code{-m68000} and related options
5588 @cindex architecture options, M680x0
5589 @cindex M680x0 architecture options
5590 The 680x0 version of @code{@value{AS}} is most frequently used to assemble
5591 programs for the Motorola MC68020 microprocessor. Occasionally it is
5592 used to assemble programs for the mostly similar, but slightly different
5593 MC68000 or MC68010 microprocessors. You can give @code{@value{AS}} the options
5594 @samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
5595 @samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
5596 target.
5597
5598 @node M68K-Syntax
5599 @section Syntax
5600
5601 @cindex @sc{mit}
5602 This syntax for the Motorola 680x0 was developed at @sc{mit}.
5603
5604 @cindex M680x0 syntax
5605 @cindex syntax, M680x0
5606 @cindex M680x0 size modifiers
5607 @cindex size modifiers, M680x0
5608 The 680x0 version of @code{@value{AS}} uses syntax similar to the Sun
5609 assembler. Intervening periods are now ignored; for example, @samp{movl}
5610 is equivalent to @samp{move.l}.
5611
5612 @ifset INTERNALS
5613 If @code{@value{AS}} is compiled with SUN_ASM_SYNTAX defined, it will
5614 also allow Sun-style local labels of the form @samp{1$} through
5615 @samp{$9}.
5616 @end ifset
5617
5618 In the following table @dfn{apc} stands for any of the address
5619 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
5620 Program Counter (@samp{pc}), or the zero-address relative to the
5621 program counter (@samp{zpc}).
5622
5623 @cindex M680x0 addressing modes
5624 @cindex addressing modes, M680x0
5625 The following addressing modes are understood:
5626 @table @dfn
5627 @item Immediate
5628 @samp{#@var{digits}}
5629
5630 @item Data Register
5631 @samp{d0} through @samp{d7}
5632
5633 @item Address Register
5634 @samp{a0} through @samp{a7}
5635
5636 @item Address Register Indirect
5637 @samp{a0@@} through @samp{a7@@}@*
5638 @samp{a7} is also known as @samp{sp}, i.e. the Stack Pointer. @code{a6}
5639 is also known as @samp{fp}, the Frame Pointer.
5640
5641 @item Address Register Postincrement
5642 @samp{a0@@+} through @samp{a7@@+}
5643
5644 @item Address Register Predecrement
5645 @samp{a0@@-} through @samp{a7@@-}
5646
5647 @item Indirect Plus Offset
5648 @samp{@var{apc}@@(@var{digits})}
5649
5650 @item Index
5651 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5652
5653 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
5654
5655 @item Postindex
5656 @samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
5657
5658 or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
5659
5660 @item Preindex
5661 @samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5662
5663 or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
5664
5665 @item Memory Indirect
5666 @samp{@var{apc}@@(@var{digits})@@(@var{digits})}
5667
5668 @item Absolute
5669 @samp{@var{symbol}}, or @samp{@var{digits}}
5670 @ignore
5671 @c pesch@cygnus.com: gnu, rich concur the following needs careful
5672 @c research before documenting.
5673 , or either of the above followed
5674 by @samp{:b}, @samp{:w}, or @samp{:l}.
5675 @end ignore
5676 @end table
5677
5678 For some configurations, especially those where the compiler normally
5679 does not prepend an underscore to the names of user variables, the
5680 assembler requires a @samp{%} before any use of a register name. This
5681 is intended to let the assembler distinguish between user variables and
5682 registers named @samp{a0} through @samp{a7}, et cetera. The @samp{%} is
5683 always accepted, but is only required for some configurations, notably
5684 @samp{m68k-coff}.
5685
5686 @node M68K-Moto-Syntax
5687 @section Motorola Syntax
5688
5689 @cindex Motorola syntax for the 680x0
5690 @cindex alternate syntax for the 680x0
5691
5692 The standard Motorola syntax for this chip differs from the syntax
5693 already discussed (@pxref{M68K-Syntax,,Syntax}). @code{@value{AS}} can
5694 accept both kinds of syntax, even within a single instruction. The
5695 syntaxes are fully compatible, because the Motorola syntax never uses
5696 the @samp{@@} character and the @sc{mit} syntax always does, except in
5697 cases where the syntaxes are identical.
5698
5699 @cindex M680x0 syntax
5700 @cindex syntax, M680x0
5701 In particular, you may write or generate M68K assembler with the
5702 following conventions:
5703
5704 (In the following table @dfn{apc} stands for any of the address
5705 registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
5706 Program Counter (@samp{pc}), or the zero-address relative to the
5707 program counter (@samp{zpc}).)
5708
5709 @cindex M680x0 addressing modes
5710 @cindex addressing modes, M680x0
5711 The following additional addressing modes are understood:
5712 @table @dfn
5713 @item Address Register Indirect
5714 @samp{a0} through @samp{a7}@*
5715 @samp{a7} is also known as @samp{sp}, i.e. the Stack Pointer. @code{a6}
5716 is also known as @samp{fp}, the Frame Pointer.
5717
5718 @item Address Register Postincrement
5719 @samp{(a0)+} through @samp{(a7)+}
5720
5721 @item Address Register Predecrement
5722 @samp{-(a0)} through @samp{-(a7)}
5723
5724 @item Indirect Plus Offset
5725 @samp{@var{digits}(@var{apc})}
5726
5727 @item Index
5728 @samp{@var{digits}(@var{apc},(@var{register}.@var{size}*@var{scale})}@*
5729 or @samp{(@var{apc},@var{register}.@var{size}*@var{scale})}@*
5730 In either case, @var{size} and @var{scale} are optional
5731 (@var{scale} defaults to @samp{1}, @var{size} defaults to @samp{l}).
5732 @var{scale} can be @samp{1}, @samp{2}, @samp{4}, or @samp{8}.
5733 @var{size} can be @samp{w} or @samp{l}. @var{scale} is only supported
5734 on the 68020 and greater.
5735 @end table
5736
5737 @node M68K-Float
5738 @section Floating Point
5739
5740 @cindex floating point, M680x0
5741 @cindex M680x0 floating point
5742 @c FIXME is this "not too well tested" crud STILL true?
5743 The floating point code is not too well tested, and may have
5744 subtle bugs in it.
5745
5746 Packed decimal (P) format floating literals are not supported.
5747 Feel free to add the code!
5748
5749 The floating point formats generated by directives are these.
5750
5751 @table @code
5752 @item .float
5753 @cindex @code{float} directive, M680x0
5754 @code{Single} precision floating point constants.
5755
5756 @item .double
5757 @cindex @code{double} directive, M680x0
5758 @code{Double} precision floating point constants.
5759 @end table
5760
5761 There is no directive to produce regions of memory holding
5762 extended precision numbers, however they can be used as
5763 immediate operands to floating-point instructions. Adding a
5764 directive to create extended precision numbers would not be
5765 hard, but it has not yet seemed necessary.
5766
5767 @node M68K-Directives
5768 @section 680x0 Machine Directives
5769
5770 @cindex M680x0 directives
5771 @cindex directives, M680x0
5772 In order to be compatible with the Sun assembler the 680x0 assembler
5773 understands the following directives.
5774
5775 @table @code
5776 @item .data1
5777 @cindex @code{data1} directive, M680x0
5778 This directive is identical to a @code{.data 1} directive.
5779
5780 @item .data2
5781 @cindex @code{data2} directive, M680x0
5782 This directive is identical to a @code{.data 2} directive.
5783
5784 @item .even
5785 @cindex @code{even} directive, M680x0
5786 This directive is identical to a @code{.align 1} directive.
5787 @c Is this true? does it work???
5788
5789 @item .skip
5790 @cindex @code{skip} directive, M680x0
5791 This directive is identical to a @code{.space} directive.
5792 @end table
5793
5794 @node M68K-opcodes
5795 @section Opcodes
5796
5797 @cindex M680x0 opcodes
5798 @cindex opcodes, M680x0
5799 @cindex instruction set, M680x0
5800 @c pesch@cygnus.com: I don't see any point in the following
5801 @c paragraph. Bugs are bugs; how does saying this
5802 @c help anyone?
5803 @ignore
5804 Danger: Several bugs have been found in the opcode table (and
5805 fixed). More bugs may exist. Be careful when using obscure
5806 instructions.
5807 @end ignore
5808
5809 @menu
5810 * M68K-Branch:: Branch Improvement
5811 * M68K-Chars:: Special Characters
5812 @end menu
5813
5814 @node M68K-Branch
5815 @subsection Branch Improvement
5816
5817 @cindex pseudo-opcodes, M680x0
5818 @cindex M680x0 pseudo-opcodes
5819 @cindex branch improvement, M680x0
5820 @cindex M680x0 branch improvement
5821 Certain pseudo opcodes are permitted for branch instructions.
5822 They expand to the shortest branch instruction that will reach the
5823 target. Generally these mnemonics are made by substituting @samp{j} for
5824 @samp{b} at the start of a Motorola mnemonic.
5825
5826 The following table summarizes the pseudo-operations. A @code{*} flags
5827 cases that are more fully described after the table:
5828
5829 @smallexample
5830 Displacement
5831 +-------------------------------------------------
5832 | 68020 68000/10
5833 Pseudo-Op |BYTE WORD LONG LONG non-PC relative
5834 +-------------------------------------------------
5835 jbsr |bsrs bsr bsrl jsr jsr
5836 jra |bras bra bral jmp jmp
5837 * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
5838 * dbXX |dbXX dbXX dbXX; bra; jmpl
5839 * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
5840
5841 XX: condition
5842 NX: negative of condition XX
5843
5844 @end smallexample
5845 @center @code{*}---see full description below
5846
5847 @table @code
5848 @item jbsr
5849 @itemx jra
5850 These are the simplest jump pseudo-operations; they always map to one
5851 particular machine instruction, depending on the displacement to the
5852 branch target.
5853
5854 @item j@var{XX}
5855 Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
5856 where @var{XX} is a conditional branch or condition-code test. The full
5857 list of pseudo-ops in this family is:
5858 @smallexample
5859 jhi jls jcc jcs jne jeq jvc
5860 jvs jpl jmi jge jlt jgt jle
5861 @end smallexample
5862
5863 For the cases of non-PC relative displacements and long displacements on
5864 the 68000 or 68010, @code{@value{AS}} will issue a longer code fragment in terms of
5865 @var{NX}, the opposite condition to @var{XX}. For example, for the
5866 non-PC relative case:
5867 @smallexample
5868 j@var{XX} foo
5869 @end smallexample
5870 gives
5871 @smallexample
5872 b@var{NX}s oof
5873 jmp foo
5874 oof:
5875 @end smallexample
5876
5877 @item db@var{XX}
5878 The full family of pseudo-operations covered here is
5879 @smallexample
5880 dbhi dbls dbcc dbcs dbne dbeq dbvc
5881 dbvs dbpl dbmi dbge dblt dbgt dble
5882 dbf dbra dbt
5883 @end smallexample
5884
5885 Other than for word and byte displacements, when the source reads
5886 @samp{db@var{XX} foo}, @code{@value{AS}} will emit
5887 @smallexample
5888 db@var{XX} oo1
5889 bra oo2
5890 oo1:jmpl foo
5891 oo2:
5892 @end smallexample
5893
5894 @item fj@var{XX}
5895 This family includes
5896 @smallexample
5897 fjne fjeq fjge fjlt fjgt fjle fjf
5898 fjt fjgl fjgle fjnge fjngl fjngle fjngt
5899 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
5900 fjor fjseq fjsf fjsne fjst fjueq fjuge
5901 fjugt fjule fjult fjun
5902 @end smallexample
5903
5904 For branch targets that are not PC relative, @code{@value{AS}} emits
5905 @smallexample
5906 fb@var{NX} oof
5907 jmp foo
5908 oof:
5909 @end smallexample
5910 when it encounters @samp{fj@var{XX} foo}.
5911
5912 @end table
5913
5914 @node M68K-Chars
5915 @subsection Special Characters
5916
5917 @cindex special characters, M680x0
5918 @cindex M680x0 immediate character
5919 @cindex immediate character, M680x0
5920 @cindex M680x0 line comment character
5921 @cindex line comment character, M680x0
5922 @cindex comments, M680x0
5923 The immediate character is @samp{#} for Sun compatibility. The
5924 line-comment character is @samp{|}. If a @samp{#} appears at the
5925 beginning of a line, it is treated as a comment unless it looks like
5926 @samp{# line file}, in which case it is treated normally.
5927
5928 @end ifset
5929 @ignore
5930 @c FIXME! Stop ignoring when filled in.
5931 @node 32x32
5932 @chapter 32x32
5933
5934 @section Options
5935 The 32x32 version of @code{@value{AS}} accepts a @kbd{-m32032} option to
5936 specify thiat it is compiling for a 32032 processor, or a
5937 @kbd{-m32532} to specify that it is compiling for a 32532 option.
5938 The default (if neither is specified) is chosen when the assembler
5939 is compiled.
5940
5941 @section Syntax
5942 I don't know anything about the 32x32 syntax assembled by
5943 @code{@value{AS}}. Someone who undersands the processor (I've never seen
5944 one) and the possible syntaxes should write this section.
5945
5946 @section Floating Point
5947 The 32x32 uses @sc{ieee} floating point numbers, but @code{@value{AS}}
5948 will only create single or double precision values. I don't know if the
5949 32x32 understands extended precision numbers.
5950
5951 @section 32x32 Machine Directives
5952 The 32x32 has no machine dependent directives.
5953
5954 @end ignore
5955 @ifset SPARC
5956 @ifset GENERIC
5957 @page
5958 @node Sparc-Dependent
5959 @chapter SPARC Dependent Features
5960 @end ifset
5961 @ifclear GENERIC
5962 @node Machine Dependencies
5963 @chapter SPARC Dependent Features
5964 @end ifclear
5965
5966 @cindex SPARC support
5967 @menu
5968 * Sparc-Opts:: Options
5969 * Sparc-Float:: Floating Point
5970 * Sparc-Directives:: Sparc Machine Directives
5971 @end menu
5972
5973 @node Sparc-Opts
5974 @section Options
5975
5976 @cindex options for SPARC
5977 @cindex SPARC options
5978 @cindex architectures, SPARC
5979 @cindex SPARC architectures
5980 The SPARC chip family includes several successive levels (or other
5981 variants) of chip, using the same core instruction set, but including
5982 a few additional instructions at each level.
5983
5984 By default, @code{@value{AS}} assumes the core instruction set (SPARC
5985 v6), but ``bumps'' the architecture level as needed: it switches to
5986 successively higher architectures as it encounters instructions that
5987 only exist in the higher levels.
5988
5989 @table @code
5990 @item -Av6 | -Av7 | -Av8 | -Asparclite
5991 @kindex -Av6
5992 @kindex Av7
5993 @kindex -Av8
5994 @kindex -Asparclite
5995 Use one of the @samp{-A} options to select one of the SPARC
5996 architectures explicitly. If you select an architecture explicitly,
5997 @code{@value{AS}} reports a fatal error if it encounters an instruction
5998 or feature requiring a higher level.
5999
6000 @item -bump
6001 Permit the assembler to ``bump'' the architecture level as required, but
6002 warn whenever it is necessary to switch to another level.
6003 @end table
6004
6005 @ignore
6006 @c FIXME: (sparc) Fill in "syntax" section!
6007 @c subsection syntax
6008 I don't know anything about Sparc syntax. Someone who does
6009 will have to write this section.
6010 @end ignore
6011
6012 @node Sparc-Float
6013 @section Floating Point
6014
6015 @cindex floating point, SPARC (@sc{ieee})
6016 @cindex SPARC floating point (@sc{ieee})
6017 The Sparc uses @sc{ieee} floating-point numbers.
6018
6019 @node Sparc-Directives
6020 @section Sparc Machine Directives
6021
6022 @cindex SPARC machine directives
6023 @cindex machine directives, SPARC
6024 The Sparc version of @code{@value{AS}} supports the following additional
6025 machine directives:
6026
6027 @table @code
6028 @item .common
6029 @cindex @code{common} directive, SPARC
6030 This must be followed by a symbol name, a positive number, and
6031 @code{"bss"}. This behaves somewhat like @code{.comm}, but the
6032 syntax is different.
6033
6034 @item .half
6035 @cindex @code{half} directive, SPARC
6036 This is functionally identical to @code{.short}.
6037
6038 @item .proc
6039 @cindex @code{proc} directive, SPARC
6040 This directive is ignored. Any text following it on the same
6041 line is also ignored.
6042
6043 @item .reserve
6044 @cindex @code{reserve} directive, SPARC
6045 This must be followed by a symbol name, a positive number, and
6046 @code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
6047 syntax is different.
6048
6049 @item .seg
6050 @cindex @code{seg} directive, SPARC
6051 This must be followed by @code{"text"}, @code{"data"}, or
6052 @code{"data1"}. It behaves like @code{.text}, @code{.data}, or
6053 @code{.data 1}.
6054
6055 @item .skip
6056 @cindex @code{skip} directive, SPARC
6057 This is functionally identical to the @code{.space} directive.
6058
6059 @item .word
6060 @cindex @code{word} directive, SPARC
6061 On the Sparc, the .word directive produces 32 bit values,
6062 instead of the 16 bit values it produces on many other machines.
6063 @end table
6064
6065 @end ifset
6066 @ifset I80386
6067 @ifset GENERIC
6068 @page
6069 @node i386-Dependent
6070 @chapter 80386 Dependent Features
6071 @end ifset
6072 @ifclear GENERIC
6073 @node Machine Dependencies
6074 @chapter 80386 Dependent Features
6075 @end ifclear
6076
6077 @cindex i386 support
6078 @cindex i80306 support
6079 @menu
6080 * i386-Options:: Options
6081 * i386-Syntax:: AT&T Syntax versus Intel Syntax
6082 * i386-Opcodes:: Opcode Naming
6083 * i386-Regs:: Register Naming
6084 * i386-prefixes:: Opcode Prefixes
6085 * i386-Memory:: Memory References
6086 * i386-jumps:: Handling of Jump Instructions
6087 * i386-Float:: Floating Point
6088 * i386-Notes:: Notes
6089 @end menu
6090
6091 @node i386-Options
6092 @section Options
6093
6094 @cindex options for i386 (none)
6095 @cindex i386 options (none)
6096 The 80386 has no machine dependent options.
6097
6098 @node i386-Syntax
6099 @section AT&T Syntax versus Intel Syntax
6100
6101 @cindex i386 syntax compatibility
6102 @cindex syntax compatibility, i386
6103 In order to maintain compatibility with the output of @code{@value{GCC}},
6104 @code{@value{AS}} supports AT&T System V/386 assembler syntax. This is quite
6105 different from Intel syntax. We mention these differences because
6106 almost all 80386 documents used only Intel syntax. Notable differences
6107 between the two syntaxes are:
6108
6109 @itemize @bullet
6110 @item
6111 @cindex immediate operands, i386
6112 @cindex i386 immediate operands
6113 @cindex register operands, i386
6114 @cindex i386 register operands
6115 @cindex jump/call operands, i386
6116 @cindex i386 jump/call operands
6117 @cindex operand delimiters, i386
6118 AT&T immediate operands are preceded by @samp{$}; Intel immediate
6119 operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
6120 AT&T register operands are preceded by @samp{%}; Intel register operands
6121 are undelimited. AT&T absolute (as opposed to PC relative) jump/call
6122 operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
6123
6124 @item
6125 @cindex i386 source, destination operands
6126 @cindex source, destination operands; i386
6127 AT&T and Intel syntax use the opposite order for source and destination
6128 operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
6129 @samp{source, dest} convention is maintained for compatibility with
6130 previous Unix assemblers.
6131
6132 @item
6133 @cindex opcode suffixes, i386
6134 @cindex sizes operands, i386
6135 @cindex i386 size suffixes
6136 In AT&T syntax the size of memory operands is determined from the last
6137 character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
6138 and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
6139 memory references. Intel syntax accomplishes this by prefixes memory
6140 operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
6141 @samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
6142 ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
6143
6144 @item
6145 @cindex return instructions, i386
6146 @cindex i386 jump, call, return
6147 Immediate form long jumps and calls are
6148 @samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
6149 Intel syntax is
6150 @samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
6151 instruction
6152 is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
6153 @samp{ret far @var{stack-adjust}}.
6154
6155 @item
6156 @cindex sections, i386
6157 @cindex i386 sections
6158 The AT&T assembler does not provide support for multiple section
6159 programs. Unix style systems expect all programs to be single sections.
6160 @end itemize
6161
6162 @node i386-Opcodes
6163 @section Opcode Naming
6164
6165 @cindex i386 opcode naming
6166 @cindex opcode naming, i386
6167 Opcode names are suffixed with one character modifiers which specify the
6168 size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
6169 byte, word, and long operands. If no suffix is specified by an
6170 instruction and it contains no memory operands then @code{@value{AS}} tries to
6171 fill in the missing suffix based on the destination register operand
6172 (the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
6173 to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
6174 @samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
6175 assembler which assumes that a missing opcode suffix implies long
6176 operand size. (This incompatibility does not affect compiler output
6177 since compilers always explicitly specify the opcode suffix.)
6178
6179 Almost all opcodes have the same names in AT&T and Intel format. There
6180 are a few exceptions. The sign extend and zero extend instructions need
6181 two sizes to specify them. They need a size to sign/zero extend
6182 @emph{from} and a size to zero extend @emph{to}. This is accomplished
6183 by using two opcode suffixes in AT&T syntax. Base names for sign extend
6184 and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
6185 syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
6186 suffixes are tacked on to this base name, the @emph{from} suffix before
6187 the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
6188 ``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
6189 thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
6190 and @samp{wl} (from word to long).
6191
6192 @cindex conversion instructions, i386
6193 @cindex i386 conversion instructions
6194 The Intel-syntax conversion instructions
6195
6196 @itemize @bullet
6197 @item
6198 @samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
6199
6200 @item
6201 @samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
6202
6203 @item
6204 @samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
6205
6206 @item
6207 @samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
6208 @end itemize
6209
6210 @noindent
6211 are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
6212 AT&T naming. @code{@value{AS}} accepts either naming for these instructions.
6213
6214 @cindex jump instructions, i386
6215 @cindex call instructions, i386
6216 Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
6217 AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
6218 convention.
6219
6220 @node i386-Regs
6221 @section Register Naming
6222
6223 @cindex i386 registers
6224 @cindex registers, i386
6225 Register operands are always prefixes with @samp{%}. The 80386 registers
6226 consist of
6227
6228 @itemize @bullet
6229 @item
6230 the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
6231 @samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
6232 frame pointer), and @samp{%esp} (the stack pointer).
6233
6234 @item
6235 the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
6236 @samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
6237
6238 @item
6239 the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
6240 @samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
6241 are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
6242 @samp{%cx}, and @samp{%dx})
6243
6244 @item
6245 the 6 section registers @samp{%cs} (code section), @samp{%ds}
6246 (data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
6247 and @samp{%gs}.
6248
6249 @item
6250 the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
6251 @samp{%cr3}.
6252
6253 @item
6254 the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
6255 @samp{%db3}, @samp{%db6}, and @samp{%db7}.
6256
6257 @item
6258 the 2 test registers @samp{%tr6} and @samp{%tr7}.
6259
6260 @item
6261 the 8 floating point register stack @samp{%st} or equivalently
6262 @samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
6263 @samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
6264 @end itemize
6265
6266 @node i386-prefixes
6267 @section Opcode Prefixes
6268
6269 @cindex i386 opcode prefixes
6270 @cindex opcode prefixes, i386
6271 @cindex prefixes, i386
6272 Opcode prefixes are used to modify the following opcode. They are used
6273 to repeat string instructions, to provide section overrides, to perform
6274 bus lock operations, and to give operand and address size (16-bit
6275 operands are specified in an instruction by prefixing what would
6276 normally be 32-bit operands with a ``operand size'' opcode prefix).
6277 Opcode prefixes are usually given as single-line instructions with no
6278 operands, and must directly precede the instruction they act upon. For
6279 example, the @samp{scas} (scan string) instruction is repeated with:
6280 @smallexample
6281 repne
6282 scas
6283 @end smallexample
6284
6285 Here is a list of opcode prefixes:
6286
6287 @itemize @bullet
6288 @item
6289 @cindex section override prefixes, i386
6290 Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
6291 @samp{fs}, @samp{gs}. These are automatically added by specifying
6292 using the @var{section}:@var{memory-operand} form for memory references.
6293
6294 @item
6295 @cindex size prefixes, i386
6296 Operand/Address size prefixes @samp{data16} and @samp{addr16}
6297 change 32-bit operands/addresses into 16-bit operands/addresses. Note
6298 that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
6299 are not supported (yet).
6300
6301 @item
6302 @cindex bus lock prefixes, i386
6303 @cindex inhibiting interrupts, i386
6304 The bus lock prefix @samp{lock} inhibits interrupts during
6305 execution of the instruction it precedes. (This is only valid with
6306 certain instructions; see a 80386 manual for details).
6307
6308 @item
6309 @cindex coprocessor wait, i386
6310 The wait for coprocessor prefix @samp{wait} waits for the
6311 coprocessor to complete the current instruction. This should never be
6312 needed for the 80386/80387 combination.
6313
6314 @item
6315 @cindex repeat prefixes, i386
6316 The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
6317 to string instructions to make them repeat @samp{%ecx} times.
6318 @end itemize
6319
6320 @node i386-Memory
6321 @section Memory References
6322
6323 @cindex i386 memory references
6324 @cindex memory references, i386
6325 An Intel syntax indirect memory reference of the form
6326
6327 @smallexample
6328 @var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
6329 @end smallexample
6330
6331 @noindent
6332 is translated into the AT&T syntax
6333
6334 @smallexample
6335 @var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
6336 @end smallexample
6337
6338 @noindent
6339 where @var{base} and @var{index} are the optional 32-bit base and
6340 index registers, @var{disp} is the optional displacement, and
6341 @var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
6342 to calculate the address of the operand. If no @var{scale} is
6343 specified, @var{scale} is taken to be 1. @var{section} specifies the
6344 optional section register for the memory operand, and may override the
6345 default section register (see a 80386 manual for section register
6346 defaults). Note that section overrides in AT&T syntax @emph{must} have
6347 be preceded by a @samp{%}. If you specify a section override which
6348 coincides with the default section register, @code{@value{AS}} will @emph{not}
6349 output any section register override prefixes to assemble the given
6350 instruction. Thus, section overrides can be specified to emphasize which
6351 section register is used for a given memory operand.
6352
6353 Here are some examples of Intel and AT&T style memory references:
6354
6355 @table @asis
6356 @item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
6357 @var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
6358 missing, and the default section is used (@samp{%ss} for addressing with
6359 @samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
6360
6361 @item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
6362 @var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
6363 @samp{foo}. All other fields are missing. The section register here
6364 defaults to @samp{%ds}.
6365
6366 @item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
6367 This uses the value pointed to by @samp{foo} as a memory operand.
6368 Note that @var{base} and @var{index} are both missing, but there is only
6369 @emph{one} @samp{,}. This is a syntactic exception.
6370
6371 @item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
6372 This selects the contents of the variable @samp{foo} with section
6373 register @var{section} being @samp{%gs}.
6374 @end table
6375
6376 Absolute (as opposed to PC relative) call and jump operands must be
6377 prefixed with @samp{*}. If no @samp{*} is specified, @code{@value{AS}} will
6378 always choose PC relative addressing for jump/call labels.
6379
6380 Any instruction that has a memory operand @emph{must} specify its size (byte,
6381 word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
6382 respectively).
6383
6384 @node i386-jumps
6385 @section Handling of Jump Instructions
6386
6387 @cindex jump optimization, i386
6388 @cindex i386 jump optimization
6389 Jump instructions are always optimized to use the smallest possible
6390 displacements. This is accomplished by using byte (8-bit) displacement
6391 jumps whenever the target is sufficiently close. If a byte displacement
6392 is insufficient a long (32-bit) displacement is used. We do not support
6393 word (16-bit) displacement jumps (i.e. prefixing the jump instruction
6394 with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
6395 @samp{%eip} to 16 bits after the word displacement is added.
6396
6397 Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
6398 @samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
6399 byte displacements, so that it is possible that use of these
6400 instructions (@code{@value{GCC}} does not use them) will cause the assembler to
6401 print an error message (and generate incorrect code). The AT&T 80386
6402 assembler tries to get around this problem by expanding @samp{jcxz foo} to
6403 @smallexample
6404 jcxz cx_zero
6405 jmp cx_nonzero
6406 cx_zero: jmp foo
6407 cx_nonzero:
6408 @end smallexample
6409
6410 @node i386-Float
6411 @section Floating Point
6412
6413 @cindex i386 floating point
6414 @cindex floating point, i386
6415 All 80387 floating point types except packed BCD are supported.
6416 (BCD support may be added without much difficulty). These data
6417 types are 16-, 32-, and 64- bit integers, and single (32-bit),
6418 double (64-bit), and extended (80-bit) precision floating point.
6419 Each supported type has an opcode suffix and a constructor
6420 associated with it. Opcode suffixes specify operand's data
6421 types. Constructors build these data types into memory.
6422
6423 @itemize @bullet
6424 @item
6425 @cindex @code{float} directive, i386
6426 @cindex @code{single} directive, i386
6427 @cindex @code{double} directive, i386
6428 @cindex @code{tfloat} directive, i386
6429 Floating point constructors are @samp{.float} or @samp{.single},
6430 @samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
6431 These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
6432 @samp{t} stands for temporary real, and that the 80387 only supports
6433 this format via the @samp{fldt} (load temporary real to stack top) and
6434 @samp{fstpt} (store temporary real and pop stack) instructions.
6435
6436 @item
6437 @cindex @code{word} directive, i386
6438 @cindex @code{long} directive, i386
6439 @cindex @code{int} directive, i386
6440 @cindex @code{quad} directive, i386
6441 Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
6442 @samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
6443 opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
6444 (quad). As with the temporary real format the 64-bit @samp{q} format is
6445 only present in the @samp{fildq} (load quad integer to stack top) and
6446 @samp{fistpq} (store quad integer and pop stack) instructions.
6447 @end itemize
6448
6449 Register to register operations do not require opcode suffixes,
6450 so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
6451
6452 @cindex i386 @code{fwait} instruction
6453 @cindex @code{fwait instruction}, i386
6454 Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
6455 instructions are almost never needed (this is not the case for the
6456 80286/80287 and 8086/8087 combinations). Therefore, @code{@value{AS}} suppresses
6457 the @samp{fwait} instruction whenever it is implicitly selected by one
6458 of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
6459 @samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
6460 instructions are made equivalent to @samp{f@dots{}} instructions. If
6461 @samp{fwait} is desired it must be explicitly coded.
6462
6463 @node i386-Notes
6464 @section Notes
6465
6466 @cindex i386 @code{mul}, @code{imul} instructions
6467 @cindex @code{mul} instruction, i386
6468 @cindex @code{imul} instruction, i386
6469 There is some trickery concerning the @samp{mul} and @samp{imul}
6470 instructions that deserves mention. The 16-, 32-, and 64-bit expanding
6471 multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
6472 for @samp{imul}) can be output only in the one operand form. Thus,
6473 @samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
6474 the expanding multiply would clobber the @samp{%edx} register, and this
6475 would confuse @code{@value{GCC}} output. Use @samp{imul %ebx} to get the
6476 64-bit product in @samp{%edx:%eax}.
6477
6478 We have added a two operand form of @samp{imul} when the first operand
6479 is an immediate mode expression and the second operand is a register.
6480 This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
6481 example, can be done with @samp{imul $69, %eax} rather than @samp{imul
6482 $69, %eax, %eax}.
6483
6484 @end ifset
6485 @ifset Z8000
6486 @ifset GENERIC
6487 @page
6488 @node Z8000-Dependent
6489 @chapter Z8000 Dependent Features
6490 @end ifset
6491 @ifclear GENERIC
6492 @node Machine Dependencies
6493 @chapter Z8000 Dependent Features
6494 @end ifclear
6495
6496 @cindex Z8000 support
6497 The Z8000 @value{AS} supports both members of the Z8000 family: the
6498 unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with
6499 24 bit addresses.
6500
6501 When the assembler is in unsegmented mode (specified with the
6502 @code{unsegm} directive), an address will take up one word (16 bit)
6503 sized register. When the assembler is in segmented mode (specified with
6504 the @code{segm} directive), a 24-bit address takes up a long (32 bit)
6505 register. @xref{Z8000 Directives,,Assembler Directives for the Z8000},
6506 for a list of other Z8000 specific assembler directives.
6507
6508 @menu
6509 * Z8000 Options:: No special command-line options for Z8000
6510 * Z8000 Syntax:: Assembler syntax for the Z8000
6511 * Z8000 Directives:: Special directives for the Z8000
6512 * Z8000 Opcodes:: Opcodes
6513 @end menu
6514
6515 @node Z8000 Options
6516 @section Options
6517
6518 @cindex Z8000 options
6519 @cindex options, Z8000
6520 @code{@value{AS}} has no additional command-line options for the Zilog
6521 Z8000 family.
6522
6523 @node Z8000 Syntax
6524 @section Syntax
6525 @menu
6526 * Z8000-Chars:: Special Characters
6527 * Z8000-Regs:: Register Names
6528 * Z8000-Addressing:: Addressing Modes
6529 @end menu
6530
6531 @node Z8000-Chars
6532 @subsection Special Characters
6533
6534 @cindex line comment character, Z8000
6535 @cindex Z8000 line comment character
6536 @samp{!} is the line comment character.
6537
6538 @cindex line separator, Z8000
6539 @cindex statement separator, Z8000
6540 @cindex Z8000 line separator
6541 You can use @samp{;} instead of a newline to separate statements.
6542
6543 @node Z8000-Regs
6544 @subsection Register Names
6545
6546 @cindex Z8000 registers
6547 @cindex registers, Z8000
6548 The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer
6549 to different sized groups of registers by register number, with the
6550 prefix @samp{r} for 16 bit registers, @samp{rr} for 32 bit registers and
6551 @samp{rq} for 64 bit registers. You can also refer to the contents of
6552 the first eight (of the sixteen 16 bit registers) by bytes. They are
6553 named @samp{r@var{n}h} and @samp{r@var{n}l}.
6554
6555 @smallexample
6556 @exdent @emph{byte registers}
6557 r0l r0h r1h r1l r2h r2l r3h r3l
6558 r4h r4l r5h r5l r6h r6l r7h r7l
6559
6560 @exdent @emph{word registers}
6561 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
6562
6563 @exdent @emph{long word registers}
6564 rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14
6565
6566 @exdent @emph{quad word registers}
6567 rq0 rq4 rq8 rq12
6568 @end smallexample
6569
6570 @node Z8000-Addressing
6571 @subsection Addressing Modes
6572
6573 @cindex addressing modes, Z8000
6574 @cindex Z800 addressing modes
6575 @value{AS} understands the following addressing modes for the Z8000:
6576
6577 @table @code
6578 @item r@var{n}
6579 Register direct
6580
6581 @item @@r@var{n}
6582 Indirect register
6583
6584 @item @var{addr}
6585 Direct: the 16 bit or 24 bit address (depending on whether the assembler
6586 is in segmented or unsegmented mode) of the operand is in the instruction.
6587
6588 @item address(r@var{n})
6589 Indexed: the 16 or 24 bit address is added to the 16 bit register to produce
6590 the final address in memory of the operand.
6591
6592 @item r@var{n}(#@var{imm})
6593 Base Address: the 16 or 24 bit register is added to the 16 bit sign
6594 extended immediate displacement to produce the final address in memory
6595 of the operand.
6596
6597 @item r@var{n}(r@var{m})
6598 Base Index: the 16 or 24 bit register r@var{n} is added to the sign
6599 extended 16 bit index register r@var{m} to produce the final address in
6600 memory of the operand.
6601
6602 @item #@var{xx}
6603 Immediate data @var{xx}.
6604 @end table
6605
6606 @node Z8000 Directives
6607 @section Assembler Directives for the Z8000
6608
6609 @cindex Z8000 directives
6610 @cindex directives, Z8000
6611 The Z8000 port of @value{AS} includes these additional assembler directives,
6612 for compatibility with other Z8000 assemblers. As shown, these do not
6613 begin with @samp{.} (unlike the ordinary @value{AS} directives).
6614
6615 @table @code
6616 @item segm
6617 @kindex segm
6618 Generates code for the segmented Z8001.
6619
6620 @item unsegm
6621 @kindex unsegm
6622 Generates code for the unsegmented Z8002.
6623
6624 @item name
6625 @kindex name
6626 Synonym for @code{.file}
6627
6628 @item global
6629 @kindex global
6630 Synonum for @code{.global}
6631
6632 @item wval
6633 @kindex wval
6634 Synonym for @code{.word}
6635
6636 @item lval
6637 @kindex lval
6638 Synonym for @code{.long}
6639
6640 @item bval
6641 @kindex bval
6642 Synonym for @code{.byte}
6643
6644 @item sval
6645 @kindex sval
6646 Assemble a string. @code{sval} expects one string literal, delimited by
6647 single quotes. It assembles each byte of the string into consecutive
6648 addresses. You can use the escape sequence @samp{%@var{xx}} (where
6649 @var{xx} represents a two-digit hexadecimal number) to represent the
6650 character whose @sc{ascii} value is @var{xx}. Use this feature to
6651 describe single quote and other characters that may not appear in string
6652 literals as themselves. For example, the C statement @w{@samp{char *a =
6653 "he said \"it's 50% off\"";}} is represented in Z8000 assembly language
6654 (shown with the assembler output in hex at the left) as
6655
6656 @iftex
6657 @begingroup
6658 @let@nonarrowing=@comment
6659 @end iftex
6660 @smallexample
6661 68652073 sval 'he said %22it%27s 50%25 off%22%00'
6662 61696420
6663 22697427
6664 73203530
6665 25206F66
6666 662200
6667 @end smallexample
6668 @iftex
6669 @endgroup
6670 @end iftex
6671
6672 @item rsect
6673 @kindex rsect
6674 synonym for @code{.section}
6675
6676 @item block
6677 @kindex block
6678 synonym for @code{.space}
6679
6680 @item even
6681 @kindex even
6682 synonym for @code{.align 1}
6683 @end table
6684
6685 @node Z8000 Opcodes
6686 @section Opcodes
6687
6688 @cindex Z8000 opcode summary
6689 @cindex opcode summary, Z8000
6690 @cindex mnemonics, Z8000
6691 @cindex instruction summary, Z8000
6692 For detailed information on the Z8000 machine instruction set, see
6693 @cite{Z8000 Technical Manual}.
6694
6695 The following table summarizes the opcodes and their arguments:
6696 @iftex
6697 @begingroup
6698 @let@nonarrowing=@comment
6699 @end iftex
6700 @smallexample
6701
6702 rs @r{16 bit source register}
6703 rd @r{16 bit destination register}
6704 rbs @r{8 bit source register}
6705 rbd @r{8 bit destination register}
6706 rrs @r{32 bit source register}
6707 rrd @r{32 bit destination register}
6708 rqs @r{64 bit source register}
6709 rqd @r{64 bit destination register}
6710 addr @r{16/24 bit address}
6711 imm @r{immediate data}
6712
6713 adc rd,rs clrb addr cpsir @@rd,@@rs,rr,cc
6714 adcb rbd,rbs clrb addr(rd) cpsirb @@rd,@@rs,rr,cc
6715 add rd,@@rs clrb rbd dab rbd
6716 add rd,addr com @@rd dbjnz rbd,disp7
6717 add rd,addr(rs) com addr dec @@rd,imm4m1
6718 add rd,imm16 com addr(rd) dec addr(rd),imm4m1
6719 add rd,rs com rd dec addr,imm4m1
6720 addb rbd,@@rs comb @@rd dec rd,imm4m1
6721 addb rbd,addr comb addr decb @@rd,imm4m1
6722 addb rbd,addr(rs) comb addr(rd) decb addr(rd),imm4m1
6723 addb rbd,imm8 comb rbd decb addr,imm4m1
6724 addb rbd,rbs comflg flags decb rbd,imm4m1
6725 addl rrd,@@rs cp @@rd,imm16 di i2
6726 addl rrd,addr cp addr(rd),imm16 div rrd,@@rs
6727 addl rrd,addr(rs) cp addr,imm16 div rrd,addr
6728 addl rrd,imm32 cp rd,@@rs div rrd,addr(rs)
6729 addl rrd,rrs cp rd,addr div rrd,imm16
6730 and rd,@@rs cp rd,addr(rs) div rrd,rs
6731 and rd,addr cp rd,imm16 divl rqd,@@rs
6732 and rd,addr(rs) cp rd,rs divl rqd,addr
6733 and rd,imm16 cpb @@rd,imm8 divl rqd,addr(rs)
6734 and rd,rs cpb addr(rd),imm8 divl rqd,imm32
6735 andb rbd,@@rs cpb addr,imm8 divl rqd,rrs
6736 andb rbd,addr cpb rbd,@@rs djnz rd,disp7
6737 andb rbd,addr(rs) cpb rbd,addr ei i2
6738 andb rbd,imm8 cpb rbd,addr(rs) ex rd,@@rs
6739 andb rbd,rbs cpb rbd,imm8 ex rd,addr
6740 bit @@rd,imm4 cpb rbd,rbs ex rd,addr(rs)
6741 bit addr(rd),imm4 cpd rd,@@rs,rr,cc ex rd,rs
6742 bit addr,imm4 cpdb rbd,@@rs,rr,cc exb rbd,@@rs
6743 bit rd,imm4 cpdr rd,@@rs,rr,cc exb rbd,addr
6744 bit rd,rs cpdrb rbd,@@rs,rr,cc exb rbd,addr(rs)
6745 bitb @@rd,imm4 cpi rd,@@rs,rr,cc exb rbd,rbs
6746 bitb addr(rd),imm4 cpib rbd,@@rs,rr,cc ext0e imm8
6747 bitb addr,imm4 cpir rd,@@rs,rr,cc ext0f imm8
6748 bitb rbd,imm4 cpirb rbd,@@rs,rr,cc ext8e imm8
6749 bitb rbd,rs cpl rrd,@@rs ext8f imm8
6750 bpt cpl rrd,addr exts rrd
6751 call @@rd cpl rrd,addr(rs) extsb rd
6752 call addr cpl rrd,imm32 extsl rqd
6753 call addr(rd) cpl rrd,rrs halt
6754 calr disp12 cpsd @@rd,@@rs,rr,cc in rd,@@rs
6755 clr @@rd cpsdb @@rd,@@rs,rr,cc in rd,imm16
6756 clr addr cpsdr @@rd,@@rs,rr,cc inb rbd,@@rs
6757 clr addr(rd) cpsdrb @@rd,@@rs,rr,cc inb rbd,imm16
6758 clr rd cpsi @@rd,@@rs,rr,cc inc @@rd,imm4m1
6759 clrb @@rd cpsib @@rd,@@rs,rr,cc inc addr(rd),imm4m1
6760 inc addr,imm4m1 ldb rbd,rs(rx) mult rrd,addr(rs)
6761 inc rd,imm4m1 ldb rd(imm16),rbs mult rrd,imm16
6762 incb @@rd,imm4m1 ldb rd(rx),rbs mult rrd,rs
6763 incb addr(rd),imm4m1 ldctl ctrl,rs multl rqd,@@rs
6764 incb addr,imm4m1 ldctl rd,ctrl multl rqd,addr
6765 incb rbd,imm4m1 ldd @@rs,@@rd,rr multl rqd,addr(rs)
6766 ind @@rd,@@rs,ra lddb @@rs,@@rd,rr multl rqd,imm32
6767 indb @@rd,@@rs,rba lddr @@rs,@@rd,rr multl rqd,rrs
6768 inib @@rd,@@rs,ra lddrb @@rs,@@rd,rr neg @@rd
6769 inibr @@rd,@@rs,ra ldi @@rd,@@rs,rr neg addr
6770 iret ldib @@rd,@@rs,rr neg addr(rd)
6771 jp cc,@@rd ldir @@rd,@@rs,rr neg rd
6772 jp cc,addr ldirb @@rd,@@rs,rr negb @@rd
6773 jp cc,addr(rd) ldk rd,imm4 negb addr
6774 jr cc,disp8 ldl @@rd,rrs negb addr(rd)
6775 ld @@rd,imm16 ldl addr(rd),rrs negb rbd
6776 ld @@rd,rs ldl addr,rrs nop
6777 ld addr(rd),imm16 ldl rd(imm16),rrs or rd,@@rs
6778 ld addr(rd),rs ldl rd(rx),rrs or rd,addr
6779 ld addr,imm16 ldl rrd,@@rs or rd,addr(rs)
6780 ld addr,rs ldl rrd,addr or rd,imm16
6781 ld rd(imm16),rs ldl rrd,addr(rs) or rd,rs
6782 ld rd(rx),rs ldl rrd,imm32 orb rbd,@@rs
6783 ld rd,@@rs ldl rrd,rrs orb rbd,addr
6784 ld rd,addr ldl rrd,rs(imm16) orb rbd,addr(rs)
6785 ld rd,addr(rs) ldl rrd,rs(rx) orb rbd,imm8
6786 ld rd,imm16 ldm @@rd,rs,n orb rbd,rbs
6787 ld rd,rs ldm addr(rd),rs,n out @@rd,rs
6788 ld rd,rs(imm16) ldm addr,rs,n out imm16,rs
6789 ld rd,rs(rx) ldm rd,@@rs,n outb @@rd,rbs
6790 lda rd,addr ldm rd,addr(rs),n outb imm16,rbs
6791 lda rd,addr(rs) ldm rd,addr,n outd @@rd,@@rs,ra
6792 lda rd,rs(imm16) ldps @@rs outdb @@rd,@@rs,rba
6793 lda rd,rs(rx) ldps addr outib @@rd,@@rs,ra
6794 ldar rd,disp16 ldps addr(rs) outibr @@rd,@@rs,ra
6795 ldb @@rd,imm8 ldr disp16,rs pop @@rd,@@rs
6796 ldb @@rd,rbs ldr rd,disp16 pop addr(rd),@@rs
6797 ldb addr(rd),imm8 ldrb disp16,rbs pop addr,@@rs
6798 ldb addr(rd),rbs ldrb rbd,disp16 pop rd,@@rs
6799 ldb addr,imm8 ldrl disp16,rrs popl @@rd,@@rs
6800 ldb addr,rbs ldrl rrd,disp16 popl addr(rd),@@rs
6801 ldb rbd,@@rs mbit popl addr,@@rs
6802 ldb rbd,addr mreq rd popl rrd,@@rs
6803 ldb rbd,addr(rs) mres push @@rd,@@rs
6804 ldb rbd,imm8 mset push @@rd,addr
6805 ldb rbd,rbs mult rrd,@@rs push @@rd,addr(rs)
6806 ldb rbd,rs(imm16) mult rrd,addr push @@rd,imm16
6807 push @@rd,rs set addr,imm4 subl rrd,imm32
6808 pushl @@rd,@@rs set rd,imm4 subl rrd,rrs
6809 pushl @@rd,addr set rd,rs tcc cc,rd
6810 pushl @@rd,addr(rs) setb @@rd,imm4 tccb cc,rbd
6811 pushl @@rd,rrs setb addr(rd),imm4 test @@rd
6812 res @@rd,imm4 setb addr,imm4 test addr
6813 res addr(rd),imm4 setb rbd,imm4 test addr(rd)
6814 res addr,imm4 setb rbd,rs test rd
6815 res rd,imm4 setflg imm4 testb @@rd
6816 res rd,rs sinb rbd,imm16 testb addr
6817 resb @@rd,imm4 sinb rd,imm16 testb addr(rd)
6818 resb addr(rd),imm4 sind @@rd,@@rs,ra testb rbd
6819 resb addr,imm4 sindb @@rd,@@rs,rba testl @@rd
6820 resb rbd,imm4 sinib @@rd,@@rs,ra testl addr
6821 resb rbd,rs sinibr @@rd,@@rs,ra testl addr(rd)
6822 resflg imm4 sla rd,imm8 testl rrd
6823 ret cc slab rbd,imm8 trdb @@rd,@@rs,rba
6824 rl rd,imm1or2 slal rrd,imm8 trdrb @@rd,@@rs,rba
6825 rlb rbd,imm1or2 sll rd,imm8 trib @@rd,@@rs,rbr
6826 rlc rd,imm1or2 sllb rbd,imm8 trirb @@rd,@@rs,rbr
6827 rlcb rbd,imm1or2 slll rrd,imm8 trtdrb @@ra,@@rb,rbr
6828 rldb rbb,rba sout imm16,rs trtib @@ra,@@rb,rr
6829 rr rd,imm1or2 soutb imm16,rbs trtirb @@ra,@@rb,rbr
6830 rrb rbd,imm1or2 soutd @@rd,@@rs,ra trtrb @@ra,@@rb,rbr
6831 rrc rd,imm1or2 soutdb @@rd,@@rs,rba tset @@rd
6832 rrcb rbd,imm1or2 soutib @@rd,@@rs,ra tset addr
6833 rrdb rbb,rba soutibr @@rd,@@rs,ra tset addr(rd)
6834 rsvd36 sra rd,imm8 tset rd
6835 rsvd38 srab rbd,imm8 tsetb @@rd
6836 rsvd78 sral rrd,imm8 tsetb addr
6837 rsvd7e srl rd,imm8 tsetb addr(rd)
6838 rsvd9d srlb rbd,imm8 tsetb rbd
6839 rsvd9f srll rrd,imm8 xor rd,@@rs
6840 rsvdb9 sub rd,@@rs xor rd,addr
6841 rsvdbf sub rd,addr xor rd,addr(rs)
6842 sbc rd,rs sub rd,addr(rs) xor rd,imm16
6843 sbcb rbd,rbs sub rd,imm16 xor rd,rs
6844 sc imm8 sub rd,rs xorb rbd,@@rs
6845 sda rd,rs subb rbd,@@rs xorb rbd,addr
6846 sdab rbd,rs subb rbd,addr xorb rbd,addr(rs)
6847 sdal rrd,rs subb rbd,addr(rs) xorb rbd,imm8
6848 sdl rd,rs subb rbd,imm8 xorb rbd,rbs
6849 sdlb rbd,rs subb rbd,rbs xorb rbd,rbs
6850 sdll rrd,rs subl rrd,@@rs
6851 set @@rd,imm4 subl rrd,addr
6852 set addr(rd),imm4 subl rrd,addr(rs)
6853 @end smallexample
6854 @iftex
6855 @endgroup
6856 @end iftex
6857
6858 @end ifset
6859
6860 @ifset MIPS
6861 @ifset GENERIC
6862 @page
6863 @node MIPS-Dependent
6864 @chapter MIPS Dependent Features
6865 @end ifset
6866 @ifclear GENERIC
6867 @node Machine Dependencies
6868 @chapter MIPS Dependent Features
6869 @end ifclear
6870 The MIPS @value{AS} supports the MIPS R2000 and R3000 processors.
6871
6872 It ignores the @kbd{-nocpp}, @kbd{-EL}, and @kbd{-EB} options.
6873
6874 Not all traditional MIPS macro instructions are currently supported.
6875 Specifically, @code{li.d} and @code{li.s} are not currently supported.
6876
6877 When using @code{@value{GCC}} with MIPS @value{AS}, @code{@value{GCC}}
6878 must be configured using the -with-gnu-as switch (this is the case for
6879 Cygnus distributions) or @code{@value{GCC}} must be invoked with the
6880 -mgas option.
6881
6882 Assembling for a MIPS ECOFF target supports some additional sections
6883 besides the usual @code{.text}, @code{.data} and @code{.bss}. The
6884 additional sections are @code{.rdata}, used for readonly data,
6885 @code{.sdata}, used for small data, and @code{.sbss}, used for small
6886 common objects.
6887
6888 When assembling for ECOFF, the assembler will automatically use the $gp
6889 ($28) register when forming the address of a small object. Any object
6890 in the .sdata or .sbss sections is considered to be small. For external
6891 objects or objects in the @code{.bss} section, the -G switch may be used
6892 to control the size of objects for which the $gp register will be used;
6893 the default value is 8, meaning that a reference to any object eight
6894 bytes or smaller will use $gp. Passing -G 0 to @value{AS} will prevent
6895 it from using the $gp register. The size of an object in the
6896 @code{.bss} section is set by the @code{.comm} or @code{.lcomm}
6897 pseudo-op that defines it. The size of an external object may be set
6898 using the @code{.extern} pseudo-op. For example, @samp{.extern sym,4}
6899 declares that the object at @code{sym} is 4 bytes in length, whie
6900 leaving @code{sym} otherwise undefined.
6901
6902 Using small ECOFF objects requires linker support, and assumes that the
6903 $gp register has been correctly initialized (normally done automatically
6904 by the startup code). MIPS ECOFF assembly code must avoid modifying the
6905 $gp register.
6906
6907 MIPS ECOFF @value{AS} supports several pseudo-ops used for generating
6908 debugging information which are not support by traditional MIPS
6909 assemblers. These are @code{.def}, @code{.endef}, @code{.dim},
6910 @code{.file}, @code{.scl}, @code{.size}, @code{.tag}, @code{.type},
6911 @code{.val}, @code{.stabd}, @code{.stabn}, and @code{.stabs}. The
6912 debugging information generated by the three @code{.stab} pseudo-ops can
6913 only be read by GDB, not by traditional MIPS debuggers (this enhancement
6914 is required to fully support C++ debugging). These psuedo-ops are
6915 primarily used by compilers, not assembly language programmers, and are
6916 described elsewhere in the manual.
6917
6918 @end ifset
6919
6920 @ifset GENERIC
6921 @c reverse effect of @down at top of generic Machine-Dep chapter
6922 @raisesections
6923 @end ifset
6924
6925 @ifset INTERNALS
6926 @c pesch@cygnus.com: we ignore the following chapters, since internals are
6927 @c changing rapidly. These may need to be moved to another
6928 @c book anyhow, if we adopt the model of user/modifier
6929 @c books.
6930 @node Maintenance
6931 @chapter Maintaining the Assembler
6932 [[this chapter is still being built]]
6933
6934 @section Design
6935 We had these goals, in descending priority:
6936 @table @b
6937 @item Accuracy.
6938 For every program composed by a compiler, @code{@value{AS}} should emit
6939 ``correct'' code. This leaves some latitude in choosing addressing
6940 modes, order of @code{relocation_info} structures in the object
6941 file, @emph{etc}.
6942
6943 @item Speed, for usual case.
6944 By far the most common use of @code{@value{AS}} will be assembling compiler
6945 emissions.
6946
6947 @item Upward compatibility for existing assembler code.
6948 Well @dots{} we don't support Vax bit fields but everything else
6949 seems to be upward compatible.
6950
6951 @item Readability.
6952 The code should be maintainable with few surprises. (JF: ha!)
6953
6954 @end table
6955
6956 We assumed that disk I/O was slow and expensive while memory was
6957 fast and access to memory was cheap. We expect the in-memory data
6958 structures to be less than 10 times the size of the emitted object
6959 file. (Contrast this with the C compiler where in-memory structures
6960 might be 100 times object file size!)
6961 This suggests:
6962 @itemize @bullet
6963 @item
6964 Try to read the source file from disk only one time. For other
6965 reasons, we keep large chunks of the source file in memory during
6966 assembly so this is not a problem. Also the assembly algorithm
6967 should only scan the source text once if the compiler composed the
6968 text according to a few simple rules.
6969 @item
6970 Emit the object code bytes only once. Don't store values and then
6971 backpatch later.
6972 @item
6973 Build the object file in memory and do direct writes to disk of
6974 large buffers.
6975 @end itemize
6976
6977 RMS suggested a one-pass algorithm which seems to work well. By not
6978 parsing text during a second pass considerable time is saved on
6979 large programs (@emph{e.g.} the sort of C program @code{yacc} would
6980 emit).
6981
6982 It happened that the data structures needed to emit relocation
6983 information to the object file were neatly subsumed into the data
6984 structures that do backpatching of addresses after pass 1.
6985
6986 Many of the functions began life as re-usable modules, loosely
6987 connected. RMS changed this to gain speed. For example, input
6988 parsing routines which used to work on pre-sanitized strings now
6989 must parse raw data. Hence they have to import knowledge of the
6990 assemblers' comment conventions @emph{etc}.
6991
6992 @section Deprecated Feature(?)s
6993 We have stopped supporting some features:
6994 @itemize @bullet
6995 @item
6996 @code{.org} statements must have @b{defined} expressions.
6997 @item
6998 Vax Bit fields (@kbd{:} operator) are entirely unsupported.
6999 @end itemize
7000
7001 It might be a good idea to not support these features in a future release:
7002 @itemize @bullet
7003 @item
7004 @kbd{#} should begin a comment, even in column 1.
7005 @item
7006 Why support the logical line & file concept any more?
7007 @item
7008 Subsections are a good candidate for flushing.
7009 Depends on which compilers need them I guess.
7010 @end itemize
7011
7012 @section Bugs, Ideas, Further Work
7013 Clearly the major improvement is DON'T USE A TEXT-READING
7014 ASSEMBLER for the back end of a compiler. It is much faster to
7015 interpret binary gobbledygook from a compiler's tables than to
7016 ask the compiler to write out human-readable code just so the
7017 assembler can parse it back to binary.
7018
7019 Assuming you use @code{@value{AS}} for human written programs: here are
7020 some ideas:
7021 @itemize @bullet
7022 @item
7023 Document (here) @code{APP}.
7024 @item
7025 Take advantage of knowing no spaces except after opcode
7026 to speed up @code{@value{AS}}. (Modify @code{app.c} to flush useless spaces:
7027 only keep space/tabs at begin of line or between 2
7028 symbols.)
7029 @item
7030 Put pointers in this documentation to @file{a.out} documentation.
7031 @item
7032 Split the assembler into parts so it can gobble direct binary
7033 from @emph{e.g.} @code{cc}. It is silly for@code{cc} to compose text
7034 just so @code{@value{AS}} can parse it back to binary.
7035 @item
7036 Rewrite hash functions: I want a more modular, faster library.
7037 @item
7038 Clean up LOTS of code.
7039 @item
7040 Include all the non-@file{.c} files in the maintenance chapter.
7041 @item
7042 Document flonums.
7043 @item
7044 Implement flonum short literals.
7045 @item
7046 Change all talk of expression operands to expression quantities,
7047 or perhaps to expression arguments.
7048 @item
7049 Implement pass 2.
7050 @item
7051 Whenever a @code{.text} or @code{.data} statement is seen, we close
7052 of the current frag with an imaginary @code{.fill 0}. This is
7053 because we only have one obstack for frags, and we can't grow new
7054 frags for a new subsection, then go back to the old subsection and
7055 append bytes to the old frag. All this nonsense goes away if we
7056 give each subsection its own obstack. It makes code simpler in
7057 about 10 places, but nobody has bothered to do it because C compiler
7058 output rarely changes subsections (compared to ending frags with
7059 relaxable addresses, which is common).
7060 @end itemize
7061
7062 @section Sources
7063 @c The following files in the @file{@value{AS}} directory
7064 @c are symbolic links to other files, of
7065 @c the same name, in a different directory.
7066 @c @itemize @bullet
7067 @c @item
7068 @c @file{atof_generic.c}
7069 @c @item
7070 @c @file{atof_vax.c}
7071 @c @item
7072 @c @file{flonum_const.c}
7073 @c @item
7074 @c @file{flonum_copy.c}
7075 @c @item
7076 @c @file{flonum_get.c}
7077 @c @item
7078 @c @file{flonum_multip.c}
7079 @c @item
7080 @c @file{flonum_normal.c}
7081 @c @item
7082 @c @file{flonum_print.c}
7083 @c @end itemize
7084
7085 Here is a list of the source files in the @file{@value{AS}} directory.
7086
7087 @table @file
7088 @item app.c
7089 This contains the pre-processing phase, which deletes comments,
7090 handles whitespace, etc. This was recently re-written, since app
7091 used to be a separate program, but RMS wanted it to be inline.
7092
7093 @item append.c
7094 This is a subroutine to append a string to another string returning a
7095 pointer just after the last @code{char} appended. (JF: All these
7096 little routines should probably all be put in one file.)
7097
7098 @item as.c
7099 Here you will find the main program of the assembler @code{@value{AS}}.
7100
7101 @item expr.c
7102 This is a branch office of @file{read.c}. This understands
7103 expressions, arguments. Inside @code{@value{AS}}, arguments are called
7104 (expression) @emph{operands}. This is confusing, because we also talk
7105 (elsewhere) about instruction @emph{operands}. Also, expression
7106 operands are called @emph{quantities} explicitly to avoid confusion
7107 with instruction operands. What a mess.
7108
7109 @item frags.c
7110 This implements the @b{frag} concept. Without frags, finding the
7111 right size for branch instructions would be a lot harder.
7112
7113 @item hash.c
7114 This contains the symbol table, opcode table @emph{etc.} hashing
7115 functions.
7116
7117 @item hex_value.c
7118 This is a table of values of digits, for use in atoi() type
7119 functions. Could probably be flushed by using calls to strtol(), or
7120 something similar.
7121
7122 @item input-file.c
7123 This contains Operating system dependent source file reading
7124 routines. Since error messages often say where we are in reading
7125 the source file, they live here too. Since @code{@value{AS}} is intended to
7126 run under GNU and Unix only, this might be worth flushing. Anyway,
7127 almost all C compilers support stdio.
7128
7129 @item input-scrub.c
7130 This deals with calling the pre-processor (if needed) and feeding the
7131 chunks back to the rest of the assembler the right way.
7132
7133 @item messages.c
7134 This contains operating system independent parts of fatal and
7135 warning message reporting. See @file{append.c} above.
7136
7137 @item output-file.c
7138 This contains operating system dependent functions that write an
7139 object file for @code{@value{AS}}. See @file{input-file.c} above.
7140
7141 @item read.c
7142 This implements all the directives of @code{@value{AS}}. This also deals
7143 with passing input lines to the machine dependent part of the
7144 assembler.
7145
7146 @item strstr.c
7147 This is a C library function that isn't in most C libraries yet.
7148 See @file{append.c} above.
7149
7150 @item subsegs.c
7151 This implements subsections.
7152
7153 @item symbols.c
7154 This implements symbols.
7155
7156 @item write.c
7157 This contains the code to perform relaxation, and to write out
7158 the object file. It is mostly operating system independent, but
7159 different OSes have different object file formats in any case.
7160
7161 @item xmalloc.c
7162 This implements @code{malloc()} or bust. See @file{append.c} above.
7163
7164 @item xrealloc.c
7165 This implements @code{realloc()} or bust. See @file{append.c} above.
7166
7167 @item atof-generic.c
7168 The following files were taken from a machine-independent subroutine
7169 library for manipulating floating point numbers and very large
7170 integers.
7171
7172 @file{atof-generic.c} turns a string into a flonum internal format
7173 floating-point number.
7174
7175 @item flonum-const.c
7176 This contains some potentially useful floating point numbers in
7177 flonum format.
7178
7179 @item flonum-copy.c
7180 This copies a flonum.
7181
7182 @item flonum-multip.c
7183 This multiplies two flonums together.
7184
7185 @item bignum-copy.c
7186 This copies a bignum.
7187
7188 @end table
7189
7190 Here is a table of all the machine-specific files (this includes
7191 both source and header files). Typically, there is a
7192 @var{machine}.c file, a @var{machine}-opcode.h file, and an
7193 atof-@var{machine}.c file. The @var{machine}-opcode.h file should
7194 be identical to the one used by GDB (which uses it for disassembly.)
7195
7196 @table @file
7197
7198 @item atof-ieee.c
7199 This contains code to turn a flonum into a ieee literal constant.
7200 This is used by tye 680x0, 32x32, sparc, and i386 versions of @code{@value{AS}}.
7201
7202 @item i386-opcode.h
7203 This is the opcode-table for the i386 version of the assembler.
7204
7205 @item i386.c
7206 This contains all the code for the i386 version of the assembler.
7207
7208 @item i386.h
7209 This defines constants and macros used by the i386 version of the assembler.
7210
7211 @item m-generic.h
7212 generic 68020 header file. To be linked to m68k.h on a
7213 non-sun3, non-hpux system.
7214
7215 @item m-sun2.h
7216 68010 header file for Sun2 workstations. Not well tested. To be linked
7217 to m68k.h on a sun2. (See also @samp{-DSUN_ASM_SYNTAX} in the
7218 @file{Makefile}.)
7219
7220 @item m-sun3.h
7221 68020 header file for Sun3 workstations. To be linked to m68k.h before
7222 compiling on a Sun3 system. (See also @samp{-DSUN_ASM_SYNTAX} in the
7223 @file{Makefile}.)
7224
7225 @item m-hpux.h
7226 68020 header file for a HPUX (system 5?) box. Which box, which
7227 version of HPUX, etc? I don't know.
7228
7229 @item m68k.h
7230 A hard- or symbolic- link to one of @file{m-generic.h},
7231 @file{m-hpux.h} or @file{m-sun3.h} depending on which kind of
7232 680x0 you are assembling for. (See also @samp{-DSUN_ASM_SYNTAX} in the
7233 @file{Makefile}.)
7234
7235 @item m68k-opcode.h
7236 Opcode table for 68020. This is now a link to the opcode table
7237 in the @code{GDB} source directory.
7238
7239 @item m68k.c
7240 All the mc680x0 code, in one huge, slow-to-compile file.
7241
7242 @item ns32k.c
7243 This contains the code for the ns32032/ns32532 version of the
7244 assembler.
7245
7246 @item ns32k-opcode.h
7247 This contains the opcode table for the ns32032/ns32532 version
7248 of the assembler.
7249
7250 @item vax-inst.h
7251 Vax specific file for describing Vax operands and other Vax-ish things.
7252
7253 @item vax-opcode.h
7254 Vax opcode table.
7255
7256 @item vax.c
7257 Vax specific parts of @code{@value{AS}}. Also includes the former files
7258 @file{vax-ins-parse.c}, @file{vax-reg-parse.c} and @file{vip-op.c}.
7259
7260 @item atof-vax.c
7261 Turns a flonum into a Vax constant.
7262
7263 @item vms.c
7264 This file contains the special code needed to put out a VMS
7265 style object file for the Vax.
7266
7267 @end table
7268
7269 Here is a list of the header files in the source directory.
7270 (Warning: This section may not be very accurate. I didn't
7271 write the header files; I just report them.) Also note that I
7272 think many of these header files could be cleaned up or
7273 eliminated.
7274
7275 @table @file
7276
7277 @item a.out.h
7278 This describes the structures used to create the binary header data
7279 inside the object file. Perhaps we should use the one in
7280 @file{/usr/include}?
7281
7282 @item as.h
7283 This defines all the globally useful things, and pulls in @file{stdio.h}
7284 and @file{assert.h}.
7285
7286 @item bignum.h
7287 This defines macros useful for dealing with bignums.
7288
7289 @item expr.h
7290 Structure and macros for dealing with expression()
7291
7292 @item flonum.h
7293 This defines the structure for dealing with floating point
7294 numbers. It #includes @file{bignum.h}.
7295
7296 @item frags.h
7297 This contains macro for appending a byte to the current frag.
7298
7299 @item hash.h
7300 Structures and function definitions for the hashing functions.
7301
7302 @item input-file.h
7303 Function headers for the input-file.c functions.
7304
7305 @item md.h
7306 structures and function headers for things defined in the
7307 machine dependent part of the assembler.
7308
7309 @item obstack.h
7310 This is the GNU systemwide include file for manipulating obstacks.
7311 Since nobody is running under real GNU yet, we include this file.
7312
7313 @item read.h
7314 Macros and function headers for reading in source files.
7315
7316 @item struct-symbol.h
7317 Structure definition and macros for dealing with the @value{AS}
7318 internal form of a symbol.
7319
7320 @item subsegs.h
7321 structure definition for dealing with the numbered subsections
7322 of the text and data sections.
7323
7324 @item symbols.h
7325 Macros and function headers for dealing with symbols.
7326
7327 @item write.h
7328 Structure for doing section fixups.
7329 @end table
7330
7331 @c ~subsection Test Directory
7332 @c (Note: The test directory seems to have disappeared somewhere
7333 @c along the line. If you want it, you'll probably have to find a
7334 @c REALLY OLD dump tape~dots{})
7335 @c
7336 @c The ~file{test/} directory is used for regression testing.
7337 @c After you modify ~@code{@value{AS}}, you can get a quick go/nogo
7338 @c confidence test by running the new ~@code{@value{AS}} over the source
7339 @c files in this directory. You use a shell script ~file{test/do}.
7340 @c
7341 @c The tests in this suite are evolving. They are not comprehensive.
7342 @c They have, however, caught hundreds of bugs early in the debugging
7343 @c cycle of ~@code{@value{AS}}. Most test statements in this suite were naturally
7344 @c selected: they were used to demonstrate actual ~@code{@value{AS}} bugs rather
7345 @c than being written ~i{a prioi}.
7346 @c
7347 @c Another testing suggestion: over 30 bugs have been found simply by
7348 @c running examples from this manual through ~@code{@value{AS}}.
7349 @c Some examples in this manual are selected
7350 @c to distinguish boundary conditions; they are good for testing ~@code{@value{AS}}.
7351 @c
7352 @c ~subsubsection Regression Testing
7353 @c Each regression test involves assembling a file and comparing the
7354 @c actual output of ~@code{@value{AS}} to ``known good'' output files. Both
7355 @c the object file and the error/warning message file (stderr) are
7356 @c inspected. Optionally the ~@code{@value{AS}} exit status may be checked.
7357 @c Discrepencies are reported. Each discrepency means either that
7358 @c you broke some part of ~@code{@value{AS}} or that the ``known good'' files
7359 @c are now out of date and should be changed to reflect the new
7360 @c definition of ``good''.
7361 @c
7362 @c Each regression test lives in its own directory, in a tree
7363 @c rooted in the directory ~file{test/}. Each such directory
7364 @c has a name ending in ~file{.ret}, where `ret' stands for
7365 @c REgression Test. The ~file{.ret} ending allows ~code{find
7366 @c (1)} to find all regression tests in the tree, without
7367 @c needing to list them explicitly.
7368 @c
7369 @c Any ~file{.ret} directory must contain a file called
7370 @c ~file{input} which is the source file to assemble. During
7371 @c testing an object file ~file{output} is created, as well as
7372 @c a file ~file{stdouterr} which contains the output to both
7373 @c stderr and stderr. If there is a file ~file{output.good} in
7374 @c the directory, and if ~file{output} contains exactly the
7375 @c same data as ~file{output.good}, the file ~file{output} is
7376 @c deleted. Likewise ~file{stdouterr} is removed if it exactly
7377 @c matches a file ~file{stdouterr.good}. If file
7378 @c ~file{status.good} is present, containing a decimal number
7379 @c before a newline, the exit status of ~@code{@value{AS}} is compared
7380 @c to this number. If the status numbers are not equal, a file
7381 @c ~file{status} is written to the directory, containing the
7382 @c actual status as a decimal number followed by newline.
7383 @c
7384 @c Should any of the ~file{*.good} files fail to match their corresponding
7385 @c actual files, this is noted by a 1-line message on the screen during
7386 @c the regression test, and you can use ~@code{find (1)} to find any
7387 @c files named ~file{status}, ~file {output} or ~file{stdouterr}.
7388 @c
7389
7390 @node Retargeting
7391 @chapter Teaching the Assembler about a New Machine
7392
7393 This chapter describes the steps required in order to make the
7394 assembler work with another machine's assembly language. This
7395 chapter is not complete, and only describes the steps in the
7396 broadest terms. You should look at the source for the
7397 currently supported machine in order to discover some of the
7398 details that aren't mentioned here.
7399
7400 You should create a new file called @file{@var{machine}.c}, and
7401 add the appropriate lines to the file @file{Makefile} so that
7402 you can compile your new version of the assembler. This should
7403 be straighforward; simply add lines similar to the ones there
7404 for the four current versions of the assembler.
7405
7406 If you want to be compatible with GDB, (and the current
7407 machine-dependent versions of the assembler), you should create
7408 a file called @file{@var{machine}-opcode.h} which should
7409 contain all the information about the names of the machine
7410 instructions, their opcodes, and what addressing modes they
7411 support. If you do this right, the assembler and GDB can share
7412 this file, and you'll only have to write it once. Note that
7413 while you're writing @code{@value{AS}}, you may want to use an
7414 independent program (if you have access to one), to make sure
7415 that @code{@value{AS}} is emitting the correct bytes. Since @code{@value{AS}}
7416 and @code{GDB} share the opcode table, an incorrect opcode
7417 table entry may make invalid bytes look OK when you disassemble
7418 them with @code{GDB}.
7419
7420 @section Functions You will Have to Write
7421
7422 Your file @file{@var{machine}.c} should contain definitions for
7423 the following functions and variables. It will need to include
7424 some header files in order to use some of the structures
7425 defined in the machine-independent part of the assembler. The
7426 needed header files are mentioned in the descriptions of the
7427 functions that will need them.
7428
7429 @table @code
7430
7431 @item long omagic;
7432 This long integer holds the value to place at the beginning of
7433 the @file{a.out} file. It is usually @samp{OMAGIC}, except on
7434 machines that store additional information in the magic-number.
7435
7436 @item char comment_chars[];
7437 This character array holds the values of the characters that
7438 start a comment anywhere in a line. Comments are stripped off
7439 automatically by the machine independent part of the
7440 assembler. Note that the @samp{/*} will always start a
7441 comment, and that only @samp{*/} will end a comment started by
7442 @samp{*/}.
7443
7444 @item char line_comment_chars[];
7445 This character array holds the values of the chars that start a
7446 comment only if they are the first (non-whitespace) character
7447 on a line. If the character @samp{#} does not appear in this
7448 list, you may get unexpected results. (Various
7449 machine-independent parts of the assembler treat the comments
7450 @samp{#APP} and @samp{#NO_APP} specially, and assume that lines
7451 that start with @samp{#} are comments.)
7452
7453 @item char EXP_CHARS[];
7454 This character array holds the letters that can separate the
7455 mantissa and the exponent of a floating point number. Typical
7456 values are @samp{e} and @samp{E}.
7457
7458 @item char FLT_CHARS[];
7459 This character array holds the letters that--when they appear
7460 immediately after a leading zero--indicate that a number is a
7461 floating-point number. (Sort of how 0x indicates that a
7462 hexadecimal number follows.)
7463
7464 @item pseudo_typeS md_pseudo_table[];
7465 (@var{pseudo_typeS} is defined in @file{md.h})
7466 This array contains a list of the machine_dependent directives
7467 the assembler must support. It contains the name of each
7468 pseudo op (Without the leading @samp{.}), a pointer to a
7469 function to be called when that directive is encountered, and
7470 an integer argument to be passed to that function.
7471
7472 @item void md_begin(void)
7473 This function is called as part of the assembler's
7474 initialization. It should do any initialization required by
7475 any of your other routines.
7476
7477 @item int md_parse_option(char **optionPTR, int *argcPTR, char ***argvPTR)
7478 This routine is called once for each option on the command line
7479 that the machine-independent part of @code{@value{AS}} does not
7480 understand. This function should return non-zero if the option
7481 pointed to by @var{optionPTR} is a valid option. If it is not
7482 a valid option, this routine should return zero. The variables
7483 @var{argcPTR} and @var{argvPTR} are provided in case the option
7484 requires a filename or something similar as an argument. If
7485 the option is multi-character, @var{optionPTR} should be
7486 advanced past the end of the option, otherwise every letter in
7487 the option will be treated as a separate single-character
7488 option.
7489
7490 @item void md_assemble(char *string)
7491 This routine is called for every machine-dependent
7492 non-directive line in the source file. It does all the real
7493 work involved in reading the opcode, parsing the operands,
7494 etc. @var{string} is a pointer to a null-terminated string,
7495 that comprises the input line, with all excess whitespace and
7496 comments removed.
7497
7498 @item void md_number_to_chars(char *outputPTR,long value,int nbytes)
7499 This routine is called to turn a C long int, short int, or char
7500 into the series of bytes that represents that number on the
7501 target machine. @var{outputPTR} points to an array where the
7502 result should be stored; @var{value} is the value to store; and
7503 @var{nbytes} is the number of bytes in 'value' that should be
7504 stored.
7505
7506 @item void md_number_to_imm(char *outputPTR,long value,int nbytes)
7507 This routine is called to turn a C long int, short int, or char
7508 into the series of bytes that represent an immediate value on
7509 the target machine. It is identical to the function @code{md_number_to_chars},
7510 except on NS32K machines.@refill
7511
7512 @item void md_number_to_disp(char *outputPTR,long value,int nbytes)
7513 This routine is called to turn a C long int, short int, or char
7514 into the series of bytes that represent an displacement value on
7515 the target machine. It is identical to the function @code{md_number_to_chars},
7516 except on NS32K machines.@refill
7517
7518 @item void md_number_to_field(char *outputPTR,long value,int nbytes)
7519 This routine is identical to @code{md_number_to_chars},
7520 except on NS32K machines.
7521
7522 @item void md_ri_to_chars(struct relocation_info *riPTR,ri)
7523 (@code{struct relocation_info} is defined in @file{a.out.h})
7524 This routine emits the relocation info in @var{ri}
7525 in the appropriate bit-pattern for the target machine.
7526 The result should be stored in the location pointed
7527 to by @var{riPTR}. This routine may be a no-op unless you are
7528 attempting to do cross-assembly.
7529
7530 @item char *md_atof(char type,char *outputPTR,int *sizePTR)
7531 This routine turns a series of digits into the appropriate
7532 internal representation for a floating-point number.
7533 @var{type} is a character from @var{FLT_CHARS[]} that describes
7534 what kind of floating point number is wanted; @var{outputPTR}
7535 is a pointer to an array that the result should be stored in;
7536 and @var{sizePTR} is a pointer to an integer where the size (in
7537 bytes) of the result should be stored. This routine should
7538 return an error message, or an empty string (not (char *)0) for
7539 success.
7540
7541 @item int md_short_jump_size;
7542 This variable holds the (maximum) size in bytes of a short (16
7543 bit or so) jump created by @code{md_create_short_jump()}. This
7544 variable is used as part of the broken-word feature, and isn't
7545 needed if the assembler is compiled with
7546 @samp{-DWORKING_DOT_WORD}.
7547
7548 @item int md_long_jump_size;
7549 This variable holds the (maximum) size in bytes of a long (32
7550 bit or so) jump created by @code{md_create_long_jump()}. This
7551 variable is used as part of the broken-word feature, and isn't
7552 needed if the assembler is compiled with
7553 @samp{-DWORKING_DOT_WORD}.
7554
7555 @item void md_create_short_jump(char *resultPTR,long from_addr,
7556 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
7557 This function emits a jump from @var{from_addr} to @var{to_addr} in
7558 the array of bytes pointed to by @var{resultPTR}. If this creates a
7559 type of jump that must be relocated, this function should call
7560 @code{fix_new()} with @var{frag} and @var{to_symbol}. The jump
7561 emitted by this function may be smaller than @var{md_short_jump_size},
7562 but it must never create a larger one.
7563 (If it creates a smaller jump, the extra bytes of memory will not be
7564 used.) This function is used as part of the broken-word feature,
7565 and isn't needed if the assembler is compiled with
7566 @samp{-DWORKING_DOT_WORD}.@refill
7567
7568 @item void md_create_long_jump(char *ptr,long from_addr,
7569 @code{long to_addr,fragS *frag,symbolS *to_symbol)}
7570 This function is similar to the previous function,
7571 @code{md_create_short_jump()}, except that it creates a long
7572 jump instead of a short one. This function is used as part of
7573 the broken-word feature, and isn't needed if the assembler is
7574 compiled with @samp{-DWORKING_DOT_WORD}.
7575
7576 @item int md_estimate_size_before_relax(fragS *fragPTR,int segment_type)
7577 This function does the initial setting up for relaxation. This
7578 includes forcing references to still-undefined symbols to the
7579 appropriate addressing modes.
7580
7581 @item relax_typeS md_relax_table[];
7582 (relax_typeS is defined in md.h)
7583 This array describes the various machine dependent states a
7584 frag may be in before relaxation. You will need one group of
7585 entries for each type of addressing mode you intend to relax.
7586
7587 @item void md_convert_frag(fragS *fragPTR)
7588 (@var{fragS} is defined in @file{as.h})
7589 This routine does the required cleanup after relaxation.
7590 Relaxation has changed the type of the frag to a type that can
7591 reach its destination. This function should adjust the opcode
7592 of the frag to use the appropriate addressing mode.
7593 @var{fragPTR} points to the frag to clean up.
7594
7595 @item void md_end(void)
7596 This function is called just before the assembler exits. It
7597 need not free up memory unless the operating system doesn't do
7598 it automatically on exit. (In which case you'll also have to
7599 track down all the other places where the assembler allocates
7600 space but never frees it.)
7601
7602 @end table
7603
7604 @section External Variables You will Need to Use
7605
7606 You will need to refer to or change the following external variables
7607 from within the machine-dependent part of the assembler.
7608
7609 @table @code
7610 @item extern char flagseen[];
7611 This array holds non-zero values in locations corresponding to
7612 the options that were on the command line. Thus, if the
7613 assembler was called with @samp{-W}, @var{flagseen['W']} would
7614 be non-zero.
7615
7616 @item extern fragS *frag_now;
7617 This pointer points to the current frag--the frag that bytes
7618 are currently being added to. If nothing else, you will need
7619 to pass it as an argument to various machine-independent
7620 functions. It is maintained automatically by the
7621 frag-manipulating functions; you should never have to change it
7622 yourself.
7623
7624 @item extern LITTLENUM_TYPE generic_bignum[];
7625 (@var{LITTLENUM_TYPE} is defined in @file{bignum.h}.
7626 This is where @dfn{bignums}--numbers larger than 32 bits--are
7627 returned when they are encountered in an expression. You will
7628 need to use this if you need to implement directives (or
7629 anything else) that must deal with these large numbers.
7630 @code{Bignums} are of @code{segT} @code{SEG_BIG} (defined in
7631 @file{as.h}, and have a positive @code{X_add_number}. The
7632 @code{X_add_number} of a @code{bignum} is the number of
7633 @code{LITTLENUMS} in @var{generic_bignum} that the number takes
7634 up.
7635
7636 @item extern FLONUM_TYPE generic_floating_point_number;
7637 (@var{FLONUM_TYPE} is defined in @file{flonum.h}.
7638 The is where @dfn{flonums}--floating-point numbers within
7639 expressions--are returned. @code{Flonums} are of @code{segT}
7640 @code{SEG_BIG}, and have a negative @code{X_add_number}.
7641 @code{Flonums} are returned in a generic format. You will have
7642 to write a routine to turn this generic format into the
7643 appropriate floating-point format for your machine.
7644
7645 @item extern int need_pass_2;
7646 If this variable is non-zero, the assembler has encountered an
7647 expression that cannot be assembled in a single pass. Since
7648 the second pass isn't implemented, this flag means that the
7649 assembler is punting, and is only looking for additional syntax
7650 errors. (Or something like that.)
7651
7652 @item extern segT now_seg;
7653 This variable holds the value of the section the assembler is
7654 currently assembling into.
7655
7656 @end table
7657
7658 @section External functions will you need
7659
7660 You will find the following external functions useful (or indispensable) when
7661 you're writing the machine-dependent part of the assembler.
7662
7663 @table @code
7664
7665 @item char *frag_more(int bytes)
7666 This function allocates @var{bytes} more bytes in the current frag (or starts a
7667 new frag, if it can't expand the current frag any more.) for you to store some
7668 object-file bytes in. It returns a pointer to the bytes, ready for you to
7669 store data in.
7670
7671 @item void fix_new(fragS *frag, int where, short size, symbolS *add_symbol, symbolS *sub_symbol, long offset, int pcrel)
7672 This function stores a relocation fixup to be acted on later.
7673 @var{frag} points to the frag the relocation belongs in;
7674 @var{where} is the location within the frag where the relocation begins;
7675 @var{size} is the size of the relocation, and is usually 1 (a single byte),
7676 2 (sixteen bits), or 4 (a longword). The value @var{add_symbol}
7677 @minus{} @var{sub_symbol} + @var{offset}, is added to the byte(s) at
7678 @var{frag->literal[where]}. If @var{pcrel} is non-zero, the address of
7679 the location is subtracted from the result. A relocation entry is also
7680 added to the @file{a.out} file. @var{add_symbol}, @var{sub_symbol},
7681 and/or @var{offset} may be NULL.@refill
7682
7683 @item char *frag_var(relax_stateT type, int max_chars, int var,
7684 @code{relax_substateT subtype, symbolS *symbol, char *opcode)}
7685 This function creates a machine-dependent frag of type @var{type}
7686 (usually @code{rs_machine_dependent}).
7687 @var{max_chars} is the maximum size in bytes that the frag may grow by;
7688 @var{var} is the current size of the variable end of the frag;
7689 @var{subtype} is the sub-type of the frag. The sub-type is used to index into
7690 @var{md_relax_table[]} during @code{relaxation}.
7691 @var{symbol} is the symbol whose value should be used to when relax-ing this frag.
7692 @var{opcode} points into a byte whose value may have to be modified if the
7693 addressing mode used by this frag changes. It typically points into the
7694 @var{fr_literal[]} of the previous frag, and is used to point to a location
7695 that @code{md_convert_frag()}, may have to change.@refill
7696
7697 @item void frag_wane(fragS *fragPTR)
7698 This function is useful from within @code{md_convert_frag}. It changes a frag
7699 to type rs_fill, and sets the variable-sized piece of the frag to zero. The
7700 frag will never change in size again.
7701
7702 @item segT expression(expressionS *retval)
7703 (@var{segT} is defined in @file{as.h}; @var{expressionS} is defined in
7704 @file{expr.h}) This function parses the string pointed to by the external char
7705 pointer @var{input_line_pointer}, and returns the section-type of the symbol
7706 used in the expression, if any. It stores the results in the @var{expressionS}
7707 pointed to by @var{retval}. @var{input_line_pointer} is advanced to point past
7708 the end of the expression. (@var{input_line_pointer} is used by other parts of
7709 the assembler. If you modify it, be sure to restore it to its original value.)
7710
7711 @item as_warn(char *message,@dots{})
7712 If warning messages are disabled, this function does nothing. Otherwise, it
7713 prints out the current file name, and the current line number, then uses
7714 @code{fprintf} to print the @var{message} and any arguments it was passed.
7715
7716 @item as_bad(char *message,@dots{})
7717 This function should be called when @code{@value{AS}} encounters conditions
7718 that are bad enough that @code{@value{AS}} should not produce an object file,
7719 but should continue reading input and printing warning and bad error messages.
7720
7721 @item as_fatal(char *message,@dots{})
7722 This function prints out the current file name and line number, prints the word
7723 @samp{FATAL:}, then uses @code{fprintf} to print the @var{message} and any
7724 arguments it was passed. Then the assembler exits. This function should only
7725 be used for serious, unrecoverable errors.
7726
7727 @item void float_const(int float_type)
7728 This function reads floating-point constants from the current input line, and
7729 calls @code{md_atof} to assemble them. It is useful as the function to call
7730 for the directives @samp{.single}, @samp{.double}, @samp{.float}, etc.
7731 @var{float_type} must be a character from @var{FLT_CHARS}.
7732
7733 @item void demand_empty_rest_of_line(void);
7734 This function can be used by machine-dependent directives to make sure the rest
7735 of the input line is empty. It prints a warning message if there are
7736 additional characters on the line.
7737
7738 @item long int get_absolute_expression(void)
7739 This function can be used by machine-dependent directives to read an absolute
7740 number from the current input line. It returns the result. If it isn't given
7741 an absolute expression, it prints a warning message and returns zero.
7742
7743 @end table
7744
7745
7746 @section The concept of Frags
7747
7748 This assembler works to optimize the size of certain addressing modes.
7749 (e.g. branch instructions) This means the size of many pieces of object code
7750 cannot be determined until after assembly is finished. (This means that the
7751 addresses of symbols cannot be determined until assembly is finished.) In
7752 order to do this, @code{@value{AS}} stores the output bytes as @dfn{frags}.
7753
7754 Here is the definition of a frag (from @file{as.h})
7755 @smallexample
7756 struct frag
7757 @{
7758 long int fr_fix;
7759 long int fr_var;
7760 relax_stateT fr_type;
7761 relax_substateT fr_substate;
7762 unsigned long fr_address;
7763 long int fr_offset;
7764 struct symbol *fr_symbol;
7765 char *fr_opcode;
7766 struct frag *fr_next;
7767 char fr_literal[];
7768 @}
7769 @end smallexample
7770
7771 @table @var
7772 @item fr_fix
7773 is the size of the fixed-size piece of the frag.
7774
7775 @item fr_var
7776 is the maximum (?) size of the variable-sized piece of the frag.
7777
7778 @item fr_type
7779 is the type of the frag.
7780 Current types are:
7781 rs_fill
7782 rs_align
7783 rs_org
7784 rs_machine_dependent
7785
7786 @item fr_substate
7787 This stores the type of machine-dependent frag this is. (what kind of
7788 addressing mode is being used, and what size is being tried/will fit/etc.
7789
7790 @item fr_address
7791 @var{fr_address} is only valid after relaxation is finished. Before
7792 relaxation, the only way to store an address is (pointer to frag containing the
7793 address) plus (offset into the frag).
7794
7795 @item fr_offset
7796 This contains a number, whose meaning depends on the type of the frag. for
7797 machine_dependent frags, this contains the offset from fr_symbol that the frag
7798 wants to go to. Thus, for branch instructions it is usually zero. (unless the
7799 instruction was @samp{jba foo+12} or something like that.)
7800
7801 @item fr_symbol
7802 for machine_dependent frags, this points to the symbol the frag needs to reach.
7803
7804 @item fr_opcode
7805 This points to the location in the frag (or in a previous frag) of the opcode
7806 for the instruction that caused this to be a frag. @var{fr_opcode} is needed
7807 if the actual opcode must be changed in order to use a different form of the
7808 addressing mode. (For example, if a conditional branch only comes in size
7809 tiny, a large-size branch could be implemented by reversing the sense of the
7810 test, and turning it into a tiny branch over a large jump. This would require
7811 changing the opcode.)
7812
7813 @var{fr_literal} is a variable-size array that contains the actual object
7814 bytes. A frag consists of a fixed size piece of object data, (which may be
7815 zero bytes long), followed by a piece of object data whose size may not have
7816 been determined yet. Other information includes the type of the frag (which
7817 controls how it is relaxed),
7818
7819 @item fr_next
7820 This is the next frag in the singly-linked list. This is usually only needed
7821 by the machine-independent part of @code{@value{AS}}.
7822
7823 @end table
7824 @end ifset
7825
7826 @node Acknowledgements
7827 @chapter Acknowledgements
7828
7829 If you've contributed to @code{@value{AS}} and your name isn't listed here, it
7830 is not meant as a slight. We just don't know about it. Send mail to the
7831 maintainer, and we'll correct the situation. Currently (June 1993), the
7832 maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}).
7833
7834 Dean Elsner wrote the original GNU assembler for the VAX.@footnote{Any more
7835 details?}
7836
7837 Jay Fenlason maintained GAS for a while, adding support for gdb-specific debug
7838 information and the 68k series machines, most of the preprocessing pass, and
7839 extensive changes in messages.c, input-file.c, write.c.
7840
7841 K. Richard Pixley maintained GAS for a while, adding various enhancements and
7842 many bug fixes, including merging support for several processors, breaking GAS
7843 up to handle multiple object file format backends (including heavy rewrite,
7844 testing, an integration of the coff and b.out backends), adding configuration
7845 including heavy testing and verification of cross assemblers and file splits
7846 and renaming, converted GAS to strictly ansi C including full prototypes, added
7847 support for m680[34]0 & cpu32, considerable work on i960 including a COFF port
7848 (including considerable amounts of reverse engineering), a SPARC opcode file
7849 rewrite, DECstation, rs6000, and hp300hpux host ports, updated "know"
7850 assertions and made them work, much other reorganization, cleanup, and lint.
7851
7852 Ken Raeburn wrote the high-level BFD interface code to replace most of the code
7853 in format-specific I/O modules.
7854
7855 The original VMS support was contributed by David L. Kashtan. Eric Youngdale
7856 has done much work with it since.
7857
7858 The Intel 80386 machine description was written by Eliot Dresselhaus.
7859
7860 Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
7861
7862 The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
7863 University and Torbjorn Granlund of the Swedish Institute of Computer Science.
7864
7865 Keith Knowles at the Open Software Foundation wrote the original MIPS back end
7866 (tc-mips.c, tc-mips.h), and contributed Rose format support (which hasn't been
7867 merged in yet). Ralph Campbell worked with the MIPS code to support a.out
7868 format.
7869
7870 Support for the Zilog Z8k and Hitachi H8/300 and H8/500 processors (tc-z8k,
7871 tc-h8300, tc-h8500), and IEEE 695 object file format (obj-ieee), was written by
7872 Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to
7873 use BFD for some low-level operations, for use with the H8/300 and AMD 29k
7874 targets.
7875
7876 John Gilmore built the AMD 29000 support, added .include support, and
7877 simplified the configuration of which versions accept which pseudo-ops. He
7878 updated the 68k machine description so that Motorola's opcodes always produced
7879 fixed-size instructions (e.g. jsr), while synthetic instructions remained
7880 shrinkable (jbsr). John fixed many bugs, including true tested
7881 cross-compilation support, and one bug in relaxation that took a week and
7882 required the apocryphal one-bit fix.
7883
7884 Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntaxes for the
7885 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix),
7886 and made a few other minor patches.
7887
7888 Steve Chamberlain made @code{@value{AS}} able to generate listings.
7889
7890 Support for the HP9000/300 was contributed by Hewlett-Packard.
7891
7892 GAS and BFD support for the native HPPA object format (SOM) along with
7893 a fairly extensive HPPA testsuite (for both SOM and ELF object formats)
7894 was written by Jeff Law. This work was supported by both the Center for
7895 Software Science at the University of Utah and Cygnus Support.
7896
7897 Support for ELF format files has been worked on by Mark Eichin of Cygnus
7898 Support (original, incomplete implementation for SPARC), Pete Hoogenboom and
7899 Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open
7900 Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc,
7901 and some initial 64-bit support).
7902
7903 Several engineers at Cygnus Support have also provided many small bug fixes and
7904 configuration enhancements.
7905
7906 Many others have contributed large or small bugfixes and enhancements. If
7907 you've contributed significant work and are not mentioned on this list, and
7908 want to be, let us know. Some of the history has been lost; we aren't
7909 intentionally leaving anyone out.
7910
7911 @ifset GENERIC
7912 @node Copying
7913 @unnumbered
7914 @include gpl.texinfo
7915 @end ifset
7916
7917 @node Index
7918 @unnumbered Index
7919
7920 @printindex cp
7921
7922 @contents
7923 @bye
7924 @c Local Variables:
7925 @c fill-column: 79
7926 @c End: