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