(1) disable documentation for .lsym at sac's request
[deliverable/binutils-gdb.git] / gas / doc / as-all.texinfo
CommitLineData
169fff49
RP
1\input texinfo @c -*-Texinfo-*-
2@c Copyright (c) 1991 1992 Free Software Foundation, Inc.
3@c %**start of header
4@setfilename as.info
5@settitle Using as
6@setchapternewpage odd
85fc7642
RP
7@c @smallbook
8@c @cropmarks
169fff49
RP
9@c %**end of header
10
5ff20e8f
RP
11@ifinfo
12@format
13START-INFO-DIR-ENTRY
14* As: (as). The GNU assembler.
15END-INFO-DIR-ENTRY
16@end format
17@end ifinfo
18
169fff49
RP
19@finalout
20@syncodeindex ky cp
21
22@c
23@ifinfo
24This file documents the GNU Assembler "as".
25
26Copyright (C) 1991 Free Software Foundation, Inc.
27
28Permission is granted to make and distribute verbatim copies of
29this manual provided the copyright notice and this permission notice
30are preserved on all copies.
31
32@ignore
33Permission is granted to process this file through Tex and print the
34results, provided the printed document carries copying permission
35notice identical to this one except for the removal of this paragraph
36(this paragraph not being relevant to the printed manual).
37
38@end ignore
39Permission is granted to copy and distribute modified versions of this
40manual under the conditions for verbatim copying, provided also that the
41section entitled ``GNU General Public License'' is included exactly as
42in the original, and provided that the entire resulting derived work is
43distributed under the terms of a permission notice identical to this
44one.
45
46Permission is granted to copy and distribute translations of this manual
47into another language, under the above conditions for modified versions,
48except that the section entitled ``GNU General Public License'' may be
49included in a translation approved by the Free Software Foundation
50instead of in the original English.
51@end ifinfo
52
53@titlepage
54@title Using as
55@subtitle The GNU Assembler
56@sp 1
57@subtitle January 1992
58@sp 1
59@sp 13
60The Free Software Foundation Inc. thanks The Nice Computer
61Company of Australia for loaning Dean Elsner to write the
62first (Vax) version of @code{as} for Project GNU.
63The proprietors, management and staff of TNCCA thank FSF for
64distracting the boss while they got some work
65done.
66@sp 3
67@author Dean Elsner, Jay Fenlason & friends
68@c edited by: pesch@cygnus.com
69@page
70@tex
71\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
72\xdef\manvers{\$Revision$} % For use in headers, footers too
73{\parskip=0pt
74\hfill {\it Using {\tt as}} \manvers\par
75\hfill \TeX{}info \texinfoversion\par
76\hfill Edited by Roland Pesch for Cygnus Support\par
77}
78%"boxit" macro for figures:
79%Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
80\gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
81 \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
82#2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
83\gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
84@end tex
85
86@vskip 0pt plus 1filll
87Copyright @copyright{} 1991 Free Software Foundation, Inc.
88
89Permission is granted to make and distribute verbatim copies of
90this manual provided the copyright notice and this permission notice
91are preserved on all copies.
92
93Permission is granted to copy and distribute modified versions of this
94manual under the conditions for verbatim copying, provided also that the
95section entitled ``GNU General Public License'' is included exactly as
96in the original, and provided that the entire resulting derived work is
97distributed under the terms of a permission notice identical to this
98one.
99
100Permission is granted to copy and distribute translations of this manual
101into another language, under the above conditions for modified versions,
102except that the section entitled ``GNU General Public License'' may be
103included in a translation approved by the Free Software Foundation
104instead of in the original English.
105@end titlepage
106@page
169fff49 107@ifinfo
41ee6e91
RP
108@node Top
109@top Using as
110
169fff49 111This file is a user guide to the GNU assembler @code{as}.
169fff49
RP
112@menu
113* Overview:: Overview
114* Invoking:: Command-Line Options
115* Syntax:: Syntax
116* Sections:: Sections and Relocation
117* Symbols:: Symbols
118* Expressions:: Expressions
119* Pseudo Ops:: Assembler Directives
120* Machine Dependent:: Machine Dependent Features
121* Copying:: GNU GENERAL PUBLIC LICENSE
122* Index:: Index
123@end menu
41ee6e91 124@end ifinfo
169fff49 125
41ee6e91 126@node Overview
169fff49
RP
127@chapter Overview
128@iftex
129This manual is a user guide to the GNU assembler @code{as}.
130@end iftex
131
132@cindex invocation summary
133@cindex option summary
134@cindex summary of options
135Here is a brief summary of how to invoke @code{as}. For details,
136@pxref{Invoking,,Comand-Line Options}.
137
138@c We don't use deffn and friends for the following because they seem
139@c to be limited to one line for the header.
140@smallexample
141 as [ -a | -al | -as ] [ -D ] [ -f ]
80381063 142 [ -I @var{path} ] [ -K ] [ -L ]
169fff49
RP
143 [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ]
144@c am29k has no machine-dependent assembler options
145@c h8/300 has no machine-dependent assembler options
146@c see md_parse_option in i960.c
147 [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
148 [ -b ] [ -norelax ]
149 [ -l ] [ -mc68000 | -mc68010 | -mc68020 ]
150 [ -- | @var{files} @dots{} ]
151@end smallexample
152
153@table @code
154@item -a | -al | -as
155Turn on assembly listings; @samp{-al}, listing only, @samp{-as}, symbols
156only, @samp{-a}, everything.
157
158@item -D
159This option is accepted only for script compatibility with calls to
160other assemblers; it has no effect on @code{as}.
161
162@item -f
163``fast''---skip preprocessing (assume source is compiler output)
164
165@item -I @var{path}
166Add @var{path} to the search list for @code{.include} directives
167
80381063 168@item -K
169fff49
RP
169Issue warnings when difference tables altered for long displacements.
170
171@item -L
172Keep (in symbol table) local symbols, starting with @samp{L}
173
174@item -o @var{objfile}
175Name the object-file output from @code{as}
176
177@item -R
178Fold data section into text section
179
180@item -v
181Announce @code{as} version
182
183@item -W
184Suppress warning messages
185
186@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
187(When configured for Intel 960).
188Specify which variant of the 960 architecture is the target.
189
190@item -b
191(When configured for Intel 960).
192Add code to collect statistics about branches taken.
193
194@item -norelax
195(When configured for Intel 960).
196Do not alter compare-and-branch instructions for long displacements;
197error if necessary.
198
199@item -l
200(When configured for Motorola 68000).
201Shorten references to undefined symbols, to one word instead of two
202
203@item -mc68000 | -mc68010 | -mc68020
204(When configured for Motorola 68000).
205Specify what processor in the 68000 family is the target (default 68020)
206
207@item -- | @var{files} @dots{}
208Standard input, or source files to assemble
209@end table
210
211@menu
212* Manual:: Structure of this Manual
213* GNU Assembler:: as, the GNU Assembler
214* Object Formats:: Object File Formats
215* Command Line:: Command Line
216* Input Files:: Input Files
217* Object:: Output (Object) File
218* Errors:: Error and Warning Messages
219@end menu
220
41ee6e91 221@node Manual
169fff49
RP
222@section Structure of this Manual
223
224@cindex manual, structure and purpose
225This manual is intended to describe what you need to know to use
226@sc{gnu} @code{as}. We cover the syntax expected in source files, including
227notation for symbols, constants, and expressions; the directives that
228@code{as} understands; and of course how to invoke @code{as}.
229
230This manual also describes some of the machine-dependent features of
231various flavors of the assembler.
232@refill
233
234@cindex machine instructions (not covered)
235On the other hand, this manual is @emph{not} intended as an introduction
236to programming in assembly language---let alone programming in general!
237In a similar vein, we make no attempt to introduce the machine
238architecture; we do @emph{not} describe the instruction set, standard
239mnemonics, registers or addressing modes that are standard to a
240particular architecture.
241You may want to consult the manufacturer's
242machine architecture manual for this information.
243
244
245@c I think this is premature---pesch@cygnus.com, 17jan1991
246@ignore
247Throughout this manual, we assume that you are running @dfn{GNU},
248the portable operating system from the @dfn{Free Software
249Foundation, Inc.}. This restricts our attention to certain kinds of
250computer (in particular, the kinds of computers that GNU can run on);
251once this assumption is granted examples and definitions need less
252qualification.
253
254@code{as} is part of a team of programs that turn a high-level
255human-readable series of instructions into a low-level
256computer-readable series of instructions. Different versions of
257@code{as} are used for different kinds of computer.
258@end ignore
259
260@c There used to be a section "Terminology" here, which defined
261@c "contents", "byte", "word", and "long". Defining "word" to any
262@c particular size is confusing when the .word directive may generate 16
263@c bits on one machine and 32 bits on another; in general, for the user
264@c version of this manual, none of these terms seem essential to define.
265@c They were used very little even in the former draft of the manual;
266@c this draft makes an effort to avoid them (except in names of
267@c directives).
268
41ee6e91 269@node GNU Assembler
169fff49
RP
270@section as, the GNU Assembler
271
272GNU @code{as} is really a family of assemblers.
273If you use (or have used) the GNU assembler on one architecture, you
274should find a fairly similar environment when you use it on another
275architecture. Each version has much in common with the others,
276including object file formats, most assembler directives (often called
277@dfn{pseudo-ops)} and assembler syntax.@refill
278
279@cindex purpose of @sc{gnu} @code{as}
280@code{as} is primarily intended to assemble the output of the GNU C
281compiler @code{gcc} for use by the linker @code{ld}. Nevertheless,
282we've tried to make @code{as} assemble correctly everything that the native
283assembler would.
284Any exceptions are documented explicitly (@pxref{Machine Dependent}).
285This doesn't mean @code{as} always uses the same syntax as another
286assembler for the same architecture; for example, we know of several
287incompatible versions of 680x0 assembly language syntax.
288
289Unlike older assemblers, @code{as} is designed to assemble a source
290program in one pass of the source file. This has a subtle impact on the
291@kbd{.org} directive (@pxref{Org,,@code{.org}}).
292
41ee6e91 293@node Object Formats
169fff49
RP
294@section Object File Formats
295
296@cindex object file format
297The GNU assembler can be configured to produce several alternative
298object file formats. For the most part, this does not affect how you
299write assembly language programs; but directives for debugging symbols
300are typically different in different file formats. @xref{Symbol
301Attributes,,Symbol Attributes}.
302
41ee6e91 303@node Command Line
169fff49
RP
304@section Command Line
305
306@cindex command line conventions
307After the program name @code{as}, the command line may contain
308options and file names. Options may appear in any order, and may be
309before, after, or between file names. The order of file names is
310significant.
311
312@cindex standard input, as input file
313@kindex --
314@file{--} (two hyphens) by itself names the standard input file
315explicitly, as one of the files for @code{as} to assemble.
316
317@cindex options, command line
318Except for @samp{--} any command line argument that begins with a
319hyphen (@samp{-}) is an option. Each option changes the behavior of
320@code{as}. No option changes the way another option works. An
321option is a @samp{-} followed by one or more letters; the case of
322the letter is important. All options are optional.
323
324Some options expect exactly one file name to follow them. The file
325name may either immediately follow the option's letter (compatible
326with older assemblers) or it may be the next command argument (GNU
327standard). These two command lines are equivalent:
328
329@smallexample
330as -o my-object-file.o mumble.s
331as -omy-object-file.o mumble.s
332@end smallexample
333
41ee6e91 334@node Input Files
169fff49
RP
335@section Input Files
336
337@cindex input
338@cindex source program
339@cindex files, input
340We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
341describe the program input to one run of @code{as}. The program may
342be in one or more files; how the source is partitioned into files
343doesn't change the meaning of the source.
344
345@c I added "con" prefix to "catenation" just to prove I can overcome my
346@c APL training... pesch@cygnus.com
347The source program is a concatenation of the text in all the files, in the
348order specified.
349
350Each time you run @code{as} it assembles exactly one source
351program. The source program is made up of one or more files.
352(The standard input is also a file.)
353
354You give @code{as} a command line that has zero or more input file
355names. The input files are read (from left file name to right). A
356command line argument (in any position) that has no special meaning
357is taken to be an input file name.
358
359If you give @code{as} no file names it attempts to read one input file
360from the @code{as} standard input, which is normally your terminal. You
361may have to type @key{ctl-D} to tell @code{as} there is no more program
362to assemble.
363
364Use @samp{--} if you need to explicitly name the standard input file
365in your command line.
366
367If the source is empty, @code{as} will produce a small, empty object
368file.
369
370@subheading Filenames and Line-numbers
371
372@cindex input file linenumbers
373@cindex line numbers, in input files
374There are two ways of locating a line in the input file (or files) and
375either may be used in reporting error messages. One way refers to a line
376number in a physical file; the other refers to a line number in a
377``logical'' file. @xref{Errors, ,Error and Warning Messages}.
378
379@dfn{Physical files} are those files named in the command line given
380to @code{as}.
381
382@dfn{Logical files} are simply names declared explicitly by assembler
383directives; they bear no relation to physical files. Logical file names
384help error messages reflect the original source file, when @code{as}
385source is itself synthesized from other files.
386@xref{App-File,,@code{.app-file}}.
387
41ee6e91 388@node Object
169fff49
RP
389@section Output (Object) File
390
391@cindex object file
392@cindex output file
393@kindex a.out
394@kindex .o
395Every time you run @code{as} it produces an output file, which is
396your assembly language program translated into numbers. This file
397is the object file, named @code{a.out} unless you tell @code{as} to
398give it another name by using the @code{-o} option. Conventionally,
399object file names end with @file{.o}. The default name of
400@file{a.out} is used for historical reasons: older assemblers were
401capable of assembling self-contained programs directly into a
402runnable program.
403@c This may still work, but hasn't been tested.
404
405@cindex linker
406@kindex ld
407The object file is meant for input to the linker @code{ld}. It contains
408assembled program code, information to help @code{ld} integrate
409the assembled program into a runnable file, and (optionally) symbolic
410information for the debugger.
411
412@c link above to some info file(s) like the description of a.out.
413@c don't forget to describe GNU info as well as Unix lossage.
414
41ee6e91 415@node Errors
169fff49
RP
416@section Error and Warning Messages
417
418@cindex error messsages
419@cindex warning messages
420@cindex messages from @code{as}
421@code{as} may write warnings and error messages to the standard error
422file (usually your terminal). This should not happen when a compiler
423runs @code{as} automatically. Warnings report an assumption made so
424that @code{as} could keep assembling a flawed program; errors report a
425grave problem that stops the assembly.
426
427@cindex format of warning messages
428Warning messages have the format
429
430@smallexample
431file_name:@b{NNN}:Warning Message Text
432@end smallexample
433
434@noindent
435@cindex line numbers, in warnings/errors
436(where @b{NNN} is a line number). If a logical file name has
437been given (@pxref{App-File,,@code{.app-file}}) it is used for the filename, otherwise the
438name of the current input file is used. If a logical line number was
439given
440(@pxref{Ln,,@code{.ln}})
441then it is used to calculate the number printed,
442otherwise the actual line in the current source file is printed. The
443message text is intended to be self explanatory (in the grand Unix
444tradition). @refill
445
446@cindex format of error messages
447Error messages have the format
448@smallexample
449file_name:@b{NNN}:FATAL:Error Message Text
450@end smallexample
451The file name and line number are derived as for warning
452messages. The actual message text may be rather less explanatory
453because many of them aren't supposed to happen.
454
41ee6e91 455@node Invoking
169fff49
RP
456@chapter Command-Line Options
457
458@cindex options, all versions of @code{as}
459This chapter describes command-line options available in @emph{all}
460versions of the GNU assembler; @pxref{Machine Dependent}, for options specific
461to particular machine architectures.
462
463@section Enable Listings: @code{-a}, @code{-al}, @code{-as}
464
465@kindex -a
466@kindex -al
467@kindex -as
468@cindex listings, enabling
469@cindex assembly listings, enabling
470These options enable listing output from the assembler. @samp{-a} by
471itself requests all listing output; @samp{-al} requests only the
472output-program listing, and @samp{-as} requests only a symbol table
473listing.
474
475Once you have specified one of these options, you can further control
476listing output and its appearance using the directives @code{.list},
477@code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
478@code{.sbttl}.
479
480If you do not request listing output with one of the @samp{-a} options, the
481listing-control directives have no effect.
482
483@section @code{-D}
484
485@kindex -D
486This option has no effect whatsoever, but it is accepted to make it more
487likely that scripts written for other assemblers will also work with
488@code{as}.
489
490@section Work Faster: @code{-f}
491
492@kindex -f
493@cindex trusted compiler
494@cindex faster processing (@code{-f})
495@samp{-f} should only be used when assembling programs written by a
496(trusted) compiler. @samp{-f} stops the assembler from pre-processing
497the input file(s) before assembling them. @xref{Pre-processing,
498,Pre-processing}.
499
500@quotation
501@emph{Warning:} if the files actually need to be pre-processed (if they
502contain comments, for example), @code{as} will not work correctly if
503@samp{-f} is used.
504@end quotation
505
506@section @code{.include} search path: @code{-I} @var{path}
507
508@kindex -I @var{path}
509@cindex paths for @code{.include}
510@cindex search path for @code{.include}
511@cindex @code{include} directive search path
512Use this option to add a @var{path} to the list of directories
513@code{as} will search for files specified in @code{.include}
514directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
515many times as necessary to include a variety of paths. The current
516working directory is always searched first; after that, @code{as}
517searches any @samp{-I} directories in the same order as they were
518specified (left to right) on the command line.
519
80381063 520@section Difference Tables: @code{-K}
169fff49 521
80381063 522@kindex -K
169fff49
RP
523
524@cindex difference tables, warning
525@cindex warning for altered difference tables
526@code{as} sometimes alters the code emitted for directives of the form
527@samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
80381063 528You can use the @samp{-K} option if you want a warning issued when this
169fff49
RP
529is done.
530
531@section Include Local Labels: @code{-L}
532
533@kindex -L
534@cindex local labels, retaining in output
535Labels beginning with @samp{L} (upper case only) are called @dfn{local
536labels}. @xref{Symbol Names}. Normally you don't see such labels when
537debugging, because they are intended for the use of programs (like
538compilers) that compose assembler programs, not for your notice.
539Normally both @code{as} and @code{ld} discard such labels, so you don't
540normally debug with them.
541
542This option tells @code{as} to retain those @samp{L@dots{}} symbols
543in the object file. Usually if you do this you also tell the linker
544@code{ld} to preserve symbols whose names begin with @samp{L}.
545
546@section Name the Object File: @code{-o}
547
548@kindex -o
549@cindex naming object file
550@cindex object file name
551There is always one object file output when you run @code{as}. By
552default it has the name @file{a.out}. You use this option (which
553takes exactly one filename) to give the object file a different name.
554
555Whatever the object file is called, @code{as} will overwrite any
556existing file of the same name.
557
558@section Join Data and Text Sections: @code{-R}
559
560@kindex -R
561@cindex data and text sections, joining
562@cindex text and data sections, joining
563@cindex joining text and data sections
564@cindex merging text and data sections
565@code{-R} tells @code{as} to write the object file as if all
566data-section data lives in the text section. This is only done at
567the very last moment: your binary data are the same, but data
568section parts are relocated differently. The data section part of
569your object file is zero bytes long because all it bytes are
570appended to the text section. (@xref{Sections,,Sections and Relocation}.)
571
572When you specify @code{-R} it would be possible to generate shorter
573address displacements (because we don't have to cross between text and
574data section). We refrain from doing this simply for compatibility with
575older versions of @code{as}. In future, @code{-R} may work this way.
576
577When @code{as} is configured for COFF output,
578this option is only useful if you use sections named @samp{.text} and
579@samp{.data}.
580
581@section Announce Version: @code{-v}
582
583@kindex -v
584@kindex -version
585@cindex @code{as} version
586@cindex version of @code{as}
587You can find out what version of as is running by including the
588option @samp{-v} (which you can also spell as @samp{-version}) on the
589command line.
590
591@section Suppress Warnings: @code{-W}
592
593@kindex -W
594@cindex suppressing warnings
595@cindex warnings, suppressing
596@code{as} should never give a warning or error message when
597assembling compiler output. But programs written by people often
598cause @code{as} to give a warning that a particular assumption was
599made. All such warnings are directed to the standard error file.
600If you use this option, no warnings are issued. This option only
601affects the warning messages: it does not change any particular of how
602@code{as} assembles your file. Errors, which stop the assembly, are
603still reported.
604
41ee6e91 605@node Syntax
169fff49
RP
606@chapter Syntax
607
608@cindex machine-independent syntax
609@cindex syntax, machine-independent
610This chapter describes the machine-independent syntax allowed in a
611source file. @code{as} syntax is similar to what many other assemblers
612use; it is inspired in BSD 4.2
613assembler, except that @code{as} does not assemble Vax bit-fields.
614
615@menu
616* Pre-processing:: Pre-processing
617* Whitespace:: Whitespace
618* Comments:: Comments
619* Symbol Intro:: Symbols
620* Statements:: Statements
621* Constants:: Constants
622@end menu
623
41ee6e91 624@node Pre-processing
169fff49
RP
625@section Pre-Processing
626
627@cindex preprocessing
628The pre-processor:
629@itemize @bullet
630@cindex whitespace, removed by preprocessor
631@item
632adjusts and removes extra whitespace. It leaves one space or tab before
633the keywords on a line, and turns any other whitespace on the line into
634a single space.
635
636@cindex comments, removed by preprocessor
637@item
638removes all comments, replacing them with a single space, or an
639appropriate number of newlines.
640
641@cindex constants, converted by preprocessor
642@item
643converts character constants into the appropriate numeric values.
644@end itemize
645
646Excess whitespace, comments, and character constants
647cannot be used in the portions of the input text that are not
648pre-processed.
649
650@cindex turning preprocessing on and off
651@cindex preprocessing, turning on and off
652@kindex #NO_APP
653@kindex #APP
654If the first line of an input file is @code{#NO_APP} or the @samp{-f}
655option is given, the input file will not be pre-processed. Within such
656an input file, parts of the file can be pre-processed by putting a line
657that says @code{#APP} before the text that should be pre-processed, and
658putting a line that says @code{#NO_APP} after them. This feature is
659mainly intend to support @code{asm} statements in compilers whose output
660normally does not need to be pre-processed.
661
41ee6e91 662@node Whitespace
169fff49
RP
663@section Whitespace
664
665@cindex whitespace
666@dfn{Whitespace} is one or more blanks or tabs, in any order.
667Whitespace is used to separate symbols, and to make programs neater for
668people to read. Unless within character constants
669(@pxref{Characters,,Character Constants}), any whitespace means the same
670as exactly one space.
671
41ee6e91 672@node Comments
169fff49
RP
673@section Comments
674
675@cindex comments
676There are two ways of rendering comments to @code{as}. In both
677cases the comment is equivalent to one space.
678
679Anything from @samp{/*} through the next @samp{*/} is a comment.
680This means you may not nest these comments.
681
682@smallexample
683/*
684 The only way to include a newline ('\n') in a comment
685 is to use this sort of comment.
686*/
687
688/* This sort of comment does not nest. */
689@end smallexample
690
691@cindex line comment character
692Anything from the @dfn{line comment} character to the next newline
693is considered a comment and is ignored. The line comment character is
694@samp{#} on the Vax;
695@samp{#} on the i960;
696@samp{|} on the 680x0;
697@samp{;} for the AMD 29K family;
698@samp{;} for the machine specific family;
699@pxref{Machine Dependent}. @refill
700@c FIXME: fill in SPARC line comment char
701
702On some machines there are two different line comment characters. One
703will only begin a comment if it is the first non-whitespace character on
704a line, while the other will always begin a comment.
705
706@kindex #
707@cindex lines starting with @code{#}
708@cindex logical line numbers
709To be compatible with past assemblers, a special interpretation is
710given to lines that begin with @samp{#}. Following the @samp{#} an
711absolute expression (@pxref{Expressions}) is expected: this will be
712the logical line number of the @b{next} line. Then a string
713(@xref{Strings}.) is allowed: if present it is a new logical file
714name. The rest of the line, if any, should be whitespace.
715
716If the first non-whitespace characters on the line are not numeric,
717the line is ignored. (Just like a comment.)
718@smallexample
719 # This is an ordinary comment.
720# 42-6 "new_file_name" # New logical file name
721 # This is logical line # 36.
722@end smallexample
723This feature is deprecated, and may disappear from future versions
724of @code{as}.
725
41ee6e91 726@node Symbol Intro
169fff49
RP
727@section Symbols
728
729@cindex characters used in symbols
730A @dfn{symbol} is one or more characters chosen from the set of all
731letters (both upper and lower case), digits and
732the two characters @samp{_.}
733On most machines, you can also use @code{$} in symbol names; exceptions
734are noted in @ref{Machine Dependent}.
735No symbol may begin with a digit. Case is significant.
736There is no length limit: all characters are significant. Symbols are
737delimited by characters not in that set, or by the beginning of a file
738(since the source program must end with a newline, the end of a file is
739not a possible symbol delimiter). @xref{Symbols}.
740@cindex length of symbols
741
41ee6e91 742@node Statements
169fff49
RP
743@section Statements
744
745@cindex statements, structure of
746@cindex line separator character
747@cindex statement separator character
748A @dfn{statement} ends at a newline character (@samp{\n}) or line
749separator character. (The line separator is usually @samp{;}, unless
750this conflicts with the comment character; @pxref{Machine Dependent}.) The
751newline or separator character is considered part of the preceding
752statement. Newlines and separators within character constants are an
753exception: they don't end statements.
754
755@cindex newline, required at file end
756@cindex EOF, newline must precede
757It is an error to end any statement with end-of-file: the last
758character of any input file should be a newline.@refill
759
760@cindex continuing statements
761@cindex multi-line statements
762@cindex statement on multiple lines
763You may write a statement on more than one line if you put a
764backslash (@kbd{\}) immediately in front of any newlines within the
765statement. When @code{as} reads a backslashed newline both
766characters are ignored. You can even put backslashed newlines in
767the middle of symbol names without changing the meaning of your
768source program.
769
770An empty statement is allowed, and may include whitespace. It is ignored.
771
772@cindex instructions and directives
773@cindex directives and instructions
774@c "key symbol" is not used elsewhere in the document; seems pedantic to
775@c @defn{} it in that case, as was done previously... pesch@cygnus.com,
776@c 13feb91.
777A statement begins with zero or more labels, optionally followed by a
778key symbol which determines what kind of statement it is. The key
779symbol determines the syntax of the rest of the statement. If the
780symbol begins with a dot @samp{.} then the statement is an assembler
781directive: typically valid for any computer. If the symbol begins with
782a letter the statement is an assembly language @dfn{instruction}: it
783will assemble into a machine language instruction.
784Different versions of @code{as} for different computers will
785recognize different instructions. In fact, the same symbol may
786represent a different instruction in a different computer's assembly
787language.@refill
788
789@cindex @code{:} (label)
790@cindex label (@code{:})
791A label is a symbol immediately followed by a colon (@code{:}).
792Whitespace before a label or after a colon is permitted, but you may not
793have whitespace between a label's symbol and its colon. @xref{Labels}.
794
795@smallexample
796label: .directive followed by something
797another_label: # This is an empty statement.
798 instruction operand_1, operand_2, @dots{}
799@end smallexample
800
41ee6e91 801@node Constants
169fff49
RP
802@section Constants
803
804@cindex constants
805A constant is a number, written so that its value is known by
806inspection, without knowing any context. Like this:
807@smallexample
808.byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
809.ascii "Ring the bell\7" # A string constant.
810.octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
811.float 0f-314159265358979323846264338327\
81295028841971.693993751E-40 # - pi, a flonum.
813@end smallexample
814
815@menu
816* Characters:: Character Constants
817* Numbers:: Number Constants
818@end menu
819
41ee6e91 820@node Characters
169fff49
RP
821@subsection Character Constants
822
823@cindex character constants
824@cindex constants, character
825There are two kinds of character constants. A @dfn{character} stands
826for one character in one byte and its value may be used in
827numeric expressions. String constants (properly called string
828@emph{literals}) are potentially many bytes and their values may not be
829used in arithmetic expressions.
830
831@menu
832* Strings:: Strings
833* Chars:: Characters
834@end menu
835
41ee6e91 836@node Strings
169fff49
RP
837@subsubsection Strings
838
839@cindex string constants
840@cindex constants, string
841A @dfn{string} is written between double-quotes. It may contain
842double-quotes or null characters. The way to get special characters
843into a string is to @dfn{escape} these characters: precede them with
844a backslash @samp{\} character. For example @samp{\\} represents
845one backslash: the first @code{\} is an escape which tells
846@code{as} to interpret the second character literally as a backslash
847(which prevents @code{as} from recognizing the second @code{\} as an
848escape character). The complete list of escapes follows.
849
850@cindex escape codes, character
851@cindex character escape codes
852@table @kbd
853@c @item \a
854@c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
855@c
856@item \b
857@cindex @code{\b} (backspace character)
858@cindex backspace (@code{\b})
859Mnemonic for backspace; for ASCII this is octal code 010.
860
861@c @item \e
862@c Mnemonic for EOText; for ASCII this is octal code 004.
863@c
864@item \f
865@cindex @code{\f} (formfeed character)
866@cindex formfeed (@code{\f})
867Mnemonic for FormFeed; for ASCII this is octal code 014.
868
869@item \n
870@cindex @code{\n} (newline character)
871@cindex newline (@code{\n})
872Mnemonic for newline; for ASCII this is octal code 012.
873
874@c @item \p
875@c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
876@c
877@item \r
878@cindex @code{\r} (carriage return character)
879@cindex carriage return (@code{\r})
880Mnemonic for carriage-Return; for ASCII this is octal code 015.
881
882@c @item \s
883@c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
884@c other assemblers.
885@c
886@item \t
887@cindex @code{\t} (tab)
888@cindex tab (@code{\t})
889Mnemonic for horizontal Tab; for ASCII this is octal code 011.
890
891@c @item \v
892@c Mnemonic for Vertical tab; for ASCII this is octal code 013.
893@c @item \x @var{digit} @var{digit} @var{digit}
894@c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
895@c
896@item \ @var{digit} @var{digit} @var{digit}
897@cindex @code{\@var{ddd}} (octal character code)
898@cindex octal character code (@code{\@var{ddd}})
899An octal character code. The numeric code is 3 octal digits.
900For compatibility with other Unix systems, 8 and 9 are accepted as digits:
901for example, @code{\008} has the value 010, and @code{\009} the value 011.
902
903@item \\
904@cindex @code{\\} (@samp{\} character)
905@cindex backslash (@code{\\})
906Represents one @samp{\} character.
907
908@c @item \'
909@c Represents one @samp{'} (accent acute) character.
910@c This is needed in single character literals
911@c (@xref{Characters,,Character Constants}.) to represent
912@c a @samp{'}.
913@c
914@item \"
915@cindex @code{\"} (doublequote character)
916@cindex doublequote (@code{\"})
917Represents one @samp{"} character. Needed in strings to represent
918this character, because an unescaped @samp{"} would end the string.
919
920@item \ @var{anything-else}
921Any other character when escaped by @kbd{\} will give a warning, but
922assemble as if the @samp{\} was not present. The idea is that if
923you used an escape sequence you clearly didn't want the literal
924interpretation of the following character. However @code{as} has no
925other interpretation, so @code{as} knows it is giving you the wrong
926code and warns you of the fact.
927@end table
928
929Which characters are escapable, and what those escapes represent,
930varies widely among assemblers. The current set is what we think
931the BSD 4.2 assembler recognizes, and is a subset of what most C
932compilers recognize. If you are in doubt, don't use an escape
933sequence.
934
41ee6e91 935@node Chars
169fff49
RP
936@subsubsection Characters
937
938@cindex single character constant
939@cindex character, single
940@cindex constant, single character
941A single character may be written as a single quote immediately
942followed by that character. The same escapes apply to characters as
943to strings. So if you want to write the character backslash, you
944must write @kbd{'\\} where the first @code{\} escapes the second
945@code{\}. As you can see, the quote is an acute accent, not a
946grave accent. A newline
947immediately following an acute accent is taken as a literal character
948and does not count as the end of a statement. The value of a character
949constant in a numeric expression is the machine's byte-wide code for
950that character. @code{as} assumes your character code is ASCII:
951@kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
952
41ee6e91 953@node Numbers
169fff49
RP
954@subsection Number Constants
955
956@cindex constants, number
957@cindex number constants
958@code{as} distinguishes three kinds of numbers according to how they
959are stored in the target machine. @emph{Integers} are numbers that
960would fit into an @code{int} in the C language. @emph{Bignums} are
961integers, but they are stored in more than 32 bits. @emph{Flonums}
962are floating point numbers, described below.
963
964@menu
965* Integers:: Integers
966* Bignums:: Bignums
967* Flonums:: Flonums
968@end menu
969
41ee6e91 970@node Integers
169fff49
RP
971@subsubsection Integers
972@cindex integers
973@cindex constants, integer
974
975@cindex binary integers
976@cindex integers, binary
977A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
978the binary digits @samp{01}.
979
980@cindex octal integers
981@cindex integers, octal
982An octal integer is @samp{0} followed by zero or more of the octal
983digits (@samp{01234567}).
984
985@cindex decimal integers
986@cindex integers, decimal
987A decimal integer starts with a non-zero digit followed by zero or
988more digits (@samp{0123456789}).
989
990@cindex hexadecimal integers
991@cindex integers, hexadecimal
992A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
993more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
994
995Integers have the usual values. To denote a negative integer, use
996the prefix operator @samp{-} discussed under expressions
997(@pxref{Prefix Ops,,Prefix Operators}).
998
41ee6e91 999@node Bignums
169fff49
RP
1000@subsubsection Bignums
1001
1002@cindex bignums
1003@cindex constants, bignum
1004A @dfn{bignum} has the same syntax and semantics as an integer
1005except that the number (or its negative) takes more than 32 bits to
1006represent in binary. The distinction is made because in some places
1007integers are permitted while bignums are not.
1008
41ee6e91 1009@node Flonums
169fff49
RP
1010@subsubsection Flonums
1011@cindex flonums
1012@cindex floating point numbers
1013@cindex constants, floating point
1014
1015@cindex precision, floating point
1016A @dfn{flonum} represents a floating point number. The translation is
1017indirect: a decimal floating point number from the text is converted by
1018@code{as} to a generic binary floating point number of more than
1019sufficient precision. This generic floating point number is converted
1020to a particular computer's floating point format (or formats) by a
1021portion of @code{as} specialized to that computer.
1022
1023A flonum is written by writing (in order)
1024@itemize @bullet
1025@item
1026The digit @samp{0}.
1027@item
1028A letter, to tell @code{as} the rest of the number is a flonum.
1029@kbd{e} is recommended. Case is not important.
1030@ignore
1031@c FIXME: verify if flonum syntax really this vague for most cases
1032 (Any otherwise illegal letter
1033will work here, but that might be changed. Vax BSD 4.2 assembler seems
1034to allow any of @samp{defghDEFGH}.)
1035@end ignore
1036On the AMD 29K and H8/300 architectures, the letter must be:
1037One of the letters @samp{DFPRSX} (in upper or lower case).
1038On the Intel 960 architecture, the letter must be:
1039One of the letters @samp{DFT} (in upper or lower case).
1040@item
1041An optional sign: either @samp{+} or @samp{-}.
1042@item
1043An optional @dfn{integer part}: zero or more decimal digits.
1044@item
1045An optional @dfn{fractional part}: @samp{.} followed by zero
1046or more decimal digits.
1047@item
1048An optional exponent, consisting of:
1049@itemize @bullet
1050@item
1051An @samp{E} or @samp{e}.
1052@c I can't find a config where "EXP_CHARS" is other than 'eE', but in
1053@c principle this can perfectly well be different on different targets.
1054@item
1055Optional sign: either @samp{+} or @samp{-}.
1056@item
1057One or more decimal digits.
1058@end itemize
1059@end itemize
1060
1061At least one of the integer part or the fractional part must be
1062present. The floating point number has the usual base-10 value.
1063
1064@code{as} does all processing using integers. Flonums are computed
1065independently of any floating point hardware in the computer running
1066@code{as}.
1067
1068
41ee6e91 1069@node Sections
169fff49
RP
1070@chapter Sections and Relocation
1071@cindex sections
1072@cindex relocation
1073
1074@menu
1075* Secs Background:: Background
1076* ld Sections:: ld Sections
1077* as Sections:: as Internal Sections
1078* Sub-Sections:: Sub-Sections
1079* bss:: bss Section
1080@end menu
1081
41ee6e91 1082@node Secs Background
169fff49
RP
1083@section Background
1084
1085Roughly, a section is a range of addresses, with no gaps; all data
1086``in'' those addresses is treated the same for some particular purpose.
1087For example there may be a ``read only'' section.
1088
1089@cindex linker, and assembler
1090@cindex assembler, and linker
1091The linker @code{ld} reads many object files (partial programs) and
1092combines their contents to form a runnable program. When @code{as}
1093emits an object file, the partial program is assumed to start at address
10940. @code{ld} will assign the final addresses the partial program
1095occupies, so that different partial programs don't overlap. This is
1096actually an over-simplification, but it will suffice to explain how
1097@code{as} uses sections.
1098
1099@code{ld} moves blocks of bytes of your program to their run-time
1100addresses. These blocks slide to their run-time addresses as rigid
1101units; their length does not change and neither does the order of bytes
1102within them. Such a rigid unit is called a @emph{section}. Assigning
1103run-time addresses to sections is called @dfn{relocation}. It includes
1104the task of adjusting mentions of object-file addresses so they refer to
1105the proper run-time addresses.
1106For the H8/300, @code{as} pads sections if needed to ensure they end
1107on a word (sixteen bit) boundary.
1108
1109@cindex standard @code{as} sections
1110An object file written by @code{as} has at least three sections, any
1111of which may be empty. These are named @dfn{text}, @dfn{data} and
1112@dfn{bss} sections.
1113
1114When it generates COFF output,
1115@code{as} can also generate whatever other named sections you specify
1116using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
1117If you don't use any directives that place output in the @samp{.text}
1118or @samp{.data} sections, these sections will still exist, but will be empty.
1119
1120Within the object file, the text section starts at address @code{0}, the
1121data section follows, and the bss section follows the data section.
1122
1123To let @code{ld} know which data will change when the sections are
1124relocated, and how to change that data, @code{as} also writes to the
1125object file details of the relocation needed. To perform relocation
1126@code{ld} must know, each time an address in the object
1127file is mentioned:
1128@itemize @bullet
1129@item
1130Where in the object file is the beginning of this reference to
1131an address?
1132@item
1133How long (in bytes) is this reference?
1134@item
1135Which section does the address refer to? What is the numeric value of
1136@display
1137(@var{address}) @minus{} (@var{start-address of section})?
1138@end display
1139@item
1140Is the reference to an address ``Program-Counter relative''?
1141@end itemize
1142
1143@cindex addresses, format of
1144@cindex section-relative addressing
1145In fact, every address @code{as} ever uses is expressed as
1146@display
1147(@var{section}) + (@var{offset into section})
1148@end display
1149@noindent
1150Further, every expression @code{as} computes is of this section-relative
1151nature. @dfn{Absolute expression} means an expression with section
1152``absolute'' (@pxref{ld Sections}). A @dfn{pass1 expression} means
1153an expression with section ``pass1'' (@pxref{as Sections,,as
1154Internal Sections}). In this manual we use the notation @{@var{secname}
1155@var{N}@} to mean ``offset @var{N} into section @var{secname}''.
1156
1157Apart from text, data and bss sections you need to know about the
1158@dfn{absolute} section. When @code{ld} mixes partial programs,
1159addresses in the absolute section remain unchanged. For example, address
1160@code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{ld}.
1161Although two partial programs' data sections will not overlap addresses
1162after linking, @emph{by definition} their absolute sections will overlap.
1163Address @code{@{absolute@ 239@}} in one partial program will always be the same
1164address when the program is running as address @code{@{absolute@ 239@}} in any
1165other partial program.
1166
1167The idea of sections is extended to the @dfn{undefined} section. Any
1168address whose section is unknown at assembly time is by definition
1169rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
1170Since numbers are always defined, the only way to generate an undefined
1171address is to mention an undefined symbol. A reference to a named
1172common block would be such a symbol: its value is unknown at assembly
1173time so it has section @emph{undefined}.
1174
1175By analogy the word @emph{section} is used to describe groups of sections in
1176the linked program. @code{ld} puts all partial programs' text
1177sections in contiguous addresses in the linked program. It is
1178customary to refer to the @emph{text section} of a program, meaning all
1179the addresses of all partial program's text sections. Likewise for
1180data and bss sections.
1181
1182Some sections are manipulated by @code{ld}; others are invented for
1183use of @code{as} and have no meaning except during assembly.
1184
41ee6e91 1185@node ld Sections
169fff49
RP
1186@section ld Sections
1187@code{ld} deals with just four kinds of sections, summarized below.
1188
1189@table @strong
1190
1191@cindex named sections
1192@cindex sections, named
1193@item named sections
1194@cindex text section
1195@cindex data section
1196@item text section
1197@itemx data section
1198These sections hold your program. @code{as} and @code{ld} treat them as
1199separate but equal sections. Anything you can say of one section is
1200true another.
1201When the program is running, however, it is
1202customary for the text section to be unalterable. The
1203text section is often shared among processes: it will contain
1204instructions, constants and the like. The data section of a running
1205program is usually alterable: for example, C variables would be stored
1206in the data section.
1207
1208@cindex bss section
1209@item bss section
1210This section contains zeroed bytes when your program begins running. It
1211is used to hold unitialized variables or common storage. The length of
1212each partial program's bss section is important, but because it starts
1213out containing zeroed bytes there is no need to store explicit zero
1214bytes in the object file. The bss section was invented to eliminate
1215those explicit zeros from object files.
1216
1217@cindex absolute section
1218@item absolute section
1219Address 0 of this section is always ``relocated'' to runtime address 0.
1220This is useful if you want to refer to an address that @code{ld} must
1221not change when relocating. In this sense we speak of absolute
1222addresses being ``unrelocatable'': they don't change during relocation.
1223
1224@cindex undefined section
1225@item undefined section
1226This ``section'' is a catch-all for address references to objects not in
1227the preceding sections.
1228@c FIXME: ref to some other doc on obj-file formats could go here.
1229@end table
1230
1231@cindex relocation example
1232An idealized example of three relocatable sections follows.
1233The example uses the traditional section names @samp{.text} and @samp{.data}.
1234Memory addresses are on the horizontal axis.
1235
1236@c TEXI2ROFF-KILL
1237@ifinfo
1238@c END TEXI2ROFF-KILL
1239@smallexample
1240 +-----+----+--+
1241partial program # 1: |ttttt|dddd|00|
1242 +-----+----+--+
1243
1244 text data bss
1245 seg. seg. seg.
1246
1247 +---+---+---+
1248partial program # 2: |TTT|DDD|000|
1249 +---+---+---+
1250
1251 +--+---+-----+--+----+---+-----+~~
1252linked program: | |TTT|ttttt| |dddd|DDD|00000|
1253 +--+---+-----+--+----+---+-----+~~
1254
1255 addresses: 0 @dots{}
1256@end smallexample
1257@c TEXI2ROFF-KILL
1258@end ifinfo
1259@c FIXME make sure no page breaks inside figure!!
1260@tex
1261
1262\line{\it Partial program \#1: \hfil}
1263\line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1264\line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
1265
1266\line{\it Partial program \#2: \hfil}
1267\line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
1268\line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
1269
1270\line{\it linked program: \hfil}
1271\line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
1272\line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
1273ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
1274DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
1275
1276\line{\it addresses: \hfil}
1277\line{0\dots\hfil}
1278
1279@end tex
1280@c END TEXI2ROFF-KILL
1281
41ee6e91 1282@node as Sections
169fff49
RP
1283@section as Internal Sections
1284
1285@cindex internal @code{as} sections
1286@cindex sections in messages, internal
1287These sections are meant only for the internal use of @code{as}. They
1288have no meaning at run-time. You don't really need to know about these
1289sections for most purposes; but they can be mentioned in @code{as}
1290warning messages, so it might be helpful to have an idea of their
1291meanings to @code{as}. These sections are used to permit the
1292value of every expression in your assembly language program to be a
1293section-relative address.
1294
1295@table @b
1296@item absent
1297@cindex absent (internal section)
1298An expression was expected and none was found.
1299
1300@item ASSEMBLER-INTERNAL-LOGIC-ERROR!
1301@cindex assembler internal logic error
1302An internal assembler logic error has been found. This means there is a
1303bug in the assembler.
1304
1305@item bignum/flonum
1306@cindex bignum/flonum (internal section)
1307If a number can't be written as a C @code{int} constant (a bignum or a
1308flonum, but not an integer), it is recorded as belonging to this
1309``section''. @code{as} has to remember that a flonum or a bignum
1310does not fit into 32 bits, and cannot be an argument (@pxref{Arguments})
1311in an expression: this is done by making a flonum or bignum be in a
1312separate internal section. This is purely for internal @code{as}
1313convenience; bignum/flonum section behaves similarly to absolute
1314section.
1315
1316@item pass1 section
1317@cindex pass1 (internal section)
1318The expression was impossible to evaluate in the first pass. The
1319assembler will attempt a second pass (second reading of the source) to
1320evaluate the expression. Your expression mentioned an undefined symbol
1321in a way that defies the one-pass (section + offset in section) assembly
1322process. No compiler need emit such an expression.
1323
1324@quotation
1325@emph{Warning:} the second pass is currently not implemented. @code{as}
1326will abort with an error message if one is required.
1327@end quotation
1328
1329@item difference section
1330@cindex difference (internal section)
1331As an assist to the C compiler, expressions of the forms
1332@display
1333 (@var{undefined symbol}) @minus{} (@var{expression})
1334 @var{something} @minus{} (@var{undefined symbol})
1335 (@var{undefined symbol}) @minus{} (@var{undefined symbol})
1336@end display
1337
1338are permitted, and belong to the difference section. @code{as}
1339re-evaluates such expressions after the source file has been read and
1340the symbol table built. If by that time there are no undefined symbols
1341in the expression then the expression assumes a new section. The
1342intention is to permit statements like
1343@samp{.word label - base_of_table}
1344to be assembled in one pass where both @code{label} and
1345@code{base_of_table} are undefined. This is useful for compiling C and
1346Algol switch statements, Pascal case statements, FORTRAN computed goto
1347statements and the like.
1348@c FIXME item debug
1349@c FIXME item transfer[t] vector preload
1350@c FIXME item transfer[t] vector postload
1351@c FIXME item register
1352@end table
1353
41ee6e91 1354@node Sub-Sections
169fff49
RP
1355@section Sub-Sections
1356
1357@cindex numbered subsections
1358@cindex grouping data
1359Assembled bytes
1360conventionally
1361fall into two sections: text and data.
1362You may have separate groups of
1363data in named sections
1364that you want to end up near to each other in the object
1365file, even though they are not contiguous in the assembler source.
1366@code{as} allows you to use @dfn{subsections} for this purpose.
1367Within each section, there can be numbered subsections with
1368values from 0 to 8192. Objects assembled into the same subsection will
1369be grouped with other objects in the same subsection when they are all
1370put into the object file. For example, a compiler might want to store
1371constants in the text section, but might not want to have them
1372interspersed with the program being assembled. In this case, the
1373compiler could issue a @samp{.text 0} before each section of code being
1374output, and a @samp{.text 1} before each group of constants being output.
1375
1376Subsections are optional. If you don't use subsections, everything
1377will be stored in subsection number zero.
1378
1379Each subsection is zero-padded up to a multiple of four bytes.
1380(Subsections may be padded a different amount on different flavors
1381of @code{as}.)
1382
1383Subsections appear in your object file in numeric order, lowest numbered
1384to highest. (All this to be compatible with other people's assemblers.)
1385The object file contains no representation of subsections; @code{ld} and
1386other programs that manipulate object files will see no trace of them.
1387They just see all your text subsections as a text section, and all your
1388data subsections as a data section.
1389
1390To specify which subsection you want subsequent statements assembled
1391into, use a numeric argument to specify it, in a @samp{.text
1392@var{expression}} or a @samp{.data @var{expression}} statement.
1393When generating COFF output, you
1394can also use an extra subsection
1395argument with arbitrary named sections: @samp{.section @var{name},
1396@var{expression}}.
1397@var{Expression} should be an absolute expression.
1398(@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
1399is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
1400begins in @code{text 0}. For instance:
1401@smallexample
1402.text 0 # The default subsection is text 0 anyway.
1403.ascii "This lives in the first text subsection. *"
1404.text 1
1405.ascii "But this lives in the second text subsection."
1406.data 0
1407.ascii "This lives in the data section,"
1408.ascii "in the first data subsection."
1409.text 0
1410.ascii "This lives in the first text section,"
1411.ascii "immediately following the asterisk (*)."
1412@end smallexample
1413
1414Each section has a @dfn{location counter} incremented by one for every
1415byte assembled into that section. Because subsections are merely a
1416convenience restricted to @code{as} there is no concept of a subsection
1417location counter. There is no way to directly manipulate a location
1418counter---but the @code{.align} directive will change it, and any label
1419definition will capture its current value. The location counter of the
1420section that statements are being assembled into is said to be the
1421@dfn{active} location counter.
1422
41ee6e91 1423@node bss
169fff49
RP
1424@section bss Section
1425
1426@cindex bss section
1427@cindex common variable storage
1428The bss section is used for local common variable storage.
1429You may allocate address space in the bss section, but you may
1430not dictate data to load into it before your program executes. When
1431your program starts running, all the contents of the bss
1432section are zeroed bytes.
1433
1434Addresses in the bss section are allocated with special directives; you
1435may not assemble anything directly into the bss section. Hence there
1436are no bss subsections. @xref{Comm,,@code{.comm}},
1437@pxref{Lcomm,,@code{.lcomm}}.
1438
41ee6e91 1439@node Symbols
169fff49
RP
1440@chapter Symbols
1441
1442@cindex symbols
1443Symbols are a central concept: the programmer uses symbols to name
1444things, the linker uses symbols to link, and the debugger uses symbols
1445to debug.
1446
1447@quotation
1448@cindex debuggers, and symbol order
1449@emph{Warning:} @code{as} does not place symbols in the object file in
1450the same order they were declared. This may break some debuggers.
1451@end quotation
1452
1453@menu
1454* Labels:: Labels
1455* Setting Symbols:: Giving Symbols Other Values
1456* Symbol Names:: Symbol Names
1457* Dot:: The Special Dot Symbol
1458* Symbol Attributes:: Symbol Attributes
1459@end menu
1460
41ee6e91 1461@node Labels
169fff49
RP
1462@section Labels
1463
1464@cindex labels
1465A @dfn{label} is written as a symbol immediately followed by a colon
1466@samp{:}. The symbol then represents the current value of the
1467active location counter, and is, for example, a suitable instruction
1468operand. You are warned if you use the same symbol to represent two
1469different locations: the first definition overrides any other
1470definitions.
1471
41ee6e91 1472@node Setting Symbols
169fff49
RP
1473@section Giving Symbols Other Values
1474
1475@cindex assigning values to symbols
1476@cindex symbol values, assigning
1477A symbol can be given an arbitrary value by writing a symbol, followed
1478by an equals sign @samp{=}, followed by an expression
1479(@pxref{Expressions}). This is equivalent to using the @code{.set}
1480directive. @xref{Set,,@code{.set}}.
1481
41ee6e91 1482@node Symbol Names
169fff49
RP
1483@section Symbol Names
1484
1485@cindex symbol names
1486@cindex names, symbol
1487Symbol names begin with a letter or with one of
1488@samp{_.}
1489(On most machines, you can also use @code{$} in symbol names; exceptions
1490are noted in @ref{Machine Dependent}.)
1491That character may be followed by any string of digits, letters,
1492dollar signs (unless otherwise noted in @ref{Machine Dependent}),
1493and underscores.
1494Case of letters is significant:
1495@code{foo} is a different symbol name than @code{Foo}.
1496
1497For the AMD 29K family, @samp{?} is also allowed in the
1498body of a symbol name, though not at its beginning.
1499
1500Each symbol has exactly one name. Each name in an assembly language
1501program refers to exactly one symbol. You may use that symbol name any
1502number of times in a program.
1503
1504@subheading Local Symbol Names
1505
1506@cindex local symbol names
1507@cindex symbol names, local
1508@cindex temporary symbol names
1509@cindex symbol names, temporary
1510Local symbols help compilers and programmers use names temporarily.
1511There are ten local symbol names, which are re-used throughout the
1512program. You may refer to them using the names @samp{0} @samp{1}
1513@dots{} @samp{9}. To define a local symbol, write a label of the form
1514@samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
1515recent previous definition of that symbol write @samp{@b{N}b}, using the
1516same digit as when you defined the label. To refer to the next
1517definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
1518a choice of 10 forward references. The @samp{b} stands for
1519``backwards'' and the @samp{f} stands for ``forwards''.
1520
1521Local symbols are not emitted by the current GNU C compiler.
1522
1523There is no restriction on how you can use these labels, but
1524remember that at any point in the assembly you can refer to at most
152510 prior local labels and to at most 10 forward local labels.
1526
1527Local symbol names are only a notation device. They are immediately
1528transformed into more conventional symbol names before the assembler
1529uses them. The symbol names stored in the symbol table, appearing in
1530error messages and optionally emitted to the object file have these
1531parts:
1532
1533@table @code
1534@item L
1535All local labels begin with @samp{L}. Normally both @code{as} and
1536@code{ld} forget symbols that start with @samp{L}. These labels are
1537used for symbols you are never intended to see. If you give the
1538@samp{-L} option then @code{as} will retain these symbols in the
1539object file. If you also instruct @code{ld} to retain these symbols,
1540you may use them in debugging.
1541
1542@item @var{digit}
1543If the label is written @samp{0:} then the digit is @samp{0}.
1544If the label is written @samp{1:} then the digit is @samp{1}.
1545And so on up through @samp{9:}.
1546
1547@item @ctrl{A}
1548This unusual character is included so you don't accidentally invent
1549a symbol of the same name. The character has ASCII value
1550@samp{\001}.
1551
1552@item @emph{ordinal number}
1553This is a serial number to keep the labels distinct. The first
1554@samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
1555number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
1556through @samp{9:}.
1557@end table
1558
1559For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th
1560@code{3:} is named @code{L3@ctrl{A}44}.
1561
41ee6e91 1562@node Dot
169fff49
RP
1563@section The Special Dot Symbol
1564
1565@cindex dot (symbol)
1566@cindex @code{.} (symbol)
1567@cindex current address
1568@cindex location counter
1569The special symbol @samp{.} refers to the current address that
1570@code{as} is assembling into. Thus, the expression @samp{melvin:
1571.long .} will cause @code{melvin} to contain its own address.
1572Assigning a value to @code{.} is treated the same as a @code{.org}
1573directive. Thus, the expression @samp{.=.+4} is the same as saying
1574@samp{.block 4}.
1575
41ee6e91 1576@node Symbol Attributes
169fff49
RP
1577@section Symbol Attributes
1578
1579@cindex symbol attributes
1580@cindex attributes, symbol
1581Every symbol has, as well as its name, the attributes ``Value'' and
1582``Type''. Depending on output format, symbols can also have auxiliary
1583attributes.
1584
1585If you use a symbol without defining it, @code{as} assumes zero for
1586all these attributes, and probably won't warn you. This makes the
1587symbol an externally defined symbol, which is generally what you
1588would want.
1589
1590@menu
1591* Symbol Value:: Value
1592* Symbol Type:: Type
1593* a.out Symbols:: Symbol Attributes: @code{a.out}
1594* COFF Symbols:: Symbol Attributes for COFF
1595@end menu
1596
41ee6e91 1597@node Symbol Value
169fff49
RP
1598@subsection Value
1599
1600@cindex value of a symbol
1601@cindex symbol value
1602The value of a symbol is (usually) 32 bits. For a symbol which labels a
1603location in the text, data, bss or absolute sections the value is the
1604number of addresses from the start of that section to the label.
1605Naturally for text, data and bss sections the value of a symbol changes
1606as @code{ld} changes section base addresses during linking. Absolute
1607symbols' values do not change during linking: that is why they are
1608called absolute.
1609
1610The value of an undefined symbol is treated in a special way. If it is
16110 then the symbol is not defined in this assembler source program, and
1612@code{ld} will try to determine its value from other programs it is
1613linked with. You make this kind of symbol simply by mentioning a symbol
1614name without defining it. A non-zero value represents a @code{.comm}
1615common declaration. The value is how much common storage to reserve, in
1616bytes (addresses). The symbol refers to the first address of the
1617allocated storage.
1618
41ee6e91 1619@node Symbol Type
169fff49
RP
1620@subsection Type
1621
1622@cindex type of a symbol
1623@cindex symbol type
1624The type attribute of a symbol contains relocation (section)
1625information, any flag settings indicating that a symbol is external, and
1626(optionally), other information for linkers and debuggers. The exact
1627format depends on the object-code output format in use.
1628
41ee6e91 1629@node a.out Symbols
169fff49
RP
1630@subsection Symbol Attributes: @code{a.out}
1631
1632@cindex @code{a.out} symbol attributes
1633@cindex symbol attributes, @code{a.out}
1634
1635@menu
1636* Symbol Desc:: Descriptor
1637* Symbol Other:: Other
1638@end menu
1639
41ee6e91 1640@node Symbol Desc
169fff49
RP
1641@subsubsection Descriptor
1642
1643@cindex descriptor, of @code{a.out} symbol
1644This is an arbitrary 16-bit value. You may establish a symbol's
1645descriptor value by using a @code{.desc} statement
1646(@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
1647@code{as}.
1648
41ee6e91 1649@node Symbol Other
169fff49
RP
1650@subsubsection Other
1651
1652@cindex other attribute, of @code{a.out} symbol
1653This is an arbitrary 8-bit value. It means nothing to @code{as}.
1654
41ee6e91 1655@node COFF Symbols
169fff49
RP
1656@subsection Symbol Attributes for COFF
1657
1658@cindex COFF symbol attributes
1659@cindex symbol attributes, COFF
1660
1661The COFF format supports a multitude of auxiliary symbol attributes;
1662like the primary symbol attributes, they are set between @code{.def} and
1663@code{.endef} directives.
1664
1665@subsubsection Primary Attributes
1666
1667@cindex primary attributes, COFF symbols
1668The symbol name is set with @code{.def}; the value and type,
1669respectively, with @code{.val} and @code{.type}.
1670
1671@subsubsection Auxiliary Attributes
1672
1673@cindex auxiliary attributes, COFF symbols
1674The @code{as} directives @code{.dim}, @code{.line}, @code{.scl},
1675@code{.size}, and @code{.tag} can generate auxiliary symbol table
1676information for COFF.
1677
41ee6e91 1678@node Expressions
169fff49
RP
1679@chapter Expressions
1680
1681@cindex expressions
1682@cindex addresses
1683@cindex numeric values
1684An @dfn{expression} specifies an address or numeric value.
1685Whitespace may precede and/or follow an expression.
1686
1687@menu
1688* Empty Exprs:: Empty Expressions
1689* Integer Exprs:: Integer Expressions
1690@end menu
1691
41ee6e91 1692@node Empty Exprs
169fff49
RP
1693@section Empty Expressions
1694
1695@cindex empty expressions
1696@cindex expressions, empty
1697An empty expression has no value: it is just whitespace or null.
1698Wherever an absolute expression is required, you may omit the
1699expression and @code{as} will assume a value of (absolute) 0. This
1700is compatible with other assemblers.
1701
41ee6e91 1702@node Integer Exprs
169fff49
RP
1703@section Integer Expressions
1704
1705@cindex integer expressions
1706@cindex expressions, integer
1707An @dfn{integer expression} is one or more @emph{arguments} delimited
1708by @emph{operators}.
1709
1710@menu
1711* Arguments:: Arguments
1712* Operators:: Operators
1713* Prefix Ops:: Prefix Operators
1714* Infix Ops:: Infix Operators
1715@end menu
1716
41ee6e91 1717@node Arguments
169fff49
RP
1718@subsection Arguments
1719
1720@cindex expression arguments
1721@cindex arguments in expressions
1722@cindex operands in expressions
1723@cindex arithmetic operands
1724@dfn{Arguments} are symbols, numbers or subexpressions. In other
1725contexts arguments are sometimes called ``arithmetic operands''. In
1726this manual, to avoid confusing them with the ``instruction operands'' of
1727the machine language, we use the term ``argument'' to refer to parts of
1728expressions only, reserving the word ``operand'' to refer only to machine
1729instruction operands.
1730
1731Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
1732@var{section} is one of text, data, bss, absolute,
1733or undefined. @var{NNN} is a signed, 2's complement 32 bit
1734integer.
1735
1736Numbers are usually integers.
1737
1738A number can be a flonum or bignum. In this case, you are warned
1739that only the low order 32 bits are used, and @code{as} pretends
1740these 32 bits are an integer. You may write integer-manipulating
1741instructions that act on exotic constants, compatible with other
1742assemblers.
1743
1744@cindex subexpressions
1745Subexpressions are a left parenthesis @samp{(} followed by an integer
1746expression, followed by a right parenthesis @samp{)}; or a prefix
1747operator followed by an argument.
1748
41ee6e91 1749@node Operators
169fff49
RP
1750@subsection Operators
1751
1752@cindex operators, in expressions
1753@cindex arithmetic functions
1754@cindex functions, in expressions
1755@dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
1756operators are followed by an argument. Infix operators appear
1757between their arguments. Operators may be preceded and/or followed by
1758whitespace.
1759
41ee6e91 1760@node Prefix Ops
169fff49
RP
1761@subsection Prefix Operator
1762
1763@cindex prefix operators
1764@code{as} has the following @dfn{prefix operators}. They each take
1765one argument, which must be absolute.
1766
1767@c the tex/end tex stuff surrounding this small table is meant to make
1768@c it align, on the printed page, with the similar table in the next
1769@c section (which is inside an enumerate).
1770@tex
1771\global\advance\leftskip by \itemindent
1772@end tex
1773
1774@table @code
1775@item -
1776@dfn{Negation}. Two's complement negation.
1777@item ~
1778@dfn{Complementation}. Bitwise not.
1779@end table
1780
1781@tex
1782\global\advance\leftskip by -\itemindent
1783@end tex
1784
41ee6e91 1785@node Infix Ops
169fff49
RP
1786@subsection Infix Operators
1787
1788@cindex infix operators
1789@cindex operators, permitted arguments
1790@dfn{Infix operators} take two arguments, one on either side. Operators
1791have precedence, but operations with equal precedence are performed left
1792to right. Apart from @code{+} or @code{-}, both arguments must be
1793absolute, and the result is absolute.
1794
1795@enumerate
1796@cindex operator precedence
1797@cindex precedence of operators
1798
1799@item
1800Highest Precedence
1801
1802@table @code
1803@item *
1804@dfn{Multiplication}.
1805
1806@item /
1807@dfn{Division}. Truncation is the same as the C operator @samp{/}
1808
1809@item %
1810@dfn{Remainder}.
1811
1812@item <
1813@itemx <<
1814@dfn{Shift Left}. Same as the C operator @samp{<<}
1815
1816@item >
1817@itemx >>
1818@dfn{Shift Right}. Same as the C operator @samp{>>}
1819@end table
1820
1821@item
1822Intermediate precedence
1823
1824@table @code
1825@item |
1826
1827@dfn{Bitwise Inclusive Or}.
1828
1829@item &
1830@dfn{Bitwise And}.
1831
1832@item ^
1833@dfn{Bitwise Exclusive Or}.
1834
1835@item !
1836@dfn{Bitwise Or Not}.
1837@end table
1838
1839@item
1840Lowest Precedence
1841
1842@table @code
1843@item +
1844@cindex addition, permitted arguments
1845@cindex plus, permitted arguments
1846@cindex arguments for addition
1847@dfn{Addition}. If either argument is absolute, the result
1848has the section of the other argument.
1849If either argument is pass1 or undefined, the result is pass1.
1850Otherwise @code{+} is illegal.
1851
1852@item -
1853@cindex subtraction, permitted arguments
1854@cindex minus, permitted arguments
1855@cindex arguments for subtraction
1856@dfn{Subtraction}. If the right argument is absolute, the
1857result has the section of the left argument.
1858If either argument is pass1 the result is pass1.
1859If either argument is undefined the result is difference section.
1860If both arguments are in the same section, the result is absolute---provided
1861that section is one of text, data or bss.
1862Otherwise subtraction is illegal.
1863@end table
1864@end enumerate
1865
1866The sense of the rule for addition is that it's only meaningful to add
1867the @emph{offsets} in an address; you can only have a defined section in
1868one of the two arguments.
1869
1870Similarly, you can't subtract quantities from two different sections.
1871
41ee6e91 1872@node Pseudo Ops
169fff49
RP
1873@chapter Assembler Directives
1874
1875@cindex directives, machine independent
1876@cindex pseudo-ops, machine independent
1877@cindex machine independent directives
1878All assembler directives have names that begin with a period (@samp{.}).
1879The rest of the name is letters, usually in lower case.
1880
1881This chapter discusses directives present regardless of the target
1882machine configuration for the GNU assembler.
1883
1884@menu
1885* Abort:: @code{.abort}
1886* coff-ABORT:: @code{.ABORT}
1887* Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
1888* App-File:: @code{.app-file @var{string}}
1889* Ascii:: @code{.ascii "@var{string}"}@dots{}
1890* Asciz:: @code{.asciz "@var{string}"}@dots{}
1891* Byte:: @code{.byte @var{expressions}}
1892* Comm:: @code{.comm @var{symbol} , @var{length} }
1893* Data:: @code{.data @var{subsection}}
1894* Def:: @code{.def @var{name}}
1895* Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
1896* Dim:: @code{.dim}
1897* Double:: @code{.double @var{flonums}}
1898* Eject:: @code{.eject}
1899* Else:: @code{.else}
1900* Endef:: @code{.endef}
1901* Endif:: @code{.endif}
1902* Equ:: @code{.equ @var{symbol}, @var{expression}}
1903* Extern:: @code{.extern}
1904* File:: @code{.file @var{string}}
1905* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
1906* Float:: @code{.float @var{flonums}}
1907* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
1908* hword:: @code{.hword @var{expressions}}
1909* Ident:: @code{.ident}
1910* If:: @code{.if @var{absolute expression}}
1911* Include:: @code{.include "@var{file}"}
1912* Int:: @code{.int @var{expressions}}
1913* Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
1914* Lflags:: @code{.lflags}
1915* Line:: @code{.line @var{line-number}}
1916* Ln:: @code{.ln @var{line-number}}
1917* List:: @code{.list}
1918* Long:: @code{.long @var{expressions}}
169fff49
RP
1919* Nolist:: @code{.nolist}
1920* Octa:: @code{.octa @var{bignums}}
1921* Org:: @code{.org @var{new-lc} , @var{fill}}
1922* Psize:: @code{.psize @var{lines}, @var{columns}}
1923* Quad:: @code{.quad @var{bignums}}
1924* Sbttl:: @code{.sbttl "@var{subheading}"}
1925* Scl:: @code{.scl @var{class}}
1926* Section:: @code{.section @var{name}, @var{subsection}}
1927* Set:: @code{.set @var{symbol}, @var{expression}}
1928* Short:: @code{.short @var{expressions}}
1929* Single:: @code{.single @var{flonums}}
1930* Size:: @code{.size}
1931* Space:: @code{.space @var{size} , @var{fill}}
1932* Stab:: @code{.stabd, .stabn, .stabs}
1933* Tag:: @code{.tag @var{structname}}
1934* Text:: @code{.text @var{subsection}}
1935* Title:: @code{.title "@var{heading}"}
1936* Type:: @code{.type @var{int}}
1937* Val:: @code{.val @var{addr}}
1938* Word:: @code{.word @var{expressions}}
1939* Deprecated:: Deprecated Directives
1940@end menu
1941
41ee6e91 1942@node Abort
169fff49
RP
1943@section @code{.abort}
1944
1945@cindex @code{abort} directive
1946@cindex stopping the assembly
1947This directive stops the assembly immediately. It is for
1948compatibility with other assemblers. The original idea was that the
1949assembly language source would be piped into the assembler. If the sender
1950of the source quit, it could use this directive tells @code{as} to
1951quit also. One day @code{.abort} will not be supported.
1952
41ee6e91 1953@node coff-ABORT
169fff49
RP
1954@section @code{.ABORT}
1955
1956@cindex @code{ABORT} directive
1957When producing COFF output, @code{as} accepts this directive as a
1958synonym for @samp{.abort}.
1959
1960
1961When producing @code{b.out} output, @code{as} accepts this directive,
1962but ignores it.
1963
41ee6e91 1964@node Align
169fff49
RP
1965@section @code{.align @var{abs-expr} , @var{abs-expr}}
1966
1967@cindex padding the location counter
1968@cindex @code{align} directive
1969Pad the location counter (in the current subsection) to a particular
1970storage boundary. The first expression (which must be absolute) is the
1971number of low-order zero bits the location counter will have after
1972advancement. For example @samp{.align 3} will advance the location
1973counter until it a multiple of 8. If the location counter is already a
1974multiple of 8, no change is needed.
1975
1976The second expression (also absolute) gives the value to be stored in
1977the padding bytes. It (and the comma) may be omitted. If it is
1978omitted, the padding bytes are zero.
1979
41ee6e91 1980@node App-File
169fff49
RP
1981@section @code{.app-file @var{string}}
1982
1983@cindex logical file name
1984@cindex file name, logical
1985@cindex @code{app-file} directive
1986@code{.app-file}
1987tells @code{as} that we are about to start a new
1988logical file. @var{string} is the new file name. In general, the
1989filename is recognized whether or not it is surrounded by quotes @samp{"};
1990but if you wish to specify an empty file name is permitted,
1991you must give the quotes--@code{""}. This statement may go away in
1992future: it is only recognized to be compatible with old @code{as}
1993programs.@refill
1994
41ee6e91 1995@node Ascii
169fff49
RP
1996@section @code{.ascii "@var{string}"}@dots{}
1997
1998@cindex @code{ascii} directive
1999@cindex string literals
2000@code{.ascii} expects zero or more string literals (@pxref{Strings})
2001separated by commas. It assembles each string (with no automatic
2002trailing zero byte) into consecutive addresses.
2003
41ee6e91 2004@node Asciz
169fff49
RP
2005@section @code{.asciz "@var{string}"}@dots{}
2006
2007@cindex @code{asciz} directive
2008@cindex zero-terminated strings
2009@cindex null-terminated strings
2010@code{.asciz} is just like @code{.ascii}, but each string is followed by
2011a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
2012
41ee6e91 2013@node Byte
169fff49
RP
2014@section @code{.byte @var{expressions}}
2015
2016@cindex @code{byte} directive
2017@cindex integers, one byte
2018@code{.byte} expects zero or more expressions, separated by commas.
2019Each expression is assembled into the next byte.
2020
41ee6e91 2021@node Comm
169fff49
RP
2022@section @code{.comm @var{symbol} , @var{length} }
2023
2024@cindex @code{comm} directive
2025@cindex symbol, common
2026@code{.comm} declares a named common area in the bss section. Normally
2027@code{ld} reserves memory addresses for it during linking, so no partial
2028program defines the location of the symbol. Use @code{.comm} to tell
2029@code{ld} that it must be at least @var{length} bytes long. @code{ld}
2030will allocate space for each @code{.comm} symbol that is at least as
2031long as the longest @code{.comm} request in any of the partial programs
2032linked. @var{length} is an absolute expression.
2033
41ee6e91 2034@node Data
169fff49
RP
2035@section @code{.data @var{subsection}}
2036
2037@cindex @code{data} directive
2038@code{.data} tells @code{as} to assemble the following statements onto the
2039end of the data subsection numbered @var{subsection} (which is an
2040absolute expression). If @var{subsection} is omitted, it defaults
2041to zero.
2042
41ee6e91 2043@node Def
169fff49
RP
2044@section @code{.def @var{name}}
2045
2046@cindex @code{def} directive
2047@cindex COFF symbols, debugging
2048@cindex debugging COFF symbols
2049Begin defining debugging information for a symbol @var{name}; the
2050definition extends until the @code{.endef} directive is encountered.
2051
2052This directive is only observed when @code{as} is configured for COFF
2053format output; when producing @code{b.out}, @samp{.def} is recognized,
2054but ignored.
2055
41ee6e91 2056@node Desc
169fff49
RP
2057@section @code{.desc @var{symbol}, @var{abs-expression}}
2058
2059@cindex @code{desc} directive
2060@cindex COFF symbol descriptor
2061@cindex symbol descriptor, COFF
2062This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
2063to the low 16 bits of an absolute expression.
2064
2065The @samp{.desc} directive is not available when @code{as} is
2066configured for COFF output; it is only for @code{a.out} or @code{b.out}
2067object format. For the sake of compatibility, @code{as} will accept
2068it, but produce no output, when configured for COFF.
2069
41ee6e91 2070@node Dim
169fff49
RP
2071@section @code{.dim}
2072
2073@cindex @code{dim} directive
2074@cindex COFF auxiliary symbol information
2075@cindex auxiliary symbol information, COFF
2076This directive is generated by compilers to include auxiliary debugging
2077information in the symbol table. It is only permitted inside
2078@code{.def}/@code{.endef} pairs.
2079
2080@samp{.dim} is only meaningful when generating COFF format output; when
2081@code{as} is generating @code{b.out}, it accepts this directive but
2082ignores it.
2083
41ee6e91 2084@node Double
169fff49
RP
2085@section @code{.double @var{flonums}}
2086
2087@cindex @code{double} directive
2088@cindex floating point numbers (double)
2089@code{.double} expects zero or more flonums, separated by commas. It
2090assembles floating point numbers.
2091The exact kind of floating point numbers emitted depends on how
2092@code{as} is configured. @xref{Machine Dependent}.
2093
41ee6e91 2094@node Eject
169fff49
RP
2095@section @code{.eject}
2096
2097@cindex @code{eject} directive
2098@cindex new page, in listings
2099@cindex page, in listings
2100@cindex listing control: new page
2101Force a page break at this point, when generating assembly listings.
2102
41ee6e91 2103@node Else
169fff49
RP
2104@section @code{.else}
2105
2106@cindex @code{else} directive
2107@code{.else} is part of the @code{as} support for conditional
2108assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
2109of code to be assembled if the condition for the preceding @code{.if}
2110was false.
2111
2112
41ee6e91 2113@node Endef
169fff49
RP
2114@section @code{.endef}
2115
2116@cindex @code{endef} directive
2117This directive flags the end of a symbol definition begun with
2118@code{.def}.
2119
2120@samp{.endef} is only meaningful when generating COFF format output; if
2121@code{as} is configured to generate @code{b.out}, it accepts this
2122directive but ignores it.
2123
41ee6e91 2124@node Endif
169fff49
RP
2125@section @code{.endif}
2126
2127@cindex @code{endif} directive
2128@code{.endif} is part of the @code{as} support for conditional assembly;
2129it marks the end of a block of code that is only assembled
2130conditionally. @xref{If,,@code{.if}}.
2131
41ee6e91 2132@node Equ
169fff49
RP
2133@section @code{.equ @var{symbol}, @var{expression}}
2134
2135@cindex @code{equ} directive
2136@cindex assigning values to symbols
2137@cindex symbols, assigning values to
2138This directive sets the value of @var{symbol} to @var{expression}.
2139It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
2140
41ee6e91 2141@node Extern
169fff49
RP
2142@section @code{.extern}
2143
2144@cindex @code{extern} directive
2145@code{.extern} is accepted in the source program---for compatibility
2146with other assemblers---but it is ignored. @code{as} treats
2147all undefined symbols as external.
2148
41ee6e91 2149@node File
169fff49
RP
2150@section @code{.file @var{string}}
2151
2152@cindex @code{file} directive
2153@cindex logical file name
2154@cindex file name, logical
2155@code{.file} (which may also be spelled @samp{.app-file}) tells
2156@code{as} that we are about to start a new logical file.
2157@var{string} is the new file name. In general, the filename is
2158recognized whether or not it is surrounded by quotes @samp{"}; but if
2159you wish to specify an empty file name, you must give the
2160quotes--@code{""}. This statement may go away in future: it is only
2161recognized to be compatible with old @code{as} programs.
2162In some configurations of @code{as}, @code{.file} has already been
2163removed to avoid conflicts with other assemblers. @xref{Machine Dependent}.
2164
41ee6e91 2165@node Fill
169fff49
RP
2166@section @code{.fill @var{repeat} , @var{size} , @var{value}}
2167
2168@cindex @code{fill} directive
2169@cindex writing patterns in memory
2170@cindex patterns, writing in memory
2171@var{result}, @var{size} and @var{value} are absolute expressions.
2172This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
2173may be zero or more. @var{Size} may be zero or more, but if it is
2174more than 8, then it is deemed to have the value 8, compatible with
2175other people's assemblers. The contents of each @var{repeat} bytes
2176is taken from an 8-byte number. The highest order 4 bytes are
2177zero. The lowest order 4 bytes are @var{value} rendered in the
2178byte-order of an integer on the computer @code{as} is assembling for.
2179Each @var{size} bytes in a repetition is taken from the lowest order
2180@var{size} bytes of this number. Again, this bizarre behavior is
2181compatible with other people's assemblers.
2182
2183@var{size} and @var{value} are optional.
2184If the second comma and @var{value} are absent, @var{value} is
2185assumed zero. If the first comma and following tokens are absent,
2186@var{size} is assumed to be 1.
2187
41ee6e91 2188@node Float
169fff49
RP
2189@section @code{.float @var{flonums}}
2190
2191@cindex floating point numbers (single)
2192@cindex @code{float} directive
2193This directive assembles zero or more flonums, separated by commas. It
2194has the same effect as @code{.single}.
2195The exact kind of floating point numbers emitted depends on how
2196@code{as} is configured.
2197@xref{Machine Dependent}.
2198
41ee6e91 2199@node Global
169fff49
RP
2200@section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
2201
2202@cindex @code{global} directive
2203@cindex symbol, making visible to linker
2204@code{.global} makes the symbol visible to @code{ld}. If you define
2205@var{symbol} in your partial program, its value is made available to
2206other partial programs that are linked with it. Otherwise,
2207@var{symbol} will take its attributes from a symbol of the same name
2208from another partial program it is linked with.
2209
2210Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
2211compatibility with other assemblers.
2212
41ee6e91 2213@node hword
169fff49
RP
2214@section @code{.hword @var{expressions}}
2215
2216@cindex @code{hword} directive
2217@cindex integers, 16-bit
2218@cindex numbers, 16-bit
2219@cindex sixteen bit integers
2220This expects zero or more @var{expressions}, and emits
2221a 16 bit number for each.
2222
2223This directive is a synonym for @samp{.short}; depending on the target
2224architecture, it may also be a synonym for @samp{.word}.
2225
41ee6e91 2226@node Ident
169fff49
RP
2227@section @code{.ident}
2228
2229@cindex @code{ident} directive
2230This directive is used by some assemblers to place tags in object files.
2231@code{as} simply accepts the directive for source-file
2232compatibility with such assemblers, but does not actually emit anything
2233for it.
2234
41ee6e91 2235@node If
169fff49
RP
2236@section @code{.if @var{absolute expression}}
2237
2238@cindex conditional assembly
2239@cindex @code{if} directive
2240@code{.if} marks the beginning of a section of code which is only
2241considered part of the source program being assembled if the argument
2242(which must be an @var{absolute expression}) is non-zero. The end of
2243the conditional section of code must be marked by @code{.endif}
2244(@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
2245alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
2246
2247The following variants of @code{.if} are also supported:
2248@table @code
2249@item .ifdef @var{symbol}
2250@cindex @code{ifdef} directive
2251Assembles the following section of code if the specified @var{symbol}
2252has been defined.
2253
2254
2255@item .ifndef @var{symbol}
2256@itemx ifnotdef @var{symbol}
2257@cindex @code{ifndef} directive
2258@cindex @code{ifnotdef} directive
2259Assembles the following section of code if the specified @var{symbol}
2260has not been defined. Both spelling variants are equivalent.
2261
2262@end table
2263
41ee6e91 2264@node Include
169fff49
RP
2265@section @code{.include "@var{file}"}
2266
2267@cindex @code{include} directive
2268@cindex supporting files, including
2269@cindex files, including
2270This directive provides a way to include supporting files at specified
2271points in your source program. The code from @var{file} is assembled as
2272if it followed the point of the @code{.include}; when the end of the
2273included file is reached, assembly of the original file continues. You
2274can control the search paths used with the @samp{-I} command-line option
2275(@pxref{Invoking,,Command-Line Options}). Quotation marks are required
2276around @var{file}.
2277
41ee6e91 2278@node Int
169fff49
RP
2279@section @code{.int @var{expressions}}
2280
2281@cindex @code{int} directive
2282@cindex integers, 32-bit
2283Expect zero or more @var{expressions}, of any section, separated by
2284commas. For each expression, emit a
228532-bit
2286number that will, at run
2287time, be the value of that expression. The byte order of the
2288expression depends on what kind of computer will run the program.
2289
41ee6e91 2290@node Lcomm
169fff49
RP
2291@section @code{.lcomm @var{symbol} , @var{length}}
2292
2293@cindex @code{lcomm} directive
2294@cindex local common symbols
2295@cindex symbols, local common
2296Reserve @var{length} (an absolute expression) bytes for a local common
2297denoted by @var{symbol}. The section and value of @var{symbol} are
2298those of the new local common. The addresses are allocated in the bss
2299section, so at run-time the bytes will start off zeroed. @var{Symbol}
2300is not declared global (@pxref{Global,,@code{.global}}), so is normally
2301not visible to @code{ld}.
2302
41ee6e91 2303@node Lflags
169fff49
RP
2304@section @code{.lflags}
2305
2306@cindex @code{lflags} directive (ignored)
2307@code{as} accepts this directive, for compatibility with other
2308assemblers, but ignores it.
2309
41ee6e91 2310@node Line
169fff49
RP
2311@section @code{.line @var{line-number}}
2312
2313@cindex @code{line} directive
2314@cindex logical line number
2315Tell @code{as} to change the logical line number. @var{line-number} must be
2316an absolute expression. The next line will have that logical line
2317number. So any other statements on the current line (after a statement
2318separator
2319character)
2320will be reported as on logical line number
2321@var{line-number} @minus{} 1.
2322One day this directive will be unsupported: it is used only
2323for compatibility with existing assembler programs. @refill
2324
2325@emph{Warning:} In the AMD29K configuration of as, this command is
2326only available with the name @code{.ln}, rather than as either
2327@code{.line} or @code{.ln}.
2328
41ee6e91 2329@node Ln
169fff49
RP
2330@section @code{.ln @var{line-number}}
2331
2332@cindex @code{ln} directive
2333@samp{.ln} is a synonym for @samp{.line}.
2334
41ee6e91 2335@node List
169fff49
RP
2336@section @code{.list}
2337
2338@cindex @code{list} directive
2339@cindex listing control, turning on
2340Control (in conjunction with the @code{.nolist} directive) whether or
2341not assembly listings are generated. These two directives maintain an
2342internal counter (which is zero initially). @code{.list} increments the
2343counter, and @code{.nolist} decrements it. Assembly listings are
2344generated whenever the counter is greater than zero.
2345
2346By default, listings are disabled. When you enable them (with the
2347@samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
2348the initial value of the listing counter is one.
2349
41ee6e91 2350@node Long
169fff49
RP
2351@section @code{.long @var{expressions}}
2352
2353@cindex @code{long} directive
2354@code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
2355
41ee6e91
RP
2356@ignore
2357@c no one seems to know what this is for or whether this description is
2358@c what it really ought to do
2359@node Lsym
169fff49
RP
2360@section @code{.lsym @var{symbol}, @var{expression}}
2361
2362@cindex @code{lsym} directive
2363@cindex symbol, not referenced in assembly
2364@code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
2365the hash table, ensuring it cannot be referenced by name during the
2366rest of the assembly. This sets the attributes of the symbol to be
2367the same as the expression value:
2368@smallexample
2369@var{other} = @var{descriptor} = 0
2370@var{type} = @r{(section of @var{expression})}
2371@var{value} = @var{expression}
2372@end smallexample
2373@noindent
2374The new symbol is not flagged as external.
41ee6e91 2375@end ignore
169fff49 2376
41ee6e91 2377@node Nolist
169fff49
RP
2378@section @code{.nolist}
2379
2380@cindex @code{nolist} directive
2381@cindex listing control, turning off
2382Control (in conjunction with the @code{.list} directive) whether or
2383not assembly listings are generated. These two directives maintain an
2384internal counter (which is zero initially). @code{.list} increments the
2385counter, and @code{.nolist} decrements it. Assembly listings are
2386generated whenever the counter is greater than zero.
2387
41ee6e91 2388@node Octa
169fff49
RP
2389@section @code{.octa @var{bignums}}
2390
2391@c FIXME: double size emitted for "octa" on i960, others? Or warn?
2392@cindex @code{octa} directive
2393@cindex integer, 16-byte
2394@cindex sixteen byte integer
2395This directive expects zero or more bignums, separated by commas. For each
2396bignum, it emits a 16-byte integer.
2397
2398The term ``octa'' comes from contexts in which a ``word'' is two bytes;
2399hence @emph{octa}-word for 16 bytes.
2400
41ee6e91 2401@node Org
169fff49
RP
2402@section @code{.org @var{new-lc} , @var{fill}}
2403
2404@cindex @code{org} directive
2405@cindex location counter, advancing
2406@cindex advancing location counter
2407@cindex current address, advancing
2408@code{.org} will advance the location counter of the current section to
2409@var{new-lc}. @var{new-lc} is either an absolute expression or an
2410expression with the same section as the current subsection. That is,
2411you can't use @code{.org} to cross sections: if @var{new-lc} has the
2412wrong section, the @code{.org} directive is ignored. To be compatible
2413with former assemblers, if the section of @var{new-lc} is absolute,
2414@code{as} will issue a warning, then pretend the section of @var{new-lc}
2415is the same as the current subsection.
2416
2417@code{.org} may only increase the location counter, or leave it
2418unchanged; you cannot use @code{.org} to move the location counter
2419backwards.
2420
2421@c double negative used below "not undefined" because this is a specific
2422@c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
2423@c section. pesch@cygnus.com 18feb91
2424Because @code{as} tries to assemble programs in one pass @var{new-lc}
2425may not be undefined. If you really detest this restriction we eagerly await
2426a chance to share your improved assembler.
2427
2428Beware that the origin is relative to the start of the section, not
2429to the start of the subsection. This is compatible with other
2430people's assemblers.
2431
2432When the location counter (of the current subsection) is advanced, the
2433intervening bytes are filled with @var{fill} which should be an
2434absolute expression. If the comma and @var{fill} are omitted,
2435@var{fill} defaults to zero.
2436
41ee6e91 2437@node Psize
169fff49
RP
2438@section @code{.psize @var{lines} , @var{columns}}
2439
2440@cindex @code{psize} directive
2441@cindex listing control: paper size
2442@cindex paper size, for listings
2443Use this directive to declare the number of lines---and, optionally, the
2444number of columns---to use for each page, when generating listings.
2445
2446If you don't use @code{.psize}, listings will use a default line-count
2447of 60. You may omit the comma and @var{columns} specification; the
2448default width is 200 columns.
2449
2450@code{as} will generate formfeeds whenever the specified number of
2451lines is exceeded (or whenever you explicitly request one, using
2452@code{.eject}).
2453
2454If you specify @var{lines} as @code{0}, no formfeeds are generated save
2455those explicitly specified with @code{.eject}.
2456
41ee6e91 2457@node Quad
169fff49
RP
2458@section @code{.quad @var{bignums}}
2459
2460@cindex @code{quad} directive
2461@code{.quad} expects zero or more bignums, separated by commas. For
2462each bignum, it emits
2463an 8-byte integer. If the bignum won't fit in 8
2464bytes, it prints a warning message; and just takes the lowest order 8
2465bytes of the bignum.@refill
2466@cindex eight-byte integer
2467@cindex integer, 8-byte
2468
2469The term ``quad'' comes from contexts in which a ``word'' is two bytes;
2470hence @emph{quad}-word for 8 bytes.
2471
41ee6e91 2472@node Sbttl
169fff49
RP
2473@section @code{.sbttl "@var{subheading}"}
2474
2475@cindex @code{sbttl} directive
2476@cindex subtitles for listings
2477@cindex listing control: subtitle
2478Use @var{subheading} as the title (third line, immediately after the
2479title line) when generating assembly listings.
2480
2481This directive affects subsequent pages, as well as the current page if
2482it appears within ten lines of the top of a page.
2483
41ee6e91 2484@node Scl
169fff49
RP
2485@section @code{.scl @var{class}}
2486
2487@cindex @code{scl} directive
2488@cindex symbol storage class (COFF)
2489@cindex COFF symbol storage class
2490Set the storage-class value for a symbol. This directive may only be
2491used inside a @code{.def}/@code{.endef} pair. Storage class may flag
2492whether a symbol is static or external, or it may record further
2493symbolic debugging information.
2494
2495The @samp{.scl} directive is primarily associated with COFF output; when
2496configured to generate @code{b.out} output format, @code{as} will
2497accept this directive but ignore it.
2498
41ee6e91 2499@node Section
169fff49
RP
2500@section @code{.section @var{name}, @var{subsection}}
2501
2502@cindex @code{section} directive
2503@cindex named section (COFF)
2504@cindex COFF named section
2505Assemble the following code into end of subsection numbered
2506@var{subsection} in the COFF named section @var{name}. If you omit
2507@var{subsection}, @code{as} uses subsection number zero.
2508@samp{.section .text} is equivalent to the @code{.text} directive;
2509@samp{.section .data} is equivalent to the @code{.data} directive.
2510
41ee6e91 2511@node Set
169fff49
RP
2512@section @code{.set @var{symbol}, @var{expression}}
2513
2514@cindex @code{set} directive
2515@cindex symbol value, setting
2516This directive sets the value of @var{symbol} to @var{expression}. This
2517will change @var{symbol}'s value and type to conform to
2518@var{expression}. If @var{symbol} was flagged as external, it remains
2519flagged. (@xref{Symbol Attributes}.)
2520
2521You may @code{.set} a symbol many times in the same assembly.
2522If the expression's section is unknowable during pass 1, a second
2523pass over the source program will be forced. The second pass is
2524currently not implemented. @code{as} will abort with an error
2525message if one is required.
2526
2527If you @code{.set} a global symbol, the value stored in the object
2528file is the last value stored into it.
2529
41ee6e91 2530@node Short
169fff49
RP
2531@section @code{.short @var{expressions}}
2532
2533@cindex @code{short} directive
2534@code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
41ee6e91
RP
2535
2536@node Single
169fff49
RP
2537@section @code{.single @var{flonums}}
2538
2539@cindex @code{single} directive
2540@cindex floating point numbers (single)
2541This directive assembles zero or more flonums, separated by commas. It
2542has the same effect as @code{.float}.
2543The exact kind of floating point numbers emitted depends on how
2544@code{as} is configured. @xref{Machine Dependent}.
2545
41ee6e91 2546@node Size
169fff49
RP
2547@section @code{.size}
2548
2549@cindex @code{size} directive
2550This directive is generated by compilers to include auxiliary debugging
2551information in the symbol table. It is only permitted inside
2552@code{.def}/@code{.endef} pairs.
2553
2554@samp{.size} is only meaningful when generating COFF format output; when
2555@code{as} is generating @code{b.out}, it accepts this directive but
2556ignores it.
2557
41ee6e91 2558@node Space
169fff49
RP
2559@section @code{.space @var{size} , @var{fill}}
2560
2561@cindex @code{space} directive
2562@cindex filling memory
2563This directive emits @var{size} bytes, each of value @var{fill}. Both
2564@var{size} and @var{fill} are absolute expressions. If the comma
2565and @var{fill} are omitted, @var{fill} is assumed to be zero.
2566
2567On the AMD 29K, this directive is ignored; it is accepted for
2568compatibility with other AMD 29K assemblers.
2569
2570@quotation
2571@emph{Warning:} In other versions of the GNU assembler, the directive
2572@code{.space} has the effect of @code{.block} @xref{Machine Dependent}.
2573@end quotation
2574
41ee6e91 2575@node Stab
169fff49
RP
2576@section @code{.stabd, .stabn, .stabs}
2577
2578@cindex symbolic debuggers, information for
2579@cindex @code{stab@var{x}} directives
2580There are three directives that begin @samp{.stab}.
2581All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
2582The symbols are not entered in the @code{as} hash table: they
2583cannot be referenced elsewhere in the source file.
2584Up to five fields are required:
2585@table @var
2586@item string
2587This is the symbol's name. It may contain any character except @samp{\000},
2588so is more general than ordinary symbol names. Some debuggers used to
2589code arbitrarily complex structures into symbol names using this field.
2590@item type
2591An absolute expression. The symbol's type is set to the low 8
2592bits of this expression.
2593Any bit pattern is permitted, but @code{ld} and debuggers will choke on
2594silly bit patterns.
2595@item other
2596An absolute expression.
2597The symbol's ``other'' attribute is set to the low 8 bits of this expression.
2598@item desc
2599An absolute expression.
2600The symbol's descriptor is set to the low 16 bits of this expression.
2601@item value
2602An absolute expression which becomes the symbol's value.
2603@end table
2604
2605If a warning is detected while reading a @code{.stabd}, @code{.stabn},
2606or @code{.stabs} statement, the symbol has probably already been created
2607and you will get a half-formed symbol in your object file. This is
2608compatible with earlier assemblers!
2609
2610@table @code
2611@cindex @code{stabd} directive
2612@item .stabd @var{type} , @var{other} , @var{desc}
2613
2614The ``name'' of the symbol generated is not even an empty string.
2615It is a null pointer, for compatibility. Older assemblers used a
2616null pointer so they didn't waste space in object files with empty
2617strings.
2618
2619The symbol's value is set to the location counter,
2620relocatably. When your program is linked, the value of this symbol
2621will be where the location counter was when the @code{.stabd} was
2622assembled.
2623
2624@item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
2625@cindex @code{stabn} directive
2626The name of the symbol is set to the empty string @code{""}.
2627
2628@item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
2629@cindex @code{stabs} directive
2630All five fields are specified.
2631@end table
2632
41ee6e91 2633@node Tag
169fff49
RP
2634@section @code{.tag @var{structname}}
2635
2636@cindex COFF structure debugging
2637@cindex structure debugging, COFF
2638@cindex @code{tag} directive
2639This directive is generated by compilers to include auxiliary debugging
2640information in the symbol table. It is only permitted inside
2641@code{.def}/@code{.endef} pairs. Tags are used to link structure
2642definitions in the symbol table with instances of those structures.
2643
2644@samp{.tag} is only used when generating COFF format output; when
2645@code{as} is generating @code{b.out}, it accepts this directive but
2646ignores it.
2647
41ee6e91 2648@node Text
169fff49
RP
2649@section @code{.text @var{subsection}}
2650
2651@cindex @code{text} directive
2652Tells @code{as} to assemble the following statements onto the end of
2653the text subsection numbered @var{subsection}, which is an absolute
2654expression. If @var{subsection} is omitted, subsection number zero
2655is used.
2656
41ee6e91 2657@node Title
169fff49
RP
2658@section @code{.title "@var{heading}"}
2659
2660@cindex @code{title} directive
2661@cindex listing control: title line
2662Use @var{heading} as the title (second line, immediately after the
2663source file name and pagenumber) when generating assembly listings.
2664
2665This directive affects subsequent pages, as well as the current page if
2666it appears within ten lines of the top of a page.
2667
41ee6e91 2668@node Type
169fff49
RP
2669@section @code{.type @var{int}}
2670
2671@cindex COFF symbol type
2672@cindex symbol type, COFF
2673@cindex @code{type} directive
2674This directive, permitted only within @code{.def}/@code{.endef} pairs,
2675records the integer @var{int} as the type attribute of a symbol table entry.
2676
2677@samp{.type} is associated only with COFF format output; when
2678@code{as} is configured for @code{b.out} output, it accepts this
2679directive but ignores it.
2680
41ee6e91 2681@node Val
169fff49
RP
2682@section @code{.val @var{addr}}
2683
2684@cindex @code{val} directive
2685@cindex COFF value attribute
2686@cindex value attribute, COFF
2687This directive, permitted only within @code{.def}/@code{.endef} pairs,
2688records the address @var{addr} as the value attribute of a symbol table
2689entry.
2690
2691@samp{.val} is used only for COFF output; when @code{as} is
2692configured for @code{b.out}, it accepts this directive but ignores it.
2693
41ee6e91 2694@node Word
169fff49
RP
2695@section @code{.word @var{expressions}}
2696
2697@cindex @code{word} directive
2698This directive expects zero or more @var{expressions}, of any section,
2699separated by commas.
2700
2701The size of the number emitted, and its byte order,
2702depends on what kind of computer will run the program.
2703
2704@c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
2705@c happen---32-bit addressability, period; no long/short jumps.
2706@cindex difference tables altered
2707@cindex altered difference tables
2708@quotation
2709@emph{Warning: Special Treatment to support Compilers}
2710@end quotation
2711
2712Machines with a 32-bit address space, but that do less than 32-bit
2713addressing, require the following special treatment. If the machine of
2714interest to you does 32-bit addressing (or doesn't require it;
2715@pxref{Machine Dependent}), you can ignore this issue.
2716
2717In order to assemble compiler output into something that will work,
2718@code{as} will occasionlly do strange things to @samp{.word} directives.
2719Directives of the form @samp{.word sym1-sym2} are often emitted by
2720compilers as part of jump tables. Therefore, when @code{as} assembles a
2721directive of the form @samp{.word sym1-sym2}, and the difference between
2722@code{sym1} and @code{sym2} does not fit in 16 bits, @code{as} will
2723create a @dfn{secondary jump table}, immediately before the next label.
2724This secondary jump table will be preceded by a short-jump to the
2725first byte after the secondary table. This short-jump prevents the flow
2726of control from accidentally falling into the new table. Inside the
2727table will be a long-jump to @code{sym2}. The original @samp{.word}
2728will contain @code{sym1} minus the address of the long-jump to
2729@code{sym2}.
2730
2731If there were several occurrences of @samp{.word sym1-sym2} before the
2732secondary jump table, all of them will be adjusted. If there was a
2733@samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
2734long-jump to @code{sym4} will be included in the secondary jump table,
2735and the @code{.word} directives will be adjusted to contain @code{sym3}
2736minus the address of the long-jump to @code{sym4}; and so on, for as many
2737entries in the original jump table as necessary.
2738
2739
41ee6e91 2740@node Deprecated
169fff49
RP
2741@section Deprecated Directives
2742
2743@cindex deprecated directives
2744@cindex obsolescent directives
2745One day these directives won't work.
2746They are included for compatibility with older assemblers.
2747@table @t
2748@item .abort
2749@item .app-file
2750@item .line
2751@end table
2752
41ee6e91 2753@node Machine Dependent
169fff49
RP
2754@chapter Machine Dependent Features
2755
2756@cindex machine dependencies
2757The machine instruction sets are (almost by definition) different on
2758each machine where @code{as} runs. Floating point representations
2759vary as well, and @code{as} often supports a few additional
2760directives or command-line options for compatibility with other
2761assemblers on a particular platform. Finally, some versions of
2762@code{as} support special pseudo-instructions for branch
2763optimization.
2764
2765This chapter discusses most of these differences, though it does not
2766include details on any machine's instruction set. For details on that
2767subject, see the hardware manufacturer's manual.
2768
2769@menu
2770* Vax-Dependent:: VAX Dependent Features
2771* AMD29K-Dependent:: AMD 29K Dependent Features
bf85ce3e 2772* H8/300-Dependent:: Hitachi H8/300 Dependent Features
169fff49
RP
2773* i960-Dependent:: Intel 80960 Dependent Features
2774* M68K-Dependent:: M680x0 Dependent Features
2775* Sparc-Dependent:: SPARC Dependent Features
2776* i386-Dependent:: 80386 Dependent Features
2777@end menu
2778
41ee6e91 2779@node Vax-Dependent
169fff49
RP
2780@section VAX Dependent Features
2781
2782@cindex VAX support
2783@menu
2784* Vax-Opts:: VAX Command-Line Options
2785* VAX-float:: VAX Floating Point
2786* VAX-directives:: Vax Machine Directives
2787* VAX-opcodes:: VAX Opcodes
2788* VAX-branch:: VAX Branch Improvement
2789* VAX-operands:: VAX Operands
2790* VAX-no:: Not Supported on VAX
2791@end menu
2792
41ee6e91 2793@node Vax-Opts
169fff49
RP
2794@subsection VAX Command-Line Options
2795
2796@cindex command-line options ignored, VAX
2797@cindex VAX command-line options ignored
2798The Vax version of @code{as} accepts any of the following options,
2799gives a warning message that the option was ignored and proceeds.
2800These options are for compatibility with scripts designed for other
2801people's assemblers.
2802
2803@table @asis
2804@item @kbd{-D} (Debug)
2805@itemx @kbd{-S} (Symbol Table)
2806@itemx @kbd{-T} (Token Trace)
2807@cindex @code{-D}, ignored on VAX
2808@cindex @code{-S}, ignored on VAX
2809@cindex @code{-T}, ignored on VAX
2810These are obsolete options used to debug old assemblers.
2811
2812@item @kbd{-d} (Displacement size for JUMPs)
2813@cindex @code{-d}, VAX option
2814This option expects a number following the @kbd{-d}. Like options
2815that expect filenames, the number may immediately follow the
2816@kbd{-d} (old standard) or constitute the whole of the command line
2817argument that follows @kbd{-d} (GNU standard).
2818
2819@item @kbd{-V} (Virtualize Interpass Temporary File)
2820@cindex @code{-V}, redundant on VAX
2821Some other assemblers use a temporary file. This option
2822commanded them to keep the information in active memory rather
2823than in a disk file. @code{as} always does this, so this
2824option is redundant.
2825
2826@item @kbd{-J} (JUMPify Longer Branches)
2827@cindex @code{-J}, ignored on VAX
2828Many 32-bit computers permit a variety of branch instructions
2829to do the same job. Some of these instructions are short (and
2830fast) but have a limited range; others are long (and slow) but
2831can branch anywhere in virtual memory. Often there are 3
2832flavors of branch: short, medium and long. Some other
2833assemblers would emit short and medium branches, unless told by
2834this option to emit short and long branches.
2835
2836@item @kbd{-t} (Temporary File Directory)
2837@cindex @code{-t}, ignored on VAX
2838Some other assemblers may use a temporary file, and this option
2839takes a filename being the directory to site the temporary
2840file. @code{as} does not use a temporary disk file, so this
2841option makes no difference. @kbd{-t} needs exactly one
2842filename.
2843@end table
2844
2845@cindex VMS (VAX) options
2846@cindex options for VAX/VMS
2847@cindex VAX/VMS options
2848@cindex @code{-h} option, VAX/VMS
2849@cindex @code{-+} option, VAX/VMS
2850@cindex Vax-11 C compatibility
2851@cindex symbols with lowercase, VAX/VMS
2852@c FIXME! look into "I think" below, correct if needed, delete.
2853The Vax version of the assembler accepts two options when
2854compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
2855@kbd{-h} option prevents @code{as} from modifying the
2856symbol-table entries for symbols that contain lowercase
2857characters (I think). The @kbd{-+} option causes @code{as} to
2858print warning messages if the FILENAME part of the object file,
2859or any symbol name is larger than 31 characters. The @kbd{-+}
2860option also insertes some code following the @samp{_main}
2861symbol so that the object file will be compatible with Vax-11
2862"C".
2863
41ee6e91 2864@node VAX-float
169fff49
RP
2865@subsection VAX Floating Point
2866
2867@cindex VAX floating point
2868@cindex floating point, VAX
2869Conversion of flonums to floating point is correct, and
2870compatible with previous assemblers. Rounding is
2871towards zero if the remainder is exactly half the least significant bit.
2872
2873@code{D}, @code{F}, @code{G} and @code{H} floating point formats
2874are understood.
2875
2876Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
2877are rendered correctly. Again, rounding is towards zero in the
2878boundary case.
2879
2880@cindex @code{float} directive, VAX
2881@cindex @code{double} directive, VAX
2882The @code{.float} directive produces @code{f} format numbers.
2883The @code{.double} directive produces @code{d} format numbers.
2884
41ee6e91 2885@node VAX-directives
169fff49
RP
2886@subsection Vax Machine Directives
2887
2888@cindex machine directives, VAX
2889@cindex VAX machine directives
2890The Vax version of the assembler supports four directives for
2891generating Vax floating point constants. They are described in the
2892table below.
2893
2894@cindex wide floating point directives, VAX
2895@table @code
2896@item .dfloat
2897@cindex @code{dfloat} directive, VAX
2898This expects zero or more flonums, separated by commas, and
2899assembles Vax @code{d} format 64-bit floating point constants.
2900
2901@item .ffloat
2902@cindex @code{ffloat} directive, VAX
2903This expects zero or more flonums, separated by commas, and
2904assembles Vax @code{f} format 32-bit floating point constants.
2905
2906@item .gfloat
2907@cindex @code{gfloat} directive, VAX
2908This expects zero or more flonums, separated by commas, and
2909assembles Vax @code{g} format 64-bit floating point constants.
2910
2911@item .hfloat
2912@cindex @code{hfloat} directive, VAX
2913This expects zero or more flonums, separated by commas, and
2914assembles Vax @code{h} format 128-bit floating point constants.
2915
2916@end table
2917
41ee6e91 2918@node VAX-opcodes
169fff49
RP
2919@subsection VAX Opcodes
2920
2921@cindex VAX opcode mnemonics
2922@cindex opcode mnemonics, VAX
2923@cindex mnemonics for opcodes, VAX
2924All DEC mnemonics are supported. Beware that @code{case@dots{}}
2925instructions have exactly 3 operands. The dispatch table that
2926follows the @code{case@dots{}} instruction should be made with
2927@code{.word} statements. This is compatible with all unix
2928assemblers we know of.
2929
41ee6e91 2930@node VAX-branch
169fff49
RP
2931@subsection VAX Branch Improvement
2932
2933@cindex VAX branch improvement
2934@cindex branch improvement, VAX
2935@cindex pseudo-ops for branch, VAX
2936Certain pseudo opcodes are permitted. They are for branch
2937instructions. They expand to the shortest branch instruction that
2938will reach the target. Generally these mnemonics are made by
2939substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
2940This feature is included both for compatibility and to help
2941compilers. If you don't need this feature, don't use these
2942opcodes. Here are the mnemonics, and the code they can expand into.
2943
2944@table @code
2945@item jbsb
2946@samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
2947@table @asis
2948@item (byte displacement)
2949@kbd{bsbb @dots{}}
2950@item (word displacement)
2951@kbd{bsbw @dots{}}
2952@item (long displacement)
2953@kbd{jsb @dots{}}
2954@end table
2955@item jbr
2956@itemx jr
2957Unconditional branch.
2958@table @asis
2959@item (byte displacement)
2960@kbd{brb @dots{}}
2961@item (word displacement)
2962@kbd{brw @dots{}}
2963@item (long displacement)
2964@kbd{jmp @dots{}}
2965@end table
2966@item j@var{COND}
2967@var{COND} may be any one of the conditional branches
2968@code{neq}, @code{nequ}, @code{eql}, @code{eqlu}, @code{gtr},
2969@code{geq}, @code{lss}, @code{gtru}, @code{lequ}, @code{vc}, @code{vs},
2970@code{gequ}, @code{cc}, @code{lssu}, @code{cs}.
2971@var{COND} may also be one of the bit tests
2972@code{bs}, @code{bc}, @code{bss}, @code{bcs}, @code{bsc}, @code{bcc},
2973@code{bssi}, @code{bcci}, @code{lbs}, @code{lbc}.
2974@var{NOTCOND} is the opposite condition to @var{COND}.
2975@table @asis
2976@item (byte displacement)
2977@kbd{b@var{COND} @dots{}}
2978@item (word displacement)
2979@kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
2980@item (long displacement)
2981@kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
2982@end table
2983@item jacb@var{X}
2984@var{X} may be one of @code{b d f g h l w}.
2985@table @asis
2986@item (word displacement)
2987@kbd{@var{OPCODE} @dots{}}
2988@item (long displacement)
2989@example
2990@var{OPCODE} @dots{}, foo ;
2991brb bar ;
2992foo: jmp @dots{} ;
2993bar:
2994@end example
2995@end table
2996@item jaob@var{YYY}
2997@var{YYY} may be one of @code{lss leq}.
2998@item jsob@var{ZZZ}
2999@var{ZZZ} may be one of @code{geq gtr}.
3000@table @asis
3001@item (byte displacement)
3002@kbd{@var{OPCODE} @dots{}}
3003@item (word displacement)
3004@example
3005@var{OPCODE} @dots{}, foo ;
3006brb bar ;
3007foo: brw @var{destination} ;
3008bar:
3009@end example
3010@item (long displacement)
3011@example
3012@var{OPCODE} @dots{}, foo ;
3013brb bar ;
3014foo: jmp @var{destination} ;
3015bar:
3016@end example
3017@end table
3018@item aobleq
3019@itemx aoblss
3020@itemx sobgeq
3021@itemx sobgtr
3022@table @asis
3023@item (byte displacement)
3024@kbd{@var{OPCODE} @dots{}}
3025@item (word displacement)
3026@example
3027@var{OPCODE} @dots{}, foo ;
3028brb bar ;
3029foo: brw @var{destination} ;
3030bar:
3031@end example
3032@item (long displacement)
3033@example
3034@var{OPCODE} @dots{}, foo ;
3035brb bar ;
3036foo: jmp @var{destination} ;
3037bar:
3038@end example
3039@end table
3040@end table
3041
41ee6e91 3042@node VAX-operands
169fff49
RP
3043@subsection VAX Operands
3044
3045@cindex VAX operand notation
3046@cindex operand notation, VAX
3047@cindex immediate character, VAX
3048@cindex VAX immediate character
3049The immediate character is @samp{$} for Unix compatibility, not
3050@samp{#} as DEC writes it.
3051
3052@cindex indirect character, VAX
3053@cindex VAX indirect character
3054The indirect character is @samp{*} for Unix compatibility, not
3055@samp{@@} as DEC writes it.
3056
3057@cindex displacement sizing character, VAX
3058@cindex VAX displacement sizing character
3059The displacement sizing character is @samp{`} (an accent grave) for
3060Unix compatibility, not @samp{^} as DEC writes it. The letter
3061preceding @samp{`} may have either case. @samp{G} is not
3062understood, but all other letters (@code{b i l s w}) are understood.
3063
3064@cindex register names, VAX
3065@cindex VAX register names
3066Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
3067pc}. Any case of letters will do.
3068
3069For instance
3070@smallexample
3071tstb *w`$4(r5)
3072@end smallexample
3073
3074Any expression is permitted in an operand. Operands are comma
3075separated.
3076
3077@c There is some bug to do with recognizing expressions
3078@c in operands, but I forget what it is. It is
3079@c a syntax clash because () is used as an address mode
3080@c and to encapsulate sub-expressions.
3081
41ee6e91 3082@node VAX-no
169fff49
RP
3083@subsection Not Supported on VAX
3084
3085@cindex VAX bitfields not supported
3086@cindex bitfields, not supported on VAX
3087Vax bit fields can not be assembled with @code{as}. Someone
3088can add the required code if they really need it.
3089
41ee6e91 3090@node AMD29K-Dependent
169fff49
RP
3091@section AMD 29K Dependent Features
3092
3093@cindex AMD 29K support
3094@cindex 29K support
3095@menu
3096* AMD29K Options:: Options
3097* AMD29K Syntax:: Syntax
3098* AMD29K Floating Point:: Floating Point
3099* AMD29K Directives:: AMD 29K Machine Directives
3100* AMD29K Opcodes:: Opcodes
3101@end menu
3102
41ee6e91 3103@node AMD29K Options
169fff49
RP
3104@subsection Options
3105@cindex AMD 29K options (none)
3106@cindex options for AMD29K (none)
3107@code{as} has no additional command-line options for the AMD
310829K family.
3109
41ee6e91 3110@node AMD29K Syntax
169fff49
RP
3111@subsection Syntax
3112@menu
3113* AMD29K-Chars:: Special Characters
3114* AMD29K-Regs:: Register Names
3115@end menu
3116
41ee6e91 3117@node AMD29K-Chars
169fff49
RP
3118@subsubsection Special Characters
3119
3120@cindex line comment character, AMD 29K
3121@cindex AMD 29K line comment character
3122@samp{;} is the line comment character.
3123
3124@cindex line separator, AMD 29K
3125@cindex AMD 29K line separator
3126@cindex statement separator, AMD 29K
3127@cindex AMD 29K statement separator
3128@samp{@@} can be used instead of a newline to separate statements.
3129
3130@cindex identifiers, AMD 29K
3131@cindex AMD 29K identifiers
3132The character @samp{?} is permitted in identifiers (but may not begin
3133an identifier).
3134
41ee6e91 3135@node AMD29K-Regs
169fff49
RP
3136@subsubsection Register Names
3137
3138@cindex AMD 29K register names
3139@cindex register names, AMD 29K
3140General-purpose registers are represented by predefined symbols of the
3141form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
3142(for local registers), where @var{nnn} represents a number between
3143@code{0} and @code{127}, written with no leading zeros. The leading
3144letters may be in either upper or lower case; for example, @samp{gr13}
3145and @samp{LR7} are both valid register names.
3146
3147You may also refer to general-purpose registers by specifying the
3148register number as the result of an expression (prefixed with @samp{%%}
3149to flag the expression as a register number):
3150@smallexample
3151%%@var{expression}
3152@end smallexample
3153@noindent
3154---where @var{expression} must be an absolute expression evaluating to a
3155number between @code{0} and @code{255}. The range [0, 127] refers to
3156global registers, and the range [128, 255] to local registers.
3157
3158@cindex special purpose registers, AMD 29K
3159@cindex AMD 29K special purpose registers
3160@cindex protected registers, AMD 29K
3161@cindex AMD 29K protected registers
3162In addition, @code{as} understands the following protected
3163special-purpose register names for the AMD 29K family:
3164
3165@smallexample
3166 vab chd pc0
3167 ops chc pc1
3168 cps rbp pc2
3169 cfg tmc mmu
3170 cha tmr lru
3171@end smallexample
3172
3173These unprotected special-purpose register names are also recognized:
3174@smallexample
3175 ipc alu fpe
3176 ipa bp inte
3177 ipb fc fps
3178 q cr exop
3179@end smallexample
3180
41ee6e91 3181@node AMD29K Floating Point
169fff49
RP
3182@subsection Floating Point
3183
3184@cindex floating point, AMD 29K (@sc{ieee})
3185@cindex AMD 29K floating point (@sc{ieee})
3186The AMD 29K family uses @sc{ieee} floating-point numbers.
3187
41ee6e91 3188@node AMD29K Directives
169fff49
RP
3189@subsection AMD 29K Machine Directives
3190
3191@cindex machine directives, AMD 29K
3192@cindex AMD 29K machine directives
3193@table @code
3194@item .block @var{size} , @var{fill}
3195@cindex @code{block} directive, AMD 29K
3196This directive emits @var{size} bytes, each of value @var{fill}. Both
3197@var{size} and @var{fill} are absolute expressions. If the comma
3198and @var{fill} are omitted, @var{fill} is assumed to be zero.
3199
3200In other versions of the GNU assembler, this directive is called
3201@samp{.space}.
3202@end table
3203
3204@table @code
3205@item .cputype
3206@cindex @code{cputype} directive, AMD 29K
3207This directive is ignored; it is accepted for compatibility with other
3208AMD 29K assemblers.
3209
3210@item .file
3211@cindex @code{file} directive, AMD 29K
3212This directive is ignored; it is accepted for compatibility with other
3213AMD 29K assemblers.
3214
3215@quotation
3216@emph{Warning:} in other versions of the GNU assembler, @code{.file} is
3217used for the directive called @code{.app-file} in the AMD 29K support.
3218@end quotation
3219
3220@item .line
3221@cindex @code{line} directive, AMD 29K
3222This directive is ignored; it is accepted for compatibility with other
3223AMD 29K assemblers.
3224
41ee6e91
RP
3225@ignore
3226@c since we're ignoring .lsym...
169fff49
RP
3227@item .reg @var{symbol}, @var{expression}
3228@cindex @code{reg} directive, AMD 29K
3229@code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
41ee6e91 3230@end ignore
169fff49
RP
3231
3232@item .sect
3233@cindex @code{sect} directive, AMD 29K
3234This directive is ignored; it is accepted for compatibility with other
3235AMD 29K assemblers.
3236
3237@item .use @var{section name}
3238@cindex @code{use} directive, AMD 29K
3239Establishes the section and subsection for the following code;
3240@var{section name} may be one of @code{.text}, @code{.data},
3241@code{.data1}, or @code{.lit}. With one of the first three @var{section
3242name} options, @samp{.use} is equivalent to the machine directive
3243@var{section name}; the remaining case, @samp{.use .lit}, is the same as
3244@samp{.data 200}.
3245@end table
3246
41ee6e91 3247@node AMD29K Opcodes
169fff49
RP
3248@subsection Opcodes
3249
3250@cindex AMD 29K opcodes
3251@cindex opcodes for AMD 29K
3252@code{as} implements all the standard AMD 29K opcodes. No
3253additional pseudo-instructions are needed on this family.
3254
3255For information on the 29K machine instruction set, see @cite{Am29000
3256User's Manual}, Advanced Micro Devices, Inc.
3257
41ee6e91 3258@node H8/300-Dependent
169fff49
RP
3259@section H8/300 Dependent Features
3260
3261@cindex H8/300 support
3262@menu
3263* H8/300 Options:: Options
3264* H8/300 Syntax:: Syntax
3265* H8/300 Floating Point:: Floating Point
3266* H8/300 Directives:: H8/300 Machine Directives
3267* H8/300 Opcodes:: Opcodes
3268@end menu
3269
41ee6e91 3270@node H8/300 Options
169fff49
RP
3271@subsection Options
3272
3273@cindex H8/300 options (none)
3274@cindex options, H8/300 (none)
3275@code{as} has no additional command-line options for the Hitachi
3276H8/300 family.
3277
41ee6e91 3278@node H8/300 Syntax
169fff49
RP
3279@subsection Syntax
3280@menu
3281* H8/300-Chars:: Special Characters
3282* H8/300-Regs:: Register Names
3283* H8/300-Addressing:: Addressing Modes
3284@end menu
3285
41ee6e91 3286@node H8/300-Chars
169fff49
RP
3287@subsubsection Special Characters
3288
3289@cindex line comment character, H8/300
3290@cindex H8/300 line comment character
3291@samp{;} is the line comment character.
3292
3293@cindex line separator, H8/300
3294@cindex statement separator, H8/300
3295@cindex H8/300 line separator
3296@samp{$} can be used instead of a newline to separate statements.
3297Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
3298
41ee6e91 3299@node H8/300-Regs
169fff49
RP
3300@subsubsection Register Names
3301
3302@cindex H8/300 registers
3303@cindex registers, H8/300
3304You can use predefined symbols of the form @samp{r@var{n}h} and
3305@samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
3306general-purpose registers. @var{n} is a digit from @samp{0} to
3307@samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
3308register names.
3309
3310You can also use the eight predefined symbols @samp{r@var{n}} to refer
3311to the H8/300 registers as 16-bit registers (you must use this form for
3312addressing).
3313
3314The two control registers are called @code{pc} (program counter; a
331516-bit register) and @code{ccr} (condition code register; an 8-bit
3316register). @code{r7} is used as the stack pointer, and can also be
3317called @code{sp}.
3318
41ee6e91 3319@node H8/300-Addressing
169fff49
RP
3320@subsubsection Addressing Modes
3321
3322@cindex addressing modes, H8/300
3323@cindex H8/300 addressing modes
3324as understands the following addressing modes for the H8/300:
3325@table @code
3326@item r@var{n}
3327Register direct
3328
3329@item @@r@var{n}
3330Register indirect
3331
3332@item @@(@var{d}, r@var{n})
3333@itemx @@(@var{d}:16, r@var{n})
3334Register indirect: 16-bit displacement @var{d} from register @var{n}.
3335(You may specify the @samp{:16} for clarity if you wish, but it is not
3336required and has no effect.)
3337
3338@item @@r@var{n}+
3339Register indirect with post-increment
3340
3341@item @@-r@var{n}
3342Register indirect with pre-decrement
3343
3344@item @code{@@}@var{aa}
3345@itemx @code{@@}@var{aa}:8
3346@itemx @code{@@}@var{aa}:16
3347Absolute address @code{aa}. You may specify the @samp{:8} or @samp{:16}
3348for clarity, if you wish; but @code{as} neither requires this nor
3349uses it---the address size required is taken from context.
3350
3351@item #@var{xx}
3352@itemx #@var{xx}:8
3353@itemx #@var{xx}:16
3354Immediate data @var{xx}. You may specify the @samp{:8} or @samp{:16}
3355for clarity, if you wish; but @code{as} neither requires this nor
3356uses it---the data size required is taken from context.
3357
3358@item @code{@@}@code{@@}@var{aa}
3359@itemx @code{@@}@code{@@}@var{aa}:8
3360Memory indirect. You may specify the @samp{:8} for clarity, if you
3361wish; but @code{as} neither requires this nor uses it.
3362@end table
3363
41ee6e91 3364@node H8/300 Floating Point
169fff49
RP
3365@subsection Floating Point
3366
3367@cindex floating point, H8/300 (@sc{ieee})
3368@cindex H8/300 floating point (@sc{ieee})
3369The H8/300 family uses @sc{ieee} floating-point numbers.
3370
41ee6e91 3371@node H8/300 Directives
169fff49
RP
3372@subsection H8/300 Machine Directives
3373
3374@cindex H8/300 machine directives (none)
3375@cindex machine directives, H8/300 (none)
3376@cindex @code{word} directive, H8/300
3377@cindex @code{int} directive, H8/300
3378@code{as} has no machine-dependent directives for the H8/300.
3379However, on this platform the @samp{.int} and @samp{.word} directives
3380generate 16-bit numbers.
3381
41ee6e91 3382@node H8/300 Opcodes
169fff49
RP
3383@subsection Opcodes
3384
3385@cindex H8/300 opcode summary
3386@cindex opcode summary, H8/300
3387@cindex mnemonics, H8/300
3388@cindex instruction summary, H8/300
3389For detailed information on the H8/300 machine instruction set, see
3390@cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025).
3391
3392@code{as} implements all the standard H8/300 opcodes. No additional
3393pseudo-instructions are needed on this family.
3394
3395The following table summarizes the opcodes and their arguments:
3396@c kluge due to lack of group outside example
3397@page
3398@smallexample
3399@group
3400 Rs @r{source register}
3401 Rd @r{destination register}
3402 imm @r{immediate data}
3403 x:3 @r{a bit (as a number between 0 and 7)}
3404 d:8 @r{eight bit displacement from @code{pc}}
3405 d:16 @r{sixteen bit displacement from @code{Rs}}
3406
3407add.b Rs,Rd biand #x:3,Rd
3408add.b #imm:8,Rd biand #x:3,@@Rd
3409add.w Rs,Rd biand #x:3,@@aa:8
3410adds #1,Rd bild #x:3,Rd
3411adds #2,Rd bild #x:3,@@Rd
3412addx #imm:8,Rd bild #x:3,@@aa:8
3413addx Rs,Rd bior #x:3,Rd
3414and #imm:8,Rd bior #x:3,@@Rd
3415and Rs,Rd bior #x:3,@@aa:8
3416andc #imm:8,ccr bist #x:3,Rd
3417band #x:3,Rd bist #x:3,@@Rd
3418band #x:3,@@Rd bist #x:3,@@aa:8
3419bra d:8 bixor #x:3,Rd
3420bt d:8 bixor #x:3,@@Rd
3421brn d:8 bixor #x:3,@@aa:8
3422bf d:8 bld #x:3,Rd
3423bhi d:8 bld #x:3,@@Rd
3424bls d:8 bld #x:3,@@aa:8
3425bcc d:8 bnot #x:3,Rd
3426bhs d:8 bnot #x:3,@@Rd
3427bcs d:8 bnot #x:3,@@aa:8
3428blo d:8 bnot Rs,Rd
3429bne d:8 bnot Rs,@@Rd
3430beq d:8 bnot Rs,@@aa:8
3431bvc d:8 bor #x:3,Rd
3432bvs d:8 bor #x:3,@@Rd
3433bpl d:8 bor #x:3,@@aa:8
3434bmi d:8 bset #x:3,@@Rd
3435bge d:8 bset #x:3,@@aa:8
3436blt d:8 bset Rs,Rd
3437bgt d:8 bset Rs,@@Rd
3438ble d:8 bset Rs,@@aa:8
3439bclr #x:3,Rd bsr d:8
3440bclr #x:3,@@Rd bst #x:3,Rd
3441bclr #x:3,@@aa:8 bst #x:3,@@Rd
3442bclr Rs,Rd bst #x:3,@@aa:8
3443bclr Rs,@@Rd btst #x:3,Rd
3444@end group
3445@group
3446btst #x:3,@@Rd mov.w @@(d:16, Rs),Rd
3447btst #x:3,@@aa:8 mov.w @@Rs+,Rd
3448btst Rs,Rd mov.w @@aa:16,Rd
3449btst Rs,@@Rd mov.w Rs,@@Rd
3450btst Rs,@@aa:8 mov.w Rs,@@(d:16, Rd)
3451bxor #x:3,Rd mov.w Rs,@@-Rd
3452bxor #x:3,@@Rd mov.w Rs,@@aa:16
3453bxor #x:3,@@aa:8 movfpe @@aa:16,Rd
3454cmp.b #imm:8,Rd movtpe Rs,@@aa:16
3455cmp.b Rs,Rd mulxu Rs,Rd
3456cmp.w Rs,Rd neg Rs
3457daa Rs nop
3458das Rs not Rs
3459dec Rs or #imm:8,Rd
3460divxu Rs,Rd or Rs,Rd
3461eepmov orc #imm:8,ccr
3462inc Rs pop Rs
3463jmp @@Rs push Rs
3464jmp @@aa:16 rotl Rs
3465jmp @@@@aa rotr Rs
3466jsr @@Rs rotxl Rs
3467jsr @@aa:16 rotxr Rs
3468jsr @@@@aa:8 rte
3469ldc #imm:8,ccr rts
3470ldc Rs,ccr shal Rs
3471mov.b Rs,Rd shar Rs
3472mov.b #imm:8,Rd shll Rs
3473mov.b @@Rs,Rd shlr Rs
3474mov.b @@(d:16, Rs),Rd sleep
3475mov.b @@Rs+,Rd stc ccr,Rd
3476mov.b @@aa:16,Rd sub.b Rs,Rd
3477mov.b @@aa:8,Rd sub.w Rs,Rd
3478mov.b Rs,@@Rd subs #1,Rd
3479mov.b Rs,@@(d:16, Rd) subs #2,Rd
3480mov.b Rs,@@-Rd subx #imm:8,Rd
3481mov.b Rs,@@aa:16 subx Rs,Rd
3482mov.b Rs,@@aa:8 xor #imm:8,Rd
3483mov.w Rs,Rd xor Rs,Rd
3484mov.w #imm:16,Rd xorc #imm:8,ccr
3485mov.w @@Rs,Rd
3486@end group
3487@end smallexample
3488
3489@cindex size suffixes, H8/300
3490@cindex H8/300 size suffixes
3491Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
3492@code{sub}) are defined with variants using the suffixes @samp{.b} and
3493@samp{.w} to specify the size of a memory operand. @code{as}
3494supports these suffixes, but does not require them; since one of the
3495operands is always a register, @code{as} can deduce the correct size.
3496
3497For example, since @code{r0} refers to a 16-bit register,
3498@example
3499mov r0,@@foo
3500@exdent is equivalent to
3501mov.w r0,@@foo
3502@end example
3503
3504If you use the size suffixes, @code{as} will issue a warning if
3505there's a mismatch between the suffix and the register size.
3506
41ee6e91 3507@node i960-Dependent
169fff49
RP
3508@section Intel 80960 Dependent Features
3509
3510@cindex i960 support
3511@menu
3512* Options-i960:: i960 Command-line Options
3513* Floating Point-i960:: Floating Point
3514* Directives-i960:: i960 Machine Directives
3515* Opcodes for i960:: i960 Opcodes
3516@end menu
3517
3518@c FIXME! Add Syntax sec with discussion of bitfields here, at least so
3519@c long as they're not turned on for other machines than 960.
41ee6e91
RP
3520
3521@node Options-i960
169fff49
RP
3522
3523@subsection i960 Command-line Options
3524
3525@cindex i960 options
3526@cindex options, i960
3527@table @code
3528
3529@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
3530@cindex i960 architecture options
3531@cindex architecture options, i960
3532@cindex @code{-A} options, i960
3533Select the 80960 architecture. Instructions or features not supported
3534by the selected architecture cause fatal errors.
3535
3536@samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
3537@samp{-AMC}. Synonyms are provided for compatibility with other tools.
3538
3539If none of these options is specified, @code{as} will generate code for any
3540instruction or feature that is supported by @emph{some} version of the
3541960 (even if this means mixing architectures!). In principle,
3542@code{as} will attempt to deduce the minimal sufficient processor
3543type if none is specified; depending on the object code format, the
3544processor type may be recorded in the object file. If it is critical
3545that the @code{as} output match a specific architecture, specify that
3546architecture explicitly.
3547
3548@item -b
3549@cindex @code{-b} option, i960
3550@cindex branch recording, i960
3551@cindex i960 branch recording
3552Add code to collect information about conditional branches taken, for
3553later optimization using branch prediction bits. (The conditional branch
3554instructions have branch prediction bits in the CA, CB, and CC
3555architectures.) If @var{BR} represents a conditional branch instruction,
3556the following represents the code generated by the assembler when
3557@samp{-b} is specified:
3558
3559@smallexample
3560 call @var{increment routine}
3561 .word 0 # pre-counter
3562Label: @var{BR}
3563 call @var{increment routine}
3564 .word 0 # post-counter
3565@end smallexample
3566
3567The counter following a branch records the number of times that branch
3568was @emph{not} taken; the differenc between the two counters is the
3569number of times the branch @emph{was} taken.
3570
3571@cindex @code{gbr960}, i960 postprocessor
3572@cindex branch statistics table, i960
3573A table of every such @code{Label} is also generated, so that the
3574external postprocessor @code{gbr960} (supplied by Intel) can locate all
3575the counters. This table is always labelled @samp{__BRANCH_TABLE__};
3576this is a local symbol to permit collecting statistics for many separate
3577object files. The table is word aligned, and begins with a two-word
3578header. The first word, initialized to 0, is used in maintaining linked
3579lists of branch tables. The second word is a count of the number of
3580entries in the table, which follow immediately: each is a word, pointing
3581to one of the labels illustrated above.
3582
3583@c TEXI2ROFF-KILL
3584@ifinfo
3585@c END TEXI2ROFF-KILL
3586@example
3587 +------------+------------+------------+ ... +------------+
3588 | | | | | |
3589 | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
3590 | | | | | |
3591 +------------+------------+------------+ ... +------------+
3592
3593 __BRANCH_TABLE__ layout
3594@end example
3595@c TEXI2ROFF-KILL
3596@end ifinfo
3597@tex
3598\vskip 1pc
3599\line{\leftskip=0pt\hskip\tableindent
3600\boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
3601*BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
3602\centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
3603@end tex
3604@c END TEXI2ROFF-KILL
3605
3606The first word of the header is used to locate multiple branch tables,
3607since each object file may contain one. Normally the links are
3608maintained with a call to an initialization routine, placed at the
3609beginning of each function in the file. The GNU C compiler will
3610generate these calls automatically when you give it a @samp{-b} option.
3611For further details, see the documentation of @samp{gbr960}.
3612
3613@item -norelax
3614@cindex @code{-norelax} option, i960
3615Normally, Compare-and-Branch instructions with targets that require
3616displacements greater than 13 bits (or that have external targets) are
3617replaced with the corresponding compare (or @samp{chkbit}) and branch
3618instructions. You can use the @samp{-norelax} option to specify that
3619@code{as} should generate errors instead, if the target displacement
3620is larger than 13 bits.
3621
3622This option does not affect the Compare-and-Jump instructions; the code
3623emitted for them is @emph{always} adjusted when necessary (depending on
3624displacement size), regardless of whether you use @samp{-norelax}.
3625@end table
3626
41ee6e91 3627@node Floating Point-i960
169fff49
RP
3628@subsection Floating Point
3629
3630@cindex floating point, i960 (@sc{ieee})
3631@cindex i960 floating point (@sc{ieee})
3632@code{as} generates @sc{ieee} floating-point numbers for the directives
3633@samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
3634
41ee6e91 3635@node Directives-i960
169fff49
RP
3636@subsection i960 Machine Directives
3637
3638@cindex machine directives, i960
3639@cindex i960 machine directives
3640
3641@table @code
3642@cindex @code{bss} directive, i960
3643@item .bss @var{symbol}, @var{length}, @var{align}
3644Reserve @var{length} bytes in the bss section for a local @var{symbol},
3645aligned to the power of two specified by @var{align}. @var{length} and
3646@var{align} must be positive absolute expressions. This directive
3647differs from @samp{.lcomm} only in that it permits you to specify
3648an alignment. @xref{Lcomm,,@code{.lcomm}}.
3649@end table
3650
3651@table @code
3652@item .extended @var{flonums}
3653@cindex @code{extended} directive, i960
3654@code{.extended} expects zero or more flonums, separated by commas; for
3655each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
3656floating-point number.
3657
3658@item .leafproc @var{call-lab}, @var{bal-lab}
3659@cindex @code{leafproc} directive, i960
3660You can use the @samp{.leafproc} directive in conjunction with the
3661optimized @code{callj} instruction to enable faster calls of leaf
3662procedures. If a procedure is known to call no other procedures, you
3663may define an entry point that skips procedure prolog code (and that does
3664not depend on system-supplied saved context), and declare it as the
3665@var{bal-lab} using @samp{.leafproc}. If the procedure also has an
3666entry point that goes through the normal prolog, you can specify that
3667entry point as @var{call-lab}.
3668
3669A @samp{.leafproc} declaration is meant for use in conjunction with the
3670optimized call instruction @samp{callj}; the directive records the data
3671needed later to choose between converting the @samp{callj} into a
3672@code{bal} or a @code{call}.
3673
3674@var{call-lab} is optional; if only one argument is present, or if the
3675two arguments are identical, the single argument is assumed to be the
3676@code{bal} entry point.
3677
3678@item .sysproc @var{name}, @var{index}
3679@cindex @code{sysproc} directive, i960
3680The @samp{.sysproc} directive defines a name for a system procedure.
3681After you define it using @samp{.sysproc}, you can use @var{name} to
3682refer to the system procedure identified by @var{index} when calling
3683procedures with the optimized call instruction @samp{callj}.
3684
3685Both arguments are required; @var{index} must be between 0 and 31
3686(inclusive).
3687@end table
3688
41ee6e91 3689@node Opcodes for i960
169fff49
RP
3690@subsection i960 Opcodes
3691
3692@cindex opcodes, i960
3693@cindex i960 opcodes
3694All Intel 960 machine instructions are supported;
3695@pxref{Options-i960,,i960 Command-line Options} for a discussion of
3696selecting the instruction subset for a particular 960
3697architecture.@refill
3698
3699Some opcodes are processed beyond simply emitting a single corresponding
3700instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
3701instructions with target displacements larger than 13 bits.
3702
3703@menu
3704* callj-i960:: @code{callj}
3705* Compare-and-branch-i960:: Compare-and-Branch
3706@end menu
3707
41ee6e91 3708@node callj-i960
169fff49
RP
3709@subsubsection @code{callj}
3710
3711@cindex @code{callj}, i960 pseudo-opcode
3712@cindex i960 @code{callj} pseudo-opcode
3713You can write @code{callj} to have the assembler or the linker determine
3714the most appropriate form of subroutine call: @samp{call},
3715@samp{bal}, or @samp{calls}. If the assembly source contains
3716enough information---a @samp{.leafproc} or @samp{.sysproc} directive
3717defining the operand---then @code{as} will translate the
3718@code{callj}; if not, it will simply emit the @code{callj}, leaving it
3719for the linker to resolve.
3720
41ee6e91 3721@node Compare-and-branch-i960
169fff49
RP
3722@subsubsection Compare-and-Branch
3723
3724@cindex i960 compare/branch instructions
3725@cindex compare/branch instructions, i960
3726The 960 architectures provide combined Compare-and-Branch instructions
3727that permit you to store the branch target in the lower 13 bits of the
3728instruction word itself. However, if you specify a branch target far
3729enough away that its address won't fit in 13 bits, the assembler can
3730either issue an error, or convert your Compare-and-Branch instruction
3731into separate instructions to do the compare and the branch.
3732
3733@cindex compare and jump expansions, i960
3734@cindex i960 compare and jump expansions
3735Whether @code{as} gives an error or expands the instruction depends
3736on two choices you can make: whether you use the @samp{-norelax} option,
3737and whether you use a ``Compare and Branch'' instruction or a ``Compare
3738and Jump'' instruction. The ``Jump'' instructions are @emph{always}
3739expanded if necessary; the ``Branch'' instructions are expanded when
3740necessary @emph{unless} you specify @code{-norelax}---in which case
3741@code{as} gives an error instead.
3742
3743These are the Compare-and-Branch instructions, their ``Jump'' variants,
3744and the instruction pairs they may expand into:
3745
3746@c TEXI2ROFF-KILL
3747@ifinfo
3748@c END TEXI2ROFF-KILL
3749@example
3750 Compare and
3751 Branch Jump Expanded to
3752 ------ ------ ------------
3753 bbc chkbit; bno
3754 bbs chkbit; bo
3755 cmpibe cmpije cmpi; be
3756 cmpibg cmpijg cmpi; bg
3757 cmpibge cmpijge cmpi; bge
3758 cmpibl cmpijl cmpi; bl
3759 cmpible cmpijle cmpi; ble
3760 cmpibno cmpijno cmpi; bno
3761 cmpibne cmpijne cmpi; bne
3762 cmpibo cmpijo cmpi; bo
3763 cmpobe cmpoje cmpo; be
3764 cmpobg cmpojg cmpo; bg
3765 cmpobge cmpojge cmpo; bge
3766 cmpobl cmpojl cmpo; bl
3767 cmpoble cmpojle cmpo; ble
3768 cmpobne cmpojne cmpo; bne
3769@end example
3770@c TEXI2ROFF-KILL
3771@end ifinfo
3772@tex
3773\hskip\tableindent
3774\halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
3775\omit{\hfil\it Compare and\hfil}\span\omit&\cr
3776{\it Branch}&{\it Jump}&{\it Expanded to}\cr
3777 bbc& & chkbit; bno\cr
3778 bbs& & chkbit; bo\cr
3779 cmpibe& cmpije& cmpi; be\cr
3780 cmpibg& cmpijg& cmpi; bg\cr
3781 cmpibge& cmpijge& cmpi; bge\cr
3782 cmpibl& cmpijl& cmpi; bl\cr
3783 cmpible& cmpijle& cmpi; ble\cr
3784 cmpibno& cmpijno& cmpi; bno\cr
3785 cmpibne& cmpijne& cmpi; bne\cr
3786 cmpibo& cmpijo& cmpi; bo\cr
3787 cmpobe& cmpoje& cmpo; be\cr
3788 cmpobg& cmpojg& cmpo; bg\cr
3789 cmpobge& cmpojge& cmpo; bge\cr
3790 cmpobl& cmpojl& cmpo; bl\cr
3791 cmpoble& cmpojle& cmpo; ble\cr
3792 cmpobne& cmpojne& cmpo; bne\cr}
3793@end tex
3794@c END TEXI2ROFF-KILL
3795
41ee6e91 3796@node M68K-Dependent
169fff49
RP
3797@section M680x0 Dependent Features
3798
3799@cindex M680x0 support
3800@menu
3801* M68K-Opts:: M680x0 Options
3802* M68K-Syntax:: Syntax
3803* M68K-Float:: Floating Point
3804* M68K-Directives:: 680x0 Machine Directives
3805* M68K-opcodes:: Opcodes
3806@end menu
3807
41ee6e91 3808@node M68K-Opts
169fff49
RP
3809@subsection M680x0 Options
3810
3811@cindex options, M680x0
3812@cindex M680x0 options
3813The Motorola 680x0 version of @code{as} has two machine dependent options.
3814One shortens undefined references from 32 to 16 bits, while the
3815other is used to tell @code{as} what kind of machine it is
3816assembling for.
3817
3818@cindex @code{-l} option, M680x0
3819You can use the @kbd{-l} option to shorten the size of references to
3820undefined symbols. If the @kbd{-l} option is not given, references to
3821undefined symbols will be a full long (32 bits) wide. (Since @code{as}
3822cannot know where these symbols will end up, @code{as} can only allocate
3823space for the linker to fill in later. Since @code{as} doesn't know how
3824far away these symbols will be, it allocates as much space as it can.)
3825If this option is given, the references will only be one word wide (16
3826bits). This may be useful if you want the object file to be as small as
3827possible, and you know that the relevant symbols will be less than 17
3828bits away.
3829
3830@cindex @code{-m68000} and related options
3831@cindex architecture options, M680x0
3832@cindex M680x0 architecture options
3833The 680x0 version of @code{as} is most frequently used to assemble
3834programs for the Motorola MC68020 microprocessor. Occasionally it is
3835used to assemble programs for the mostly similar, but slightly different
3836MC68000 or MC68010 microprocessors. You can give @code{as} the options
3837@samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
3838@samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
3839target.
3840
41ee6e91 3841@node M68K-Syntax
169fff49
RP
3842@subsection Syntax
3843
3844@cindex M680x0 syntax
3845@cindex syntax, M680x0
3846@cindex M680x0 size modifiers
3847@cindex size modifiers, M680x0
3848The 680x0 version of @code{as} uses syntax similar to the Sun assembler.
3849Size modifiers are appended directly to the end of the opcode without an
3850intervening period. For example, write @samp{movl} rather than
3851@samp{move.l}.
3852
3853
3854In the following table @dfn{apc} stands for any of the address
3855registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
3856Program Counter (@samp{pc}), or the zero-address relative to the
3857program counter (@samp{zpc}).
3858
3859@cindex M680x0 addressing modes
3860@cindex addressing modes, M680x0
3861The following addressing modes are understood:
3862@table @dfn
3863@item Immediate
3864@samp{#@var{digits}}
3865
3866@item Data Register
3867@samp{d0} through @samp{d7}
3868
3869@item Address Register
3870@samp{a0} through @samp{a7}
3871
3872@item Address Register Indirect
3873@samp{a0@@} through @samp{a7@@}
3874
3875@item Address Register Postincrement
3876@samp{a0@@+} through @samp{a7@@+}
3877
3878@item Address Register Predecrement
3879@samp{a0@@-} through @samp{a7@@-}
3880
3881@item Indirect Plus Offset
3882@samp{@var{apc}@@(@var{digits})}
3883
3884@item Index
3885@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3886
3887or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
3888
3889@item Postindex
3890@samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
3891
3892or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
3893
3894@item Preindex
3895@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3896
3897or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
3898
3899@item Memory Indirect
3900@samp{@var{apc}@@(@var{digits})@@(@var{digits})}
3901
3902@item Absolute
3903@samp{@var{symbol}}, or @samp{@var{digits}}
3904@ignore
3905@c pesch@cygnus.com: gnu, rich concur the following needs careful
3906@c research before documenting.
3907 , or either of the above followed
3908by @samp{:b}, @samp{:w}, or @samp{:l}.
3909@end ignore
3910@end table
3911
41ee6e91 3912@node M68K-Float
169fff49
RP
3913@subsection Floating Point
3914
3915@cindex floating point, M680x0
3916@cindex M680x0 floating point
3917@c FIXME is this "not too well tested" crud STILL true?
3918The floating point code is not too well tested, and may have
3919subtle bugs in it.
3920
3921Packed decimal (P) format floating literals are not supported.
3922Feel free to add the code!
3923
3924The floating point formats generated by directives are these.
3925
3926@table @code
3927@item .float
3928@cindex @code{float} directive, M680x0
3929@code{Single} precision floating point constants.
3930
3931@item .double
3932@cindex @code{double} directive, M680x0
3933@code{Double} precision floating point constants.
3934@end table
3935
3936There is no directive to produce regions of memory holding
3937extended precision numbers, however they can be used as
3938immediate operands to floating-point instructions. Adding a
3939directive to create extended precision numbers would not be
3940hard, but it has not yet seemed necessary.
3941
41ee6e91 3942@node M68K-Directives
169fff49
RP
3943@subsection 680x0 Machine Directives
3944
3945@cindex M680x0 directives
3946@cindex directives, M680x0
3947In order to be compatible with the Sun assembler the 680x0 assembler
3948understands the following directives.
3949
3950@table @code
3951@item .data1
3952@cindex @code{data1} directive, M680x0
3953This directive is identical to a @code{.data 1} directive.
3954
3955@item .data2
3956@cindex @code{data2} directive, M680x0
3957This directive is identical to a @code{.data 2} directive.
3958
3959@item .even
3960@cindex @code{even} directive, M680x0
3961This directive is identical to a @code{.align 1} directive.
3962@c Is this true? does it work???
3963
3964@item .skip
3965@cindex @code{skip} directive, M680x0
3966This directive is identical to a @code{.space} directive.
3967@end table
3968
41ee6e91 3969@node M68K-opcodes
169fff49
RP
3970@subsection Opcodes
3971
3972@cindex M680x0 opcodes
3973@cindex opcodes, M680x0
3974@cindex instruction set, M680x0
3975@c pesch@cygnus.com: I don't see any point in the following
3976@c paragraph. Bugs are bugs; how does saying this
3977@c help anyone?
3978@ignore
3979Danger: Several bugs have been found in the opcode table (and
3980fixed). More bugs may exist. Be careful when using obscure
3981instructions.
3982@end ignore
3983
3984@menu
3985* M68K-Branch:: Branch Improvement
3986* M68K-Chars:: Special Characters
3987@end menu
3988
41ee6e91 3989@node M68K-Branch
169fff49
RP
3990@subsubsection Branch Improvement
3991
3992@cindex pseudo-opcodes, M680x0
3993@cindex M680x0 pseudo-opcodes
3994@cindex branch improvement, M680x0
3995@cindex M680x0 branch improvement
3996Certain pseudo opcodes are permitted for branch instructions.
3997They expand to the shortest branch instruction that will reach the
3998target. Generally these mnemonics are made by substituting @samp{j} for
3999@samp{b} at the start of a Motorola mnemonic.
4000
4001The following table summarizes the pseudo-operations. A @code{*} flags
4002cases that are more fully described after the table:
4003
4004@smallexample
4005 Displacement
4006 +-------------------------------------------------
4007 | 68020 68000/10
4008Pseudo-Op |BYTE WORD LONG LONG non-PC relative
4009 +-------------------------------------------------
4010 jbsr |bsrs bsr bsrl jsr jsr
4011 jra |bras bra bral jmp jmp
4012* jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
4013* dbXX |dbXX dbXX dbXX; bra; jmpl
4014* fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
4015
4016XX: condition
4017NX: negative of condition XX
4018
4019@end smallexample
4020@center @code{*}---see full description below
4021
4022@table @code
4023@item jbsr
4024@itemx jra
4025These are the simplest jump pseudo-operations; they always map to one
4026particular machine instruction, depending on the displacement to the
4027branch target.
4028
4029@item j@var{XX}
4030Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
4031where @var{XX} is a conditional branch or condition-code test. The full
4032list of pseudo-ops in this family is:
4033@smallexample
4034 jhi jls jcc jcs jne jeq jvc
4035 jvs jpl jmi jge jlt jgt jle
4036@end smallexample
4037
4038For the cases of non-PC relative displacements and long displacements on
4039the 68000 or 68010, @code{as} will issue a longer code fragment in terms of
574fcd7b
RP
4040@var{NX}, the opposite condition to @var{XX}. For example, for the
4041non-PC relative case:
169fff49
RP
4042@smallexample
4043 j@var{XX} foo
4044@end smallexample
4045gives
4046@smallexample
4047 b@var{NX}s oof
4048 jmp foo
4049 oof:
4050@end smallexample
4051
4052@item db@var{XX}
4053The full family of pseudo-operations covered here is
4054@smallexample
4055 dbhi dbls dbcc dbcs dbne dbeq dbvc
4056 dbvs dbpl dbmi dbge dblt dbgt dble
4057 dbf dbra dbt
4058@end smallexample
4059
4060Other than for word and byte displacements, when the source reads
4061@samp{db@var{XX} foo}, @code{as} will emit
4062@smallexample
4063 db@var{XX} oo1
4064 bra oo2
4065 oo1:jmpl foo
4066 oo2:
4067@end smallexample
4068
4069@item fj@var{XX}
4070This family includes
4071@smallexample
4072 fjne fjeq fjge fjlt fjgt fjle fjf
4073 fjt fjgl fjgle fjnge fjngl fjngle fjngt
4074 fjnle fjnlt fjoge fjogl fjogt fjole fjolt
4075 fjor fjseq fjsf fjsne fjst fjueq fjuge
4076 fjugt fjule fjult fjun
4077@end smallexample
4078
4079For branch targets that are not PC relative, @code{as} emits
4080@smallexample
4081 fb@var{NX} oof
4082 jmp foo
4083 oof:
4084@end smallexample
4085when it encounters @samp{fj@var{XX} foo}.
4086
4087@end table
4088
41ee6e91 4089@node M68K-Chars
169fff49
RP
4090@subsubsection Special Characters
4091
4092@cindex special characters, M680x0
4093@cindex M680x0 immediate character
4094@cindex immediate character, M680x0
4095@cindex M680x0 line comment character
4096@cindex line comment character, M680x0
4097@cindex comments, M680x0
4098The immediate character is @samp{#} for Sun compatibility. The
4099line-comment character is @samp{|}. If a @samp{#} appears at the
4100beginning of a line, it is treated as a comment unless it looks like
4101@samp{# line file}, in which case it is treated normally.
4102
41ee6e91 4103@node Sparc-Dependent
169fff49
RP
4104@section SPARC Dependent Features
4105
4106@cindex SPARC support
4107@menu
4108* Sparc-Opts:: Options
4109* Sparc-Float:: Floating Point
4110* Sparc-Directives:: Sparc Machine Directives
4111@end menu
4112
41ee6e91 4113@node Sparc-Opts
169fff49
RP
4114@subsection Options
4115
4116@cindex options for SPARC (none)
4117@cindex SPARC options (none)
4118The Sparc has no machine dependent options.
4119
4120@ignore
4121@c FIXME: (sparc) Fill in "syntax" section!
4122@c subsection syntax
4123I don't know anything about Sparc syntax. Someone who does
4124will have to write this section.
4125@end ignore
4126
41ee6e91 4127@node Sparc-Float
169fff49
RP
4128@subsection Floating Point
4129
4130@cindex floating point, SPARC (@sc{ieee})
4131@cindex SPARC floating point (@sc{ieee})
4132The Sparc uses @sc{ieee} floating-point numbers.
4133
41ee6e91 4134@node Sparc-Directives
169fff49
RP
4135@subsection Sparc Machine Directives
4136
4137@cindex SPARC machine directives
4138@cindex machine directives, SPARC
4139The Sparc version of @code{as} supports the following additional
4140machine directives:
4141
4142@table @code
4143@item .common
4144@cindex @code{common} directive, SPARC
4145This must be followed by a symbol name, a positive number, and
4146@code{"bss"}. This behaves somewhat like @code{.comm}, but the
4147syntax is different.
4148
4149@item .half
4150@cindex @code{half} directive, SPARC
4151This is functionally identical to @code{.short}.
4152
4153@item .proc
4154@cindex @code{proc} directive, SPARC
4155This directive is ignored. Any text following it on the same
4156line is also ignored.
4157
4158@item .reserve
4159@cindex @code{reserve} directive, SPARC
4160This must be followed by a symbol name, a positive number, and
4161@code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
4162syntax is different.
4163
4164@item .seg
4165@cindex @code{seg} directive, SPARC
4166This must be followed by @code{"text"}, @code{"data"}, or
4167@code{"data1"}. It behaves like @code{.text}, @code{.data}, or
4168@code{.data 1}.
4169
4170@item .skip
4171@cindex @code{skip} directive, SPARC
4172This is functionally identical to the @code{.space} directive.
4173
4174@item .word
4175@cindex @code{word} directive, SPARC
4176On the Sparc, the .word directive produces 32 bit values,
4177instead of the 16 bit values it produces on many other machines.
4178@end table
4179
41ee6e91 4180@node i386-Dependent
169fff49
RP
4181@section 80386 Dependent Features
4182
4183@cindex i386 support
4184@cindex i80306 support
4185@menu
4186* i386-Options:: Options
4187* i386-Syntax:: AT&T Syntax versus Intel Syntax
4188* i386-Opcodes:: Opcode Naming
4189* i386-Regs:: Register Naming
4190* i386-prefixes:: Opcode Prefixes
4191* i386-Memory:: Memory References
4192* i386-jumps:: Handling of Jump Instructions
4193* i386-Float:: Floating Point
4194* i386-Notes:: Notes
4195@end menu
4196
41ee6e91 4197@node i386-Options
169fff49
RP
4198@subsection Options
4199
4200@cindex options for i386 (none)
4201@cindex i386 options (none)
4202The 80386 has no machine dependent options.
4203
41ee6e91 4204@node i386-Syntax
169fff49
RP
4205@subsection AT&T Syntax versus Intel Syntax
4206
4207@cindex i386 syntax compatibility
4208@cindex syntax compatibility, i386
4209In order to maintain compatibility with the output of @code{gcc},
4210@code{as} supports AT&T System V/386 assembler syntax. This is quite
4211different from Intel syntax. We mention these differences because
4212almost all 80386 documents used only Intel syntax. Notable differences
4213between the two syntaxes are:
4214
4215@itemize @bullet
4216@item
4217@cindex immediate operands, i386
4218@cindex i386 immediate operands
4219@cindex register operands, i386
4220@cindex i386 register operands
4221@cindex jump/call operands, i386
4222@cindex i386 jump/call operands
4223@cindex operand delimiters, i386
4224AT&T immediate operands are preceded by @samp{$}; Intel immediate
4225operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
4226AT&T register operands are preceded by @samp{%}; Intel register operands
4227are undelimited. AT&T absolute (as opposed to PC relative) jump/call
4228operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
4229
4230@item
4231@cindex i386 source, destination operands
4232@cindex source, destination operands; i386
4233AT&T and Intel syntax use the opposite order for source and destination
4234operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
4235@samp{source, dest} convention is maintained for compatibility with
4236previous Unix assemblers.
4237
4238@item
4239@cindex opcode suffixes, i386
4240@cindex sizes operands, i386
4241@cindex i386 size suffixes
4242In AT&T syntax the size of memory operands is determined from the last
4243character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
4244and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
4245memory references. Intel syntax accomplishes this by prefixes memory
4246operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
4247@samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
4248ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
4249
4250@item
4251@cindex return instructions, i386
4252@cindex i386 jump, call, return
4253Immediate form long jumps and calls are
4254@samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
4255Intel syntax is
4256@samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
4257instruction
4258is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
4259@samp{ret far @var{stack-adjust}}.
4260
4261@item
4262@cindex sections, i386
4263@cindex i386 sections
4264The AT&T assembler does not provide support for multiple section
4265programs. Unix style systems expect all programs to be single sections.
4266@end itemize
4267
41ee6e91 4268@node i386-Opcodes
169fff49
RP
4269@subsection Opcode Naming
4270
4271@cindex i386 opcode naming
4272@cindex opcode naming, i386
4273Opcode names are suffixed with one character modifiers which specify the
4274size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
4275byte, word, and long operands. If no suffix is specified by an
4276instruction and it contains no memory operands then @code{as} tries to
4277fill in the missing suffix based on the destination register operand
4278(the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
4279to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
4280@samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
4281assembler which assumes that a missing opcode suffix implies long
4282operand size. (This incompatibility does not affect compiler output
4283since compilers always explicitly specify the opcode suffix.)
4284
4285Almost all opcodes have the same names in AT&T and Intel format. There
4286are a few exceptions. The sign extend and zero extend instructions need
4287two sizes to specify them. They need a size to sign/zero extend
4288@emph{from} and a size to zero extend @emph{to}. This is accomplished
4289by using two opcode suffixes in AT&T syntax. Base names for sign extend
4290and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
4291syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
4292suffixes are tacked on to this base name, the @emph{from} suffix before
4293the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
4294``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
4295thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
4296and @samp{wl} (from word to long).
4297
4298@cindex conversion instructions, i386
4299@cindex i386 conversion instructions
4300The Intel-syntax conversion instructions
4301
4302@itemize @bullet
4303@item
4304@samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
4305
4306@item
4307@samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
4308
4309@item
4310@samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
4311
4312@item
4313@samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
4314@end itemize
4315
4316@noindent
4317are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
4318AT&T naming. @code{as} accepts either naming for these instructions.
4319
4320@cindex jump instructions, i386
4321@cindex call instructions, i386
4322Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
4323AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
4324convention.
4325
41ee6e91 4326@node i386-Regs
169fff49
RP
4327@subsection Register Naming
4328
4329@cindex i386 registers
4330@cindex registers, i386
4331Register operands are always prefixes with @samp{%}. The 80386 registers
4332consist of
4333
4334@itemize @bullet
4335@item
4336the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
4337@samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
4338frame pointer), and @samp{%esp} (the stack pointer).
4339
4340@item
4341the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
4342@samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
4343
4344@item
4345the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
4346@samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
4347are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
4348@samp{%cx}, and @samp{%dx})
4349
4350@item
4351the 6 section registers @samp{%cs} (code section), @samp{%ds}
4352(data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
4353and @samp{%gs}.
4354
4355@item
4356the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
4357@samp{%cr3}.
4358
4359@item
4360the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
4361@samp{%db3}, @samp{%db6}, and @samp{%db7}.
4362
4363@item
4364the 2 test registers @samp{%tr6} and @samp{%tr7}.
4365
4366@item
4367the 8 floating point register stack @samp{%st} or equivalently
4368@samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
4369@samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
4370@end itemize
4371
41ee6e91 4372@node i386-prefixes
169fff49
RP
4373@subsection Opcode Prefixes
4374
4375@cindex i386 opcode prefixes
4376@cindex opcode prefixes, i386
4377@cindex prefixes, i386
4378Opcode prefixes are used to modify the following opcode. They are used
4379to repeat string instructions, to provide section overrides, to perform
4380bus lock operations, and to give operand and address size (16-bit
4381operands are specified in an instruction by prefixing what would
4382normally be 32-bit operands with a ``operand size'' opcode prefix).
4383Opcode prefixes are usually given as single-line instructions with no
4384operands, and must directly precede the instruction they act upon. For
4385example, the @samp{scas} (scan string) instruction is repeated with:
4386@smallexample
4387 repne
4388 scas
4389@end smallexample
4390
4391Here is a list of opcode prefixes:
4392
4393@itemize @bullet
4394@item
4395@cindex section override prefixes, i386
4396Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
4397@samp{fs}, @samp{gs}. These are automatically added by specifying
4398using the @var{section}:@var{memory-operand} form for memory references.
4399
4400@item
4401@cindex size prefixes, i386
4402Operand/Address size prefixes @samp{data16} and @samp{addr16}
4403change 32-bit operands/addresses into 16-bit operands/addresses. Note
4404that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
4405are not supported (yet).
4406
4407@item
4408@cindex bus lock prefixes, i386
4409@cindex inhibiting interrupts, i386
4410The bus lock prefix @samp{lock} inhibits interrupts during
4411execution of the instruction it precedes. (This is only valid with
4412certain instructions; see a 80386 manual for details).
4413
4414@item
4415@cindex coprocessor wait, i386
4416The wait for coprocessor prefix @samp{wait} waits for the
4417coprocessor to complete the current instruction. This should never be
4418needed for the 80386/80387 combination.
4419
4420@item
4421@cindex repeat prefixes, i386
4422The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
4423to string instructions to make them repeat @samp{%ecx} times.
4424@end itemize
4425
41ee6e91 4426@node i386-Memory
169fff49
RP
4427@subsection Memory References
4428
4429@cindex i386 memory references
4430@cindex memory references, i386
4431An Intel syntax indirect memory reference of the form
4432
4433@smallexample
4434@var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
4435@end smallexample
4436
4437@noindent
4438is translated into the AT&T syntax
4439
4440@smallexample
4441@var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
4442@end smallexample
4443
4444@noindent
4445where @var{base} and @var{index} are the optional 32-bit base and
4446index registers, @var{disp} is the optional displacement, and
4447@var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
4448to calculate the address of the operand. If no @var{scale} is
4449specified, @var{scale} is taken to be 1. @var{section} specifies the
4450optional section register for the memory operand, and may override the
4451default section register (see a 80386 manual for section register
4452defaults). Note that section overrides in AT&T syntax @emph{must} have
4453be preceded by a @samp{%}. If you specify a section override which
4454coincides with the default section register, @code{as} will @emph{not}
4455output any section register override prefixes to assemble the given
4456instruction. Thus, section overrides can be specified to emphasize which
4457section register is used for a given memory operand.
4458
4459Here are some examples of Intel and AT&T style memory references:
4460
4461@table @asis
4462@item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
4463@var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
4464missing, and the default section is used (@samp{%ss} for addressing with
4465@samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
4466
4467@item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
4468@var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
4469@samp{foo}. All other fields are missing. The section register here
4470defaults to @samp{%ds}.
4471
4472@item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
4473This uses the value pointed to by @samp{foo} as a memory operand.
4474Note that @var{base} and @var{index} are both missing, but there is only
4475@emph{one} @samp{,}. This is a syntactic exception.
4476
4477@item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
4478This selects the contents of the variable @samp{foo} with section
4479register @var{section} being @samp{%gs}.
4480@end table
4481
4482Absolute (as opposed to PC relative) call and jump operands must be
4483prefixed with @samp{*}. If no @samp{*} is specified, @code{as} will
4484always choose PC relative addressing for jump/call labels.
4485
4486Any instruction that has a memory operand @emph{must} specify its size (byte,
4487word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
4488respectively).
4489
41ee6e91 4490@node i386-jumps
169fff49
RP
4491@subsection Handling of Jump Instructions
4492
4493@cindex jump optimization, i386
4494@cindex i386 jump optimization
4495Jump instructions are always optimized to use the smallest possible
4496displacements. This is accomplished by using byte (8-bit) displacement
4497jumps whenever the target is sufficiently close. If a byte displacement
4498is insufficient a long (32-bit) displacement is used. We do not support
4499word (16-bit) displacement jumps (i.e. prefixing the jump instruction
4500with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
4501@samp{%eip} to 16 bits after the word displacement is added.
4502
4503Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
4504@samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
4505byte displacements, so that it is possible that use of these
4506instructions (@code{gcc} does not use them) will cause the assembler to
4507print an error message (and generate incorrect code). The AT&T 80386
4508assembler tries to get around this problem by expanding @samp{jcxz foo} to
4509@smallexample
4510 jcxz cx_zero
4511 jmp cx_nonzero
4512cx_zero: jmp foo
4513cx_nonzero:
4514@end smallexample
4515
41ee6e91 4516@node i386-Float
169fff49
RP
4517@subsection Floating Point
4518
4519@cindex i386 floating point
4520@cindex floating point, i386
4521All 80387 floating point types except packed BCD are supported.
4522(BCD support may be added without much difficulty). These data
4523types are 16-, 32-, and 64- bit integers, and single (32-bit),
4524double (64-bit), and extended (80-bit) precision floating point.
4525Each supported type has an opcode suffix and a constructor
4526associated with it. Opcode suffixes specify operand's data
4527types. Constructors build these data types into memory.
4528
4529@itemize @bullet
4530@item
4531@cindex @code{float} directive, i386
4532@cindex @code{single} directive, i386
4533@cindex @code{double} directive, i386
4534@cindex @code{tfloat} directive, i386
4535Floating point constructors are @samp{.float} or @samp{.single},
4536@samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
4537These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
4538@samp{t} stands for temporary real, and that the 80387 only supports
4539this format via the @samp{fldt} (load temporary real to stack top) and
4540@samp{fstpt} (store temporary real and pop stack) instructions.
4541
4542@item
4543@cindex @code{word} directive, i386
4544@cindex @code{long} directive, i386
4545@cindex @code{int} directive, i386
4546@cindex @code{quad} directive, i386
4547Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
4548@samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
4549opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
4550(quad). As with the temporary real format the 64-bit @samp{q} format is
4551only present in the @samp{fildq} (load quad integer to stack top) and
4552@samp{fistpq} (store quad integer and pop stack) instructions.
4553@end itemize
4554
4555Register to register operations do not require opcode suffixes,
4556so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
4557
4558@cindex i386 @code{fwait} instruction
4559@cindex @code{fwait instruction}, i386
4560Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
4561instructions are almost never needed (this is not the case for the
456280286/80287 and 8086/8087 combinations). Therefore, @code{as} suppresses
4563the @samp{fwait} instruction whenever it is implicitly selected by one
4564of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
4565@samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
4566instructions are made equivalent to @samp{f@dots{}} instructions. If
4567@samp{fwait} is desired it must be explicitly coded.
4568
41ee6e91 4569@node i386-Notes
169fff49
RP
4570@subsection Notes
4571
4572@cindex i386 @code{mul}, @code{imul} instructions
4573@cindex @code{mul} instruction, i386
4574@cindex @code{imul} instruction, i386
4575There is some trickery concerning the @samp{mul} and @samp{imul}
4576instructions that deserves mention. The 16-, 32-, and 64-bit expanding
4577multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
4578for @samp{imul}) can be output only in the one operand form. Thus,
4579@samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
4580the expanding multiply would clobber the @samp{%edx} register, and this
4581would confuse @code{gcc} output. Use @samp{imul %ebx} to get the
458264-bit product in @samp{%edx:%eax}.
4583
4584We have added a two operand form of @samp{imul} when the first operand
4585is an immediate mode expression and the second operand is a register.
4586This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
4587example, can be done with @samp{imul $69, %eax} rather than @samp{imul
4588$69, %eax, %eax}.
4589
4590
41ee6e91 4591@node Copying
169fff49
RP
4592@unnumbered GNU GENERAL PUBLIC LICENSE
4593
4594@cindex license
4595@cindex GPL
4596@cindex copying @code{as}
4597@center Version 2, June 1991
4598
4599@display
4600Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
4601675 Mass Ave, Cambridge, MA 02139, USA
4602
4603Everyone is permitted to copy and distribute verbatim copies
4604of this license document, but changing it is not allowed.
4605@end display
4606
4607@unnumberedsec Preamble
4608
4609 The licenses for most software are designed to take away your
4610freedom to share and change it. By contrast, the GNU General Public
4611License is intended to guarantee your freedom to share and change free
4612software---to make sure the software is free for all its users. This
4613General Public License applies to most of the Free Software
4614Foundation's software and to any other program whose authors commit to
4615using it. (Some other Free Software Foundation software is covered by
4616the GNU Library General Public License instead.) You can apply it to
4617your programs, too.
4618
4619 When we speak of free software, we are referring to freedom, not
4620price. Our General Public Licenses are designed to make sure that you
4621have the freedom to distribute copies of free software (and charge for
4622this service if you wish), that you receive source code or can get it
4623if you want it, that you can change the software or use pieces of it
4624in new free programs; and that you know you can do these things.
4625
4626 To protect your rights, we need to make restrictions that forbid
4627anyone to deny you these rights or to ask you to surrender the rights.
4628These restrictions translate to certain responsibilities for you if you
4629distribute copies of the software, or if you modify it.
4630
4631 For example, if you distribute copies of such a program, whether
4632gratis or for a fee, you must give the recipients all the rights that
4633you have. You must make sure that they, too, receive or can get the
4634source code. And you must show them these terms so they know their
4635rights.
4636
4637 We protect your rights with two steps: (1) copyright the software, and
4638(2) offer you this license which gives you legal permission to copy,
4639distribute and/or modify the software.
4640
4641 Also, for each author's protection and ours, we want to make certain
4642that everyone understands that there is no warranty for this free
4643software. If the software is modified by someone else and passed on, we
4644want its recipients to know that what they have is not the original, so
4645that any problems introduced by others will not reflect on the original
4646authors' reputations.
4647
4648 Finally, any free program is threatened constantly by software
4649patents. We wish to avoid the danger that redistributors of a free
4650program will individually obtain patent licenses, in effect making the
4651program proprietary. To prevent this, we have made it clear that any
4652patent must be licensed for everyone's free use or not licensed at all.
4653
4654 The precise terms and conditions for copying, distribution and
4655modification follow.
4656
4657@iftex
4658@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4659@end iftex
4660@ifinfo
4661@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4662@end ifinfo
4663
4664@enumerate
4665@item
4666This License applies to any program or other work which contains
4667a notice placed by the copyright holder saying it may be distributed
4668under the terms of this General Public License. The ``Program'', below,
4669refers to any such program or work, and a ``work based on the Program''
4670means either the Program or any derivative work under copyright law:
4671that is to say, a work containing the Program or a portion of it,
4672either verbatim or with modifications and/or translated into another
4673language. (Hereinafter, translation is included without limitation in
4674the term ``modification''.) Each licensee is addressed as ``you''.
4675
4676Activities other than copying, distribution and modification are not
4677covered by this License; they are outside its scope. The act of
4678running the Program is not restricted, and the output from the Program
4679is covered only if its contents constitute a work based on the
4680Program (independent of having been made by running the Program).
4681Whether that is true depends on what the Program does.
4682
4683@item
4684You may copy and distribute verbatim copies of the Program's
4685source code as you receive it, in any medium, provided that you
4686conspicuously and appropriately publish on each copy an appropriate
4687copyright notice and disclaimer of warranty; keep intact all the
4688notices that refer to this License and to the absence of any warranty;
4689and give any other recipients of the Program a copy of this License
4690along with the Program.
4691
4692You may charge a fee for the physical act of transferring a copy, and
4693you may at your option offer warranty protection in exchange for a fee.
4694
4695@item
4696You may modify your copy or copies of the Program or any portion
4697of it, thus forming a work based on the Program, and copy and
4698distribute such modifications or work under the terms of Section 1
4699above, provided that you also meet all of these conditions:
4700
4701@enumerate a
4702@item
4703You must cause the modified files to carry prominent notices
4704stating that you changed the files and the date of any change.
4705
4706@item
4707You must cause any work that you distribute or publish, that in
4708whole or in part contains or is derived from the Program or any
4709part thereof, to be licensed as a whole at no charge to all third
4710parties under the terms of this License.
4711
4712@item
4713If the modified program normally reads commands interactively
4714when run, you must cause it, when started running for such
4715interactive use in the most ordinary way, to print or display an
4716announcement including an appropriate copyright notice and a
4717notice that there is no warranty (or else, saying that you provide
4718a warranty) and that users may redistribute the program under
4719these conditions, and telling the user how to view a copy of this
4720License. (Exception: if the Program itself is interactive but
4721does not normally print such an announcement, your work based on
4722the Program is not required to print an announcement.)
4723@end enumerate
4724
4725These requirements apply to the modified work as a whole. If
4726identifiable sections of that work are not derived from the Program,
4727and can be reasonably considered independent and separate works in
4728themselves, then this License, and its terms, do not apply to those
4729sections when you distribute them as separate works. But when you
4730distribute the same sections as part of a whole which is a work based
4731on the Program, the distribution of the whole must be on the terms of
4732this License, whose permissions for other licensees extend to the
4733entire whole, and thus to each and every part regardless of who wrote it.
4734
4735Thus, it is not the intent of this section to claim rights or contest
4736your rights to work written entirely by you; rather, the intent is to
4737exercise the right to control the distribution of derivative or
4738collective works based on the Program.
4739
4740In addition, mere aggregation of another work not based on the Program
4741with the Program (or with a work based on the Program) on a volume of
4742a storage or distribution medium does not bring the other work under
4743the scope of this License.
4744
4745@item
4746You may copy and distribute the Program (or a work based on it,
4747under Section 2) in object code or executable form under the terms of
4748Sections 1 and 2 above provided that you also do one of the following:
4749
4750@enumerate a
4751@item
4752Accompany it with the complete corresponding machine-readable
4753source code, which must be distributed under the terms of Sections
47541 and 2 above on a medium customarily used for software interchange; or,
4755
4756@item
4757Accompany it with a written offer, valid for at least three
4758years, to give any third party, for a charge no more than your
4759cost of physically performing source distribution, a complete
4760machine-readable copy of the corresponding source code, to be
4761distributed under the terms of Sections 1 and 2 above on a medium
4762customarily used for software interchange; or,
4763
4764@item
4765Accompany it with the information you received as to the offer
4766to distribute corresponding source code. (This alternative is
4767allowed only for noncommercial distribution and only if you
4768received the program in object code or executable form with such
4769an offer, in accord with Subsection b above.)
4770@end enumerate
4771
4772The source code for a work means the preferred form of the work for
4773making modifications to it. For an executable work, complete source
4774code means all the source code for all modules it contains, plus any
4775associated interface definition files, plus the scripts used to
4776control compilation and installation of the executable. However, as a
4777special exception, the source code distributed need not include
4778anything that is normally distributed (in either source or binary
4779form) with the major components (compiler, kernel, and so on) of the
4780operating system on which the executable runs, unless that component
4781itself accompanies the executable.
4782
4783If distribution of executable or object code is made by offering
4784access to copy from a designated place, then offering equivalent
4785access to copy the source code from the same place counts as
4786distribution of the source code, even though third parties are not
4787compelled to copy the source along with the object code.
4788
4789@item
4790You may not copy, modify, sublicense, or distribute the Program
4791except as expressly provided under this License. Any attempt
4792otherwise to copy, modify, sublicense or distribute the Program is
4793void, and will automatically terminate your rights under this License.
4794However, parties who have received copies, or rights, from you under
4795this License will not have their licenses terminated so long as such
4796parties remain in full compliance.
4797
4798@item
4799You are not required to accept this License, since you have not
4800signed it. However, nothing else grants you permission to modify or
4801distribute the Program or its derivative works. These actions are
4802prohibited by law if you do not accept this License. Therefore, by
4803modifying or distributing the Program (or any work based on the
4804Program), you indicate your acceptance of this License to do so, and
4805all its terms and conditions for copying, distributing or modifying
4806the Program or works based on it.
4807
4808@item
4809Each time you redistribute the Program (or any work based on the
4810Program), the recipient automatically receives a license from the
4811original licensor to copy, distribute or modify the Program subject to
4812these terms and conditions. You may not impose any further
4813restrictions on the recipients' exercise of the rights granted herein.
4814You are not responsible for enforcing compliance by third parties to
4815this License.
4816
4817@item
4818If, as a consequence of a court judgment or allegation of patent
4819infringement or for any other reason (not limited to patent issues),
4820conditions are imposed on you (whether by court order, agreement or
4821otherwise) that contradict the conditions of this License, they do not
4822excuse you from the conditions of this License. If you cannot
4823distribute so as to satisfy simultaneously your obligations under this
4824License and any other pertinent obligations, then as a consequence you
4825may not distribute the Program at all. For example, if a patent
4826license would not permit royalty-free redistribution of the Program by
4827all those who receive copies directly or indirectly through you, then
4828the only way you could satisfy both it and this License would be to
4829refrain entirely from distribution of the Program.
4830
4831If any portion of this section is held invalid or unenforceable under
4832any particular circumstance, the balance of the section is intended to
4833apply and the section as a whole is intended to apply in other
4834circumstances.
4835
4836It is not the purpose of this section to induce you to infringe any
4837patents or other property right claims or to contest validity of any
4838such claims; this section has the sole purpose of protecting the
4839integrity of the free software distribution system, which is
4840implemented by public license practices. Many people have made
4841generous contributions to the wide range of software distributed
4842through that system in reliance on consistent application of that
4843system; it is up to the author/donor to decide if he or she is willing
4844to distribute software through any other system and a licensee cannot
4845impose that choice.
4846
4847This section is intended to make thoroughly clear what is believed to
4848be a consequence of the rest of this License.
4849
4850@item
4851If the distribution and/or use of the Program is restricted in
4852certain countries either by patents or by copyrighted interfaces, the
4853original copyright holder who places the Program under this License
4854may add an explicit geographical distribution limitation excluding
4855those countries, so that distribution is permitted only in or among
4856countries not thus excluded. In such case, this License incorporates
4857the limitation as if written in the body of this License.
4858
4859@item
4860The Free Software Foundation may publish revised and/or new versions
4861of the General Public License from time to time. Such new versions will
4862be similar in spirit to the present version, but may differ in detail to
4863address new problems or concerns.
4864
4865Each version is given a distinguishing version number. If the Program
4866specifies a version number of this License which applies to it and ``any
4867later version'', you have the option of following the terms and conditions
4868either of that version or of any later version published by the Free
4869Software Foundation. If the Program does not specify a version number of
4870this License, you may choose any version ever published by the Free Software
4871Foundation.
4872
4873@item
4874If you wish to incorporate parts of the Program into other free
4875programs whose distribution conditions are different, write to the author
4876to ask for permission. For software which is copyrighted by the Free
4877Software Foundation, write to the Free Software Foundation; we sometimes
4878make exceptions for this. Our decision will be guided by the two goals
4879of preserving the free status of all derivatives of our free software and
4880of promoting the sharing and reuse of software generally.
4881
4882@iftex
4883@heading NO WARRANTY
4884@end iftex
4885@ifinfo
4886@center NO WARRANTY
4887@end ifinfo
4888
4889@item
4890BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
4891FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
4892OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
4893PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
4894OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4895MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
4896TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
4897PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
4898REPAIR OR CORRECTION.
4899
4900@item
4901IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
4902WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
4903REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
4904INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
4905OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
4906TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
4907YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
4908PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
4909POSSIBILITY OF SUCH DAMAGES.
4910@end enumerate
4911
4912@iftex
4913@heading END OF TERMS AND CONDITIONS
4914@end iftex
4915@ifinfo
4916@center END OF TERMS AND CONDITIONS
4917@end ifinfo
4918
4919@page
4920@unnumberedsec Applying These Terms to Your New Programs
4921
4922 If you develop a new program, and you want it to be of the greatest
4923possible use to the public, the best way to achieve this is to make it
4924free software which everyone can redistribute and change under these terms.
4925
4926 To do so, attach the following notices to the program. It is safest
4927to attach them to the start of each source file to most effectively
4928convey the exclusion of warranty; and each file should have at least
4929the ``copyright'' line and a pointer to where the full notice is found.
4930
4931@smallexample
4932@var{one line to give the program's name and an idea of what it does.}
4933Copyright (C) 19@var{yy} @var{name of author}
4934
4935This program is free software; you can redistribute it and/or
4936modify it under the terms of the GNU General Public License
4937as published by the Free Software Foundation; either version 2
4938of the License, or (at your option) any later version.
4939
4940This program is distributed in the hope that it will be useful,
4941but WITHOUT ANY WARRANTY; without even the implied warranty of
4942MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4943GNU General Public License for more details.
4944
4945You should have received a copy of the GNU General Public License
4946along with this program; if not, write to the
4947Free Software Foundation, Inc., 675 Mass Ave,
4948Cambridge, MA 02139, USA.
4949@end smallexample
4950
4951Also add information on how to contact you by electronic and paper mail.
4952
4953If the program is interactive, make it output a short notice like this
4954when it starts in an interactive mode:
4955
4956@smallexample
4957Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
4958Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
4959type `show w'. This is free software, and you are welcome
4960to redistribute it under certain conditions; type `show c'
4961for details.
4962@end smallexample
4963
4964The hypothetical commands @samp{show w} and @samp{show c} should show
4965the appropriate parts of the General Public License. Of course, the
4966commands you use may be called something other than @samp{show w} and
4967@samp{show c}; they could even be mouse-clicks or menu items---whatever
4968suits your program.
4969
4970You should also get your employer (if you work as a programmer) or your
4971school, if any, to sign a ``copyright disclaimer'' for the program, if
4972necessary. Here is a sample; alter the names:
4973
4974@smallexample
4975Yoyodyne, Inc., hereby disclaims all copyright interest in
4976the program `Gnomovision' (which makes passes at compilers)
4977written by James Hacker.
4978
4979@var{signature of Ty Coon}, 1 April 1989
4980Ty Coon, President of Vice
4981@end smallexample
4982
4983This General Public License does not permit incorporating your program into
4984proprietary programs. If your program is a subroutine library, you may
4985consider it more useful to permit linking proprietary applications with the
4986library. If this is what you want to do, use the GNU Library General
4987Public License instead of this License.
4988
41ee6e91 4989@node Index
169fff49
RP
4990@unnumbered Index
4991
4992@printindex cp
4993
4994@summarycontents
4995@contents
4996@bye
This page took 0.213421 seconds and 4 git commands to generate.