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