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