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