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