Commit | Line | Data |
---|---|---|
252b5132 | 1 | \input texinfo @c -*-Texinfo-*- |
f7e42eb4 | 2 | @c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
28c9d252 | 3 | @c 2001, 2002, 2003, 2004, 2005, 2006 |
252b5132 RH |
4 | @c Free Software Foundation, Inc. |
5 | @c UPDATE!! On future updates-- | |
6 | @c (1) check for new machine-dep cmdline options in | |
7 | @c md_parse_option definitions in config/tc-*.c | |
8 | @c (2) for platform-specific directives, examine md_pseudo_op | |
9 | @c in config/tc-*.c | |
10 | @c (3) for object-format specific directives, examine obj_pseudo_op | |
11 | @c in config/obj-*.c | |
12 | @c (4) portable directives in potable[] in read.c | |
13 | @c %**start of header | |
14 | @setfilename as.info | |
15 | @c ---config--- | |
a4fb0134 SC |
16 | @macro gcctabopt{body} |
17 | @code{\body\} | |
18 | @end macro | |
252b5132 RH |
19 | @c defaults, config file may override: |
20 | @set have-stabs | |
21 | @c --- | |
4a4c4a1d MR |
22 | @c man begin NAME |
23 | @c --- | |
252b5132 RH |
24 | @include asconfig.texi |
25 | @include gasver.texi | |
26 | @c --- | |
0285c67d | 27 | @c man end |
4a4c4a1d | 28 | @c --- |
252b5132 | 29 | @c common OR combinations of conditions |
c1253627 NC |
30 | @ifset COFF |
31 | @set COFF-ELF | |
32 | @end ifset | |
33 | @ifset ELF | |
34 | @set COFF-ELF | |
35 | @end ifset | |
252b5132 RH |
36 | @ifset AOUT |
37 | @set aout-bout | |
38 | @end ifset | |
39 | @ifset ARM/Thumb | |
40 | @set ARM | |
41 | @end ifset | |
42 | @ifset BOUT | |
43 | @set aout-bout | |
44 | @end ifset | |
45 | @ifset H8/300 | |
46 | @set H8 | |
47 | @end ifset | |
252b5132 RH |
48 | @ifset SH |
49 | @set H8 | |
50 | @end ifset | |
51 | @ifset HPPA | |
52 | @set abnormal-separator | |
53 | @end ifset | |
54 | @c ------------ | |
55 | @ifset GENERIC | |
56 | @settitle Using @value{AS} | |
57 | @end ifset | |
58 | @ifclear GENERIC | |
59 | @settitle Using @value{AS} (@value{TARGET}) | |
60 | @end ifclear | |
61 | @setchapternewpage odd | |
62 | @c %**end of header | |
63 | ||
64 | @c @smallbook | |
65 | @c @set SMALL | |
66 | @c WARE! Some of the machine-dependent sections contain tables of machine | |
67 | @c instructions. Except in multi-column format, these tables look silly. | |
68 | @c Unfortunately, Texinfo doesn't have a general-purpose multi-col format, so | |
69 | @c the multi-col format is faked within @example sections. | |
70 | @c | |
71 | @c Again unfortunately, the natural size that fits on a page, for these tables, | |
72 | @c is different depending on whether or not smallbook is turned on. | |
73 | @c This matters, because of order: text flow switches columns at each page | |
74 | @c break. | |
75 | @c | |
76 | @c The format faked in this source works reasonably well for smallbook, | |
77 | @c not well for the default large-page format. This manual expects that if you | |
78 | @c turn on @smallbook, you will also uncomment the "@set SMALL" to enable the | |
79 | @c tables in question. You can turn on one without the other at your | |
80 | @c discretion, of course. | |
81 | @ifinfo | |
82 | @set SMALL | |
83 | @c the insn tables look just as silly in info files regardless of smallbook, | |
84 | @c might as well show 'em anyways. | |
85 | @end ifinfo | |
86 | ||
87 | @ifinfo | |
88 | @format | |
89 | START-INFO-DIR-ENTRY | |
90 | * As: (as). The GNU assembler. | |
59455fb1 | 91 | * Gas: (as). The GNU assembler. |
252b5132 RH |
92 | END-INFO-DIR-ENTRY |
93 | @end format | |
94 | @end ifinfo | |
95 | ||
96 | @finalout | |
97 | @syncodeindex ky cp | |
98 | ||
99 | @ifinfo | |
100 | This file documents the GNU Assembler "@value{AS}". | |
101 | ||
0285c67d | 102 | @c man begin COPYRIGHT |
28c9d252 | 103 | Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006 Free Software Foundation, Inc. |
252b5132 | 104 | |
0285c67d NC |
105 | Permission is granted to copy, distribute and/or modify this document |
106 | under the terms of the GNU Free Documentation License, Version 1.1 | |
107 | or any later version published by the Free Software Foundation; | |
108 | with no Invariant Sections, with no Front-Cover Texts, and with no | |
109 | Back-Cover Texts. A copy of the license is included in the | |
c1253627 | 110 | section entitled ``GNU Free Documentation License''. |
0285c67d NC |
111 | |
112 | @c man end | |
252b5132 RH |
113 | |
114 | @ignore | |
115 | Permission is granted to process this file through Tex and print the | |
116 | results, provided the printed document carries copying permission | |
117 | notice identical to this one except for the removal of this paragraph | |
118 | (this paragraph not being relevant to the printed manual). | |
119 | ||
120 | @end ignore | |
252b5132 RH |
121 | @end ifinfo |
122 | ||
123 | @titlepage | |
124 | @title Using @value{AS} | |
125 | @subtitle The @sc{gnu} Assembler | |
126 | @ifclear GENERIC | |
127 | @subtitle for the @value{TARGET} family | |
128 | @end ifclear | |
129 | @sp 1 | |
130 | @subtitle Version @value{VERSION} | |
131 | @sp 1 | |
132 | @sp 13 | |
b45619c0 | 133 | The Free Software Foundation Inc.@: thanks The Nice Computer |
252b5132 | 134 | Company of Australia for loaning Dean Elsner to write the |
a4fb0134 | 135 | first (Vax) version of @command{as} for Project @sc{gnu}. |
252b5132 RH |
136 | The proprietors, management and staff of TNCCA thank FSF for |
137 | distracting the boss while they got some work | |
138 | done. | |
139 | @sp 3 | |
140 | @author Dean Elsner, Jay Fenlason & friends | |
141 | @page | |
142 | @tex | |
143 | {\parskip=0pt | |
144 | \hfill {\it Using {\tt @value{AS}}}\par | |
145 | \hfill Edited by Cygnus Support\par | |
146 | } | |
147 | %"boxit" macro for figures: | |
148 | %Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3) | |
149 | \gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt | |
150 | \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil | |
151 | #2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline | |
152 | \gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box | |
153 | @end tex | |
154 | ||
155 | @vskip 0pt plus 1filll | |
28c9d252 | 156 | Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006 Free Software Foundation, Inc. |
252b5132 | 157 | |
cf055d54 NC |
158 | Permission is granted to copy, distribute and/or modify this document |
159 | under the terms of the GNU Free Documentation License, Version 1.1 | |
160 | or any later version published by the Free Software Foundation; | |
161 | with no Invariant Sections, with no Front-Cover Texts, and with no | |
162 | Back-Cover Texts. A copy of the license is included in the | |
c1253627 | 163 | section entitled ``GNU Free Documentation License''. |
252b5132 | 164 | |
252b5132 RH |
165 | @end titlepage |
166 | ||
2e64b665 | 167 | @ifnottex |
252b5132 RH |
168 | @node Top |
169 | @top Using @value{AS} | |
170 | ||
a4fb0134 | 171 | This file is a user guide to the @sc{gnu} assembler @command{@value{AS}} version |
252b5132 RH |
172 | @value{VERSION}. |
173 | @ifclear GENERIC | |
a4fb0134 | 174 | This version of the file describes @command{@value{AS}} configured to generate |
252b5132 RH |
175 | code for @value{TARGET} architectures. |
176 | @end ifclear | |
cf055d54 NC |
177 | |
178 | This document is distributed under the terms of the GNU Free | |
179 | Documentation License. A copy of the license is included in the | |
c1253627 | 180 | section entitled ``GNU Free Documentation License''. |
cf055d54 | 181 | |
252b5132 RH |
182 | @menu |
183 | * Overview:: Overview | |
184 | * Invoking:: Command-Line Options | |
185 | * Syntax:: Syntax | |
186 | * Sections:: Sections and Relocation | |
187 | * Symbols:: Symbols | |
188 | * Expressions:: Expressions | |
189 | * Pseudo Ops:: Assembler Directives | |
190 | * Machine Dependencies:: Machine Dependent Features | |
191 | * Reporting Bugs:: Reporting Bugs | |
192 | * Acknowledgements:: Who Did What | |
cf055d54 | 193 | * GNU Free Documentation License:: GNU Free Documentation License |
28c9d252 | 194 | * AS Index:: AS Index |
252b5132 | 195 | @end menu |
2e64b665 | 196 | @end ifnottex |
252b5132 RH |
197 | |
198 | @node Overview | |
199 | @chapter Overview | |
200 | @iftex | |
a4fb0134 | 201 | This manual is a user guide to the @sc{gnu} assembler @command{@value{AS}}. |
252b5132 | 202 | @ifclear GENERIC |
a4fb0134 | 203 | This version of the manual describes @command{@value{AS}} configured to generate |
252b5132 RH |
204 | code for @value{TARGET} architectures. |
205 | @end ifclear | |
206 | @end iftex | |
207 | ||
208 | @cindex invocation summary | |
209 | @cindex option summary | |
210 | @cindex summary of options | |
a4fb0134 | 211 | Here is a brief summary of how to invoke @command{@value{AS}}. For details, |
96e9638b | 212 | see @ref{Invoking,,Command-Line Options}. |
252b5132 | 213 | |
0285c67d NC |
214 | @c man title AS the portable GNU assembler. |
215 | ||
a4fb0134 | 216 | @ignore |
0285c67d NC |
217 | @c man begin SEEALSO |
218 | gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. | |
219 | @c man end | |
a4fb0134 | 220 | @end ignore |
0285c67d | 221 | |
252b5132 RH |
222 | @c We don't use deffn and friends for the following because they seem |
223 | @c to be limited to one line for the header. | |
224 | @smallexample | |
0285c67d | 225 | @c man begin SYNOPSIS |
caa32fe5 | 226 | @value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}] |
4bdd3565 NC |
227 | [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}] |
228 | [@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}] | |
229 | [@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}] | |
230 | [@b{--listing-lhs-width2}=@var{NUM}] [@b{--listing-rhs-width}=@var{NUM}] | |
231 | [@b{--listing-cont-lines}=@var{NUM}] [@b{--keep-locals}] [@b{-o} | |
232 | @var{objfile}] [@b{-R}] [@b{--reduce-memory-overheads}] [@b{--statistics}] | |
233 | [@b{-v}] [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}] | |
a0b7da79 MM |
234 | [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] [@b{-Z}] [@b{@@@var{FILE}}] |
235 | [@b{--target-help}] [@var{target-options}] | |
236 | [@b{--}|@var{files} @dots{}] | |
a4fb0134 SC |
237 | @c |
238 | @c Target dependent options are listed below. Keep the list sorted. | |
239 | @c Add an empty line for separation. | |
625e1353 RH |
240 | @ifset ALPHA |
241 | ||
242 | @emph{Target Alpha options:} | |
243 | [@b{-m@var{cpu}}] | |
244 | [@b{-mdebug} | @b{-no-mdebug}] | |
245 | [@b{-relax}] [@b{-g}] [@b{-G@var{size}}] | |
246 | [@b{-F}] [@b{-32addr}] | |
247 | @end ifset | |
252b5132 | 248 | @ifset ARC |
a4fb0134 SC |
249 | |
250 | @emph{Target ARC options:} | |
251 | [@b{-marc[5|6|7|8]}] | |
252 | [@b{-EB}|@b{-EL}] | |
252b5132 RH |
253 | @end ifset |
254 | @ifset ARM | |
a4fb0134 SC |
255 | |
256 | @emph{Target ARM options:} | |
03b1477f | 257 | @c Don't document the deprecated options |
92081f48 HPN |
258 | [@b{-mcpu}=@var{processor}[+@var{extension}@dots{}]] |
259 | [@b{-march}=@var{architecture}[+@var{extension}@dots{}]] | |
33a392fb PB |
260 | [@b{-mfpu}=@var{floating-point-format}] |
261 | [@b{-mfloat-abi}=@var{abi}] | |
d507cf36 | 262 | [@b{-meabi}=@var{ver}] |
03b1477f | 263 | [@b{-mthumb}] |
a4fb0134 SC |
264 | [@b{-EB}|@b{-EL}] |
265 | [@b{-mapcs-32}|@b{-mapcs-26}|@b{-mapcs-float}| | |
266 | @b{-mapcs-reentrant}] | |
7f266840 | 267 | [@b{-mthumb-interwork}] [@b{-k}] |
252b5132 | 268 | @end ifset |
328eb32e HPN |
269 | @ifset CRIS |
270 | ||
271 | @emph{Target CRIS options:} | |
272 | [@b{--underscore} | @b{--no-underscore}] | |
273 | [@b{--pic}] [@b{-N}] | |
274 | [@b{--emulation=criself} | @b{--emulation=crisaout}] | |
ae57792d | 275 | [@b{--march=v0_v10} | @b{--march=v10} | @b{--march=v32} | @b{--march=common_v10_v32}] |
328eb32e HPN |
276 | @c Deprecated -- deliberately not documented. |
277 | @c [@b{-h}] [@b{-H}] | |
278 | @end ifset | |
252b5132 | 279 | @ifset D10V |
a4fb0134 SC |
280 | |
281 | @emph{Target D10V options:} | |
282 | [@b{-O}] | |
252b5132 RH |
283 | @end ifset |
284 | @ifset D30V | |
a4fb0134 SC |
285 | |
286 | @emph{Target D30V options:} | |
287 | [@b{-O}|@b{-n}|@b{-N}] | |
252b5132 RH |
288 | @end ifset |
289 | @ifset H8 | |
c2dcd04e | 290 | @c Renesas family chips have no machine-dependent assembler options |
252b5132 RH |
291 | @end ifset |
292 | @ifset HPPA | |
293 | @c HPPA has no machine-dependent assembler options (yet). | |
294 | @end ifset | |
a4fb0134 SC |
295 | @ifset I80386 |
296 | ||
297 | @emph{Target i386 options:} | |
12b55ccc | 298 | [@b{--32}|@b{--64}] [@b{-n}] |
9103f4f4 | 299 | [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}] |
252b5132 RH |
300 | @end ifset |
301 | @ifset I960 | |
a4fb0134 SC |
302 | |
303 | @emph{Target i960 options:} | |
252b5132 | 304 | @c see md_parse_option in tc-i960.c |
a4fb0134 SC |
305 | [@b{-ACA}|@b{-ACA_A}|@b{-ACB}|@b{-ACC}|@b{-AKA}|@b{-AKB}| |
306 | @b{-AKC}|@b{-AMC}] | |
307 | [@b{-b}] [@b{-no-relax}] | |
252b5132 | 308 | @end ifset |
587fe2b3 | 309 | @ifset IA64 |
a4fb0134 | 310 | |
9e32ca89 NC |
311 | @emph{Target IA-64 options:} |
312 | [@b{-mconstant-gp}|@b{-mauto-pic}] | |
313 | [@b{-milp32}|@b{-milp64}|@b{-mlp64}|@b{-mp64}] | |
314 | [@b{-mle}|@b{mbe}] | |
8c2fda1d | 315 | [@b{-mtune=itanium1}|@b{-mtune=itanium2}] |
970d6792 | 316 | [@b{-munwind-check=warning}|@b{-munwind-check=error}] |
91d777ee | 317 | [@b{-mhint.b=ok}|@b{-mhint.b=warning}|@b{-mhint.b=error}] |
9e32ca89 NC |
318 | [@b{-x}|@b{-xexplicit}] [@b{-xauto}] [@b{-xdebug}] |
319 | @end ifset | |
a40cbfa3 NC |
320 | @ifset IP2K |
321 | ||
322 | @emph{Target IP2K options:} | |
323 | [@b{-mip2022}|@b{-mip2022ext}] | |
324 | @end ifset | |
49f58d10 JB |
325 | @ifset M32C |
326 | ||
327 | @emph{Target M32C options:} | |
328 | [@b{-m32c}|@b{-m16c}] | |
329 | @end ifset | |
587fe2b3 | 330 | @ifset M32R |
9e32ca89 | 331 | |
a4fb0134 SC |
332 | @emph{Target M32R options:} |
333 | [@b{--m32rx}|@b{--[no-]warn-explicit-parallel-conflicts}| | |
587fe2b3 | 334 | @b{--W[n]p}] |
ec694b89 | 335 | @end ifset |
252b5132 | 336 | @ifset M680X0 |
a4fb0134 SC |
337 | |
338 | @emph{Target M680X0 options:} | |
339 | [@b{-l}] [@b{-m68000}|@b{-m68010}|@b{-m68020}|@dots{}] | |
252b5132 | 340 | @end ifset |
60bcf0fa | 341 | @ifset M68HC11 |
a4fb0134 SC |
342 | |
343 | @emph{Target M68HC11 options:} | |
d01030e6 | 344 | [@b{-m68hc11}|@b{-m68hc12}|@b{-m68hcs12}] |
2f904664 SC |
345 | [@b{-mshort}|@b{-mlong}] |
346 | [@b{-mshort-double}|@b{-mlong-double}] | |
1370e33d | 347 | [@b{--force-long-branches}] [@b{--short-branches}] |
a4fb0134 SC |
348 | [@b{--strict-direct-mode}] [@b{--print-insn-syntax}] |
349 | [@b{--print-opcodes}] [@b{--generate-example}] | |
350 | @end ifset | |
351 | @ifset MCORE | |
352 | ||
353 | @emph{Target MCORE options:} | |
354 | [@b{-jsri2bsr}] [@b{-sifilter}] [@b{-relax}] | |
355 | [@b{-mcpu=[210|340]}] | |
60bcf0fa | 356 | @end ifset |
252b5132 | 357 | @ifset MIPS |
a4fb0134 SC |
358 | |
359 | @emph{Target MIPS options:} | |
78849248 | 360 | [@b{-nocpp}] [@b{-EL}] [@b{-EB}] [@b{-O}[@var{optimization level}]] |
437ee9d5 | 361 | [@b{-g}[@var{debug level}]] [@b{-G} @var{num}] [@b{-KPIC}] [@b{-call_shared}] |
1ffcab4b | 362 | [@b{-non_shared}] [@b{-xgot}] |
437ee9d5 TS |
363 | [@b{-mabi}=@var{ABI}] [@b{-32}] [@b{-n32}] [@b{-64}] [@b{-mfp32}] [@b{-mgp32}] |
364 | [@b{-march}=@var{CPU}] [@b{-mtune}=@var{CPU}] [@b{-mips1}] [@b{-mips2}] | |
af7ee8bf | 365 | [@b{-mips3}] [@b{-mips4}] [@b{-mips5}] [@b{-mips32}] [@b{-mips32r2}] |
5f74bc13 | 366 | [@b{-mips64}] [@b{-mips64r2}] |
437ee9d5 TS |
367 | [@b{-construct-floats}] [@b{-no-construct-floats}] |
368 | [@b{-trap}] [@b{-no-break}] [@b{-break}] [@b{-no-trap}] | |
369 | [@b{-mfix7000}] [@b{-mno-fix7000}] | |
370 | [@b{-mips16}] [@b{-no-mips16}] | |
e16bfa71 | 371 | [@b{-msmartmips}] [@b{-mno-smartmips}] |
1f25f5d3 | 372 | [@b{-mips3d}] [@b{-no-mips3d}] |
deec1734 | 373 | [@b{-mdmx}] [@b{-no-mdmx}] |
2ef2b9ae | 374 | [@b{-mdsp}] [@b{-mno-dsp}] |
ef2e4d86 | 375 | [@b{-mmt}] [@b{-mno-mt}] |
ecb4347a | 376 | [@b{-mdebug}] [@b{-no-mdebug}] |
dcd410fe | 377 | [@b{-mpdr}] [@b{-mno-pdr}] |
3c3bdf30 NC |
378 | @end ifset |
379 | @ifset MMIX | |
a4fb0134 SC |
380 | |
381 | @emph{Target MMIX options:} | |
382 | [@b{--fixed-special-register-names}] [@b{--globalize-symbols}] | |
383 | [@b{--gnu-syntax}] [@b{--relax}] [@b{--no-predefined-symbols}] | |
384 | [@b{--no-expand}] [@b{--no-merge-gregs}] [@b{-x}] | |
973eb340 | 385 | [@b{--linker-allocated-gregs}] |
a4fb0134 SC |
386 | @end ifset |
387 | @ifset PDP11 | |
388 | ||
389 | @emph{Target PDP11 options:} | |
390 | [@b{-mpic}|@b{-mno-pic}] [@b{-mall}] [@b{-mno-extensions}] | |
391 | [@b{-m}@var{extension}|@b{-mno-}@var{extension}] | |
392 | [@b{-m}@var{cpu}] [@b{-m}@var{machine}] | |
393 | @end ifset | |
394 | @ifset PJ | |
395 | ||
396 | @emph{Target picoJava options:} | |
397 | [@b{-mb}|@b{-me}] | |
398 | @end ifset | |
399 | @ifset PPC | |
400 | ||
401 | @emph{Target PowerPC options:} | |
402 | [@b{-mpwrx}|@b{-mpwr2}|@b{-mpwr}|@b{-m601}|@b{-mppc}|@b{-mppc32}|@b{-m603}|@b{-m604}| | |
403 | @b{-m403}|@b{-m405}|@b{-mppc64}|@b{-m620}|@b{-mppc64bridge}|@b{-mbooke}| | |
404 | @b{-mbooke32}|@b{-mbooke64}] | |
405 | [@b{-mcom}|@b{-many}|@b{-maltivec}] [@b{-memb}] | |
406 | [@b{-mregnames}|@b{-mno-regnames}] | |
407 | [@b{-mrelocatable}|@b{-mrelocatable-lib}] | |
408 | [@b{-mlittle}|@b{-mlittle-endian}|@b{-mbig}|@b{-mbig-endian}] | |
409 | [@b{-msolaris}|@b{-mno-solaris}] | |
410 | @end ifset | |
411 | @ifset SPARC | |
412 | ||
413 | @emph{Target SPARC options:} | |
414 | @c The order here is important. See c-sparc.texi. | |
415 | [@b{-Av6}|@b{-Av7}|@b{-Av8}|@b{-Asparclet}|@b{-Asparclite} | |
416 | @b{-Av8plus}|@b{-Av8plusa}|@b{-Av9}|@b{-Av9a}] | |
417 | [@b{-xarch=v8plus}|@b{-xarch=v8plusa}] [@b{-bump}] | |
418 | [@b{-32}|@b{-64}] | |
419 | @end ifset | |
420 | @ifset TIC54X | |
421 | ||
422 | @emph{Target TIC54X options:} | |
423 | [@b{-mcpu=54[123589]}|@b{-mcpu=54[56]lp}] [@b{-mfar-mode}|@b{-mf}] | |
424 | [@b{-merrors-to-file} @var{<filename>}|@b{-me} @var{<filename>}] | |
425 | @end ifset | |
3c9b82ba NC |
426 | |
427 | @ifset Z80 | |
428 | ||
429 | @emph{Target Z80 options:} | |
430 | [@b{-z80}] [@b{-r800}] | |
431 | [@b{ -ignore-undocumented-instructions}] [@b{-Wnud}] | |
432 | [@b{ -ignore-unportable-instructions}] [@b{-Wnup}] | |
433 | [@b{ -warn-undocumented-instructions}] [@b{-Wud}] | |
434 | [@b{ -warn-unportable-instructions}] [@b{-Wup}] | |
435 | [@b{ -forbid-undocumented-instructions}] [@b{-Fud}] | |
436 | [@b{ -forbid-unportable-instructions}] [@b{-Fup}] | |
437 | @end ifset | |
438 | ||
a4fb0134 SC |
439 | @ifset Z8000 |
440 | @c Z8000 has no machine-dependent assembler options | |
252b5132 | 441 | @end ifset |
e0001a05 NC |
442 | @ifset XTENSA |
443 | ||
444 | @emph{Target Xtensa options:} | |
43cd72b9 | 445 | [@b{--[no-]text-section-literals}] [@b{--[no-]absolute-literals}] |
e0001a05 | 446 | [@b{--[no-]target-align}] [@b{--[no-]longcalls}] |
43cd72b9 | 447 | [@b{--[no-]transform}] |
9456465c | 448 | [@b{--rename-section} @var{oldname}=@var{newname}] |
e0001a05 | 449 | @end ifset |
0285c67d | 450 | @c man end |
252b5132 RH |
451 | @end smallexample |
452 | ||
0285c67d NC |
453 | @c man begin OPTIONS |
454 | ||
a4fb0134 | 455 | @table @gcctabopt |
38fc1cb1 | 456 | @include at-file.texi |
a0b7da79 | 457 | |
252b5132 RH |
458 | @item -a[cdhlmns] |
459 | Turn on listings, in any of a variety of ways: | |
460 | ||
a4fb0134 | 461 | @table @gcctabopt |
252b5132 RH |
462 | @item -ac |
463 | omit false conditionals | |
464 | ||
465 | @item -ad | |
466 | omit debugging directives | |
467 | ||
468 | @item -ah | |
469 | include high-level source | |
470 | ||
471 | @item -al | |
472 | include assembly | |
473 | ||
474 | @item -am | |
475 | include macro expansions | |
476 | ||
477 | @item -an | |
478 | omit forms processing | |
479 | ||
480 | @item -as | |
481 | include symbols | |
482 | ||
483 | @item =file | |
484 | set the name of the listing file | |
485 | @end table | |
486 | ||
487 | You may combine these options; for example, use @samp{-aln} for assembly | |
488 | listing without forms processing. The @samp{=file} option, if used, must be | |
489 | the last one. By itself, @samp{-a} defaults to @samp{-ahls}. | |
490 | ||
caa32fe5 | 491 | @item --alternate |
96e9638b BW |
492 | Begin in alternate macro mode. |
493 | @ifclear man | |
494 | @xref{Altmacro,,@code{.altmacro}}. | |
495 | @end ifclear | |
caa32fe5 | 496 | |
252b5132 RH |
497 | @item -D |
498 | Ignored. This option is accepted for script compatibility with calls to | |
499 | other assemblers. | |
500 | ||
501 | @item --defsym @var{sym}=@var{value} | |
502 | Define the symbol @var{sym} to be @var{value} before assembling the input file. | |
503 | @var{value} must be an integer constant. As in C, a leading @samp{0x} | |
504 | indicates a hexadecimal value, and a leading @samp{0} indicates an octal value. | |
505 | ||
506 | @item -f | |
507 | ``fast''---skip whitespace and comment preprocessing (assume source is | |
508 | compiler output). | |
509 | ||
329e276d NC |
510 | @item -g |
511 | @itemx --gen-debug | |
512 | Generate debugging information for each assembler source line using whichever | |
513 | debug format is preferred by the target. This currently means either STABS, | |
514 | ECOFF or DWARF2. | |
515 | ||
252b5132 RH |
516 | @item --gstabs |
517 | Generate stabs debugging information for each assembler line. This | |
518 | may help debugging assembler code, if the debugger can handle it. | |
519 | ||
05da4302 NC |
520 | @item --gstabs+ |
521 | Generate stabs debugging information for each assembler line, with GNU | |
522 | extensions that probably only gdb can handle, and that could make other | |
523 | debuggers crash or refuse to read your program. This | |
524 | may help debugging assembler code. Currently the only GNU extension is | |
525 | the location of the current working directory at assembling time. | |
526 | ||
329e276d | 527 | @item --gdwarf-2 |
cdf82bcf | 528 | Generate DWARF2 debugging information for each assembler line. This |
c1253627 | 529 | may help debugging assembler code, if the debugger can handle it. Note---this |
85a39694 | 530 | option is only supported by some targets, not all of them. |
cdf82bcf | 531 | |
252b5132 RH |
532 | @item --help |
533 | Print a summary of the command line options and exit. | |
534 | ||
ea20a7da CC |
535 | @item --target-help |
536 | Print a summary of all target specific options and exit. | |
537 | ||
252b5132 RH |
538 | @item -I @var{dir} |
539 | Add directory @var{dir} to the search list for @code{.include} directives. | |
540 | ||
541 | @item -J | |
542 | Don't warn about signed overflow. | |
543 | ||
544 | @item -K | |
545 | @ifclear DIFF-TBL-KLUGE | |
546 | This option is accepted but has no effect on the @value{TARGET} family. | |
547 | @end ifclear | |
548 | @ifset DIFF-TBL-KLUGE | |
549 | Issue warnings when difference tables altered for long displacements. | |
550 | @end ifset | |
551 | ||
552 | @item -L | |
553 | @itemx --keep-locals | |
ba83aca1 BW |
554 | Keep (in the symbol table) local symbols. These symbols start with |
555 | system-specific local label prefixes, typically @samp{.L} for ELF systems | |
556 | or @samp{L} for traditional a.out systems. | |
557 | @ifclear man | |
558 | @xref{Symbol Names}. | |
559 | @end ifclear | |
252b5132 | 560 | |
c3a27914 NC |
561 | @item --listing-lhs-width=@var{number} |
562 | Set the maximum width, in words, of the output data column for an assembler | |
563 | listing to @var{number}. | |
564 | ||
565 | @item --listing-lhs-width2=@var{number} | |
566 | Set the maximum width, in words, of the output data column for continuation | |
567 | lines in an assembler listing to @var{number}. | |
568 | ||
569 | @item --listing-rhs-width=@var{number} | |
570 | Set the maximum width of an input source line, as displayed in a listing, to | |
571 | @var{number} bytes. | |
572 | ||
573 | @item --listing-cont-lines=@var{number} | |
574 | Set the maximum number of lines printed in a listing for a single line of input | |
575 | to @var{number} + 1. | |
576 | ||
252b5132 | 577 | @item -o @var{objfile} |
a4fb0134 | 578 | Name the object-file output from @command{@value{AS}} @var{objfile}. |
252b5132 RH |
579 | |
580 | @item -R | |
581 | Fold the data section into the text section. | |
582 | ||
4bdd3565 NC |
583 | @kindex --hash-size=@var{number} |
584 | Set the default size of GAS's hash tables to a prime number close to | |
585 | @var{number}. Increasing this value can reduce the length of time it takes the | |
586 | assembler to perform its tasks, at the expense of increasing the assembler's | |
587 | memory requirements. Similarly reducing this value can reduce the memory | |
588 | requirements at the expense of speed. | |
589 | ||
590 | @item --reduce-memory-overheads | |
591 | This option reduces GAS's memory requirements, at the expense of making the | |
592 | assembly processes slower. Currently this switch is a synonym for | |
593 | @samp{--hash-size=4051}, but in the future it may have other effects as well. | |
594 | ||
252b5132 RH |
595 | @item --statistics |
596 | Print the maximum space (in bytes) and total time (in seconds) used by | |
597 | assembly. | |
598 | ||
599 | @item --strip-local-absolute | |
600 | Remove local absolute symbols from the outgoing symbol table. | |
601 | ||
602 | @item -v | |
603 | @itemx -version | |
a4fb0134 | 604 | Print the @command{as} version. |
252b5132 RH |
605 | |
606 | @item --version | |
a4fb0134 | 607 | Print the @command{as} version and exit. |
252b5132 RH |
608 | |
609 | @item -W | |
2bdd6cf5 | 610 | @itemx --no-warn |
252b5132 RH |
611 | Suppress warning messages. |
612 | ||
2bdd6cf5 GK |
613 | @item --fatal-warnings |
614 | Treat warnings as errors. | |
615 | ||
616 | @item --warn | |
617 | Don't suppress warning messages or treat them as errors. | |
618 | ||
252b5132 RH |
619 | @item -w |
620 | Ignored. | |
621 | ||
622 | @item -x | |
623 | Ignored. | |
624 | ||
625 | @item -Z | |
626 | Generate an object file even after errors. | |
627 | ||
628 | @item -- | @var{files} @dots{} | |
629 | Standard input, or source files to assemble. | |
630 | ||
631 | @end table | |
632 | ||
633 | @ifset ARC | |
634 | The following options are available when @value{AS} is configured for | |
635 | an ARC processor. | |
636 | ||
a4fb0134 | 637 | @table @gcctabopt |
0d2bcfaf NC |
638 | @item -marc[5|6|7|8] |
639 | This option selects the core processor variant. | |
640 | @item -EB | -EL | |
641 | Select either big-endian (-EB) or little-endian (-EL) output. | |
252b5132 RH |
642 | @end table |
643 | @end ifset | |
644 | ||
645 | @ifset ARM | |
646 | The following options are available when @value{AS} is configured for the ARM | |
647 | processor family. | |
648 | ||
a4fb0134 | 649 | @table @gcctabopt |
92081f48 | 650 | @item -mcpu=@var{processor}[+@var{extension}@dots{}] |
cdf82bcf | 651 | Specify which ARM processor variant is the target. |
92081f48 | 652 | @item -march=@var{architecture}[+@var{extension}@dots{}] |
cdf82bcf | 653 | Specify which ARM architecture variant is used by the target. |
03b1477f | 654 | @item -mfpu=@var{floating-point-format} |
a349d9dd | 655 | Select which Floating Point architecture is the target. |
33a392fb PB |
656 | @item -mfloat-abi=@var{abi} |
657 | Select which floating point ABI is in use. | |
03b1477f RE |
658 | @item -mthumb |
659 | Enable Thumb only instruction decoding. | |
7f266840 | 660 | @item -mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant |
252b5132 RH |
661 | Select which procedure calling convention is in use. |
662 | @item -EB | -EL | |
663 | Select either big-endian (-EB) or little-endian (-EL) output. | |
cdf82bcf NC |
664 | @item -mthumb-interwork |
665 | Specify that the code has been generated with interworking between Thumb and | |
666 | ARM code in mind. | |
667 | @item -k | |
668 | Specify that PIC code has been generated. | |
252b5132 RH |
669 | @end table |
670 | @end ifset | |
671 | ||
328eb32e HPN |
672 | @ifset CRIS |
673 | See the info pages for documentation of the CRIS-specific options. | |
674 | @end ifset | |
675 | ||
252b5132 RH |
676 | @ifset D10V |
677 | The following options are available when @value{AS} is configured for | |
678 | a D10V processor. | |
a4fb0134 | 679 | @table @gcctabopt |
252b5132 RH |
680 | @cindex D10V optimization |
681 | @cindex optimization, D10V | |
682 | @item -O | |
683 | Optimize output by parallelizing instructions. | |
684 | @end table | |
685 | @end ifset | |
686 | ||
687 | @ifset D30V | |
688 | The following options are available when @value{AS} is configured for a D30V | |
689 | processor. | |
a4fb0134 | 690 | @table @gcctabopt |
252b5132 RH |
691 | @cindex D30V optimization |
692 | @cindex optimization, D30V | |
693 | @item -O | |
694 | Optimize output by parallelizing instructions. | |
695 | ||
696 | @cindex D30V nops | |
697 | @item -n | |
698 | Warn when nops are generated. | |
699 | ||
700 | @cindex D30V nops after 32-bit multiply | |
701 | @item -N | |
702 | Warn when a nop after a 32-bit multiply instruction is generated. | |
703 | @end table | |
704 | @end ifset | |
705 | ||
706 | @ifset I960 | |
707 | The following options are available when @value{AS} is configured for the | |
708 | Intel 80960 processor. | |
709 | ||
a4fb0134 | 710 | @table @gcctabopt |
252b5132 RH |
711 | @item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC |
712 | Specify which variant of the 960 architecture is the target. | |
713 | ||
714 | @item -b | |
715 | Add code to collect statistics about branches taken. | |
716 | ||
717 | @item -no-relax | |
718 | Do not alter compare-and-branch instructions for long displacements; | |
719 | error if necessary. | |
720 | ||
721 | @end table | |
722 | @end ifset | |
723 | ||
a40cbfa3 NC |
724 | @ifset IP2K |
725 | The following options are available when @value{AS} is configured for the | |
ec88d317 | 726 | Ubicom IP2K series. |
a40cbfa3 NC |
727 | |
728 | @table @gcctabopt | |
729 | ||
730 | @item -mip2022ext | |
731 | Specifies that the extended IP2022 instructions are allowed. | |
732 | ||
733 | @item -mip2022 | |
8dfa0188 | 734 | Restores the default behaviour, which restricts the permitted instructions to |
a40cbfa3 NC |
735 | just the basic IP2022 ones. |
736 | ||
737 | @end table | |
738 | @end ifset | |
739 | ||
49f58d10 JB |
740 | @ifset M32C |
741 | The following options are available when @value{AS} is configured for the | |
742 | Renesas M32C and M16C processors. | |
743 | ||
744 | @table @gcctabopt | |
745 | ||
746 | @item -m32c | |
747 | Assemble M32C instructions. | |
748 | ||
749 | @item -m16c | |
750 | Assemble M16C instructions (the default). | |
751 | ||
752 | @end table | |
753 | @end ifset | |
754 | ||
ec694b89 NC |
755 | @ifset M32R |
756 | The following options are available when @value{AS} is configured for the | |
26597c86 | 757 | Renesas M32R (formerly Mitsubishi M32R) series. |
ec694b89 | 758 | |
a4fb0134 | 759 | @table @gcctabopt |
ec694b89 NC |
760 | |
761 | @item --m32rx | |
762 | Specify which processor in the M32R family is the target. The default | |
763 | is normally the M32R, but this option changes it to the M32RX. | |
764 | ||
765 | @item --warn-explicit-parallel-conflicts or --Wp | |
766 | Produce warning messages when questionable parallel constructs are | |
767 | encountered. | |
768 | ||
769 | @item --no-warn-explicit-parallel-conflicts or --Wnp | |
770 | Do not produce warning messages when questionable parallel constructs are | |
771 | encountered. | |
772 | ||
773 | @end table | |
774 | @end ifset | |
252b5132 RH |
775 | |
776 | @ifset M680X0 | |
777 | The following options are available when @value{AS} is configured for the | |
778 | Motorola 68000 series. | |
779 | ||
a4fb0134 | 780 | @table @gcctabopt |
252b5132 RH |
781 | |
782 | @item -l | |
783 | Shorten references to undefined symbols, to one word instead of two. | |
784 | ||
0285c67d NC |
785 | @item -m68000 | -m68008 | -m68010 | -m68020 | -m68030 |
786 | @itemx | -m68040 | -m68060 | -m68302 | -m68331 | -m68332 | |
787 | @itemx | -m68333 | -m68340 | -mcpu32 | -m5200 | |
252b5132 RH |
788 | Specify what processor in the 68000 family is the target. The default |
789 | is normally the 68020, but this can be changed at configuration time. | |
790 | ||
791 | @item -m68881 | -m68882 | -mno-68881 | -mno-68882 | |
792 | The target machine does (or does not) have a floating-point coprocessor. | |
793 | The default is to assume a coprocessor for 68020, 68030, and cpu32. Although | |
794 | the basic 68000 is not compatible with the 68881, a combination of the | |
795 | two can be specified, since it's possible to do emulation of the | |
796 | coprocessor instructions with the main processor. | |
797 | ||
798 | @item -m68851 | -mno-68851 | |
799 | The target machine does (or does not) have a memory-management | |
800 | unit coprocessor. The default is to assume an MMU for 68020 and up. | |
801 | ||
802 | @end table | |
803 | @end ifset | |
804 | ||
e135f41b NC |
805 | @ifset PDP11 |
806 | ||
807 | For details about the PDP-11 machine dependent features options, | |
808 | see @ref{PDP-11-Options}. | |
809 | ||
a4fb0134 | 810 | @table @gcctabopt |
e135f41b NC |
811 | @item -mpic | -mno-pic |
812 | Generate position-independent (or position-dependent) code. The | |
a4fb0134 | 813 | default is @option{-mpic}. |
e135f41b NC |
814 | |
815 | @item -mall | |
816 | @itemx -mall-extensions | |
817 | Enable all instruction set extensions. This is the default. | |
818 | ||
819 | @item -mno-extensions | |
820 | Disable all instruction set extensions. | |
821 | ||
822 | @item -m@var{extension} | -mno-@var{extension} | |
823 | Enable (or disable) a particular instruction set extension. | |
824 | ||
825 | @item -m@var{cpu} | |
826 | Enable the instruction set extensions supported by a particular CPU, and | |
827 | disable all other extensions. | |
828 | ||
829 | @item -m@var{machine} | |
830 | Enable the instruction set extensions supported by a particular machine | |
831 | model, and disable all other extensions. | |
832 | @end table | |
833 | ||
834 | @end ifset | |
835 | ||
041dd5a9 ILT |
836 | @ifset PJ |
837 | The following options are available when @value{AS} is configured for | |
838 | a picoJava processor. | |
839 | ||
a4fb0134 | 840 | @table @gcctabopt |
041dd5a9 ILT |
841 | |
842 | @cindex PJ endianness | |
843 | @cindex endianness, PJ | |
844 | @cindex big endian output, PJ | |
845 | @item -mb | |
846 | Generate ``big endian'' format output. | |
847 | ||
848 | @cindex little endian output, PJ | |
849 | @item -ml | |
850 | Generate ``little endian'' format output. | |
851 | ||
852 | @end table | |
853 | @end ifset | |
854 | ||
60bcf0fa NC |
855 | @ifset M68HC11 |
856 | The following options are available when @value{AS} is configured for the | |
857 | Motorola 68HC11 or 68HC12 series. | |
858 | ||
a4fb0134 | 859 | @table @gcctabopt |
60bcf0fa | 860 | |
d01030e6 | 861 | @item -m68hc11 | -m68hc12 | -m68hcs12 |
60bcf0fa NC |
862 | Specify what processor is the target. The default is |
863 | defined by the configuration option when building the assembler. | |
864 | ||
2f904664 SC |
865 | @item -mshort |
866 | Specify to use the 16-bit integer ABI. | |
867 | ||
868 | @item -mlong | |
869 | Specify to use the 32-bit integer ABI. | |
870 | ||
871 | @item -mshort-double | |
872 | Specify to use the 32-bit double ABI. | |
873 | ||
874 | @item -mlong-double | |
875 | Specify to use the 64-bit double ABI. | |
876 | ||
1370e33d | 877 | @item --force-long-branches |
60bcf0fa NC |
878 | Relative branches are turned into absolute ones. This concerns |
879 | conditional branches, unconditional branches and branches to a | |
880 | sub routine. | |
881 | ||
1370e33d NC |
882 | @item -S | --short-branches |
883 | Do not turn relative branches into absolute ones | |
60bcf0fa NC |
884 | when the offset is out of range. |
885 | ||
886 | @item --strict-direct-mode | |
887 | Do not turn the direct addressing mode into extended addressing mode | |
888 | when the instruction does not support direct addressing mode. | |
889 | ||
890 | @item --print-insn-syntax | |
891 | Print the syntax of instruction in case of error. | |
892 | ||
893 | @item --print-opcodes | |
894 | print the list of instructions with syntax and then exit. | |
895 | ||
896 | @item --generate-example | |
897 | print an example of instruction for each possible instruction and then exit. | |
a4fb0134 | 898 | This option is only useful for testing @command{@value{AS}}. |
60bcf0fa NC |
899 | |
900 | @end table | |
901 | @end ifset | |
902 | ||
252b5132 | 903 | @ifset SPARC |
a4fb0134 | 904 | The following options are available when @command{@value{AS}} is configured |
252b5132 RH |
905 | for the SPARC architecture: |
906 | ||
a4fb0134 | 907 | @table @gcctabopt |
252b5132 RH |
908 | @item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite |
909 | @itemx -Av8plus | -Av8plusa | -Av9 | -Av9a | |
910 | Explicitly select a variant of the SPARC architecture. | |
911 | ||
912 | @samp{-Av8plus} and @samp{-Av8plusa} select a 32 bit environment. | |
913 | @samp{-Av9} and @samp{-Av9a} select a 64 bit environment. | |
914 | ||
915 | @samp{-Av8plusa} and @samp{-Av9a} enable the SPARC V9 instruction set with | |
916 | UltraSPARC extensions. | |
917 | ||
918 | @item -xarch=v8plus | -xarch=v8plusa | |
919 | For compatibility with the Solaris v9 assembler. These options are | |
920 | equivalent to -Av8plus and -Av8plusa, respectively. | |
921 | ||
922 | @item -bump | |
923 | Warn when the assembler switches to another architecture. | |
924 | @end table | |
925 | @end ifset | |
926 | ||
39bec121 TW |
927 | @ifset TIC54X |
928 | The following options are available when @value{AS} is configured for the 'c54x | |
929 | architecture. | |
930 | ||
a4fb0134 | 931 | @table @gcctabopt |
39bec121 TW |
932 | @item -mfar-mode |
933 | Enable extended addressing mode. All addresses and relocations will assume | |
934 | extended addressing (usually 23 bits). | |
935 | @item -mcpu=@var{CPU_VERSION} | |
936 | Sets the CPU version being compiled for. | |
937 | @item -merrors-to-file @var{FILENAME} | |
938 | Redirect error output to a file, for broken systems which don't support such | |
939 | behaviour in the shell. | |
940 | @end table | |
941 | @end ifset | |
942 | ||
252b5132 RH |
943 | @ifset MIPS |
944 | The following options are available when @value{AS} is configured for | |
437ee9d5 | 945 | a @sc{mips} processor. |
252b5132 | 946 | |
a4fb0134 | 947 | @table @gcctabopt |
252b5132 RH |
948 | @item -G @var{num} |
949 | This option sets the largest size of an object that can be referenced | |
950 | implicitly with the @code{gp} register. It is only accepted for targets that | |
951 | use ECOFF format, such as a DECstation running Ultrix. The default value is 8. | |
952 | ||
953 | @cindex MIPS endianness | |
954 | @cindex endianness, MIPS | |
955 | @cindex big endian output, MIPS | |
956 | @item -EB | |
957 | Generate ``big endian'' format output. | |
958 | ||
959 | @cindex little endian output, MIPS | |
960 | @item -EL | |
961 | Generate ``little endian'' format output. | |
962 | ||
963 | @cindex MIPS ISA | |
964 | @item -mips1 | |
965 | @itemx -mips2 | |
966 | @itemx -mips3 | |
e7af610e | 967 | @itemx -mips4 |
437ee9d5 | 968 | @itemx -mips5 |
e7af610e | 969 | @itemx -mips32 |
af7ee8bf | 970 | @itemx -mips32r2 |
4058e45f | 971 | @itemx -mips64 |
5f74bc13 | 972 | @itemx -mips64r2 |
437ee9d5 TS |
973 | Generate code for a particular @sc{mips} Instruction Set Architecture level. |
974 | @samp{-mips1} is an alias for @samp{-march=r3000}, @samp{-mips2} is an | |
975 | alias for @samp{-march=r6000}, @samp{-mips3} is an alias for | |
976 | @samp{-march=r4000} and @samp{-mips4} is an alias for @samp{-march=r8000}. | |
5f74bc13 CD |
977 | @samp{-mips5}, @samp{-mips32}, @samp{-mips32r2}, @samp{-mips64}, and |
978 | @samp{-mips64r2} | |
af7ee8bf | 979 | correspond to generic |
5f74bc13 CD |
980 | @samp{MIPS V}, @samp{MIPS32}, @samp{MIPS32 Release 2}, @samp{MIPS64}, |
981 | and @samp{MIPS64 Release 2} | |
982 | ISA processors, respectively. | |
437ee9d5 TS |
983 | |
984 | @item -march=@var{CPU} | |
985 | Generate code for a particular @sc{mips} cpu. | |
986 | ||
987 | @item -mtune=@var{cpu} | |
988 | Schedule and tune for a particular @sc{mips} cpu. | |
989 | ||
990 | @item -mfix7000 | |
991 | @itemx -mno-fix7000 | |
992 | Cause nops to be inserted if the read of the destination register | |
993 | of an mfhi or mflo instruction occurs in the following two instructions. | |
994 | ||
ecb4347a DJ |
995 | @item -mdebug |
996 | @itemx -no-mdebug | |
997 | Cause stabs-style debugging output to go into an ECOFF-style .mdebug | |
998 | section instead of the standard ELF .stabs sections. | |
999 | ||
dcd410fe RO |
1000 | @item -mpdr |
1001 | @itemx -mno-pdr | |
1002 | Control generation of @code{.pdr} sections. | |
1003 | ||
437ee9d5 TS |
1004 | @item -mgp32 |
1005 | @itemx -mfp32 | |
1006 | The register sizes are normally inferred from the ISA and ABI, but these | |
1007 | flags force a certain group of registers to be treated as 32 bits wide at | |
1008 | all times. @samp{-mgp32} controls the size of general-purpose registers | |
1009 | and @samp{-mfp32} controls the size of floating-point registers. | |
1010 | ||
1011 | @item -mips16 | |
1012 | @itemx -no-mips16 | |
1013 | Generate code for the MIPS 16 processor. This is equivalent to putting | |
1014 | @code{.set mips16} at the start of the assembly file. @samp{-no-mips16} | |
1015 | turns off this option. | |
252b5132 | 1016 | |
e16bfa71 TS |
1017 | @item -msmartmips |
1018 | @itemx -mno-smartmips | |
1019 | Enables the SmartMIPS extension to the MIPS32 instruction set. This is | |
1020 | equivalent to putting @code{.set smartmips} at the start of the assembly file. | |
1021 | @samp{-mno-smartmips} turns off this option. | |
1022 | ||
1f25f5d3 CD |
1023 | @item -mips3d |
1024 | @itemx -no-mips3d | |
1025 | Generate code for the MIPS-3D Application Specific Extension. | |
1026 | This tells the assembler to accept MIPS-3D instructions. | |
1027 | @samp{-no-mips3d} turns off this option. | |
1028 | ||
deec1734 CD |
1029 | @item -mdmx |
1030 | @itemx -no-mdmx | |
1031 | Generate code for the MDMX Application Specific Extension. | |
1032 | This tells the assembler to accept MDMX instructions. | |
1033 | @samp{-no-mdmx} turns off this option. | |
1034 | ||
2ef2b9ae CF |
1035 | @item -mdsp |
1036 | @itemx -mno-dsp | |
1037 | Generate code for the DSP Application Specific Extension. | |
1038 | This tells the assembler to accept DSP instructions. | |
1039 | @samp{-mno-dsp} turns off this option. | |
1040 | ||
ef2e4d86 CF |
1041 | @item -mmt |
1042 | @itemx -mno-mt | |
1043 | Generate code for the MT Application Specific Extension. | |
1044 | This tells the assembler to accept MT instructions. | |
1045 | @samp{-mno-mt} turns off this option. | |
1046 | ||
437ee9d5 TS |
1047 | @item --construct-floats |
1048 | @itemx --no-construct-floats | |
1049 | The @samp{--no-construct-floats} option disables the construction of | |
1050 | double width floating point constants by loading the two halves of the | |
1051 | value into the two single width floating point registers that make up | |
1052 | the double width register. By default @samp{--construct-floats} is | |
1053 | selected, allowing construction of these floating point constants. | |
252b5132 RH |
1054 | |
1055 | @cindex emulation | |
1056 | @item --emulation=@var{name} | |
a4fb0134 | 1057 | This option causes @command{@value{AS}} to emulate @command{@value{AS}} configured |
252b5132 RH |
1058 | for some other target, in all respects, including output format (choosing |
1059 | between ELF and ECOFF only), handling of pseudo-opcodes which may generate | |
1060 | debugging information or store symbol table information, and default | |
1061 | endianness. The available configuration names are: @samp{mipsecoff}, | |
1062 | @samp{mipself}, @samp{mipslecoff}, @samp{mipsbecoff}, @samp{mipslelf}, | |
1063 | @samp{mipsbelf}. The first two do not alter the default endianness from that | |
1064 | of the primary target for which the assembler was configured; the others change | |
1065 | the default to little- or big-endian as indicated by the @samp{b} or @samp{l} | |
1066 | in the name. Using @samp{-EB} or @samp{-EL} will override the endianness | |
1067 | selection in any case. | |
1068 | ||
1069 | This option is currently supported only when the primary target | |
437ee9d5 | 1070 | @command{@value{AS}} is configured for is a @sc{mips} ELF or ECOFF target. |
252b5132 RH |
1071 | Furthermore, the primary target or others specified with |
1072 | @samp{--enable-targets=@dots{}} at configuration time must include support for | |
1073 | the other format, if both are to be available. For example, the Irix 5 | |
1074 | configuration includes support for both. | |
1075 | ||
1076 | Eventually, this option will support more configurations, with more | |
1077 | fine-grained control over the assembler's behavior, and will be supported for | |
1078 | more processors. | |
1079 | ||
1080 | @item -nocpp | |
a4fb0134 | 1081 | @command{@value{AS}} ignores this option. It is accepted for compatibility with |
252b5132 RH |
1082 | the native tools. |
1083 | ||
252b5132 RH |
1084 | @item --trap |
1085 | @itemx --no-trap | |
1086 | @itemx --break | |
1087 | @itemx --no-break | |
1088 | Control how to deal with multiplication overflow and division by zero. | |
1089 | @samp{--trap} or @samp{--no-break} (which are synonyms) take a trap exception | |
1090 | (and only work for Instruction Set Architecture level 2 and higher); | |
1091 | @samp{--break} or @samp{--no-trap} (also synonyms, and the default) take a | |
1092 | break exception. | |
63486801 L |
1093 | |
1094 | @item -n | |
a4fb0134 | 1095 | When this option is used, @command{@value{AS}} will issue a warning every |
63486801 | 1096 | time it generates a nop instruction from a macro. |
252b5132 RH |
1097 | @end table |
1098 | @end ifset | |
1099 | ||
1100 | @ifset MCORE | |
1101 | The following options are available when @value{AS} is configured for | |
1102 | an MCore processor. | |
1103 | ||
a4fb0134 | 1104 | @table @gcctabopt |
252b5132 RH |
1105 | @item -jsri2bsr |
1106 | @itemx -nojsri2bsr | |
1107 | Enable or disable the JSRI to BSR transformation. By default this is enabled. | |
1108 | The command line option @samp{-nojsri2bsr} can be used to disable it. | |
1109 | ||
1110 | @item -sifilter | |
1111 | @itemx -nosifilter | |
1112 | Enable or disable the silicon filter behaviour. By default this is disabled. | |
a349d9dd | 1113 | The default can be overridden by the @samp{-sifilter} command line option. |
252b5132 RH |
1114 | |
1115 | @item -relax | |
1116 | Alter jump instructions for long displacements. | |
1117 | ||
ec694b89 NC |
1118 | @item -mcpu=[210|340] |
1119 | Select the cpu type on the target hardware. This controls which instructions | |
1120 | can be assembled. | |
1121 | ||
1122 | @item -EB | |
1123 | Assemble for a big endian target. | |
1124 | ||
1125 | @item -EL | |
1126 | Assemble for a little endian target. | |
252b5132 RH |
1127 | |
1128 | @end table | |
1129 | @end ifset | |
1130 | ||
3c3bdf30 NC |
1131 | @ifset MMIX |
1132 | See the info pages for documentation of the MMIX-specific options. | |
1133 | @end ifset | |
1134 | ||
e0001a05 NC |
1135 | @ifset XTENSA |
1136 | The following options are available when @value{AS} is configured for | |
1137 | an Xtensa processor. | |
1138 | ||
1139 | @table @gcctabopt | |
e0001a05 NC |
1140 | @item --text-section-literals | --no-text-section-literals |
1141 | With @option{--text-@-section-@-literals}, literal pools are interspersed | |
1142 | in the text section. The default is | |
1143 | @option{--no-@-text-@-section-@-literals}, which places literals in a | |
43cd72b9 BW |
1144 | separate section in the output file. These options only affect literals |
1145 | referenced via PC-relative @code{L32R} instructions; literals for | |
1146 | absolute mode @code{L32R} instructions are handled separately. | |
1147 | ||
1148 | @item --absolute-literals | --no-absolute-literals | |
1149 | Indicate to the assembler whether @code{L32R} instructions use absolute | |
1150 | or PC-relative addressing. The default is to assume absolute addressing | |
1151 | if the Xtensa processor includes the absolute @code{L32R} addressing | |
1152 | option. Otherwise, only the PC-relative @code{L32R} mode can be used. | |
e0001a05 NC |
1153 | |
1154 | @item --target-align | --no-target-align | |
1155 | Enable or disable automatic alignment to reduce branch penalties at the | |
1156 | expense of some code density. The default is @option{--target-@-align}. | |
1157 | ||
1158 | @item --longcalls | --no-longcalls | |
1159 | Enable or disable transformation of call instructions to allow calls | |
1160 | across a greater range of addresses. The default is | |
1161 | @option{--no-@-longcalls}. | |
43cd72b9 BW |
1162 | |
1163 | @item --transform | --no-transform | |
1164 | Enable or disable all assembler transformations of Xtensa instructions. | |
1165 | The default is @option{--transform}; | |
1166 | @option{--no-transform} should be used only in the rare cases when the | |
1167 | instructions must be exactly as specified in the assembly source. | |
e0001a05 NC |
1168 | @end table |
1169 | @end ifset | |
1170 | ||
3c9b82ba NC |
1171 | @ifset Z80 |
1172 | The following options are available when @value{AS} is configured for | |
1173 | a Z80 family processor. | |
1174 | @table @gcctabopt | |
1175 | @item -z80 | |
1176 | Assemble for Z80 processor. | |
1177 | @item -r800 | |
1178 | Assemble for R800 processor. | |
1179 | @item -ignore-undocumented-instructions | |
1180 | @itemx -Wnud | |
1181 | Assemble undocumented Z80 instructions that also work on R800 without warning. | |
1182 | @item -ignore-unportable-instructions | |
1183 | @itemx -Wnup | |
1184 | Assemble all undocumented Z80 instructions without warning. | |
1185 | @item -warn-undocumented-instructions | |
1186 | @itemx -Wud | |
1187 | Issue a warning for undocumented Z80 instructions that also work on R800. | |
1188 | @item -warn-unportable-instructions | |
1189 | @itemx -Wup | |
b45619c0 | 1190 | Issue a warning for undocumented Z80 instructions that do not work on R800. |
3c9b82ba NC |
1191 | @item -forbid-undocumented-instructions |
1192 | @itemx -Fud | |
1193 | Treat all undocumented instructions as errors. | |
1194 | @item -forbid-unportable-instructions | |
1195 | @itemx -Fup | |
b45619c0 | 1196 | Treat undocumented Z80 instructions that do not work on R800 as errors. |
3c9b82ba NC |
1197 | @end table |
1198 | @end ifset | |
1199 | ||
0285c67d NC |
1200 | @c man end |
1201 | ||
252b5132 RH |
1202 | @menu |
1203 | * Manual:: Structure of this Manual | |
1204 | * GNU Assembler:: The GNU Assembler | |
1205 | * Object Formats:: Object File Formats | |
1206 | * Command Line:: Command Line | |
1207 | * Input Files:: Input Files | |
1208 | * Object:: Output (Object) File | |
1209 | * Errors:: Error and Warning Messages | |
1210 | @end menu | |
1211 | ||
1212 | @node Manual | |
1213 | @section Structure of this Manual | |
1214 | ||
1215 | @cindex manual, structure and purpose | |
1216 | This manual is intended to describe what you need to know to use | |
a4fb0134 | 1217 | @sc{gnu} @command{@value{AS}}. We cover the syntax expected in source files, including |
252b5132 | 1218 | notation for symbols, constants, and expressions; the directives that |
a4fb0134 | 1219 | @command{@value{AS}} understands; and of course how to invoke @command{@value{AS}}. |
252b5132 RH |
1220 | |
1221 | @ifclear GENERIC | |
1222 | We also cover special features in the @value{TARGET} | |
a4fb0134 | 1223 | configuration of @command{@value{AS}}, including assembler directives. |
252b5132 RH |
1224 | @end ifclear |
1225 | @ifset GENERIC | |
1226 | This manual also describes some of the machine-dependent features of | |
1227 | various flavors of the assembler. | |
1228 | @end ifset | |
1229 | ||
1230 | @cindex machine instructions (not covered) | |
1231 | On the other hand, this manual is @emph{not} intended as an introduction | |
1232 | to programming in assembly language---let alone programming in general! | |
1233 | In a similar vein, we make no attempt to introduce the machine | |
1234 | architecture; we do @emph{not} describe the instruction set, standard | |
1235 | mnemonics, registers or addressing modes that are standard to a | |
1236 | particular architecture. | |
1237 | @ifset GENERIC | |
1238 | You may want to consult the manufacturer's | |
1239 | machine architecture manual for this information. | |
1240 | @end ifset | |
1241 | @ifclear GENERIC | |
1242 | @ifset H8/300 | |
1243 | For information on the H8/300 machine instruction set, see @cite{H8/300 | |
c2dcd04e NC |
1244 | Series Programming Manual}. For the H8/300H, see @cite{H8/300H Series |
1245 | Programming Manual} (Renesas). | |
252b5132 | 1246 | @end ifset |
252b5132 | 1247 | @ifset SH |
ef230218 JR |
1248 | For information on the Renesas (formerly Hitachi) / SuperH SH machine instruction set, |
1249 | see @cite{SH-Microcomputer User's Manual} (Renesas) or | |
1250 | @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and | |
1251 | @cite{SuperH (SH) 64-Bit RISC Series} (SuperH). | |
252b5132 RH |
1252 | @end ifset |
1253 | @ifset Z8000 | |
1254 | For information on the Z8000 machine instruction set, see @cite{Z8000 CPU Technical Manual} | |
1255 | @end ifset | |
1256 | @end ifclear | |
1257 | ||
1258 | @c I think this is premature---doc@cygnus.com, 17jan1991 | |
1259 | @ignore | |
1260 | Throughout this manual, we assume that you are running @dfn{GNU}, | |
1261 | the portable operating system from the @dfn{Free Software | |
1262 | Foundation, Inc.}. This restricts our attention to certain kinds of | |
1263 | computer (in particular, the kinds of computers that @sc{gnu} can run on); | |
1264 | once this assumption is granted examples and definitions need less | |
1265 | qualification. | |
1266 | ||
a4fb0134 | 1267 | @command{@value{AS}} is part of a team of programs that turn a high-level |
252b5132 RH |
1268 | human-readable series of instructions into a low-level |
1269 | computer-readable series of instructions. Different versions of | |
a4fb0134 | 1270 | @command{@value{AS}} are used for different kinds of computer. |
252b5132 RH |
1271 | @end ignore |
1272 | ||
1273 | @c There used to be a section "Terminology" here, which defined | |
1274 | @c "contents", "byte", "word", and "long". Defining "word" to any | |
1275 | @c particular size is confusing when the .word directive may generate 16 | |
1276 | @c bits on one machine and 32 bits on another; in general, for the user | |
1277 | @c version of this manual, none of these terms seem essential to define. | |
1278 | @c They were used very little even in the former draft of the manual; | |
1279 | @c this draft makes an effort to avoid them (except in names of | |
1280 | @c directives). | |
1281 | ||
1282 | @node GNU Assembler | |
1283 | @section The GNU Assembler | |
1284 | ||
0285c67d NC |
1285 | @c man begin DESCRIPTION |
1286 | ||
a4fb0134 | 1287 | @sc{gnu} @command{as} is really a family of assemblers. |
252b5132 | 1288 | @ifclear GENERIC |
a4fb0134 | 1289 | This manual describes @command{@value{AS}}, a member of that family which is |
252b5132 RH |
1290 | configured for the @value{TARGET} architectures. |
1291 | @end ifclear | |
1292 | If you use (or have used) the @sc{gnu} assembler on one architecture, you | |
1293 | should find a fairly similar environment when you use it on another | |
1294 | architecture. Each version has much in common with the others, | |
1295 | including object file formats, most assembler directives (often called | |
1296 | @dfn{pseudo-ops}) and assembler syntax.@refill | |
1297 | ||
1298 | @cindex purpose of @sc{gnu} assembler | |
a4fb0134 | 1299 | @command{@value{AS}} is primarily intended to assemble the output of the |
252b5132 | 1300 | @sc{gnu} C compiler @code{@value{GCC}} for use by the linker |
a4fb0134 | 1301 | @code{@value{LD}}. Nevertheless, we've tried to make @command{@value{AS}} |
252b5132 RH |
1302 | assemble correctly everything that other assemblers for the same |
1303 | machine would assemble. | |
1304 | @ifset VAX | |
1305 | Any exceptions are documented explicitly (@pxref{Machine Dependencies}). | |
1306 | @end ifset | |
1307 | @ifset M680X0 | |
1308 | @c This remark should appear in generic version of manual; assumption | |
1309 | @c here is that generic version sets M680x0. | |
a4fb0134 | 1310 | This doesn't mean @command{@value{AS}} always uses the same syntax as another |
252b5132 RH |
1311 | assembler for the same architecture; for example, we know of several |
1312 | incompatible versions of 680x0 assembly language syntax. | |
1313 | @end ifset | |
1314 | ||
0285c67d NC |
1315 | @c man end |
1316 | ||
a4fb0134 | 1317 | Unlike older assemblers, @command{@value{AS}} is designed to assemble a source |
252b5132 RH |
1318 | program in one pass of the source file. This has a subtle impact on the |
1319 | @kbd{.org} directive (@pxref{Org,,@code{.org}}). | |
1320 | ||
1321 | @node Object Formats | |
1322 | @section Object File Formats | |
1323 | ||
1324 | @cindex object file format | |
1325 | The @sc{gnu} assembler can be configured to produce several alternative | |
1326 | object file formats. For the most part, this does not affect how you | |
1327 | write assembly language programs; but directives for debugging symbols | |
1328 | are typically different in different file formats. @xref{Symbol | |
1329 | Attributes,,Symbol Attributes}. | |
1330 | @ifclear GENERIC | |
1331 | @ifclear MULTI-OBJ | |
c1253627 | 1332 | For the @value{TARGET} target, @command{@value{AS}} is configured to produce |
252b5132 RH |
1333 | @value{OBJ-NAME} format object files. |
1334 | @end ifclear | |
1335 | @c The following should exhaust all configs that set MULTI-OBJ, ideally | |
252b5132 | 1336 | @ifset I960 |
a4fb0134 | 1337 | On the @value{TARGET}, @command{@value{AS}} can be configured to produce either |
252b5132 RH |
1338 | @code{b.out} or COFF format object files. |
1339 | @end ifset | |
1340 | @ifset HPPA | |
a4fb0134 | 1341 | On the @value{TARGET}, @command{@value{AS}} can be configured to produce either |
252b5132 RH |
1342 | SOM or ELF format object files. |
1343 | @end ifset | |
1344 | @end ifclear | |
1345 | ||
1346 | @node Command Line | |
1347 | @section Command Line | |
1348 | ||
1349 | @cindex command line conventions | |
0285c67d | 1350 | |
a4fb0134 | 1351 | After the program name @command{@value{AS}}, the command line may contain |
252b5132 RH |
1352 | options and file names. Options may appear in any order, and may be |
1353 | before, after, or between file names. The order of file names is | |
1354 | significant. | |
1355 | ||
1356 | @cindex standard input, as input file | |
1357 | @kindex -- | |
1358 | @file{--} (two hyphens) by itself names the standard input file | |
a4fb0134 | 1359 | explicitly, as one of the files for @command{@value{AS}} to assemble. |
252b5132 RH |
1360 | |
1361 | @cindex options, command line | |
1362 | Except for @samp{--} any command line argument that begins with a | |
1363 | hyphen (@samp{-}) is an option. Each option changes the behavior of | |
a4fb0134 | 1364 | @command{@value{AS}}. No option changes the way another option works. An |
252b5132 RH |
1365 | option is a @samp{-} followed by one or more letters; the case of |
1366 | the letter is important. All options are optional. | |
1367 | ||
1368 | Some options expect exactly one file name to follow them. The file | |
1369 | name may either immediately follow the option's letter (compatible | |
1370 | with older assemblers) or it may be the next command argument (@sc{gnu} | |
1371 | standard). These two command lines are equivalent: | |
1372 | ||
1373 | @smallexample | |
1374 | @value{AS} -o my-object-file.o mumble.s | |
1375 | @value{AS} -omy-object-file.o mumble.s | |
1376 | @end smallexample | |
1377 | ||
1378 | @node Input Files | |
1379 | @section Input Files | |
1380 | ||
1381 | @cindex input | |
1382 | @cindex source program | |
1383 | @cindex files, input | |
1384 | We use the phrase @dfn{source program}, abbreviated @dfn{source}, to | |
a4fb0134 | 1385 | describe the program input to one run of @command{@value{AS}}. The program may |
252b5132 RH |
1386 | be in one or more files; how the source is partitioned into files |
1387 | doesn't change the meaning of the source. | |
1388 | ||
1389 | @c I added "con" prefix to "catenation" just to prove I can overcome my | |
1390 | @c APL training... doc@cygnus.com | |
1391 | The source program is a concatenation of the text in all the files, in the | |
1392 | order specified. | |
1393 | ||
0285c67d | 1394 | @c man begin DESCRIPTION |
a4fb0134 | 1395 | Each time you run @command{@value{AS}} it assembles exactly one source |
252b5132 RH |
1396 | program. The source program is made up of one or more files. |
1397 | (The standard input is also a file.) | |
1398 | ||
a4fb0134 | 1399 | You give @command{@value{AS}} a command line that has zero or more input file |
252b5132 RH |
1400 | names. The input files are read (from left file name to right). A |
1401 | command line argument (in any position) that has no special meaning | |
1402 | is taken to be an input file name. | |
1403 | ||
a4fb0134 SC |
1404 | If you give @command{@value{AS}} no file names it attempts to read one input file |
1405 | from the @command{@value{AS}} standard input, which is normally your terminal. You | |
1406 | may have to type @key{ctl-D} to tell @command{@value{AS}} there is no more program | |
252b5132 RH |
1407 | to assemble. |
1408 | ||
1409 | Use @samp{--} if you need to explicitly name the standard input file | |
1410 | in your command line. | |
1411 | ||
a4fb0134 | 1412 | If the source is empty, @command{@value{AS}} produces a small, empty object |
252b5132 RH |
1413 | file. |
1414 | ||
0285c67d NC |
1415 | @c man end |
1416 | ||
252b5132 RH |
1417 | @subheading Filenames and Line-numbers |
1418 | ||
1419 | @cindex input file linenumbers | |
1420 | @cindex line numbers, in input files | |
1421 | There are two ways of locating a line in the input file (or files) and | |
1422 | either may be used in reporting error messages. One way refers to a line | |
1423 | number in a physical file; the other refers to a line number in a | |
1424 | ``logical'' file. @xref{Errors, ,Error and Warning Messages}. | |
1425 | ||
1426 | @dfn{Physical files} are those files named in the command line given | |
a4fb0134 | 1427 | to @command{@value{AS}}. |
252b5132 RH |
1428 | |
1429 | @dfn{Logical files} are simply names declared explicitly by assembler | |
1430 | directives; they bear no relation to physical files. Logical file names help | |
a4fb0134 SC |
1431 | error messages reflect the original source file, when @command{@value{AS}} source |
1432 | is itself synthesized from other files. @command{@value{AS}} understands the | |
252b5132 RH |
1433 | @samp{#} directives emitted by the @code{@value{GCC}} preprocessor. See also |
1434 | @ref{File,,@code{.file}}. | |
1435 | ||
1436 | @node Object | |
1437 | @section Output (Object) File | |
1438 | ||
1439 | @cindex object file | |
1440 | @cindex output file | |
1441 | @kindex a.out | |
1442 | @kindex .o | |
a4fb0134 | 1443 | Every time you run @command{@value{AS}} it produces an output file, which is |
252b5132 RH |
1444 | your assembly language program translated into numbers. This file |
1445 | is the object file. Its default name is | |
1446 | @ifclear BOUT | |
1447 | @code{a.out}. | |
1448 | @end ifclear | |
1449 | @ifset BOUT | |
1450 | @ifset GENERIC | |
1451 | @code{a.out}, or | |
1452 | @end ifset | |
a4fb0134 | 1453 | @code{b.out} when @command{@value{AS}} is configured for the Intel 80960. |
252b5132 | 1454 | @end ifset |
a4fb0134 | 1455 | You can give it another name by using the @option{-o} option. Conventionally, |
252b5132 RH |
1456 | object file names end with @file{.o}. The default name is used for historical |
1457 | reasons: older assemblers were capable of assembling self-contained programs | |
1458 | directly into a runnable program. (For some formats, this isn't currently | |
1459 | possible, but it can be done for the @code{a.out} format.) | |
1460 | ||
1461 | @cindex linker | |
1462 | @kindex ld | |
1463 | The object file is meant for input to the linker @code{@value{LD}}. It contains | |
1464 | assembled program code, information to help @code{@value{LD}} integrate | |
1465 | the assembled program into a runnable file, and (optionally) symbolic | |
1466 | information for the debugger. | |
1467 | ||
1468 | @c link above to some info file(s) like the description of a.out. | |
1469 | @c don't forget to describe @sc{gnu} info as well as Unix lossage. | |
1470 | ||
1471 | @node Errors | |
1472 | @section Error and Warning Messages | |
1473 | ||
0285c67d NC |
1474 | @c man begin DESCRIPTION |
1475 | ||
a349d9dd | 1476 | @cindex error messages |
252b5132 RH |
1477 | @cindex warning messages |
1478 | @cindex messages from assembler | |
a4fb0134 | 1479 | @command{@value{AS}} may write warnings and error messages to the standard error |
252b5132 | 1480 | file (usually your terminal). This should not happen when a compiler |
a4fb0134 SC |
1481 | runs @command{@value{AS}} automatically. Warnings report an assumption made so |
1482 | that @command{@value{AS}} could keep assembling a flawed program; errors report a | |
252b5132 RH |
1483 | grave problem that stops the assembly. |
1484 | ||
0285c67d NC |
1485 | @c man end |
1486 | ||
252b5132 RH |
1487 | @cindex format of warning messages |
1488 | Warning messages have the format | |
1489 | ||
1490 | @smallexample | |
1491 | file_name:@b{NNN}:Warning Message Text | |
1492 | @end smallexample | |
1493 | ||
1494 | @noindent | |
1495 | @cindex line numbers, in warnings/errors | |
1496 | (where @b{NNN} is a line number). If a logical file name has been given | |
1497 | (@pxref{File,,@code{.file}}) it is used for the filename, otherwise the name of | |
1498 | the current input file is used. If a logical line number was given | |
1499 | @ifset GENERIC | |
1500 | (@pxref{Line,,@code{.line}}) | |
1501 | @end ifset | |
252b5132 RH |
1502 | then it is used to calculate the number printed, |
1503 | otherwise the actual line in the current source file is printed. The | |
1504 | message text is intended to be self explanatory (in the grand Unix | |
1505 | tradition). | |
1506 | ||
1507 | @cindex format of error messages | |
1508 | Error messages have the format | |
1509 | @smallexample | |
1510 | file_name:@b{NNN}:FATAL:Error Message Text | |
1511 | @end smallexample | |
1512 | The file name and line number are derived as for warning | |
1513 | messages. The actual message text may be rather less explanatory | |
1514 | because many of them aren't supposed to happen. | |
1515 | ||
1516 | @node Invoking | |
1517 | @chapter Command-Line Options | |
1518 | ||
1519 | @cindex options, all versions of assembler | |
1520 | This chapter describes command-line options available in @emph{all} | |
96e9638b BW |
1521 | versions of the @sc{gnu} assembler; see @ref{Machine Dependencies}, |
1522 | for options specific | |
252b5132 | 1523 | @ifclear GENERIC |
c1253627 | 1524 | to the @value{TARGET} target. |
252b5132 RH |
1525 | @end ifclear |
1526 | @ifset GENERIC | |
1527 | to particular machine architectures. | |
1528 | @end ifset | |
1529 | ||
0285c67d NC |
1530 | @c man begin DESCRIPTION |
1531 | ||
c1253627 | 1532 | If you are invoking @command{@value{AS}} via the @sc{gnu} C compiler, |
252b5132 RH |
1533 | you can use the @samp{-Wa} option to pass arguments through to the assembler. |
1534 | The assembler arguments must be separated from each other (and the @samp{-Wa}) | |
1535 | by commas. For example: | |
1536 | ||
1537 | @smallexample | |
1538 | gcc -c -g -O -Wa,-alh,-L file.c | |
1539 | @end smallexample | |
1540 | ||
1541 | @noindent | |
1542 | This passes two options to the assembler: @samp{-alh} (emit a listing to | |
5f5e16be | 1543 | standard output with high-level and assembly source) and @samp{-L} (retain |
252b5132 RH |
1544 | local symbols in the symbol table). |
1545 | ||
1546 | Usually you do not need to use this @samp{-Wa} mechanism, since many compiler | |
1547 | command-line options are automatically passed to the assembler by the compiler. | |
1548 | (You can call the @sc{gnu} compiler driver with the @samp{-v} option to see | |
1549 | precisely what options it passes to each compilation pass, including the | |
1550 | assembler.) | |
1551 | ||
0285c67d NC |
1552 | @c man end |
1553 | ||
252b5132 RH |
1554 | @menu |
1555 | * a:: -a[cdhlns] enable listings | |
caa32fe5 | 1556 | * alternate:: --alternate enable alternate macro syntax |
252b5132 RH |
1557 | * D:: -D for compatibility |
1558 | * f:: -f to work faster | |
1559 | * I:: -I for .include search path | |
1560 | @ifclear DIFF-TBL-KLUGE | |
1561 | * K:: -K for compatibility | |
1562 | @end ifclear | |
1563 | @ifset DIFF-TBL-KLUGE | |
1564 | * K:: -K for difference tables | |
1565 | @end ifset | |
1566 | ||
ba83aca1 | 1567 | * L:: -L to retain local symbols |
c3a27914 | 1568 | * listing:: --listing-XXX to configure listing output |
252b5132 RH |
1569 | * M:: -M or --mri to assemble in MRI compatibility mode |
1570 | * MD:: --MD for dependency tracking | |
1571 | * o:: -o to name the object file | |
1572 | * R:: -R to join data and text sections | |
1573 | * statistics:: --statistics to see statistics about assembly | |
1574 | * traditional-format:: --traditional-format for compatible output | |
1575 | * v:: -v to announce version | |
2bdd6cf5 | 1576 | * W:: -W, --no-warn, --warn, --fatal-warnings to control warnings |
252b5132 RH |
1577 | * Z:: -Z to make object file even after errors |
1578 | @end menu | |
1579 | ||
1580 | @node a | |
a4fb0134 | 1581 | @section Enable Listings: @option{-a[cdhlns]} |
252b5132 RH |
1582 | |
1583 | @kindex -a | |
1584 | @kindex -ac | |
1585 | @kindex -ad | |
1586 | @kindex -ah | |
1587 | @kindex -al | |
1588 | @kindex -an | |
1589 | @kindex -as | |
1590 | @cindex listings, enabling | |
1591 | @cindex assembly listings, enabling | |
1592 | ||
1593 | These options enable listing output from the assembler. By itself, | |
1594 | @samp{-a} requests high-level, assembly, and symbols listing. | |
1595 | You can use other letters to select specific options for the list: | |
1596 | @samp{-ah} requests a high-level language listing, | |
1597 | @samp{-al} requests an output-program assembly listing, and | |
1598 | @samp{-as} requests a symbol table listing. | |
1599 | High-level listings require that a compiler debugging option like | |
1600 | @samp{-g} be used, and that assembly listings (@samp{-al}) be requested | |
1601 | also. | |
1602 | ||
1603 | Use the @samp{-ac} option to omit false conditionals from a listing. Any lines | |
1604 | which are not assembled because of a false @code{.if} (or @code{.ifdef}, or any | |
1605 | other conditional), or a true @code{.if} followed by an @code{.else}, will be | |
1606 | omitted from the listing. | |
1607 | ||
1608 | Use the @samp{-ad} option to omit debugging directives from the | |
1609 | listing. | |
1610 | ||
1611 | Once you have specified one of these options, you can further control | |
1612 | listing output and its appearance using the directives @code{.list}, | |
1613 | @code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and | |
1614 | @code{.sbttl}. | |
1615 | The @samp{-an} option turns off all forms processing. | |
1616 | If you do not request listing output with one of the @samp{-a} options, the | |
1617 | listing-control directives have no effect. | |
1618 | ||
1619 | The letters after @samp{-a} may be combined into one option, | |
1620 | @emph{e.g.}, @samp{-aln}. | |
1621 | ||
96e9638b BW |
1622 | Note if the assembler source is coming from the standard input (e.g., |
1623 | because it | |
c3a27914 NC |
1624 | is being created by @code{@value{GCC}} and the @samp{-pipe} command line switch |
1625 | is being used) then the listing will not contain any comments or preprocessor | |
1626 | directives. This is because the listing code buffers input source lines from | |
1627 | stdin only after they have been preprocessed by the assembler. This reduces | |
1628 | memory usage and makes the code more efficient. | |
1629 | ||
caa32fe5 NC |
1630 | @node alternate |
1631 | @section @option{--alternate} | |
1632 | ||
1633 | @kindex --alternate | |
1634 | Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}. | |
1635 | ||
252b5132 | 1636 | @node D |
a4fb0134 | 1637 | @section @option{-D} |
252b5132 RH |
1638 | |
1639 | @kindex -D | |
1640 | This option has no effect whatsoever, but it is accepted to make it more | |
1641 | likely that scripts written for other assemblers also work with | |
a4fb0134 | 1642 | @command{@value{AS}}. |
252b5132 RH |
1643 | |
1644 | @node f | |
a4fb0134 | 1645 | @section Work Faster: @option{-f} |
252b5132 RH |
1646 | |
1647 | @kindex -f | |
1648 | @cindex trusted compiler | |
a4fb0134 | 1649 | @cindex faster processing (@option{-f}) |
252b5132 RH |
1650 | @samp{-f} should only be used when assembling programs written by a |
1651 | (trusted) compiler. @samp{-f} stops the assembler from doing whitespace | |
1652 | and comment preprocessing on | |
1653 | the input file(s) before assembling them. @xref{Preprocessing, | |
1654 | ,Preprocessing}. | |
1655 | ||
1656 | @quotation | |
1657 | @emph{Warning:} if you use @samp{-f} when the files actually need to be | |
a4fb0134 | 1658 | preprocessed (if they contain comments, for example), @command{@value{AS}} does |
252b5132 RH |
1659 | not work correctly. |
1660 | @end quotation | |
1661 | ||
1662 | @node I | |
c1253627 | 1663 | @section @code{.include} Search Path: @option{-I} @var{path} |
252b5132 RH |
1664 | |
1665 | @kindex -I @var{path} | |
1666 | @cindex paths for @code{.include} | |
1667 | @cindex search path for @code{.include} | |
1668 | @cindex @code{include} directive search path | |
1669 | Use this option to add a @var{path} to the list of directories | |
a4fb0134 SC |
1670 | @command{@value{AS}} searches for files specified in @code{.include} |
1671 | directives (@pxref{Include,,@code{.include}}). You may use @option{-I} as | |
252b5132 | 1672 | many times as necessary to include a variety of paths. The current |
a4fb0134 | 1673 | working directory is always searched first; after that, @command{@value{AS}} |
252b5132 RH |
1674 | searches any @samp{-I} directories in the same order as they were |
1675 | specified (left to right) on the command line. | |
1676 | ||
1677 | @node K | |
a4fb0134 | 1678 | @section Difference Tables: @option{-K} |
252b5132 RH |
1679 | |
1680 | @kindex -K | |
1681 | @ifclear DIFF-TBL-KLUGE | |
1682 | On the @value{TARGET} family, this option is allowed, but has no effect. It is | |
1683 | permitted for compatibility with the @sc{gnu} assembler on other platforms, | |
1684 | where it can be used to warn when the assembler alters the machine code | |
1685 | generated for @samp{.word} directives in difference tables. The @value{TARGET} | |
1686 | family does not have the addressing limitations that sometimes lead to this | |
1687 | alteration on other platforms. | |
1688 | @end ifclear | |
1689 | ||
1690 | @ifset DIFF-TBL-KLUGE | |
1691 | @cindex difference tables, warning | |
1692 | @cindex warning for altered difference tables | |
96e9638b BW |
1693 | @command{@value{AS}} sometimes alters the code emitted for directives of the |
1694 | form @samp{.word @var{sym1}-@var{sym2}}. @xref{Word,,@code{.word}}. | |
252b5132 RH |
1695 | You can use the @samp{-K} option if you want a warning issued when this |
1696 | is done. | |
1697 | @end ifset | |
1698 | ||
1699 | @node L | |
ba83aca1 | 1700 | @section Include Local Symbols: @option{-L} |
252b5132 RH |
1701 | |
1702 | @kindex -L | |
ba83aca1 BW |
1703 | @cindex local symbols, retaining in output |
1704 | Symbols beginning with system-specific local label prefixes, typically | |
1705 | @samp{.L} for ELF systems or @samp{L} for traditional a.out systems, are | |
1706 | called @dfn{local symbols}. @xref{Symbol Names}. Normally you do not see | |
1707 | such symbols when debugging, because they are intended for the use of | |
1708 | programs (like compilers) that compose assembler programs, not for your | |
1709 | notice. Normally both @command{@value{AS}} and @code{@value{LD}} discard | |
1710 | such symbols, so you do not normally debug with them. | |
1711 | ||
1712 | This option tells @command{@value{AS}} to retain those local symbols | |
252b5132 | 1713 | in the object file. Usually if you do this you also tell the linker |
ba83aca1 | 1714 | @code{@value{LD}} to preserve those symbols. |
252b5132 | 1715 | |
c3a27914 | 1716 | @node listing |
a4fb0134 | 1717 | @section Configuring listing output: @option{--listing} |
c3a27914 NC |
1718 | |
1719 | The listing feature of the assembler can be enabled via the command line switch | |
1720 | @samp{-a} (@pxref{a}). This feature combines the input source file(s) with a | |
1721 | hex dump of the corresponding locations in the output object file, and displays | |
96e9638b BW |
1722 | them as a listing file. The format of this listing can be controlled by |
1723 | directives inside the assembler source (i.e., @code{.list} (@pxref{List}), | |
1724 | @code{.title} (@pxref{Title}), @code{.sbttl} (@pxref{Sbttl}), | |
1725 | @code{.psize} (@pxref{Psize}), and | |
1726 | @code{.eject} (@pxref{Eject}) and also by the following switches: | |
c3a27914 | 1727 | |
a4fb0134 | 1728 | @table @gcctabopt |
c3a27914 NC |
1729 | @item --listing-lhs-width=@samp{number} |
1730 | @kindex --listing-lhs-width | |
1731 | @cindex Width of first line disassembly output | |
1732 | Sets the maximum width, in words, of the first line of the hex byte dump. This | |
1733 | dump appears on the left hand side of the listing output. | |
1734 | ||
1735 | @item --listing-lhs-width2=@samp{number} | |
1736 | @kindex --listing-lhs-width2 | |
1737 | @cindex Width of continuation lines of disassembly output | |
1738 | Sets the maximum width, in words, of any further lines of the hex byte dump for | |
8dfa0188 | 1739 | a given input source line. If this value is not specified, it defaults to being |
c3a27914 NC |
1740 | the same as the value specified for @samp{--listing-lhs-width}. If neither |
1741 | switch is used the default is to one. | |
1742 | ||
1743 | @item --listing-rhs-width=@samp{number} | |
1744 | @kindex --listing-rhs-width | |
1745 | @cindex Width of source line output | |
1746 | Sets the maximum width, in characters, of the source line that is displayed | |
1747 | alongside the hex dump. The default value for this parameter is 100. The | |
1748 | source line is displayed on the right hand side of the listing output. | |
1749 | ||
1750 | @item --listing-cont-lines=@samp{number} | |
1751 | @kindex --listing-cont-lines | |
1752 | @cindex Maximum number of continuation lines | |
1753 | Sets the maximum number of continuation lines of hex dump that will be | |
1754 | displayed for a given single line of source input. The default value is 4. | |
1755 | @end table | |
1756 | ||
252b5132 | 1757 | @node M |
a4fb0134 | 1758 | @section Assemble in MRI Compatibility Mode: @option{-M} |
252b5132 RH |
1759 | |
1760 | @kindex -M | |
1761 | @cindex MRI compatibility mode | |
a4fb0134 SC |
1762 | The @option{-M} or @option{--mri} option selects MRI compatibility mode. This |
1763 | changes the syntax and pseudo-op handling of @command{@value{AS}} to make it | |
252b5132 RH |
1764 | compatible with the @code{ASM68K} or the @code{ASM960} (depending upon the |
1765 | configured target) assembler from Microtec Research. The exact nature of the | |
1766 | MRI syntax will not be documented here; see the MRI manuals for more | |
1767 | information. Note in particular that the handling of macros and macro | |
1768 | arguments is somewhat different. The purpose of this option is to permit | |
a4fb0134 | 1769 | assembling existing MRI assembler code using @command{@value{AS}}. |
252b5132 RH |
1770 | |
1771 | The MRI compatibility is not complete. Certain operations of the MRI assembler | |
1772 | depend upon its object file format, and can not be supported using other object | |
1773 | file formats. Supporting these would require enhancing each object file format | |
1774 | individually. These are: | |
1775 | ||
1776 | @itemize @bullet | |
1777 | @item global symbols in common section | |
1778 | ||
1779 | The m68k MRI assembler supports common sections which are merged by the linker. | |
a4fb0134 | 1780 | Other object file formats do not support this. @command{@value{AS}} handles |
252b5132 RH |
1781 | common sections by treating them as a single common symbol. It permits local |
1782 | symbols to be defined within a common section, but it can not support global | |
1783 | symbols, since it has no way to describe them. | |
1784 | ||
1785 | @item complex relocations | |
1786 | ||
1787 | The MRI assemblers support relocations against a negated section address, and | |
1788 | relocations which combine the start addresses of two or more sections. These | |
1789 | are not support by other object file formats. | |
1790 | ||
1791 | @item @code{END} pseudo-op specifying start address | |
1792 | ||
1793 | The MRI @code{END} pseudo-op permits the specification of a start address. | |
1794 | This is not supported by other object file formats. The start address may | |
a4fb0134 | 1795 | instead be specified using the @option{-e} option to the linker, or in a linker |
252b5132 RH |
1796 | script. |
1797 | ||
1798 | @item @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops | |
1799 | ||
1800 | The MRI @code{IDNT}, @code{.ident} and @code{NAME} pseudo-ops assign a module | |
1801 | name to the output file. This is not supported by other object file formats. | |
1802 | ||
1803 | @item @code{ORG} pseudo-op | |
1804 | ||
1805 | The m68k MRI @code{ORG} pseudo-op begins an absolute section at a given | |
a4fb0134 | 1806 | address. This differs from the usual @command{@value{AS}} @code{.org} pseudo-op, |
252b5132 RH |
1807 | which changes the location within the current section. Absolute sections are |
1808 | not supported by other object file formats. The address of a section may be | |
1809 | assigned within a linker script. | |
1810 | @end itemize | |
1811 | ||
1812 | There are some other features of the MRI assembler which are not supported by | |
a4fb0134 | 1813 | @command{@value{AS}}, typically either because they are difficult or because they |
252b5132 RH |
1814 | seem of little consequence. Some of these may be supported in future releases. |
1815 | ||
1816 | @itemize @bullet | |
1817 | ||
1818 | @item EBCDIC strings | |
1819 | ||
1820 | EBCDIC strings are not supported. | |
1821 | ||
1822 | @item packed binary coded decimal | |
1823 | ||
1824 | Packed binary coded decimal is not supported. This means that the @code{DC.P} | |
1825 | and @code{DCB.P} pseudo-ops are not supported. | |
1826 | ||
1827 | @item @code{FEQU} pseudo-op | |
1828 | ||
1829 | The m68k @code{FEQU} pseudo-op is not supported. | |
1830 | ||
1831 | @item @code{NOOBJ} pseudo-op | |
1832 | ||
1833 | The m68k @code{NOOBJ} pseudo-op is not supported. | |
1834 | ||
1835 | @item @code{OPT} branch control options | |
1836 | ||
1837 | The m68k @code{OPT} branch control options---@code{B}, @code{BRS}, @code{BRB}, | |
a4fb0134 | 1838 | @code{BRL}, and @code{BRW}---are ignored. @command{@value{AS}} automatically |
252b5132 RH |
1839 | relaxes all branches, whether forward or backward, to an appropriate size, so |
1840 | these options serve no purpose. | |
1841 | ||
1842 | @item @code{OPT} list control options | |
1843 | ||
1844 | The following m68k @code{OPT} list control options are ignored: @code{C}, | |
1845 | @code{CEX}, @code{CL}, @code{CRE}, @code{E}, @code{G}, @code{I}, @code{M}, | |
1846 | @code{MEX}, @code{MC}, @code{MD}, @code{X}. | |
1847 | ||
1848 | @item other @code{OPT} options | |
1849 | ||
1850 | The following m68k @code{OPT} options are ignored: @code{NEST}, @code{O}, | |
1851 | @code{OLD}, @code{OP}, @code{P}, @code{PCO}, @code{PCR}, @code{PCS}, @code{R}. | |
1852 | ||
1853 | @item @code{OPT} @code{D} option is default | |
1854 | ||
1855 | The m68k @code{OPT} @code{D} option is the default, unlike the MRI assembler. | |
1856 | @code{OPT NOD} may be used to turn it off. | |
1857 | ||
1858 | @item @code{XREF} pseudo-op. | |
1859 | ||
1860 | The m68k @code{XREF} pseudo-op is ignored. | |
1861 | ||
1862 | @item @code{.debug} pseudo-op | |
1863 | ||
1864 | The i960 @code{.debug} pseudo-op is not supported. | |
1865 | ||
1866 | @item @code{.extended} pseudo-op | |
1867 | ||
1868 | The i960 @code{.extended} pseudo-op is not supported. | |
1869 | ||
1870 | @item @code{.list} pseudo-op. | |
1871 | ||
1872 | The various options of the i960 @code{.list} pseudo-op are not supported. | |
1873 | ||
1874 | @item @code{.optimize} pseudo-op | |
1875 | ||
1876 | The i960 @code{.optimize} pseudo-op is not supported. | |
1877 | ||
1878 | @item @code{.output} pseudo-op | |
1879 | ||
1880 | The i960 @code{.output} pseudo-op is not supported. | |
1881 | ||
1882 | @item @code{.setreal} pseudo-op | |
1883 | ||
1884 | The i960 @code{.setreal} pseudo-op is not supported. | |
1885 | ||
1886 | @end itemize | |
1887 | ||
1888 | @node MD | |
c1253627 | 1889 | @section Dependency Tracking: @option{--MD} |
252b5132 RH |
1890 | |
1891 | @kindex --MD | |
1892 | @cindex dependency tracking | |
1893 | @cindex make rules | |
1894 | ||
a4fb0134 | 1895 | @command{@value{AS}} can generate a dependency file for the file it creates. This |
252b5132 RH |
1896 | file consists of a single rule suitable for @code{make} describing the |
1897 | dependencies of the main source file. | |
1898 | ||
1899 | The rule is written to the file named in its argument. | |
1900 | ||
1901 | This feature is used in the automatic updating of makefiles. | |
1902 | ||
1903 | @node o | |
a4fb0134 | 1904 | @section Name the Object File: @option{-o} |
252b5132 RH |
1905 | |
1906 | @kindex -o | |
1907 | @cindex naming object file | |
1908 | @cindex object file name | |
a4fb0134 | 1909 | There is always one object file output when you run @command{@value{AS}}. By |
252b5132 RH |
1910 | default it has the name |
1911 | @ifset GENERIC | |
1912 | @ifset I960 | |
1913 | @file{a.out} (or @file{b.out}, for Intel 960 targets only). | |
1914 | @end ifset | |
1915 | @ifclear I960 | |
1916 | @file{a.out}. | |
1917 | @end ifclear | |
1918 | @end ifset | |
1919 | @ifclear GENERIC | |
1920 | @ifset I960 | |
1921 | @file{b.out}. | |
1922 | @end ifset | |
1923 | @ifclear I960 | |
1924 | @file{a.out}. | |
1925 | @end ifclear | |
1926 | @end ifclear | |
1927 | You use this option (which takes exactly one filename) to give the | |
1928 | object file a different name. | |
1929 | ||
a4fb0134 | 1930 | Whatever the object file is called, @command{@value{AS}} overwrites any |
252b5132 RH |
1931 | existing file of the same name. |
1932 | ||
1933 | @node R | |
a4fb0134 | 1934 | @section Join Data and Text Sections: @option{-R} |
252b5132 RH |
1935 | |
1936 | @kindex -R | |
1937 | @cindex data and text sections, joining | |
1938 | @cindex text and data sections, joining | |
1939 | @cindex joining text and data sections | |
1940 | @cindex merging text and data sections | |
a4fb0134 | 1941 | @option{-R} tells @command{@value{AS}} to write the object file as if all |
252b5132 RH |
1942 | data-section data lives in the text section. This is only done at |
1943 | the very last moment: your binary data are the same, but data | |
1944 | section parts are relocated differently. The data section part of | |
1945 | your object file is zero bytes long because all its bytes are | |
1946 | appended to the text section. (@xref{Sections,,Sections and Relocation}.) | |
1947 | ||
a4fb0134 | 1948 | When you specify @option{-R} it would be possible to generate shorter |
252b5132 RH |
1949 | address displacements (because we do not have to cross between text and |
1950 | data section). We refrain from doing this simply for compatibility with | |
a4fb0134 | 1951 | older versions of @command{@value{AS}}. In future, @option{-R} may work this way. |
252b5132 | 1952 | |
c1253627 NC |
1953 | @ifset COFF-ELF |
1954 | When @command{@value{AS}} is configured for COFF or ELF output, | |
252b5132 RH |
1955 | this option is only useful if you use sections named @samp{.text} and |
1956 | @samp{.data}. | |
1957 | @end ifset | |
1958 | ||
1959 | @ifset HPPA | |
a4fb0134 SC |
1960 | @option{-R} is not supported for any of the HPPA targets. Using |
1961 | @option{-R} generates a warning from @command{@value{AS}}. | |
252b5132 RH |
1962 | @end ifset |
1963 | ||
1964 | @node statistics | |
a4fb0134 | 1965 | @section Display Assembly Statistics: @option{--statistics} |
252b5132 RH |
1966 | |
1967 | @kindex --statistics | |
1968 | @cindex statistics, about assembly | |
1969 | @cindex time, total for assembly | |
1970 | @cindex space used, maximum for assembly | |
1971 | Use @samp{--statistics} to display two statistics about the resources used by | |
a4fb0134 | 1972 | @command{@value{AS}}: the maximum amount of space allocated during the assembly |
252b5132 RH |
1973 | (in bytes), and the total execution time taken for the assembly (in @sc{cpu} |
1974 | seconds). | |
1975 | ||
1976 | @node traditional-format | |
c1253627 | 1977 | @section Compatible Output: @option{--traditional-format} |
252b5132 RH |
1978 | |
1979 | @kindex --traditional-format | |
a4fb0134 | 1980 | For some targets, the output of @command{@value{AS}} is different in some ways |
252b5132 | 1981 | from the output of some existing assembler. This switch requests |
a4fb0134 | 1982 | @command{@value{AS}} to use the traditional format instead. |
252b5132 RH |
1983 | |
1984 | For example, it disables the exception frame optimizations which | |
a4fb0134 | 1985 | @command{@value{AS}} normally does by default on @code{@value{GCC}} output. |
252b5132 RH |
1986 | |
1987 | @node v | |
a4fb0134 | 1988 | @section Announce Version: @option{-v} |
252b5132 RH |
1989 | |
1990 | @kindex -v | |
1991 | @kindex -version | |
1992 | @cindex assembler version | |
1993 | @cindex version of assembler | |
1994 | You can find out what version of as is running by including the | |
1995 | option @samp{-v} (which you can also spell as @samp{-version}) on the | |
1996 | command line. | |
1997 | ||
1998 | @node W | |
a4fb0134 | 1999 | @section Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings} |
252b5132 | 2000 | |
a4fb0134 | 2001 | @command{@value{AS}} should never give a warning or error message when |
252b5132 | 2002 | assembling compiler output. But programs written by people often |
a4fb0134 | 2003 | cause @command{@value{AS}} to give a warning that a particular assumption was |
252b5132 | 2004 | made. All such warnings are directed to the standard error file. |
2bdd6cf5 | 2005 | |
c1253627 NC |
2006 | @kindex -W |
2007 | @kindex --no-warn | |
2bdd6cf5 GK |
2008 | @cindex suppressing warnings |
2009 | @cindex warnings, suppressing | |
a4fb0134 | 2010 | If you use the @option{-W} and @option{--no-warn} options, no warnings are issued. |
2bdd6cf5 | 2011 | This only affects the warning messages: it does not change any particular of |
a4fb0134 | 2012 | how @command{@value{AS}} assembles your file. Errors, which stop the assembly, |
2bdd6cf5 GK |
2013 | are still reported. |
2014 | ||
c1253627 | 2015 | @kindex --fatal-warnings |
2bdd6cf5 GK |
2016 | @cindex errors, caused by warnings |
2017 | @cindex warnings, causing error | |
a4fb0134 | 2018 | If you use the @option{--fatal-warnings} option, @command{@value{AS}} considers |
2bdd6cf5 GK |
2019 | files that generate warnings to be in error. |
2020 | ||
c1253627 | 2021 | @kindex --warn |
2bdd6cf5 | 2022 | @cindex warnings, switching on |
a4fb0134 | 2023 | You can switch these options off again by specifying @option{--warn}, which |
2bdd6cf5 | 2024 | causes warnings to be output as usual. |
252b5132 RH |
2025 | |
2026 | @node Z | |
a4fb0134 | 2027 | @section Generate Object File in Spite of Errors: @option{-Z} |
252b5132 RH |
2028 | @cindex object file, after errors |
2029 | @cindex errors, continuing after | |
a4fb0134 | 2030 | After an error message, @command{@value{AS}} normally produces no output. If for |
252b5132 | 2031 | some reason you are interested in object file output even after |
a4fb0134 SC |
2032 | @command{@value{AS}} gives an error message on your program, use the @samp{-Z} |
2033 | option. If there are any errors, @command{@value{AS}} continues anyways, and | |
252b5132 RH |
2034 | writes an object file after a final warning message of the form @samp{@var{n} |
2035 | errors, @var{m} warnings, generating bad object file.} | |
2036 | ||
2037 | @node Syntax | |
2038 | @chapter Syntax | |
2039 | ||
2040 | @cindex machine-independent syntax | |
2041 | @cindex syntax, machine-independent | |
2042 | This chapter describes the machine-independent syntax allowed in a | |
a4fb0134 | 2043 | source file. @command{@value{AS}} syntax is similar to what many other |
252b5132 RH |
2044 | assemblers use; it is inspired by the BSD 4.2 |
2045 | @ifclear VAX | |
2046 | assembler. | |
2047 | @end ifclear | |
2048 | @ifset VAX | |
a4fb0134 | 2049 | assembler, except that @command{@value{AS}} does not assemble Vax bit-fields. |
252b5132 RH |
2050 | @end ifset |
2051 | ||
2052 | @menu | |
2053 | * Preprocessing:: Preprocessing | |
2054 | * Whitespace:: Whitespace | |
2055 | * Comments:: Comments | |
2056 | * Symbol Intro:: Symbols | |
2057 | * Statements:: Statements | |
2058 | * Constants:: Constants | |
2059 | @end menu | |
2060 | ||
2061 | @node Preprocessing | |
2062 | @section Preprocessing | |
2063 | ||
2064 | @cindex preprocessing | |
a4fb0134 | 2065 | The @command{@value{AS}} internal preprocessor: |
252b5132 RH |
2066 | @itemize @bullet |
2067 | @cindex whitespace, removed by preprocessor | |
2068 | @item | |
2069 | adjusts and removes extra whitespace. It leaves one space or tab before | |
2070 | the keywords on a line, and turns any other whitespace on the line into | |
2071 | a single space. | |
2072 | ||
2073 | @cindex comments, removed by preprocessor | |
2074 | @item | |
2075 | removes all comments, replacing them with a single space, or an | |
2076 | appropriate number of newlines. | |
2077 | ||
2078 | @cindex constants, converted by preprocessor | |
2079 | @item | |
2080 | converts character constants into the appropriate numeric values. | |
2081 | @end itemize | |
2082 | ||
2083 | It does not do macro processing, include file handling, or | |
2084 | anything else you may get from your C compiler's preprocessor. You can | |
2085 | do include file processing with the @code{.include} directive | |
2086 | (@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver | |
c1253627 | 2087 | to get other ``CPP'' style preprocessing by giving the input file a |
96e9638b | 2088 | @samp{.S} suffix. @xref{Overall Options, ,Options Controlling the Kind of |
252b5132 RH |
2089 | Output, gcc.info, Using GNU CC}. |
2090 | ||
2091 | Excess whitespace, comments, and character constants | |
2092 | cannot be used in the portions of the input text that are not | |
2093 | preprocessed. | |
2094 | ||
2095 | @cindex turning preprocessing on and off | |
2096 | @cindex preprocessing, turning on and off | |
2097 | @kindex #NO_APP | |
2098 | @kindex #APP | |
2099 | If the first line of an input file is @code{#NO_APP} or if you use the | |
2100 | @samp{-f} option, whitespace and comments are not removed from the input file. | |
2101 | Within an input file, you can ask for whitespace and comment removal in | |
2102 | specific portions of the by putting a line that says @code{#APP} before the | |
2103 | text that may contain whitespace or comments, and putting a line that says | |
2104 | @code{#NO_APP} after this text. This feature is mainly intend to support | |
2105 | @code{asm} statements in compilers whose output is otherwise free of comments | |
2106 | and whitespace. | |
2107 | ||
2108 | @node Whitespace | |
2109 | @section Whitespace | |
2110 | ||
2111 | @cindex whitespace | |
2112 | @dfn{Whitespace} is one or more blanks or tabs, in any order. | |
2113 | Whitespace is used to separate symbols, and to make programs neater for | |
2114 | people to read. Unless within character constants | |
2115 | (@pxref{Characters,,Character Constants}), any whitespace means the same | |
2116 | as exactly one space. | |
2117 | ||
2118 | @node Comments | |
2119 | @section Comments | |
2120 | ||
2121 | @cindex comments | |
a4fb0134 | 2122 | There are two ways of rendering comments to @command{@value{AS}}. In both |
252b5132 RH |
2123 | cases the comment is equivalent to one space. |
2124 | ||
2125 | Anything from @samp{/*} through the next @samp{*/} is a comment. | |
2126 | This means you may not nest these comments. | |
2127 | ||
2128 | @smallexample | |
2129 | /* | |
2130 | The only way to include a newline ('\n') in a comment | |
2131 | is to use this sort of comment. | |
2132 | */ | |
2133 | ||
2134 | /* This sort of comment does not nest. */ | |
2135 | @end smallexample | |
2136 | ||
2137 | @cindex line comment character | |
2138 | Anything from the @dfn{line comment} character to the next newline | |
2139 | is considered a comment and is ignored. The line comment character is | |
252b5132 RH |
2140 | @ifset ARC |
2141 | @samp{;} on the ARC; | |
2142 | @end ifset | |
550262c4 NC |
2143 | @ifset ARM |
2144 | @samp{@@} on the ARM; | |
2145 | @end ifset | |
252b5132 RH |
2146 | @ifset H8/300 |
2147 | @samp{;} for the H8/300 family; | |
2148 | @end ifset | |
252b5132 RH |
2149 | @ifset HPPA |
2150 | @samp{;} for the HPPA; | |
2151 | @end ifset | |
55b62671 AJ |
2152 | @ifset I80386 |
2153 | @samp{#} on the i386 and x86-64; | |
2154 | @end ifset | |
252b5132 RH |
2155 | @ifset I960 |
2156 | @samp{#} on the i960; | |
2157 | @end ifset | |
e135f41b NC |
2158 | @ifset PDP11 |
2159 | @samp{;} for the PDP-11; | |
2160 | @end ifset | |
041dd5a9 ILT |
2161 | @ifset PJ |
2162 | @samp{;} for picoJava; | |
2163 | @end ifset | |
418c1742 | 2164 | @ifset PPC |
3fb9d77f | 2165 | @samp{#} for Motorola PowerPC; |
418c1742 | 2166 | @end ifset |
252b5132 | 2167 | @ifset SH |
ef230218 | 2168 | @samp{!} for the Renesas / SuperH SH; |
252b5132 RH |
2169 | @end ifset |
2170 | @ifset SPARC | |
2171 | @samp{!} on the SPARC; | |
2172 | @end ifset | |
a40cbfa3 NC |
2173 | @ifset IP2K |
2174 | @samp{#} on the ip2k; | |
2175 | @end ifset | |
49f58d10 JB |
2176 | @ifset M32C |
2177 | @samp{#} on the m32c; | |
2178 | @end ifset | |
252b5132 RH |
2179 | @ifset M32R |
2180 | @samp{#} on the m32r; | |
2181 | @end ifset | |
2182 | @ifset M680X0 | |
2183 | @samp{|} on the 680x0; | |
2184 | @end ifset | |
60bcf0fa NC |
2185 | @ifset M68HC11 |
2186 | @samp{#} on the 68HC11 and 68HC12; | |
2187 | @end ifset | |
252b5132 RH |
2188 | @ifset VAX |
2189 | @samp{#} on the Vax; | |
2190 | @end ifset | |
3c9b82ba NC |
2191 | @ifset Z80 |
2192 | @samp{;} for the Z80; | |
2193 | @end ifset | |
252b5132 RH |
2194 | @ifset Z8000 |
2195 | @samp{!} for the Z8000; | |
2196 | @end ifset | |
2197 | @ifset V850 | |
2198 | @samp{#} on the V850; | |
2199 | @end ifset | |
e0001a05 NC |
2200 | @ifset XTENSA |
2201 | @samp{#} for Xtensa systems; | |
2202 | @end ifset | |
252b5132 | 2203 | see @ref{Machine Dependencies}. @refill |
81b0b3f1 | 2204 | @c FIXME What about i860? |
252b5132 RH |
2205 | |
2206 | @ifset GENERIC | |
2207 | On some machines there are two different line comment characters. One | |
2208 | character only begins a comment if it is the first non-whitespace character on | |
2209 | a line, while the other always begins a comment. | |
2210 | @end ifset | |
2211 | ||
2212 | @ifset V850 | |
2213 | The V850 assembler also supports a double dash as starting a comment that | |
2214 | extends to the end of the line. | |
2215 | ||
2216 | @samp{--}; | |
2217 | @end ifset | |
2218 | ||
2219 | @kindex # | |
2220 | @cindex lines starting with @code{#} | |
2221 | @cindex logical line numbers | |
2222 | To be compatible with past assemblers, lines that begin with @samp{#} have a | |
2223 | special interpretation. Following the @samp{#} should be an absolute | |
2224 | expression (@pxref{Expressions}): the logical line number of the @emph{next} | |
96e9638b | 2225 | line. Then a string (@pxref{Strings, ,Strings}) is allowed: if present it is a |
252b5132 RH |
2226 | new logical file name. The rest of the line, if any, should be whitespace. |
2227 | ||
2228 | If the first non-whitespace characters on the line are not numeric, | |
2229 | the line is ignored. (Just like a comment.) | |
2230 | ||
2231 | @smallexample | |
2232 | # This is an ordinary comment. | |
2233 | # 42-6 "new_file_name" # New logical file name | |
2234 | # This is logical line # 36. | |
2235 | @end smallexample | |
2236 | This feature is deprecated, and may disappear from future versions | |
a4fb0134 | 2237 | of @command{@value{AS}}. |
252b5132 RH |
2238 | |
2239 | @node Symbol Intro | |
2240 | @section Symbols | |
2241 | ||
2242 | @cindex characters used in symbols | |
2243 | @ifclear SPECIAL-SYMS | |
2244 | A @dfn{symbol} is one or more characters chosen from the set of all | |
2245 | letters (both upper and lower case), digits and the three characters | |
2246 | @samp{_.$}. | |
2247 | @end ifclear | |
2248 | @ifset SPECIAL-SYMS | |
2249 | @ifclear GENERIC | |
2250 | @ifset H8 | |
2251 | A @dfn{symbol} is one or more characters chosen from the set of all | |
2252 | letters (both upper and lower case), digits and the three characters | |
2253 | @samp{._$}. (Save that, on the H8/300 only, you may not use @samp{$} in | |
2254 | symbol names.) | |
2255 | @end ifset | |
2256 | @end ifclear | |
2257 | @end ifset | |
2258 | @ifset GENERIC | |
2259 | On most machines, you can also use @code{$} in symbol names; exceptions | |
2260 | are noted in @ref{Machine Dependencies}. | |
2261 | @end ifset | |
2262 | No symbol may begin with a digit. Case is significant. | |
2263 | There is no length limit: all characters are significant. Symbols are | |
2264 | delimited by characters not in that set, or by the beginning of a file | |
2265 | (since the source program must end with a newline, the end of a file is | |
2266 | not a possible symbol delimiter). @xref{Symbols}. | |
2267 | @cindex length of symbols | |
2268 | ||
2269 | @node Statements | |
2270 | @section Statements | |
2271 | ||
2272 | @cindex statements, structure of | |
2273 | @cindex line separator character | |
2274 | @cindex statement separator character | |
2275 | @ifclear GENERIC | |
2276 | @ifclear abnormal-separator | |
2277 | A @dfn{statement} ends at a newline character (@samp{\n}) or at a | |
2278 | semicolon (@samp{;}). The newline or semicolon is considered part of | |
2279 | the preceding statement. Newlines and semicolons within character | |
2280 | constants are an exception: they do not end statements. | |
2281 | @end ifclear | |
2282 | @ifset abnormal-separator | |
252b5132 RH |
2283 | @ifset HPPA |
2284 | A @dfn{statement} ends at a newline character (@samp{\n}) or an exclamation | |
2285 | point (@samp{!}). The newline or exclamation point is considered part of the | |
2286 | preceding statement. Newlines and exclamation points within character | |
2287 | constants are an exception: they do not end statements. | |
2288 | @end ifset | |
2289 | @ifset H8 | |
2290 | A @dfn{statement} ends at a newline character (@samp{\n}); or (for the | |
7be1c489 | 2291 | H8/300) a dollar sign (@samp{$}); or (for the Renesas-SH) a semicolon |
252b5132 RH |
2292 | (@samp{;}). The newline or separator character is considered part of |
2293 | the preceding statement. Newlines and separators within character | |
2294 | constants are an exception: they do not end statements. | |
2295 | @end ifset | |
2296 | @end ifset | |
2297 | @end ifclear | |
2298 | @ifset GENERIC | |
2299 | A @dfn{statement} ends at a newline character (@samp{\n}) or line | |
96e9638b BW |
2300 | separator character. (The line separator is usually @samp{;}, unless this |
2301 | conflicts with the comment character; see @ref{Machine Dependencies}.) The | |
252b5132 RH |
2302 | newline or separator character is considered part of the preceding |
2303 | statement. Newlines and separators within character constants are an | |
2304 | exception: they do not end statements. | |
2305 | @end ifset | |
2306 | ||
2307 | @cindex newline, required at file end | |
2308 | @cindex EOF, newline must precede | |
2309 | It is an error to end any statement with end-of-file: the last | |
2310 | character of any input file should be a newline.@refill | |
2311 | ||
2312 | An empty statement is allowed, and may include whitespace. It is ignored. | |
2313 | ||
2314 | @cindex instructions and directives | |
2315 | @cindex directives and instructions | |
2316 | @c "key symbol" is not used elsewhere in the document; seems pedantic to | |
2317 | @c @defn{} it in that case, as was done previously... doc@cygnus.com, | |
2318 | @c 13feb91. | |
2319 | A statement begins with zero or more labels, optionally followed by a | |
2320 | key symbol which determines what kind of statement it is. The key | |
2321 | symbol determines the syntax of the rest of the statement. If the | |
2322 | symbol begins with a dot @samp{.} then the statement is an assembler | |
2323 | directive: typically valid for any computer. If the symbol begins with | |
2324 | a letter the statement is an assembly language @dfn{instruction}: it | |
2325 | assembles into a machine language instruction. | |
2326 | @ifset GENERIC | |
a4fb0134 | 2327 | Different versions of @command{@value{AS}} for different computers |
252b5132 RH |
2328 | recognize different instructions. In fact, the same symbol may |
2329 | represent a different instruction in a different computer's assembly | |
2330 | language.@refill | |
2331 | @end ifset | |
2332 | ||
2333 | @cindex @code{:} (label) | |
2334 | @cindex label (@code{:}) | |
2335 | A label is a symbol immediately followed by a colon (@code{:}). | |
2336 | Whitespace before a label or after a colon is permitted, but you may not | |
2337 | have whitespace between a label's symbol and its colon. @xref{Labels}. | |
2338 | ||
2339 | @ifset HPPA | |
2340 | For HPPA targets, labels need not be immediately followed by a colon, but | |
2341 | the definition of a label must begin in column zero. This also implies that | |
2342 | only one label may be defined on each line. | |
2343 | @end ifset | |
2344 | ||
2345 | @smallexample | |
2346 | label: .directive followed by something | |
2347 | another_label: # This is an empty statement. | |
2348 | instruction operand_1, operand_2, @dots{} | |
2349 | @end smallexample | |
2350 | ||
2351 | @node Constants | |
2352 | @section Constants | |
2353 | ||
2354 | @cindex constants | |
2355 | A constant is a number, written so that its value is known by | |
2356 | inspection, without knowing any context. Like this: | |
2357 | @smallexample | |
2358 | @group | |
2359 | .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value. | |
2360 | .ascii "Ring the bell\7" # A string constant. | |
2361 | .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum. | |
2362 | .float 0f-314159265358979323846264338327\ | |
2363 | 95028841971.693993751E-40 # - pi, a flonum. | |
2364 | @end group | |
2365 | @end smallexample | |
2366 | ||
2367 | @menu | |
2368 | * Characters:: Character Constants | |
2369 | * Numbers:: Number Constants | |
2370 | @end menu | |
2371 | ||
2372 | @node Characters | |
2373 | @subsection Character Constants | |
2374 | ||
2375 | @cindex character constants | |
2376 | @cindex constants, character | |
2377 | There are two kinds of character constants. A @dfn{character} stands | |
2378 | for one character in one byte and its value may be used in | |
2379 | numeric expressions. String constants (properly called string | |
2380 | @emph{literals}) are potentially many bytes and their values may not be | |
2381 | used in arithmetic expressions. | |
2382 | ||
2383 | @menu | |
2384 | * Strings:: Strings | |
2385 | * Chars:: Characters | |
2386 | @end menu | |
2387 | ||
2388 | @node Strings | |
2389 | @subsubsection Strings | |
2390 | ||
2391 | @cindex string constants | |
2392 | @cindex constants, string | |
2393 | A @dfn{string} is written between double-quotes. It may contain | |
2394 | double-quotes or null characters. The way to get special characters | |
2395 | into a string is to @dfn{escape} these characters: precede them with | |
2396 | a backslash @samp{\} character. For example @samp{\\} represents | |
2397 | one backslash: the first @code{\} is an escape which tells | |
a4fb0134 SC |
2398 | @command{@value{AS}} to interpret the second character literally as a backslash |
2399 | (which prevents @command{@value{AS}} from recognizing the second @code{\} as an | |
252b5132 RH |
2400 | escape character). The complete list of escapes follows. |
2401 | ||
2402 | @cindex escape codes, character | |
2403 | @cindex character escape codes | |
2404 | @table @kbd | |
2405 | @c @item \a | |
2406 | @c Mnemonic for ACKnowledge; for ASCII this is octal code 007. | |
2407 | @c | |
2408 | @cindex @code{\b} (backspace character) | |
2409 | @cindex backspace (@code{\b}) | |
2410 | @item \b | |
2411 | Mnemonic for backspace; for ASCII this is octal code 010. | |
2412 | ||
2413 | @c @item \e | |
2414 | @c Mnemonic for EOText; for ASCII this is octal code 004. | |
2415 | @c | |
2416 | @cindex @code{\f} (formfeed character) | |
2417 | @cindex formfeed (@code{\f}) | |
2418 | @item \f | |
2419 | Mnemonic for FormFeed; for ASCII this is octal code 014. | |
2420 | ||
2421 | @cindex @code{\n} (newline character) | |
2422 | @cindex newline (@code{\n}) | |
2423 | @item \n | |
2424 | Mnemonic for newline; for ASCII this is octal code 012. | |
2425 | ||
2426 | @c @item \p | |
2427 | @c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}. | |
2428 | @c | |
2429 | @cindex @code{\r} (carriage return character) | |
2430 | @cindex carriage return (@code{\r}) | |
2431 | @item \r | |
2432 | Mnemonic for carriage-Return; for ASCII this is octal code 015. | |
2433 | ||
2434 | @c @item \s | |
2435 | @c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with | |
2436 | @c other assemblers. | |
2437 | @c | |
2438 | @cindex @code{\t} (tab) | |
2439 | @cindex tab (@code{\t}) | |
2440 | @item \t | |
2441 | Mnemonic for horizontal Tab; for ASCII this is octal code 011. | |
2442 | ||
2443 | @c @item \v | |
2444 | @c Mnemonic for Vertical tab; for ASCII this is octal code 013. | |
2445 | @c @item \x @var{digit} @var{digit} @var{digit} | |
2446 | @c A hexadecimal character code. The numeric code is 3 hexadecimal digits. | |
2447 | @c | |
2448 | @cindex @code{\@var{ddd}} (octal character code) | |
2449 | @cindex octal character code (@code{\@var{ddd}}) | |
2450 | @item \ @var{digit} @var{digit} @var{digit} | |
2451 | An octal character code. The numeric code is 3 octal digits. | |
2452 | For compatibility with other Unix systems, 8 and 9 are accepted as digits: | |
2453 | for example, @code{\008} has the value 010, and @code{\009} the value 011. | |
2454 | ||
2455 | @cindex @code{\@var{xd...}} (hex character code) | |
2456 | @cindex hex character code (@code{\@var{xd...}}) | |
2457 | @item \@code{x} @var{hex-digits...} | |
2458 | A hex character code. All trailing hex digits are combined. Either upper or | |
2459 | lower case @code{x} works. | |
2460 | ||
2461 | @cindex @code{\\} (@samp{\} character) | |
2462 | @cindex backslash (@code{\\}) | |
2463 | @item \\ | |
2464 | Represents one @samp{\} character. | |
2465 | ||
2466 | @c @item \' | |
2467 | @c Represents one @samp{'} (accent acute) character. | |
2468 | @c This is needed in single character literals | |
2469 | @c (@xref{Characters,,Character Constants}.) to represent | |
2470 | @c a @samp{'}. | |
2471 | @c | |
2472 | @cindex @code{\"} (doublequote character) | |
2473 | @cindex doublequote (@code{\"}) | |
2474 | @item \" | |
2475 | Represents one @samp{"} character. Needed in strings to represent | |
2476 | this character, because an unescaped @samp{"} would end the string. | |
2477 | ||
2478 | @item \ @var{anything-else} | |
2479 | Any other character when escaped by @kbd{\} gives a warning, but | |
2480 | assembles as if the @samp{\} was not present. The idea is that if | |
2481 | you used an escape sequence you clearly didn't want the literal | |
a4fb0134 SC |
2482 | interpretation of the following character. However @command{@value{AS}} has no |
2483 | other interpretation, so @command{@value{AS}} knows it is giving you the wrong | |
252b5132 RH |
2484 | code and warns you of the fact. |
2485 | @end table | |
2486 | ||
2487 | Which characters are escapable, and what those escapes represent, | |
2488 | varies widely among assemblers. The current set is what we think | |
2489 | the BSD 4.2 assembler recognizes, and is a subset of what most C | |
2490 | compilers recognize. If you are in doubt, do not use an escape | |
2491 | sequence. | |
2492 | ||
2493 | @node Chars | |
2494 | @subsubsection Characters | |
2495 | ||
2496 | @cindex single character constant | |
2497 | @cindex character, single | |
2498 | @cindex constant, single character | |
2499 | A single character may be written as a single quote immediately | |
2500 | followed by that character. The same escapes apply to characters as | |
2501 | to strings. So if you want to write the character backslash, you | |
2502 | must write @kbd{'\\} where the first @code{\} escapes the second | |
2503 | @code{\}. As you can see, the quote is an acute accent, not a | |
2504 | grave accent. A newline | |
2505 | @ifclear GENERIC | |
2506 | @ifclear abnormal-separator | |
2507 | (or semicolon @samp{;}) | |
2508 | @end ifclear | |
2509 | @ifset abnormal-separator | |
252b5132 RH |
2510 | @ifset H8 |
2511 | (or dollar sign @samp{$}, for the H8/300; or semicolon @samp{;} for the | |
7be1c489 | 2512 | Renesas SH) |
252b5132 RH |
2513 | @end ifset |
2514 | @end ifset | |
2515 | @end ifclear | |
2516 | immediately following an acute accent is taken as a literal character | |
2517 | and does not count as the end of a statement. The value of a character | |
2518 | constant in a numeric expression is the machine's byte-wide code for | |
a4fb0134 | 2519 | that character. @command{@value{AS}} assumes your character code is ASCII: |
252b5132 RH |
2520 | @kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill |
2521 | ||
2522 | @node Numbers | |
2523 | @subsection Number Constants | |
2524 | ||
2525 | @cindex constants, number | |
2526 | @cindex number constants | |
a4fb0134 | 2527 | @command{@value{AS}} distinguishes three kinds of numbers according to how they |
252b5132 RH |
2528 | are stored in the target machine. @emph{Integers} are numbers that |
2529 | would fit into an @code{int} in the C language. @emph{Bignums} are | |
2530 | integers, but they are stored in more than 32 bits. @emph{Flonums} | |
2531 | are floating point numbers, described below. | |
2532 | ||
2533 | @menu | |
2534 | * Integers:: Integers | |
2535 | * Bignums:: Bignums | |
2536 | * Flonums:: Flonums | |
2537 | @ifclear GENERIC | |
2538 | @ifset I960 | |
2539 | * Bit Fields:: Bit Fields | |
2540 | @end ifset | |
2541 | @end ifclear | |
2542 | @end menu | |
2543 | ||
2544 | @node Integers | |
2545 | @subsubsection Integers | |
2546 | @cindex integers | |
2547 | @cindex constants, integer | |
2548 | ||
2549 | @cindex binary integers | |
2550 | @cindex integers, binary | |
2551 | A binary integer is @samp{0b} or @samp{0B} followed by zero or more of | |
2552 | the binary digits @samp{01}. | |
2553 | ||
2554 | @cindex octal integers | |
2555 | @cindex integers, octal | |
2556 | An octal integer is @samp{0} followed by zero or more of the octal | |
2557 | digits (@samp{01234567}). | |
2558 | ||
2559 | @cindex decimal integers | |
2560 | @cindex integers, decimal | |
2561 | A decimal integer starts with a non-zero digit followed by zero or | |
2562 | more digits (@samp{0123456789}). | |
2563 | ||
2564 | @cindex hexadecimal integers | |
2565 | @cindex integers, hexadecimal | |
2566 | A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or | |
2567 | more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}. | |
2568 | ||
2569 | Integers have the usual values. To denote a negative integer, use | |
2570 | the prefix operator @samp{-} discussed under expressions | |
2571 | (@pxref{Prefix Ops,,Prefix Operators}). | |
2572 | ||
2573 | @node Bignums | |
2574 | @subsubsection Bignums | |
2575 | ||
2576 | @cindex bignums | |
2577 | @cindex constants, bignum | |
2578 | A @dfn{bignum} has the same syntax and semantics as an integer | |
2579 | except that the number (or its negative) takes more than 32 bits to | |
2580 | represent in binary. The distinction is made because in some places | |
2581 | integers are permitted while bignums are not. | |
2582 | ||
2583 | @node Flonums | |
2584 | @subsubsection Flonums | |
2585 | @cindex flonums | |
2586 | @cindex floating point numbers | |
2587 | @cindex constants, floating point | |
2588 | ||
2589 | @cindex precision, floating point | |
2590 | A @dfn{flonum} represents a floating point number. The translation is | |
2591 | indirect: a decimal floating point number from the text is converted by | |
a4fb0134 | 2592 | @command{@value{AS}} to a generic binary floating point number of more than |
252b5132 RH |
2593 | sufficient precision. This generic floating point number is converted |
2594 | to a particular computer's floating point format (or formats) by a | |
a4fb0134 | 2595 | portion of @command{@value{AS}} specialized to that computer. |
252b5132 RH |
2596 | |
2597 | A flonum is written by writing (in order) | |
2598 | @itemize @bullet | |
2599 | @item | |
2600 | The digit @samp{0}. | |
2601 | @ifset HPPA | |
2602 | (@samp{0} is optional on the HPPA.) | |
2603 | @end ifset | |
2604 | ||
2605 | @item | |
a4fb0134 | 2606 | A letter, to tell @command{@value{AS}} the rest of the number is a flonum. |
252b5132 RH |
2607 | @ifset GENERIC |
2608 | @kbd{e} is recommended. Case is not important. | |
2609 | @ignore | |
2610 | @c FIXME: verify if flonum syntax really this vague for most cases | |
2611 | (Any otherwise illegal letter works here, but that might be changed. Vax BSD | |
2612 | 4.2 assembler seems to allow any of @samp{defghDEFGH}.) | |
2613 | @end ignore | |
2614 | ||
7be1c489 | 2615 | On the H8/300, Renesas / SuperH SH, |
252b5132 RH |
2616 | and AMD 29K architectures, the letter must be |
2617 | one of the letters @samp{DFPRSX} (in upper or lower case). | |
2618 | ||
2619 | On the ARC, the letter must be one of the letters @samp{DFRS} | |
2620 | (in upper or lower case). | |
2621 | ||
2622 | On the Intel 960 architecture, the letter must be | |
2623 | one of the letters @samp{DFT} (in upper or lower case). | |
2624 | ||
2625 | On the HPPA architecture, the letter must be @samp{E} (upper case only). | |
2626 | @end ifset | |
2627 | @ifclear GENERIC | |
252b5132 RH |
2628 | @ifset ARC |
2629 | One of the letters @samp{DFRS} (in upper or lower case). | |
2630 | @end ifset | |
2631 | @ifset H8 | |
2632 | One of the letters @samp{DFPRSX} (in upper or lower case). | |
2633 | @end ifset | |
2634 | @ifset HPPA | |
2635 | The letter @samp{E} (upper case only). | |
2636 | @end ifset | |
2637 | @ifset I960 | |
2638 | One of the letters @samp{DFT} (in upper or lower case). | |
2639 | @end ifset | |
2640 | @end ifclear | |
2641 | ||
2642 | @item | |
2643 | An optional sign: either @samp{+} or @samp{-}. | |
2644 | ||
2645 | @item | |
2646 | An optional @dfn{integer part}: zero or more decimal digits. | |
2647 | ||
2648 | @item | |
2649 | An optional @dfn{fractional part}: @samp{.} followed by zero | |
2650 | or more decimal digits. | |
2651 | ||
2652 | @item | |
2653 | An optional exponent, consisting of: | |
2654 | ||
2655 | @itemize @bullet | |
2656 | @item | |
2657 | An @samp{E} or @samp{e}. | |
2658 | @c I can't find a config where "EXP_CHARS" is other than 'eE', but in | |
2659 | @c principle this can perfectly well be different on different targets. | |
2660 | @item | |
2661 | Optional sign: either @samp{+} or @samp{-}. | |
2662 | @item | |
2663 | One or more decimal digits. | |
2664 | @end itemize | |
2665 | ||
2666 | @end itemize | |
2667 | ||
2668 | At least one of the integer part or the fractional part must be | |
2669 | present. The floating point number has the usual base-10 value. | |
2670 | ||
a4fb0134 | 2671 | @command{@value{AS}} does all processing using integers. Flonums are computed |
252b5132 | 2672 | independently of any floating point hardware in the computer running |
a4fb0134 | 2673 | @command{@value{AS}}. |
252b5132 RH |
2674 | |
2675 | @ifclear GENERIC | |
2676 | @ifset I960 | |
2677 | @c Bit fields are written as a general facility but are also controlled | |
2678 | @c by a conditional-compilation flag---which is as of now (21mar91) | |
2679 | @c turned on only by the i960 config of GAS. | |
2680 | @node Bit Fields | |
2681 | @subsubsection Bit Fields | |
2682 | ||
2683 | @cindex bit fields | |
2684 | @cindex constants, bit field | |
2685 | You can also define numeric constants as @dfn{bit fields}. | |
b45619c0 | 2686 | Specify two numbers separated by a colon--- |
252b5132 RH |
2687 | @example |
2688 | @var{mask}:@var{value} | |
2689 | @end example | |
2690 | @noindent | |
a4fb0134 | 2691 | @command{@value{AS}} applies a bitwise @sc{and} between @var{mask} and |
252b5132 RH |
2692 | @var{value}. |
2693 | ||
2694 | The resulting number is then packed | |
2695 | @ifset GENERIC | |
2696 | @c this conditional paren in case bit fields turned on elsewhere than 960 | |
2697 | (in host-dependent byte order) | |
2698 | @end ifset | |
2699 | into a field whose width depends on which assembler directive has the | |
2700 | bit-field as its argument. Overflow (a result from the bitwise and | |
2701 | requiring more binary digits to represent) is not an error; instead, | |
2702 | more constants are generated, of the specified width, beginning with the | |
2703 | least significant digits.@refill | |
2704 | ||
2705 | The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long}, | |
2706 | @code{.short}, and @code{.word} accept bit-field arguments. | |
2707 | @end ifset | |
2708 | @end ifclear | |
2709 | ||
2710 | @node Sections | |
2711 | @chapter Sections and Relocation | |
2712 | @cindex sections | |
2713 | @cindex relocation | |
2714 | ||
2715 | @menu | |
2716 | * Secs Background:: Background | |
2717 | * Ld Sections:: Linker Sections | |
2718 | * As Sections:: Assembler Internal Sections | |
2719 | * Sub-Sections:: Sub-Sections | |
2720 | * bss:: bss Section | |
2721 | @end menu | |
2722 | ||
2723 | @node Secs Background | |
2724 | @section Background | |
2725 | ||
2726 | Roughly, a section is a range of addresses, with no gaps; all data | |
2727 | ``in'' those addresses is treated the same for some particular purpose. | |
2728 | For example there may be a ``read only'' section. | |
2729 | ||
2730 | @cindex linker, and assembler | |
2731 | @cindex assembler, and linker | |
2732 | The linker @code{@value{LD}} reads many object files (partial programs) and | |
a4fb0134 | 2733 | combines their contents to form a runnable program. When @command{@value{AS}} |
252b5132 RH |
2734 | emits an object file, the partial program is assumed to start at address 0. |
2735 | @code{@value{LD}} assigns the final addresses for the partial program, so that | |
2736 | different partial programs do not overlap. This is actually an | |
a4fb0134 | 2737 | oversimplification, but it suffices to explain how @command{@value{AS}} uses |
252b5132 RH |
2738 | sections. |
2739 | ||
2740 | @code{@value{LD}} moves blocks of bytes of your program to their run-time | |
2741 | addresses. These blocks slide to their run-time addresses as rigid | |
2742 | units; their length does not change and neither does the order of bytes | |
2743 | within them. Such a rigid unit is called a @emph{section}. Assigning | |
2744 | run-time addresses to sections is called @dfn{relocation}. It includes | |
2745 | the task of adjusting mentions of object-file addresses so they refer to | |
2746 | the proper run-time addresses. | |
2747 | @ifset H8 | |
7be1c489 | 2748 | For the H8/300, and for the Renesas / SuperH SH, |
a4fb0134 | 2749 | @command{@value{AS}} pads sections if needed to |
252b5132 RH |
2750 | ensure they end on a word (sixteen bit) boundary. |
2751 | @end ifset | |
2752 | ||
2753 | @cindex standard assembler sections | |
a4fb0134 | 2754 | An object file written by @command{@value{AS}} has at least three sections, any |
252b5132 RH |
2755 | of which may be empty. These are named @dfn{text}, @dfn{data} and |
2756 | @dfn{bss} sections. | |
2757 | ||
c1253627 | 2758 | @ifset COFF-ELF |
252b5132 | 2759 | @ifset GENERIC |
c1253627 | 2760 | When it generates COFF or ELF output, |
252b5132 | 2761 | @end ifset |
a4fb0134 | 2762 | @command{@value{AS}} can also generate whatever other named sections you specify |
252b5132 RH |
2763 | using the @samp{.section} directive (@pxref{Section,,@code{.section}}). |
2764 | If you do not use any directives that place output in the @samp{.text} | |
2765 | or @samp{.data} sections, these sections still exist, but are empty. | |
2766 | @end ifset | |
2767 | ||
2768 | @ifset HPPA | |
2769 | @ifset GENERIC | |
a4fb0134 | 2770 | When @command{@value{AS}} generates SOM or ELF output for the HPPA, |
252b5132 | 2771 | @end ifset |
a4fb0134 | 2772 | @command{@value{AS}} can also generate whatever other named sections you |
252b5132 RH |
2773 | specify using the @samp{.space} and @samp{.subspace} directives. See |
2774 | @cite{HP9000 Series 800 Assembly Language Reference Manual} | |
2775 | (HP 92432-90001) for details on the @samp{.space} and @samp{.subspace} | |
2776 | assembler directives. | |
2777 | ||
2778 | @ifset SOM | |
a4fb0134 | 2779 | Additionally, @command{@value{AS}} uses different names for the standard |
252b5132 RH |
2780 | text, data, and bss sections when generating SOM output. Program text |
2781 | is placed into the @samp{$CODE$} section, data into @samp{$DATA$}, and | |
2782 | BSS into @samp{$BSS$}. | |
2783 | @end ifset | |
2784 | @end ifset | |
2785 | ||
2786 | Within the object file, the text section starts at address @code{0}, the | |
2787 | data section follows, and the bss section follows the data section. | |
2788 | ||
2789 | @ifset HPPA | |
2790 | When generating either SOM or ELF output files on the HPPA, the text | |
2791 | section starts at address @code{0}, the data section at address | |
2792 | @code{0x4000000}, and the bss section follows the data section. | |
2793 | @end ifset | |
2794 | ||
2795 | To let @code{@value{LD}} know which data changes when the sections are | |
a4fb0134 | 2796 | relocated, and how to change that data, @command{@value{AS}} also writes to the |
252b5132 RH |
2797 | object file details of the relocation needed. To perform relocation |
2798 | @code{@value{LD}} must know, each time an address in the object | |
2799 | file is mentioned: | |
2800 | @itemize @bullet | |
2801 | @item | |
2802 | Where in the object file is the beginning of this reference to | |
2803 | an address? | |
2804 | @item | |
2805 | How long (in bytes) is this reference? | |
2806 | @item | |
2807 | Which section does the address refer to? What is the numeric value of | |
2808 | @display | |
2809 | (@var{address}) @minus{} (@var{start-address of section})? | |
2810 | @end display | |
2811 | @item | |
2812 | Is the reference to an address ``Program-Counter relative''? | |
2813 | @end itemize | |
2814 | ||
2815 | @cindex addresses, format of | |
2816 | @cindex section-relative addressing | |
a4fb0134 | 2817 | In fact, every address @command{@value{AS}} ever uses is expressed as |
252b5132 RH |
2818 | @display |
2819 | (@var{section}) + (@var{offset into section}) | |
2820 | @end display | |
2821 | @noindent | |
a4fb0134 | 2822 | Further, most expressions @command{@value{AS}} computes have this section-relative |
252b5132 RH |
2823 | nature. |
2824 | @ifset SOM | |
2825 | (For some object formats, such as SOM for the HPPA, some expressions are | |
2826 | symbol-relative instead.) | |
2827 | @end ifset | |
2828 | ||
2829 | In this manual we use the notation @{@var{secname} @var{N}@} to mean ``offset | |
2830 | @var{N} into section @var{secname}.'' | |
2831 | ||
2832 | Apart from text, data and bss sections you need to know about the | |
2833 | @dfn{absolute} section. When @code{@value{LD}} mixes partial programs, | |
2834 | addresses in the absolute section remain unchanged. For example, address | |
2835 | @code{@{absolute 0@}} is ``relocated'' to run-time address 0 by | |
2836 | @code{@value{LD}}. Although the linker never arranges two partial programs' | |
2837 | data sections with overlapping addresses after linking, @emph{by definition} | |
2838 | their absolute sections must overlap. Address @code{@{absolute@ 239@}} in one | |
2839 | part of a program is always the same address when the program is running as | |
2840 | address @code{@{absolute@ 239@}} in any other part of the program. | |
2841 | ||
2842 | The idea of sections is extended to the @dfn{undefined} section. Any | |
2843 | address whose section is unknown at assembly time is by definition | |
2844 | rendered @{undefined @var{U}@}---where @var{U} is filled in later. | |
2845 | Since numbers are always defined, the only way to generate an undefined | |
2846 | address is to mention an undefined symbol. A reference to a named | |
2847 | common block would be such a symbol: its value is unknown at assembly | |
2848 | time so it has section @emph{undefined}. | |
2849 | ||
2850 | By analogy the word @emph{section} is used to describe groups of sections in | |
2851 | the linked program. @code{@value{LD}} puts all partial programs' text | |
2852 | sections in contiguous addresses in the linked program. It is | |
2853 | customary to refer to the @emph{text section} of a program, meaning all | |
2854 | the addresses of all partial programs' text sections. Likewise for | |
2855 | data and bss sections. | |
2856 | ||
2857 | Some sections are manipulated by @code{@value{LD}}; others are invented for | |
a4fb0134 | 2858 | use of @command{@value{AS}} and have no meaning except during assembly. |
252b5132 RH |
2859 | |
2860 | @node Ld Sections | |
2861 | @section Linker Sections | |
2862 | @code{@value{LD}} deals with just four kinds of sections, summarized below. | |
2863 | ||
2864 | @table @strong | |
2865 | ||
c1253627 | 2866 | @ifset COFF-ELF |
252b5132 RH |
2867 | @cindex named sections |
2868 | @cindex sections, named | |
2869 | @item named sections | |
2870 | @end ifset | |
2871 | @ifset aout-bout | |
2872 | @cindex text section | |
2873 | @cindex data section | |
2874 | @itemx text section | |
2875 | @itemx data section | |
2876 | @end ifset | |
a4fb0134 | 2877 | These sections hold your program. @command{@value{AS}} and @code{@value{LD}} treat them as |
252b5132 | 2878 | separate but equal sections. Anything you can say of one section is |
c1253627 NC |
2879 | true of another. |
2880 | @c @ifset aout-bout | |
252b5132 RH |
2881 | When the program is running, however, it is |
2882 | customary for the text section to be unalterable. The | |
2883 | text section is often shared among processes: it contains | |
2884 | instructions, constants and the like. The data section of a running | |
2885 | program is usually alterable: for example, C variables would be stored | |
2886 | in the data section. | |
c1253627 | 2887 | @c @end ifset |
252b5132 RH |
2888 | |
2889 | @cindex bss section | |
2890 | @item bss section | |
2891 | This section contains zeroed bytes when your program begins running. It | |
a349d9dd | 2892 | is used to hold uninitialized variables or common storage. The length of |
252b5132 RH |
2893 | each partial program's bss section is important, but because it starts |
2894 | out containing zeroed bytes there is no need to store explicit zero | |
2895 | bytes in the object file. The bss section was invented to eliminate | |
2896 | those explicit zeros from object files. | |
2897 | ||
2898 | @cindex absolute section | |
2899 | @item absolute section | |
2900 | Address 0 of this section is always ``relocated'' to runtime address 0. | |
2901 | This is useful if you want to refer to an address that @code{@value{LD}} must | |
2902 | not change when relocating. In this sense we speak of absolute | |
2903 | addresses being ``unrelocatable'': they do not change during relocation. | |
2904 | ||
2905 | @cindex undefined section | |
2906 | @item undefined section | |
2907 | This ``section'' is a catch-all for address references to objects not in | |
2908 | the preceding sections. | |
2909 | @c FIXME: ref to some other doc on obj-file formats could go here. | |
2910 | @end table | |
2911 | ||
2912 | @cindex relocation example | |
2913 | An idealized example of three relocatable sections follows. | |
c1253627 | 2914 | @ifset COFF-ELF |
252b5132 RH |
2915 | The example uses the traditional section names @samp{.text} and @samp{.data}. |
2916 | @end ifset | |
2917 | Memory addresses are on the horizontal axis. | |
2918 | ||
2919 | @c TEXI2ROFF-KILL | |
c1253627 | 2920 | @ifnottex |
252b5132 RH |
2921 | @c END TEXI2ROFF-KILL |
2922 | @smallexample | |
2923 | +-----+----+--+ | |
2924 | partial program # 1: |ttttt|dddd|00| | |
2925 | +-----+----+--+ | |
2926 | ||
2927 | text data bss | |
2928 | seg. seg. seg. | |
2929 | ||
2930 | +---+---+---+ | |
2931 | partial program # 2: |TTT|DDD|000| | |
2932 | +---+---+---+ | |
2933 | ||
2934 | +--+---+-----+--+----+---+-----+~~ | |
2935 | linked program: | |TTT|ttttt| |dddd|DDD|00000| | |
2936 | +--+---+-----+--+----+---+-----+~~ | |
2937 | ||
2938 | addresses: 0 @dots{} | |
2939 | @end smallexample | |
2940 | @c TEXI2ROFF-KILL | |
c1253627 | 2941 | @end ifnottex |
252b5132 RH |
2942 | @need 5000 |
2943 | @tex | |
c1253627 | 2944 | \bigskip |
252b5132 RH |
2945 | \line{\it Partial program \#1: \hfil} |
2946 | \line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil} | |
2947 | \line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil} | |
2948 | ||
2949 | \line{\it Partial program \#2: \hfil} | |
2950 | \line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil} | |
2951 | \line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil} | |
2952 | ||
2953 | \line{\it linked program: \hfil} | |
2954 | \line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil} | |
2955 | \line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt | |
2956 | ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt | |
2957 | DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil} | |
2958 | ||
2959 | \line{\it addresses: \hfil} | |
2960 | \line{0\dots\hfil} | |
2961 | ||
2962 | @end tex | |
2963 | @c END TEXI2ROFF-KILL | |
2964 | ||
2965 | @node As Sections | |
2966 | @section Assembler Internal Sections | |
2967 | ||
2968 | @cindex internal assembler sections | |
2969 | @cindex sections in messages, internal | |
a4fb0134 | 2970 | These sections are meant only for the internal use of @command{@value{AS}}. They |
252b5132 | 2971 | have no meaning at run-time. You do not really need to know about these |
a4fb0134 | 2972 | sections for most purposes; but they can be mentioned in @command{@value{AS}} |
252b5132 | 2973 | warning messages, so it might be helpful to have an idea of their |
a4fb0134 | 2974 | meanings to @command{@value{AS}}. These sections are used to permit the |
252b5132 RH |
2975 | value of every expression in your assembly language program to be a |
2976 | section-relative address. | |
2977 | ||
2978 | @table @b | |
2979 | @cindex assembler internal logic error | |
2980 | @item ASSEMBLER-INTERNAL-LOGIC-ERROR! | |
2981 | An internal assembler logic error has been found. This means there is a | |
2982 | bug in the assembler. | |
2983 | ||
2984 | @cindex expr (internal section) | |
2985 | @item expr section | |
2986 | The assembler stores complex expression internally as combinations of | |
2987 | symbols. When it needs to represent an expression as a symbol, it puts | |
2988 | it in the expr section. | |
2989 | @c FIXME item debug | |
2990 | @c FIXME item transfer[t] vector preload | |
2991 | @c FIXME item transfer[t] vector postload | |
2992 | @c FIXME item register | |
2993 | @end table | |
2994 | ||
2995 | @node Sub-Sections | |
2996 | @section Sub-Sections | |
2997 | ||
2998 | @cindex numbered subsections | |
2999 | @cindex grouping data | |
3000 | @ifset aout-bout | |
3001 | Assembled bytes | |
c1253627 | 3002 | @ifset COFF-ELF |
252b5132 RH |
3003 | conventionally |
3004 | @end ifset | |
3005 | fall into two sections: text and data. | |
3006 | @end ifset | |
3007 | You may have separate groups of | |
3008 | @ifset GENERIC | |
3009 | data in named sections | |
3010 | @end ifset | |
3011 | @ifclear GENERIC | |
3012 | @ifclear aout-bout | |
3013 | data in named sections | |
3014 | @end ifclear | |
3015 | @ifset aout-bout | |
3016 | text or data | |
3017 | @end ifset | |
3018 | @end ifclear | |
3019 | that you want to end up near to each other in the object file, even though they | |
a4fb0134 | 3020 | are not contiguous in the assembler source. @command{@value{AS}} allows you to |
252b5132 RH |
3021 | use @dfn{subsections} for this purpose. Within each section, there can be |
3022 | numbered subsections with values from 0 to 8192. Objects assembled into the | |
3023 | same subsection go into the object file together with other objects in the same | |
3024 | subsection. For example, a compiler might want to store constants in the text | |
3025 | section, but might not want to have them interspersed with the program being | |
3026 | assembled. In this case, the compiler could issue a @samp{.text 0} before each | |
3027 | section of code being output, and a @samp{.text 1} before each group of | |
3028 | constants being output. | |
3029 | ||
3030 | Subsections are optional. If you do not use subsections, everything | |
3031 | goes in subsection number zero. | |
3032 | ||
3033 | @ifset GENERIC | |
3034 | Each subsection is zero-padded up to a multiple of four bytes. | |
3035 | (Subsections may be padded a different amount on different flavors | |
a4fb0134 | 3036 | of @command{@value{AS}}.) |
252b5132 RH |
3037 | @end ifset |
3038 | @ifclear GENERIC | |
3039 | @ifset H8 | |
7be1c489 | 3040 | On the H8/300 platform, each subsection is zero-padded to a word |
252b5132 | 3041 | boundary (two bytes). |
c2dcd04e | 3042 | The same is true on the Renesas SH. |
252b5132 RH |
3043 | @end ifset |
3044 | @ifset I960 | |
3045 | @c FIXME section padding (alignment)? | |
3046 | @c Rich Pixley says padding here depends on target obj code format; that | |
3047 | @c doesn't seem particularly useful to say without further elaboration, | |
3048 | @c so for now I say nothing about it. If this is a generic BFD issue, | |
3049 | @c these paragraphs might need to vanish from this manual, and be | |
3050 | @c discussed in BFD chapter of binutils (or some such). | |
3051 | @end ifset | |
252b5132 RH |
3052 | @end ifclear |
3053 | ||
3054 | Subsections appear in your object file in numeric order, lowest numbered | |
3055 | to highest. (All this to be compatible with other people's assemblers.) | |
3056 | The object file contains no representation of subsections; @code{@value{LD}} and | |
3057 | other programs that manipulate object files see no trace of them. | |
3058 | They just see all your text subsections as a text section, and all your | |
3059 | data subsections as a data section. | |
3060 | ||
3061 | To specify which subsection you want subsequent statements assembled | |
3062 | into, use a numeric argument to specify it, in a @samp{.text | |
3063 | @var{expression}} or a @samp{.data @var{expression}} statement. | |
ed9589d4 | 3064 | @ifset COFF |
252b5132 | 3065 | @ifset GENERIC |
ed9589d4 | 3066 | When generating COFF output, you |
252b5132 RH |
3067 | @end ifset |
3068 | @ifclear GENERIC | |
3069 | You | |
3070 | @end ifclear | |
3071 | can also use an extra subsection | |
3072 | argument with arbitrary named sections: @samp{.section @var{name}, | |
3073 | @var{expression}}. | |
3074 | @end ifset | |
ed9589d4 BW |
3075 | @ifset ELF |
3076 | @ifset GENERIC | |
3077 | When generating ELF output, you | |
3078 | @end ifset | |
3079 | @ifclear GENERIC | |
3080 | You | |
3081 | @end ifclear | |
3082 | can also use the @code{.subsection} directive (@pxref{SubSection}) | |
3083 | to specify a subsection: @samp{.subsection @var{expression}}. | |
3084 | @end ifset | |
96e9638b BW |
3085 | @var{Expression} should be an absolute expression |
3086 | (@pxref{Expressions}). If you just say @samp{.text} then @samp{.text 0} | |
252b5132 RH |
3087 | is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly |
3088 | begins in @code{text 0}. For instance: | |
3089 | @smallexample | |
3090 | .text 0 # The default subsection is text 0 anyway. | |
3091 | .ascii "This lives in the first text subsection. *" | |
3092 | .text 1 | |
3093 | .ascii "But this lives in the second text subsection." | |
3094 | .data 0 | |
3095 | .ascii "This lives in the data section," | |
3096 | .ascii "in the first data subsection." | |
3097 | .text 0 | |
3098 | .ascii "This lives in the first text section," | |
3099 | .ascii "immediately following the asterisk (*)." | |
3100 | @end smallexample | |
3101 | ||
3102 | Each section has a @dfn{location counter} incremented by one for every byte | |
3103 | assembled into that section. Because subsections are merely a convenience | |
a4fb0134 | 3104 | restricted to @command{@value{AS}} there is no concept of a subsection location |
252b5132 RH |
3105 | counter. There is no way to directly manipulate a location counter---but the |
3106 | @code{.align} directive changes it, and any label definition captures its | |
3107 | current value. The location counter of the section where statements are being | |
3108 | assembled is said to be the @dfn{active} location counter. | |
3109 | ||
3110 | @node bss | |
3111 | @section bss Section | |
3112 | ||
3113 | @cindex bss section | |
3114 | @cindex common variable storage | |
3115 | The bss section is used for local common variable storage. | |
3116 | You may allocate address space in the bss section, but you may | |
3117 | not dictate data to load into it before your program executes. When | |
3118 | your program starts running, all the contents of the bss | |
3119 | section are zeroed bytes. | |
3120 | ||
3121 | The @code{.lcomm} pseudo-op defines a symbol in the bss section; see | |
3122 | @ref{Lcomm,,@code{.lcomm}}. | |
3123 | ||
3124 | The @code{.comm} pseudo-op may be used to declare a common symbol, which is | |
96e9638b | 3125 | another form of uninitialized symbol; see @ref{Comm,,@code{.comm}}. |
252b5132 RH |
3126 | |
3127 | @ifset GENERIC | |
3128 | When assembling for a target which supports multiple sections, such as ELF or | |
3129 | COFF, you may switch into the @code{.bss} section and define symbols as usual; | |
3130 | see @ref{Section,,@code{.section}}. You may only assemble zero values into the | |
3131 | section. Typically the section will only contain symbol definitions and | |
3132 | @code{.skip} directives (@pxref{Skip,,@code{.skip}}). | |
3133 | @end ifset | |
3134 | ||
3135 | @node Symbols | |
3136 | @chapter Symbols | |
3137 | ||
3138 | @cindex symbols | |
3139 | Symbols are a central concept: the programmer uses symbols to name | |
3140 | things, the linker uses symbols to link, and the debugger uses symbols | |
3141 | to debug. | |
3142 | ||
3143 | @quotation | |
3144 | @cindex debuggers, and symbol order | |
a4fb0134 | 3145 | @emph{Warning:} @command{@value{AS}} does not place symbols in the object file in |
252b5132 RH |
3146 | the same order they were declared. This may break some debuggers. |
3147 | @end quotation | |
3148 | ||
3149 | @menu | |
3150 | * Labels:: Labels | |
3151 | * Setting Symbols:: Giving Symbols Other Values | |
3152 | * Symbol Names:: Symbol Names | |
3153 | * Dot:: The Special Dot Symbol | |
3154 | * Symbol Attributes:: Symbol Attributes | |
3155 | @end menu | |
3156 | ||
3157 | @node Labels | |
3158 | @section Labels | |
3159 | ||
3160 | @cindex labels | |
3161 | A @dfn{label} is written as a symbol immediately followed by a colon | |
3162 | @samp{:}. The symbol then represents the current value of the | |
3163 | active location counter, and is, for example, a suitable instruction | |
3164 | operand. You are warned if you use the same symbol to represent two | |
3165 | different locations: the first definition overrides any other | |
3166 | definitions. | |
3167 | ||
3168 | @ifset HPPA | |
3169 | On the HPPA, the usual form for a label need not be immediately followed by a | |
3170 | colon, but instead must start in column zero. Only one label may be defined on | |
a4fb0134 | 3171 | a single line. To work around this, the HPPA version of @command{@value{AS}} also |
252b5132 RH |
3172 | provides a special directive @code{.label} for defining labels more flexibly. |
3173 | @end ifset | |
3174 | ||
3175 | @node Setting Symbols | |
3176 | @section Giving Symbols Other Values | |
3177 | ||
3178 | @cindex assigning values to symbols | |
3179 | @cindex symbol values, assigning | |
3180 | A symbol can be given an arbitrary value by writing a symbol, followed | |
3181 | by an equals sign @samp{=}, followed by an expression | |
3182 | (@pxref{Expressions}). This is equivalent to using the @code{.set} | |
9497f5ac NC |
3183 | directive. @xref{Set,,@code{.set}}. In the same way, using a double |
3184 | equals sign @samp{=}@samp{=} here represents an equivalent of the | |
3185 | @code{.eqv} directive. @xref{Eqv,,@code{.eqv}}. | |
252b5132 RH |
3186 | |
3187 | @node Symbol Names | |
3188 | @section Symbol Names | |
3189 | ||
3190 | @cindex symbol names | |
3191 | @cindex names, symbol | |
3192 | @ifclear SPECIAL-SYMS | |
3193 | Symbol names begin with a letter or with one of @samp{._}. On most | |
3194 | machines, you can also use @code{$} in symbol names; exceptions are | |
3195 | noted in @ref{Machine Dependencies}. That character may be followed by any | |
96e9638b BW |
3196 | string of digits, letters, dollar signs (unless otherwise noted for a |
3197 | particular target machine), and underscores. | |
252b5132 | 3198 | @end ifclear |
252b5132 RH |
3199 | @ifset SPECIAL-SYMS |
3200 | @ifset H8 | |
3201 | Symbol names begin with a letter or with one of @samp{._}. On the | |
7be1c489 | 3202 | Renesas SH you can also use @code{$} in symbol names. That |
c2dcd04e NC |
3203 | character may be followed by any string of digits, letters, dollar signs (save |
3204 | on the H8/300), and underscores. | |
252b5132 RH |
3205 | @end ifset |
3206 | @end ifset | |
3207 | ||
3208 | Case of letters is significant: @code{foo} is a different symbol name | |
3209 | than @code{Foo}. | |
3210 | ||
3211 | Each symbol has exactly one name. Each name in an assembly language program | |
3212 | refers to exactly one symbol. You may use that symbol name any number of times | |
3213 | in a program. | |
3214 | ||
3215 | @subheading Local Symbol Names | |
3216 | ||
3217 | @cindex local symbol names | |
3218 | @cindex symbol names, local | |
ba83aca1 BW |
3219 | A local symbol is any symbol beginning with certain local label prefixes. |
3220 | By default, the local label prefix is @samp{.L} for ELF systems or | |
3221 | @samp{L} for traditional a.out systems, but each target may have its own | |
3222 | set of local label prefixes. | |
3223 | @ifset HPPA | |
3224 | On the HPPA local symbols begin with @samp{L$}. | |
3225 | @end ifset | |
3226 | ||
3227 | Local symbols are defined and used within the assembler, but they are | |
3228 | normally not saved in object files. Thus, they are not visible when debugging. | |
3229 | You may use the @samp{-L} option (@pxref{L, ,Include Local Symbols: | |
3230 | @option{-L}}) to retain the local symbols in the object files. | |
3231 | ||
3232 | @subheading Local Labels | |
3233 | ||
3234 | @cindex local labels | |
252b5132 RH |
3235 | @cindex temporary symbol names |
3236 | @cindex symbol names, temporary | |
ba83aca1 | 3237 | Local labels help compilers and programmers use names temporarily. |
2d5aaba0 NC |
3238 | They create symbols which are guaranteed to be unique over the entire scope of |
3239 | the input source code and which can be referred to by a simple notation. | |
ba83aca1 | 3240 | To define a local label, write a label of the form @samp{@b{N}:} (where @b{N} |
2d5aaba0 | 3241 | represents any positive integer). To refer to the most recent previous |
ba83aca1 | 3242 | definition of that label write @samp{@b{N}b}, using the same number as when |
2d5aaba0 | 3243 | you defined the label. To refer to the next definition of a local label, write |
96e9638b | 3244 | @samp{@b{N}f}---the @samp{b} stands for ``backwards'' and the @samp{f} stands |
2d5aaba0 NC |
3245 | for ``forwards''. |
3246 | ||
3247 | There is no restriction on how you can use these labels, and you can reuse them | |
3248 | too. So that it is possible to repeatedly define the same local label (using | |
3249 | the same number @samp{@b{N}}), although you can only refer to the most recently | |
3250 | defined local label of that number (for a backwards reference) or the next | |
3251 | definition of a specific local label for a forward reference. It is also worth | |
3252 | noting that the first 10 local labels (@samp{@b{0:}}@dots{}@samp{@b{9:}}) are | |
3253 | implemented in a slightly more efficient manner than the others. | |
3254 | ||
3255 | Here is an example: | |
3256 | ||
3257 | @smallexample | |
3258 | 1: branch 1f | |
3259 | 2: branch 1b | |
3260 | 1: branch 2f | |
3261 | 2: branch 1b | |
3262 | @end smallexample | |
3263 | ||
3264 | Which is the equivalent of: | |
3265 | ||
3266 | @smallexample | |
3267 | label_1: branch label_3 | |
3268 | label_2: branch label_1 | |
3269 | label_3: branch label_4 | |
3270 | label_4: branch label_3 | |
3271 | @end smallexample | |
3272 | ||
ba83aca1 | 3273 | Local label names are only a notational device. They are immediately |
2d5aaba0 | 3274 | transformed into more conventional symbol names before the assembler uses them. |
96e9638b BW |
3275 | The symbol names are stored in the symbol table, appear in error messages, and |
3276 | are optionally emitted to the object file. The names are constructed using | |
3277 | these parts: | |
252b5132 RH |
3278 | |
3279 | @table @code | |
ba83aca1 BW |
3280 | @item @emph{local label prefix} |
3281 | All local symbols begin with the system-specific local label prefix. | |
3282 | Normally both @command{@value{AS}} and @code{@value{LD}} forget symbols | |
3283 | that start with the local label prefix. These labels are | |
252b5132 | 3284 | used for symbols you are never intended to see. If you use the |
a4fb0134 | 3285 | @samp{-L} option then @command{@value{AS}} retains these symbols in the |
252b5132 RH |
3286 | object file. If you also instruct @code{@value{LD}} to retain these symbols, |
3287 | you may use them in debugging. | |
3288 | ||
2d5aaba0 NC |
3289 | @item @var{number} |
3290 | This is the number that was used in the local label definition. So if the | |
3291 | label is written @samp{55:} then the number is @samp{55}. | |
252b5132 | 3292 | |
2d5aaba0 NC |
3293 | @item @kbd{C-B} |
3294 | This unusual character is included so you do not accidentally invent a symbol | |
3295 | of the same name. The character has ASCII value of @samp{\002} (control-B). | |
252b5132 RH |
3296 | |
3297 | @item @emph{ordinal number} | |
2d5aaba0 NC |
3298 | This is a serial number to keep the labels distinct. The first definition of |
3299 | @samp{0:} gets the number @samp{1}. The 15th definition of @samp{0:} gets the | |
3300 | number @samp{15}, and so on. Likewise the first definition of @samp{1:} gets | |
b45619c0 | 3301 | the number @samp{1} and its 15th definition gets @samp{15} as well. |
252b5132 RH |
3302 | @end table |
3303 | ||
ba83aca1 BW |
3304 | So for example, the first @code{1:} may be named @code{.L1@kbd{C-B}1}, and |
3305 | the 44th @code{3:} may be named @code{.L3@kbd{C-B}44}. | |
2d5aaba0 NC |
3306 | |
3307 | @subheading Dollar Local Labels | |
3308 | @cindex dollar local symbols | |
3309 | ||
3310 | @code{@value{AS}} also supports an even more local form of local labels called | |
96e9638b BW |
3311 | dollar labels. These labels go out of scope (i.e., they become undefined) as |
3312 | soon as a non-local label is defined. Thus they remain valid for only a small | |
2d5aaba0 NC |
3313 | region of the input source code. Normal local labels, by contrast, remain in |
3314 | scope for the entire file, or until they are redefined by another occurrence of | |
3315 | the same local label. | |
3316 | ||
3317 | Dollar labels are defined in exactly the same way as ordinary local labels, | |
3318 | except that instead of being terminated by a colon, they are terminated by a | |
96e9638b | 3319 | dollar sign, e.g., @samp{@b{55$}}. |
2d5aaba0 NC |
3320 | |
3321 | They can also be distinguished from ordinary local labels by their transformed | |
96e9638b BW |
3322 | names which use ASCII character @samp{\001} (control-A) as the magic character |
3323 | to distinguish them from ordinary labels. For example, the fifth definition of | |
ba83aca1 | 3324 | @samp{6$} may be named @samp{.L6@kbd{C-A}5}. |
252b5132 RH |
3325 | |
3326 | @node Dot | |
3327 | @section The Special Dot Symbol | |
3328 | ||
3329 | @cindex dot (symbol) | |
3330 | @cindex @code{.} (symbol) | |
3331 | @cindex current address | |
3332 | @cindex location counter | |
3333 | The special symbol @samp{.} refers to the current address that | |
a4fb0134 | 3334 | @command{@value{AS}} is assembling into. Thus, the expression @samp{melvin: |
252b5132 RH |
3335 | .long .} defines @code{melvin} to contain its own address. |
3336 | Assigning a value to @code{.} is treated the same as a @code{.org} | |
3337 | directive. Thus, the expression @samp{.=.+4} is the same as saying | |
3338 | @ifclear no-space-dir | |
3339 | @samp{.space 4}. | |
3340 | @end ifclear | |
252b5132 RH |
3341 | |
3342 | @node Symbol Attributes | |
3343 | @section Symbol Attributes | |
3344 | ||
3345 | @cindex symbol attributes | |
3346 | @cindex attributes, symbol | |
3347 | Every symbol has, as well as its name, the attributes ``Value'' and | |
3348 | ``Type''. Depending on output format, symbols can also have auxiliary | |
3349 | attributes. | |
3350 | @ifset INTERNALS | |
3351 | The detailed definitions are in @file{a.out.h}. | |
3352 | @end ifset | |
3353 | ||
a4fb0134 | 3354 | If you use a symbol without defining it, @command{@value{AS}} assumes zero for |
252b5132 RH |
3355 | all these attributes, and probably won't warn you. This makes the |
3356 | symbol an externally defined symbol, which is generally what you | |
3357 | would want. | |
3358 | ||
3359 | @menu | |
3360 | * Symbol Value:: Value | |
3361 | * Symbol Type:: Type | |
3362 | @ifset aout-bout | |
3363 | @ifset GENERIC | |
3364 | * a.out Symbols:: Symbol Attributes: @code{a.out} | |
3365 | @end ifset | |
3366 | @ifclear GENERIC | |
3367 | @ifclear BOUT | |
3368 | * a.out Symbols:: Symbol Attributes: @code{a.out} | |
3369 | @end ifclear | |
3370 | @ifset BOUT | |
3371 | * a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out} | |
3372 | @end ifset | |
3373 | @end ifclear | |
3374 | @end ifset | |
3375 | @ifset COFF | |
3376 | * COFF Symbols:: Symbol Attributes for COFF | |
3377 | @end ifset | |
3378 | @ifset SOM | |
3379 | * SOM Symbols:: Symbol Attributes for SOM | |
3380 | @end ifset | |
3381 | @end menu | |
3382 | ||
3383 | @node Symbol Value | |
3384 | @subsection Value | |
3385 | ||
3386 | @cindex value of a symbol | |
3387 | @cindex symbol value | |
3388 | The value of a symbol is (usually) 32 bits. For a symbol which labels a | |
3389 | location in the text, data, bss or absolute sections the value is the | |
3390 | number of addresses from the start of that section to the label. | |
3391 | Naturally for text, data and bss sections the value of a symbol changes | |
3392 | as @code{@value{LD}} changes section base addresses during linking. Absolute | |
3393 | symbols' values do not change during linking: that is why they are | |
3394 | called absolute. | |
3395 | ||
3396 | The value of an undefined symbol is treated in a special way. If it is | |
3397 | 0 then the symbol is not defined in this assembler source file, and | |
3398 | @code{@value{LD}} tries to determine its value from other files linked into the | |
3399 | same program. You make this kind of symbol simply by mentioning a symbol | |
3400 | name without defining it. A non-zero value represents a @code{.comm} | |
3401 | common declaration. The value is how much common storage to reserve, in | |
3402 | bytes (addresses). The symbol refers to the first address of the | |
3403 | allocated storage. | |
3404 | ||
3405 | @node Symbol Type | |
3406 | @subsection Type | |
3407 | ||
3408 | @cindex type of a symbol | |
3409 | @cindex symbol type | |
3410 | The type attribute of a symbol contains relocation (section) | |
3411 | information, any flag settings indicating that a symbol is external, and | |
3412 | (optionally), other information for linkers and debuggers. The exact | |
3413 | format depends on the object-code output format in use. | |
3414 | ||
3415 | @ifset aout-bout | |
3416 | @ifclear GENERIC | |
3417 | @ifset BOUT | |
3418 | @c The following avoids a "widow" subsection title. @group would be | |
3419 | @c better if it were available outside examples. | |
3420 | @need 1000 | |
3421 | @node a.out Symbols | |
3422 | @subsection Symbol Attributes: @code{a.out}, @code{b.out} | |
3423 | ||
3424 | @cindex @code{b.out} symbol attributes | |
3425 | @cindex symbol attributes, @code{b.out} | |
a4fb0134 | 3426 | These symbol attributes appear only when @command{@value{AS}} is configured for |
252b5132 RH |
3427 | one of the Berkeley-descended object output formats---@code{a.out} or |
3428 | @code{b.out}. | |
3429 | ||
3430 | @end ifset | |
3431 | @ifclear BOUT | |
3432 | @node a.out Symbols | |
3433 | @subsection Symbol Attributes: @code{a.out} | |
3434 | ||
3435 | @cindex @code{a.out} symbol attributes | |
3436 | @cindex symbol attributes, @code{a.out} | |
3437 | ||
3438 | @end ifclear | |
3439 | @end ifclear | |
3440 | @ifset GENERIC | |
3441 | @node a.out Symbols | |
3442 | @subsection Symbol Attributes: @code{a.out} | |
3443 | ||
3444 | @cindex @code{a.out} symbol attributes | |
3445 | @cindex symbol attributes, @code{a.out} | |
3446 | ||
3447 | @end ifset | |
3448 | @menu | |
3449 | * Symbol Desc:: Descriptor | |
3450 | * Symbol Other:: Other | |
3451 | @end menu | |
3452 | ||
3453 | @node Symbol Desc | |
3454 | @subsubsection Descriptor | |
3455 | ||
3456 | @cindex descriptor, of @code{a.out} symbol | |
3457 | This is an arbitrary 16-bit value. You may establish a symbol's | |
3458 | descriptor value by using a @code{.desc} statement | |
3459 | (@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to | |
a4fb0134 | 3460 | @command{@value{AS}}. |
252b5132 RH |
3461 | |
3462 | @node Symbol Other | |
3463 | @subsubsection Other | |
3464 | ||
3465 | @cindex other attribute, of @code{a.out} symbol | |
a4fb0134 | 3466 | This is an arbitrary 8-bit value. It means nothing to @command{@value{AS}}. |
252b5132 RH |
3467 | @end ifset |
3468 | ||
3469 | @ifset COFF | |
3470 | @node COFF Symbols | |
3471 | @subsection Symbol Attributes for COFF | |
3472 | ||
3473 | @cindex COFF symbol attributes | |
3474 | @cindex symbol attributes, COFF | |
3475 | ||
3476 | The COFF format supports a multitude of auxiliary symbol attributes; | |
3477 | like the primary symbol attributes, they are set between @code{.def} and | |
3478 | @code{.endef} directives. | |
3479 | ||
3480 | @subsubsection Primary Attributes | |
3481 | ||
3482 | @cindex primary attributes, COFF symbols | |
3483 | The symbol name is set with @code{.def}; the value and type, | |
3484 | respectively, with @code{.val} and @code{.type}. | |
3485 | ||
3486 | @subsubsection Auxiliary Attributes | |
3487 | ||
3488 | @cindex auxiliary attributes, COFF symbols | |
a4fb0134 | 3489 | The @command{@value{AS}} directives @code{.dim}, @code{.line}, @code{.scl}, |
c87db184 CF |
3490 | @code{.size}, @code{.tag}, and @code{.weak} can generate auxiliary symbol |
3491 | table information for COFF. | |
252b5132 RH |
3492 | @end ifset |
3493 | ||
3494 | @ifset SOM | |
3495 | @node SOM Symbols | |
3496 | @subsection Symbol Attributes for SOM | |
3497 | ||
3498 | @cindex SOM symbol attributes | |
3499 | @cindex symbol attributes, SOM | |
3500 | ||
3501 | The SOM format for the HPPA supports a multitude of symbol attributes set with | |
3502 | the @code{.EXPORT} and @code{.IMPORT} directives. | |
3503 | ||
3504 | The attributes are described in @cite{HP9000 Series 800 Assembly | |
3505 | Language Reference Manual} (HP 92432-90001) under the @code{IMPORT} and | |
3506 | @code{EXPORT} assembler directive documentation. | |
3507 | @end ifset | |
3508 | ||
3509 | @node Expressions | |
3510 | @chapter Expressions | |
3511 | ||
3512 | @cindex expressions | |
3513 | @cindex addresses | |
3514 | @cindex numeric values | |
3515 | An @dfn{expression} specifies an address or numeric value. | |
3516 | Whitespace may precede and/or follow an expression. | |
3517 | ||
3518 | The result of an expression must be an absolute number, or else an offset into | |
3519 | a particular section. If an expression is not absolute, and there is not | |
a4fb0134 | 3520 | enough information when @command{@value{AS}} sees the expression to know its |
252b5132 RH |
3521 | section, a second pass over the source program might be necessary to interpret |
3522 | the expression---but the second pass is currently not implemented. | |
a4fb0134 | 3523 | @command{@value{AS}} aborts with an error message in this situation. |
252b5132 RH |
3524 | |
3525 | @menu | |
3526 | * Empty Exprs:: Empty Expressions | |
3527 | * Integer Exprs:: Integer Expressions | |
3528 | @end menu | |
3529 | ||
3530 | @node Empty Exprs | |
3531 | @section Empty Expressions | |
3532 | ||
3533 | @cindex empty expressions | |
3534 | @cindex expressions, empty | |
3535 | An empty expression has no value: it is just whitespace or null. | |
3536 | Wherever an absolute expression is required, you may omit the | |
a4fb0134 | 3537 | expression, and @command{@value{AS}} assumes a value of (absolute) 0. This |
252b5132 RH |
3538 | is compatible with other assemblers. |
3539 | ||
3540 | @node Integer Exprs | |
3541 | @section Integer Expressions | |
3542 | ||
3543 | @cindex integer expressions | |
3544 | @cindex expressions, integer | |
3545 | An @dfn{integer expression} is one or more @emph{arguments} delimited | |
3546 | by @emph{operators}. | |
3547 | ||
3548 | @menu | |
3549 | * Arguments:: Arguments | |
3550 | * Operators:: Operators | |
3551 | * Prefix Ops:: Prefix Operators | |
3552 | * Infix Ops:: Infix Operators | |
3553 | @end menu | |
3554 | ||
3555 | @node Arguments | |
3556 | @subsection Arguments | |
3557 | ||
3558 | @cindex expression arguments | |
3559 | @cindex arguments in expressions | |
3560 | @cindex operands in expressions | |
3561 | @cindex arithmetic operands | |
3562 | @dfn{Arguments} are symbols, numbers or subexpressions. In other | |
3563 | contexts arguments are sometimes called ``arithmetic operands''. In | |
3564 | this manual, to avoid confusing them with the ``instruction operands'' of | |
3565 | the machine language, we use the term ``argument'' to refer to parts of | |
3566 | expressions only, reserving the word ``operand'' to refer only to machine | |
3567 | instruction operands. | |
3568 | ||
3569 | Symbols are evaluated to yield @{@var{section} @var{NNN}@} where | |
3570 | @var{section} is one of text, data, bss, absolute, | |
3571 | or undefined. @var{NNN} is a signed, 2's complement 32 bit | |
3572 | integer. | |
3573 | ||
3574 | Numbers are usually integers. | |
3575 | ||
3576 | A number can be a flonum or bignum. In this case, you are warned | |
a4fb0134 | 3577 | that only the low order 32 bits are used, and @command{@value{AS}} pretends |
252b5132 RH |
3578 | these 32 bits are an integer. You may write integer-manipulating |
3579 | instructions that act on exotic constants, compatible with other | |
3580 | assemblers. | |
3581 | ||
3582 | @cindex subexpressions | |
3583 | Subexpressions are a left parenthesis @samp{(} followed by an integer | |
3584 | expression, followed by a right parenthesis @samp{)}; or a prefix | |
3585 | operator followed by an argument. | |
3586 | ||
3587 | @node Operators | |
3588 | @subsection Operators | |
3589 | ||
3590 | @cindex operators, in expressions | |
3591 | @cindex arithmetic functions | |
3592 | @cindex functions, in expressions | |
3593 | @dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix | |
3594 | operators are followed by an argument. Infix operators appear | |
3595 | between their arguments. Operators may be preceded and/or followed by | |
3596 | whitespace. | |
3597 | ||
3598 | @node Prefix Ops | |
3599 | @subsection Prefix Operator | |
3600 | ||
3601 | @cindex prefix operators | |
a4fb0134 | 3602 | @command{@value{AS}} has the following @dfn{prefix operators}. They each take |
252b5132 RH |
3603 | one argument, which must be absolute. |
3604 | ||
3605 | @c the tex/end tex stuff surrounding this small table is meant to make | |
3606 | @c it align, on the printed page, with the similar table in the next | |
3607 | @c section (which is inside an enumerate). | |
3608 | @tex | |
3609 | \global\advance\leftskip by \itemindent | |
3610 | @end tex | |
3611 | ||
3612 | @table @code | |
3613 | @item - | |
3614 | @dfn{Negation}. Two's complement negation. | |
3615 | @item ~ | |
3616 | @dfn{Complementation}. Bitwise not. | |
3617 | @end table | |
3618 | ||
3619 | @tex | |
3620 | \global\advance\leftskip by -\itemindent | |
3621 | @end tex | |
3622 | ||
3623 | @node Infix Ops | |
3624 | @subsection Infix Operators | |
3625 | ||
3626 | @cindex infix operators | |
3627 | @cindex operators, permitted arguments | |
3628 | @dfn{Infix operators} take two arguments, one on either side. Operators | |
3629 | have precedence, but operations with equal precedence are performed left | |
a4fb0134 | 3630 | to right. Apart from @code{+} or @option{-}, both arguments must be |
252b5132 RH |
3631 | absolute, and the result is absolute. |
3632 | ||
3633 | @enumerate | |
3634 | @cindex operator precedence | |
3635 | @cindex precedence of operators | |
3636 | ||
3637 | @item | |
3638 | Highest Precedence | |
3639 | ||
3640 | @table @code | |
3641 | @item * | |
3642 | @dfn{Multiplication}. | |
3643 | ||
3644 | @item / | |
3645 | @dfn{Division}. Truncation is the same as the C operator @samp{/} | |
3646 | ||
3647 | @item % | |
3648 | @dfn{Remainder}. | |
3649 | ||
d1eac9d9 | 3650 | @item << |
252b5132 RH |
3651 | @dfn{Shift Left}. Same as the C operator @samp{<<}. |
3652 | ||
d1eac9d9 | 3653 | @item >> |
252b5132 RH |
3654 | @dfn{Shift Right}. Same as the C operator @samp{>>}. |
3655 | @end table | |
3656 | ||
3657 | @item | |
3658 | Intermediate precedence | |
3659 | ||
3660 | @table @code | |
3661 | @item | | |
3662 | ||
3663 | @dfn{Bitwise Inclusive Or}. | |
3664 | ||
3665 | @item & | |
3666 | @dfn{Bitwise And}. | |
3667 | ||
3668 | @item ^ | |
3669 | @dfn{Bitwise Exclusive Or}. | |
3670 | ||
3671 | @item ! | |
3672 | @dfn{Bitwise Or Not}. | |
3673 | @end table | |
3674 | ||
3675 | @item | |
b131d4dc | 3676 | Low Precedence |
252b5132 RH |
3677 | |
3678 | @table @code | |
3679 | @cindex addition, permitted arguments | |
3680 | @cindex plus, permitted arguments | |
3681 | @cindex arguments for addition | |
3682 | @item + | |
3683 | @dfn{Addition}. If either argument is absolute, the result has the section of | |
3684 | the other argument. You may not add together arguments from different | |
3685 | sections. | |
3686 | ||
3687 | @cindex subtraction, permitted arguments | |
3688 | @cindex minus, permitted arguments | |
3689 | @cindex arguments for subtraction | |
3690 | @item - | |
3691 | @dfn{Subtraction}. If the right argument is absolute, the | |
3692 | result has the section of the left argument. | |
3693 | If both arguments are in the same section, the result is absolute. | |
3694 | You may not subtract arguments from different sections. | |
3695 | @c FIXME is there still something useful to say about undefined - undefined ? | |
b131d4dc NC |
3696 | |
3697 | @cindex comparison expressions | |
3698 | @cindex expressions, comparison | |
3699 | @item == | |
3700 | @dfn{Is Equal To} | |
3701 | @item <> | |
723a8472 | 3702 | @itemx != |
b131d4dc NC |
3703 | @dfn{Is Not Equal To} |
3704 | @item < | |
3705 | @dfn{Is Less Than} | |
d1eac9d9 | 3706 | @item > |
b131d4dc | 3707 | @dfn{Is Greater Than} |
d1eac9d9 | 3708 | @item >= |
b131d4dc | 3709 | @dfn{Is Greater Than Or Equal To} |
d1eac9d9 | 3710 | @item <= |
b131d4dc NC |
3711 | @dfn{Is Less Than Or Equal To} |
3712 | ||
3713 | The comparison operators can be used as infix operators. A true results has a | |
3714 | value of -1 whereas a false result has a value of 0. Note, these operators | |
3715 | perform signed comparisons. | |
3716 | @end table | |
3717 | ||
3718 | @item Lowest Precedence | |
3719 | ||
3720 | @table @code | |
3721 | @item && | |
3722 | @dfn{Logical And}. | |
3723 | ||
3724 | @item || | |
3725 | @dfn{Logical Or}. | |
3726 | ||
3727 | These two logical operations can be used to combine the results of sub | |
3728 | expressions. Note, unlike the comparison operators a true result returns a | |
3729 | value of 1 but a false results does still return 0. Also note that the logical | |
3730 | or operator has a slightly lower precedence than logical and. | |
3731 | ||
252b5132 RH |
3732 | @end table |
3733 | @end enumerate | |
3734 | ||
3735 | In short, it's only meaningful to add or subtract the @emph{offsets} in an | |
3736 | address; you can only have a defined section in one of the two arguments. | |
3737 | ||
3738 | @node Pseudo Ops | |
3739 | @chapter Assembler Directives | |
3740 | ||
3741 | @cindex directives, machine independent | |
3742 | @cindex pseudo-ops, machine independent | |
3743 | @cindex machine independent directives | |
3744 | All assembler directives have names that begin with a period (@samp{.}). | |
3745 | The rest of the name is letters, usually in lower case. | |
3746 | ||
3747 | This chapter discusses directives that are available regardless of the | |
3748 | target machine configuration for the @sc{gnu} assembler. | |
3749 | @ifset GENERIC | |
3750 | Some machine configurations provide additional directives. | |
3751 | @xref{Machine Dependencies}. | |
3752 | @end ifset | |
3753 | @ifclear GENERIC | |
3754 | @ifset machine-directives | |
96e9638b | 3755 | @xref{Machine Dependencies}, for additional directives. |
252b5132 RH |
3756 | @end ifset |
3757 | @end ifclear | |
3758 | ||
3759 | @menu | |
3760 | * Abort:: @code{.abort} | |
3761 | @ifset COFF | |
370b66a1 | 3762 | * ABORT (COFF):: @code{.ABORT} |
252b5132 | 3763 | @end ifset |
f0dc282c | 3764 | |
252b5132 | 3765 | * Align:: @code{.align @var{abs-expr} , @var{abs-expr}} |
caa32fe5 | 3766 | * Altmacro:: @code{.altmacro} |
252b5132 RH |
3767 | * Ascii:: @code{.ascii "@var{string}"}@dots{} |
3768 | * Asciz:: @code{.asciz "@var{string}"}@dots{} | |
3769 | * Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}} | |
3770 | * Byte:: @code{.byte @var{expressions}} | |
3771 | * Comm:: @code{.comm @var{symbol} , @var{length} } | |
54cfded0 | 3772 | |
cdfbf930 | 3773 | * CFI directives:: @code{.cfi_startproc}, @code{.cfi_endproc}, etc. |
54cfded0 | 3774 | |
252b5132 RH |
3775 | * Data:: @code{.data @var{subsection}} |
3776 | @ifset COFF | |
3777 | * Def:: @code{.def @var{name}} | |
3778 | @end ifset | |
3779 | @ifset aout-bout | |
3780 | * Desc:: @code{.desc @var{symbol}, @var{abs-expression}} | |
3781 | @end ifset | |
3782 | @ifset COFF | |
3783 | * Dim:: @code{.dim} | |
3784 | @end ifset | |
f0dc282c | 3785 | |
252b5132 RH |
3786 | * Double:: @code{.double @var{flonums}} |
3787 | * Eject:: @code{.eject} | |
3788 | * Else:: @code{.else} | |
3fd9f047 | 3789 | * Elseif:: @code{.elseif} |
252b5132 RH |
3790 | * End:: @code{.end} |
3791 | @ifset COFF | |
3792 | * Endef:: @code{.endef} | |
3793 | @end ifset | |
f0dc282c | 3794 | |
252b5132 RH |
3795 | * Endfunc:: @code{.endfunc} |
3796 | * Endif:: @code{.endif} | |
3797 | * Equ:: @code{.equ @var{symbol}, @var{expression}} | |
3798 | * Equiv:: @code{.equiv @var{symbol}, @var{expression}} | |
9497f5ac | 3799 | * Eqv:: @code{.eqv @var{symbol}, @var{expression}} |
252b5132 | 3800 | * Err:: @code{.err} |
d190d046 | 3801 | * Error:: @code{.error @var{string}} |
252b5132 RH |
3802 | * Exitm:: @code{.exitm} |
3803 | * Extern:: @code{.extern} | |
3804 | * Fail:: @code{.fail} | |
3805 | @ifclear no-file-dir | |
3806 | * File:: @code{.file @var{string}} | |
3807 | @end ifclear | |
f0dc282c | 3808 | |
252b5132 RH |
3809 | * Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}} |
3810 | * Float:: @code{.float @var{flonums}} | |
3811 | * Func:: @code{.func} | |
3812 | * Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}} | |
c91d2e08 NC |
3813 | @ifset ELF |
3814 | * Hidden:: @code{.hidden @var{names}} | |
3815 | @end ifset | |
f0dc282c | 3816 | |
252b5132 RH |
3817 | * hword:: @code{.hword @var{expressions}} |
3818 | * Ident:: @code{.ident} | |
3819 | * If:: @code{.if @var{absolute expression}} | |
7e005732 | 3820 | * Incbin:: @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]} |
252b5132 RH |
3821 | * Include:: @code{.include "@var{file}"} |
3822 | * Int:: @code{.int @var{expressions}} | |
c91d2e08 NC |
3823 | @ifset ELF |
3824 | * Internal:: @code{.internal @var{names}} | |
3825 | @end ifset | |
f0dc282c | 3826 | |
252b5132 RH |
3827 | * Irp:: @code{.irp @var{symbol},@var{values}}@dots{} |
3828 | * Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{} | |
3829 | * Lcomm:: @code{.lcomm @var{symbol} , @var{length}} | |
3830 | * Lflags:: @code{.lflags} | |
3831 | @ifclear no-line-dir | |
3832 | * Line:: @code{.line @var{line-number}} | |
3833 | @end ifclear | |
f0dc282c | 3834 | |
252b5132 RH |
3835 | * Linkonce:: @code{.linkonce [@var{type}]} |
3836 | * List:: @code{.list} | |
bd0eb99b RH |
3837 | * Ln:: @code{.ln @var{line-number}} |
3838 | ||
3839 | * LNS directives:: @code{.file}, @code{.loc}, etc. | |
3840 | ||
252b5132 RH |
3841 | * Long:: @code{.long @var{expressions}} |
3842 | @ignore | |
3843 | * Lsym:: @code{.lsym @var{symbol}, @var{expression}} | |
3844 | @end ignore | |
f0dc282c | 3845 | |
252b5132 RH |
3846 | * Macro:: @code{.macro @var{name} @var{args}}@dots{} |
3847 | * MRI:: @code{.mri @var{val}} | |
caa32fe5 | 3848 | * Noaltmacro:: @code{.noaltmacro} |
252b5132 RH |
3849 | * Nolist:: @code{.nolist} |
3850 | * Octa:: @code{.octa @var{bignums}} | |
85234291 L |
3851 | * Org:: @code{.org @var{new-lc}, @var{fill}} |
3852 | * P2align:: @code{.p2align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}} | |
c91d2e08 NC |
3853 | @ifset ELF |
3854 | * PopSection:: @code{.popsection} | |
3855 | * Previous:: @code{.previous} | |
3856 | @end ifset | |
f0dc282c | 3857 | |
252b5132 | 3858 | * Print:: @code{.print @var{string}} |
c91d2e08 NC |
3859 | @ifset ELF |
3860 | * Protected:: @code{.protected @var{names}} | |
3861 | @end ifset | |
f0dc282c | 3862 | |
252b5132 RH |
3863 | * Psize:: @code{.psize @var{lines}, @var{columns}} |
3864 | * Purgem:: @code{.purgem @var{name}} | |
c91d2e08 NC |
3865 | @ifset ELF |
3866 | * PushSection:: @code{.pushsection @var{name}} | |
3867 | @end ifset | |
f0dc282c | 3868 | |
252b5132 RH |
3869 | * Quad:: @code{.quad @var{bignums}} |
3870 | * Rept:: @code{.rept @var{count}} | |
3871 | * Sbttl:: @code{.sbttl "@var{subheading}"} | |
3872 | @ifset COFF | |
3873 | * Scl:: @code{.scl @var{class}} | |
c1253627 NC |
3874 | @end ifset |
3875 | @ifset COFF-ELF | |
3876 | * Section:: @code{.section @var{name}} | |
252b5132 | 3877 | @end ifset |
f0dc282c | 3878 | |
252b5132 RH |
3879 | * Set:: @code{.set @var{symbol}, @var{expression}} |
3880 | * Short:: @code{.short @var{expressions}} | |
3881 | * Single:: @code{.single @var{flonums}} | |
c1253627 | 3882 | @ifset COFF-ELF |
c91d2e08 | 3883 | * Size:: @code{.size [@var{name} , @var{expression}]} |
c1253627 NC |
3884 | @end ifset |
3885 | ||
252b5132 RH |
3886 | * Skip:: @code{.skip @var{size} , @var{fill}} |
3887 | * Sleb128:: @code{.sleb128 @var{expressions}} | |
3888 | * Space:: @code{.space @var{size} , @var{fill}} | |
3889 | @ifset have-stabs | |
3890 | * Stab:: @code{.stabd, .stabn, .stabs} | |
3891 | @end ifset | |
f0dc282c | 3892 | |
252b5132 RH |
3893 | * String:: @code{.string "@var{str}"} |
3894 | * Struct:: @code{.struct @var{expression}} | |
3895 | @ifset ELF | |
c91d2e08 | 3896 | * SubSection:: @code{.subsection} |
252b5132 RH |
3897 | * Symver:: @code{.symver @var{name},@var{name2@@nodename}} |
3898 | @end ifset | |
f0dc282c | 3899 | |
252b5132 RH |
3900 | @ifset COFF |
3901 | * Tag:: @code{.tag @var{structname}} | |
3902 | @end ifset | |
f0dc282c | 3903 | |
252b5132 RH |
3904 | * Text:: @code{.text @var{subsection}} |
3905 | * Title:: @code{.title "@var{heading}"} | |
c1253627 | 3906 | @ifset COFF-ELF |
c91d2e08 | 3907 | * Type:: @code{.type <@var{int} | @var{name} , @var{type description}>} |
c1253627 NC |
3908 | @end ifset |
3909 | ||
c91d2e08 | 3910 | * Uleb128:: @code{.uleb128 @var{expressions}} |
252b5132 | 3911 | @ifset COFF |
252b5132 RH |
3912 | * Val:: @code{.val @var{addr}} |
3913 | @end ifset | |
f0dc282c | 3914 | |
2e13b764 | 3915 | @ifset ELF |
c91d2e08 | 3916 | * Version:: @code{.version "@var{string}"} |
c91d2e08 NC |
3917 | * VTableEntry:: @code{.vtable_entry @var{table}, @var{offset}} |
3918 | * VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}} | |
2e13b764 | 3919 | @end ifset |
f0dc282c | 3920 | |
d190d046 | 3921 | * Warning:: @code{.warning @var{string}} |
c87db184 | 3922 | * Weak:: @code{.weak @var{names}} |
06e77878 | 3923 | * Weakref:: @code{.weakref @var{alias}, @var{symbol}} |
252b5132 RH |
3924 | * Word:: @code{.word @var{expressions}} |
3925 | * Deprecated:: Deprecated Directives | |
3926 | @end menu | |
3927 | ||
3928 | @node Abort | |
3929 | @section @code{.abort} | |
3930 | ||
3931 | @cindex @code{abort} directive | |
3932 | @cindex stopping the assembly | |
3933 | This directive stops the assembly immediately. It is for | |
3934 | compatibility with other assemblers. The original idea was that the | |
3935 | assembly language source would be piped into the assembler. If the sender | |
a4fb0134 | 3936 | of the source quit, it could use this directive tells @command{@value{AS}} to |
252b5132 RH |
3937 | quit also. One day @code{.abort} will not be supported. |
3938 | ||
3939 | @ifset COFF | |
370b66a1 CD |
3940 | @node ABORT (COFF) |
3941 | @section @code{.ABORT} (COFF) | |
252b5132 RH |
3942 | |
3943 | @cindex @code{ABORT} directive | |
a4fb0134 | 3944 | When producing COFF output, @command{@value{AS}} accepts this directive as a |
252b5132 RH |
3945 | synonym for @samp{.abort}. |
3946 | ||
3947 | @ifset BOUT | |
a4fb0134 | 3948 | When producing @code{b.out} output, @command{@value{AS}} accepts this directive, |
252b5132 RH |
3949 | but ignores it. |
3950 | @end ifset | |
3951 | @end ifset | |
3952 | ||
3953 | @node Align | |
3954 | @section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}} | |
3955 | ||
3956 | @cindex padding the location counter | |
3957 | @cindex @code{align} directive | |
3958 | Pad the location counter (in the current subsection) to a particular storage | |
3959 | boundary. The first expression (which must be absolute) is the alignment | |
3960 | required, as described below. | |
3961 | ||
3962 | The second expression (also absolute) gives the fill value to be stored in the | |
3963 | padding bytes. It (and the comma) may be omitted. If it is omitted, the | |
3964 | padding bytes are normally zero. However, on some systems, if the section is | |
3965 | marked as containing code and the fill value is omitted, the space is filled | |
3966 | with no-op instructions. | |
3967 | ||
3968 | The third expression is also absolute, and is also optional. If it is present, | |
3969 | it is the maximum number of bytes that should be skipped by this alignment | |
3970 | directive. If doing the alignment would require skipping more bytes than the | |
3971 | specified maximum, then the alignment is not done at all. You can omit the | |
3972 | fill value (the second argument) entirely by simply using two commas after the | |
3973 | required alignment; this can be useful if you want the alignment to be filled | |
3974 | with no-op instructions when appropriate. | |
3975 | ||
3976 | The way the required alignment is specified varies from system to system. | |
7be1c489 | 3977 | For the arc, hppa, i386 using ELF, i860, iq2000, m68k, or32, |
60946ad0 | 3978 | s390, sparc, tic4x, tic80 and xtensa, the first expression is the |
252b5132 RH |
3979 | alignment request in bytes. For example @samp{.align 8} advances |
3980 | the location counter until it is a multiple of 8. If the location counter | |
60946ad0 AM |
3981 | is already a multiple of 8, no change is needed. For the tic54x, the |
3982 | first expression is the alignment request in words. | |
252b5132 | 3983 | |
adcf07e6 NC |
3984 | For other systems, including the i386 using a.out format, and the arm and |
3985 | strongarm, it is the | |
252b5132 RH |
3986 | number of low-order zero bits the location counter must have after |
3987 | advancement. For example @samp{.align 3} advances the location | |
3988 | counter until it a multiple of 8. If the location counter is already a | |
3989 | multiple of 8, no change is needed. | |
3990 | ||
3991 | This inconsistency is due to the different behaviors of the various | |
3992 | native assemblers for these systems which GAS must emulate. | |
3993 | GAS also provides @code{.balign} and @code{.p2align} directives, | |
3994 | described later, which have a consistent behavior across all | |
3995 | architectures (but are specific to GAS). | |
3996 | ||
3997 | @node Ascii | |
3998 | @section @code{.ascii "@var{string}"}@dots{} | |
3999 | ||
4000 | @cindex @code{ascii} directive | |
4001 | @cindex string literals | |
4002 | @code{.ascii} expects zero or more string literals (@pxref{Strings}) | |
4003 | separated by commas. It assembles each string (with no automatic | |
4004 | trailing zero byte) into consecutive addresses. | |
4005 | ||
4006 | @node Asciz | |
4007 | @section @code{.asciz "@var{string}"}@dots{} | |
4008 | ||
4009 | @cindex @code{asciz} directive | |
4010 | @cindex zero-terminated strings | |
4011 | @cindex null-terminated strings | |
4012 | @code{.asciz} is just like @code{.ascii}, but each string is followed by | |
4013 | a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''. | |
4014 | ||
4015 | @node Balign | |
4016 | @section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}} | |
4017 | ||
4018 | @cindex padding the location counter given number of bytes | |
4019 | @cindex @code{balign} directive | |
4020 | Pad the location counter (in the current subsection) to a particular | |
4021 | storage boundary. The first expression (which must be absolute) is the | |
4022 | alignment request in bytes. For example @samp{.balign 8} advances | |
4023 | the location counter until it is a multiple of 8. If the location counter | |
4024 | is already a multiple of 8, no change is needed. | |
4025 | ||
4026 | The second expression (also absolute) gives the fill value to be stored in the | |
4027 | padding bytes. It (and the comma) may be omitted. If it is omitted, the | |
4028 | padding bytes are normally zero. However, on some systems, if the section is | |
4029 | marked as containing code and the fill value is omitted, the space is filled | |
4030 | with no-op instructions. | |
4031 | ||
4032 | The third expression is also absolute, and is also optional. If it is present, | |
4033 | it is the maximum number of bytes that should be skipped by this alignment | |
4034 | directive. If doing the alignment would require skipping more bytes than the | |
4035 | specified maximum, then the alignment is not done at all. You can omit the | |
4036 | fill value (the second argument) entirely by simply using two commas after the | |
4037 | required alignment; this can be useful if you want the alignment to be filled | |
4038 | with no-op instructions when appropriate. | |
4039 | ||
4040 | @cindex @code{balignw} directive | |
4041 | @cindex @code{balignl} directive | |
4042 | The @code{.balignw} and @code{.balignl} directives are variants of the | |
4043 | @code{.balign} directive. The @code{.balignw} directive treats the fill | |
4044 | pattern as a two byte word value. The @code{.balignl} directives treats the | |
4045 | fill pattern as a four byte longword value. For example, @code{.balignw | |
4046 | 4,0x368d} will align to a multiple of 4. If it skips two bytes, they will be | |
4047 | filled in with the value 0x368d (the exact placement of the bytes depends upon | |
4048 | the endianness of the processor). If it skips 1 or 3 bytes, the fill value is | |
4049 | undefined. | |
4050 | ||
4051 | @node Byte | |
4052 | @section @code{.byte @var{expressions}} | |
4053 | ||
4054 | @cindex @code{byte} directive | |
4055 | @cindex integers, one byte | |
4056 | @code{.byte} expects zero or more expressions, separated by commas. | |
4057 | Each expression is assembled into the next byte. | |
4058 | ||
d88ef7a6 TT |
4059 | @node Comm |
4060 | @section @code{.comm @var{symbol} , @var{length} } | |
4061 | ||
4062 | @cindex @code{comm} directive | |
4063 | @cindex symbol, common | |
4064 | @code{.comm} declares a common symbol named @var{symbol}. When linking, a | |
4065 | common symbol in one object file may be merged with a defined or common symbol | |
4066 | of the same name in another object file. If @code{@value{LD}} does not see a | |
4067 | definition for the symbol--just one or more common symbols--then it will | |
4068 | allocate @var{length} bytes of uninitialized memory. @var{length} must be an | |
4069 | absolute expression. If @code{@value{LD}} sees multiple common symbols with | |
4070 | the same name, and they do not all have the same size, it will allocate space | |
4071 | using the largest size. | |
4072 | ||
4073 | @ifset ELF | |
4074 | When using ELF, the @code{.comm} directive takes an optional third argument. | |
4075 | This is the desired alignment of the symbol, specified as a byte boundary (for | |
4076 | example, an alignment of 16 means that the least significant 4 bits of the | |
4077 | address should be zero). The alignment must be an absolute expression, and it | |
4078 | must be a power of two. If @code{@value{LD}} allocates uninitialized memory | |
4079 | for the common symbol, it will use the alignment when placing the symbol. If | |
4080 | no alignment is specified, @command{@value{AS}} will set the alignment to the | |
4081 | largest power of two less than or equal to the size of the symbol, up to a | |
4082 | maximum of 16. | |
4083 | @end ifset | |
4084 | ||
4085 | @ifset HPPA | |
4086 | The syntax for @code{.comm} differs slightly on the HPPA. The syntax is | |
4087 | @samp{@var{symbol} .comm, @var{length}}; @var{symbol} is optional. | |
4088 | @end ifset | |
4089 | ||
54cfded0 AM |
4090 | @node CFI directives |
4091 | @section @code{.cfi_startproc} | |
4092 | @cindex @code{cfi_startproc} directive | |
4093 | @code{.cfi_startproc} is used at the beginning of each function that | |
4094 | should have an entry in @code{.eh_frame}. It initializes some internal | |
4095 | data structures and emits architecture dependent initial CFI instructions. | |
4096 | Don't forget to close the function by | |
4097 | @code{.cfi_endproc}. | |
4098 | ||
4099 | @section @code{.cfi_endproc} | |
4100 | @cindex @code{cfi_endproc} directive | |
4101 | @code{.cfi_endproc} is used at the end of a function where it closes its | |
4102 | unwind entry previously opened by | |
b45619c0 | 4103 | @code{.cfi_startproc}, and emits it to @code{.eh_frame}. |
54cfded0 AM |
4104 | |
4105 | @section @code{.cfi_def_cfa @var{register}, @var{offset}} | |
4106 | @code{.cfi_def_cfa} defines a rule for computing CFA as: @i{take | |
4107 | address from @var{register} and add @var{offset} to it}. | |
4108 | ||
4109 | @section @code{.cfi_def_cfa_register @var{register}} | |
4110 | @code{.cfi_def_cfa_register} modifies a rule for computing CFA. From | |
4111 | now on @var{register} will be used instead of the old one. Offset | |
4112 | remains the same. | |
4113 | ||
4114 | @section @code{.cfi_def_cfa_offset @var{offset}} | |
4115 | @code{.cfi_def_cfa_offset} modifies a rule for computing CFA. Register | |
4116 | remains the same, but @var{offset} is new. Note that it is the | |
4117 | absolute offset that will be added to a defined register to compute | |
4118 | CFA address. | |
4119 | ||
4120 | @section @code{.cfi_adjust_cfa_offset @var{offset}} | |
4121 | Same as @code{.cfi_def_cfa_offset} but @var{offset} is a relative | |
4122 | value that is added/substracted from the previous offset. | |
4123 | ||
4124 | @section @code{.cfi_offset @var{register}, @var{offset}} | |
4125 | Previous value of @var{register} is saved at offset @var{offset} from | |
4126 | CFA. | |
4127 | ||
17076204 RH |
4128 | @section @code{.cfi_rel_offset @var{register}, @var{offset}} |
4129 | Previous value of @var{register} is saved at offset @var{offset} from | |
4130 | the current CFA register. This is transformed to @code{.cfi_offset} | |
4131 | using the known displacement of the CFA register from the CFA. | |
4132 | This is often easier to use, because the number will match the | |
4133 | code it's annotating. | |
54cfded0 | 4134 | |
63752a75 JJ |
4135 | @section @code{.cfi_signal_frame} |
4136 | Mark current function as signal trampoline. | |
4137 | ||
6749011b | 4138 | @section @code{.cfi_window_save} |
364b6d8b JJ |
4139 | SPARC register window has been saved. |
4140 | ||
cdfbf930 RH |
4141 | @section @code{.cfi_escape} @var{expression}[, @dots{}] |
4142 | Allows the user to add arbitrary bytes to the unwind info. One | |
4143 | might use this to add OS-specific CFI opcodes, or generic CFI | |
4144 | opcodes that GAS does not yet support. | |
252b5132 | 4145 | |
bd0eb99b RH |
4146 | @node LNS directives |
4147 | @section @code{.file @var{fileno} @var{filename}} | |
4148 | @cindex @code{file} directive | |
4149 | When emitting dwarf2 line number information @code{.file} assigns filenames | |
4150 | to the @code{.debug_line} file name table. The @var{fileno} operand should | |
4151 | be a unique positive integer to use as the index of the entry in the table. | |
4152 | The @var{filename} operand is a C string literal. | |
4153 | ||
b45619c0 | 4154 | The detail of filename indices is exposed to the user because the filename |
bd0eb99b | 4155 | table is shared with the @code{.debug_info} section of the dwarf2 debugging |
b45619c0 | 4156 | information, and thus the user must know the exact indices that table |
bd0eb99b RH |
4157 | entries will have. |
4158 | ||
ecea7679 | 4159 | @section @code{.loc @var{fileno} @var{lineno} [@var{column}] [@var{options}]} |
bd0eb99b RH |
4160 | @cindex @code{loc} directive |
4161 | The @code{.loc} directive will add row to the @code{.debug_line} line | |
4162 | number matrix corresponding to the immediately following assembly | |
4163 | instruction. The @var{fileno}, @var{lineno}, and optional @var{column} | |
4164 | arguments will be applied to the @code{.debug_line} state machine before | |
4165 | the row is added. | |
4166 | ||
ecea7679 RH |
4167 | The @var{options} are a sequence of the following tokens in any order: |
4168 | ||
4169 | @table @code | |
4170 | @item basic_block | |
4171 | This option will set the @code{basic_block} register in the | |
bd0eb99b RH |
4172 | @code{.debug_line} state machine to @code{true}. |
4173 | ||
ecea7679 RH |
4174 | @item prologue_end |
4175 | This option will set the @code{prologue_end} register in the | |
bd0eb99b RH |
4176 | @code{.debug_line} state machine to @code{true}. |
4177 | ||
ecea7679 RH |
4178 | @item epilogue_begin |
4179 | This option will set the @code{epilogue_begin} register in the | |
bd0eb99b RH |
4180 | @code{.debug_line} state machine to @code{true}. |
4181 | ||
ecea7679 RH |
4182 | @item is_stmt @var{value} |
4183 | This option will set the @code{is_stmt} register in the | |
bd0eb99b RH |
4184 | @code{.debug_line} state machine to @code{value}, which must be |
4185 | either 0 or 1. | |
4186 | ||
ecea7679 | 4187 | @item isa @var{value} |
bd0eb99b RH |
4188 | This directive will set the @code{isa} register in the @code{.debug_line} |
4189 | state machine to @var{value}, which must be an unsigned integer. | |
07a53e5c | 4190 | |
cd1fcb49 NC |
4191 | @end table |
4192 | ||
07a53e5c RH |
4193 | @section @code{.loc_mark_blocks @var{enable}} |
4194 | @cindex @code{loc_mark_blocks} directive | |
4195 | The @code{.loc_mark_blocks} directive makes the assembler emit an entry | |
4196 | to the @code{.debug_line} line number matrix with the @code{basic_block} | |
4197 | register in the state machine set whenever a code label is seen. | |
4198 | The @var{enable} argument should be either 1 or 0, to enable or disable | |
4199 | this function respectively. | |
4200 | ||
252b5132 RH |
4201 | @node Data |
4202 | @section @code{.data @var{subsection}} | |
4203 | ||
4204 | @cindex @code{data} directive | |
a4fb0134 | 4205 | @code{.data} tells @command{@value{AS}} to assemble the following statements onto the |
252b5132 RH |
4206 | end of the data subsection numbered @var{subsection} (which is an |
4207 | absolute expression). If @var{subsection} is omitted, it defaults | |
4208 | to zero. | |
4209 | ||
4210 | @ifset COFF | |
4211 | @node Def | |
4212 | @section @code{.def @var{name}} | |
4213 | ||
4214 | @cindex @code{def} directive | |
4215 | @cindex COFF symbols, debugging | |
4216 | @cindex debugging COFF symbols | |
4217 | Begin defining debugging information for a symbol @var{name}; the | |
4218 | definition extends until the @code{.endef} directive is encountered. | |
4219 | @ifset BOUT | |
4220 | ||
a4fb0134 | 4221 | This directive is only observed when @command{@value{AS}} is configured for COFF |
252b5132 RH |
4222 | format output; when producing @code{b.out}, @samp{.def} is recognized, |
4223 | but ignored. | |
4224 | @end ifset | |
4225 | @end ifset | |
4226 | ||
4227 | @ifset aout-bout | |
4228 | @node Desc | |
4229 | @section @code{.desc @var{symbol}, @var{abs-expression}} | |
4230 | ||
4231 | @cindex @code{desc} directive | |
4232 | @cindex COFF symbol descriptor | |
4233 | @cindex symbol descriptor, COFF | |
4234 | This directive sets the descriptor of the symbol (@pxref{Symbol Attributes}) | |
4235 | to the low 16 bits of an absolute expression. | |
4236 | ||
4237 | @ifset COFF | |
a4fb0134 | 4238 | The @samp{.desc} directive is not available when @command{@value{AS}} is |
252b5132 | 4239 | configured for COFF output; it is only for @code{a.out} or @code{b.out} |
a4fb0134 | 4240 | object format. For the sake of compatibility, @command{@value{AS}} accepts |
252b5132 RH |
4241 | it, but produces no output, when configured for COFF. |
4242 | @end ifset | |
4243 | @end ifset | |
4244 | ||
4245 | @ifset COFF | |
4246 | @node Dim | |
4247 | @section @code{.dim} | |
4248 | ||
4249 | @cindex @code{dim} directive | |
4250 | @cindex COFF auxiliary symbol information | |
4251 | @cindex auxiliary symbol information, COFF | |
4252 | This directive is generated by compilers to include auxiliary debugging | |
4253 | information in the symbol table. It is only permitted inside | |
4254 | @code{.def}/@code{.endef} pairs. | |
4255 | @ifset BOUT | |
4256 | ||
4257 | @samp{.dim} is only meaningful when generating COFF format output; when | |
a4fb0134 | 4258 | @command{@value{AS}} is generating @code{b.out}, it accepts this directive but |
252b5132 RH |
4259 | ignores it. |
4260 | @end ifset | |
4261 | @end ifset | |
4262 | ||
4263 | @node Double | |
4264 | @section @code{.double @var{flonums}} | |
4265 | ||
4266 | @cindex @code{double} directive | |
4267 | @cindex floating point numbers (double) | |
4268 | @code{.double} expects zero or more flonums, separated by commas. It | |
4269 | assembles floating point numbers. | |
4270 | @ifset GENERIC | |
4271 | The exact kind of floating point numbers emitted depends on how | |
a4fb0134 | 4272 | @command{@value{AS}} is configured. @xref{Machine Dependencies}. |
252b5132 RH |
4273 | @end ifset |
4274 | @ifclear GENERIC | |
4275 | @ifset IEEEFLOAT | |
4276 | On the @value{TARGET} family @samp{.double} emits 64-bit floating-point numbers | |
4277 | in @sc{ieee} format. | |
4278 | @end ifset | |
4279 | @end ifclear | |
4280 | ||
4281 | @node Eject | |
4282 | @section @code{.eject} | |
4283 | ||
4284 | @cindex @code{eject} directive | |
4285 | @cindex new page, in listings | |
4286 | @cindex page, in listings | |
4287 | @cindex listing control: new page | |
4288 | Force a page break at this point, when generating assembly listings. | |
4289 | ||
4290 | @node Else | |
4291 | @section @code{.else} | |
4292 | ||
4293 | @cindex @code{else} directive | |
a4fb0134 | 4294 | @code{.else} is part of the @command{@value{AS}} support for conditional |
96e9638b | 4295 | assembly; see @ref{If,,@code{.if}}. It marks the beginning of a section |
252b5132 RH |
4296 | of code to be assembled if the condition for the preceding @code{.if} |
4297 | was false. | |
4298 | ||
3fd9f047 TW |
4299 | @node Elseif |
4300 | @section @code{.elseif} | |
4301 | ||
4302 | @cindex @code{elseif} directive | |
a4fb0134 | 4303 | @code{.elseif} is part of the @command{@value{AS}} support for conditional |
96e9638b | 4304 | assembly; see @ref{If,,@code{.if}}. It is shorthand for beginning a new |
3fd9f047 TW |
4305 | @code{.if} block that would otherwise fill the entire @code{.else} section. |
4306 | ||
252b5132 RH |
4307 | @node End |
4308 | @section @code{.end} | |
4309 | ||
4310 | @cindex @code{end} directive | |
a4fb0134 | 4311 | @code{.end} marks the end of the assembly file. @command{@value{AS}} does not |
252b5132 RH |
4312 | process anything in the file past the @code{.end} directive. |
4313 | ||
4314 | @ifset COFF | |
4315 | @node Endef | |
4316 | @section @code{.endef} | |
4317 | ||
4318 | @cindex @code{endef} directive | |
4319 | This directive flags the end of a symbol definition begun with | |
4320 | @code{.def}. | |
4321 | @ifset BOUT | |
4322 | ||
4323 | @samp{.endef} is only meaningful when generating COFF format output; if | |
a4fb0134 | 4324 | @command{@value{AS}} is configured to generate @code{b.out}, it accepts this |
252b5132 RH |
4325 | directive but ignores it. |
4326 | @end ifset | |
4327 | @end ifset | |
4328 | ||
4329 | @node Endfunc | |
4330 | @section @code{.endfunc} | |
4331 | @cindex @code{endfunc} directive | |
4332 | @code{.endfunc} marks the end of a function specified with @code{.func}. | |
4333 | ||
4334 | @node Endif | |
4335 | @section @code{.endif} | |
4336 | ||
4337 | @cindex @code{endif} directive | |
a4fb0134 | 4338 | @code{.endif} is part of the @command{@value{AS}} support for conditional assembly; |
252b5132 RH |
4339 | it marks the end of a block of code that is only assembled |
4340 | conditionally. @xref{If,,@code{.if}}. | |
4341 | ||
4342 | @node Equ | |
4343 | @section @code{.equ @var{symbol}, @var{expression}} | |
4344 | ||
4345 | @cindex @code{equ} directive | |
4346 | @cindex assigning values to symbols | |
4347 | @cindex symbols, assigning values to | |
4348 | This directive sets the value of @var{symbol} to @var{expression}. | |
96e9638b | 4349 | It is synonymous with @samp{.set}; see @ref{Set,,@code{.set}}. |
252b5132 RH |
4350 | |
4351 | @ifset HPPA | |
4352 | The syntax for @code{equ} on the HPPA is | |
4353 | @samp{@var{symbol} .equ @var{expression}}. | |
4354 | @end ifset | |
4355 | ||
3c9b82ba NC |
4356 | @ifset Z80 |
4357 | The syntax for @code{equ} on the Z80 is | |
4358 | @samp{@var{symbol} equ @var{expression}}. | |
4359 | On the Z80 it is an eror if @var{symbol} is already defined, | |
96e9638b BW |
4360 | but the symbol is not protected from later redefinition. |
4361 | Compare @ref{Equiv}. | |
3c9b82ba NC |
4362 | @end ifset |
4363 | ||
252b5132 RH |
4364 | @node Equiv |
4365 | @section @code{.equiv @var{symbol}, @var{expression}} | |
4366 | @cindex @code{equiv} directive | |
4367 | The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that | |
8dfa0188 NC |
4368 | the assembler will signal an error if @var{symbol} is already defined. Note a |
4369 | symbol which has been referenced but not actually defined is considered to be | |
4370 | undefined. | |
252b5132 RH |
4371 | |
4372 | Except for the contents of the error message, this is roughly equivalent to | |
4373 | @smallexample | |
4374 | .ifdef SYM | |
4375 | .err | |
4376 | .endif | |
4377 | .equ SYM,VAL | |
4378 | @end smallexample | |
9497f5ac NC |
4379 | plus it protects the symbol from later redefinition. |
4380 | ||
4381 | @node Eqv | |
4382 | @section @code{.eqv @var{symbol}, @var{expression}} | |
4383 | @cindex @code{eqv} directive | |
4384 | The @code{.eqv} directive is like @code{.equiv}, but no attempt is made to | |
4385 | evaluate the expression or any part of it immediately. Instead each time | |
4386 | the resulting symbol is used in an expression, a snapshot of its current | |
4387 | value is taken. | |
252b5132 RH |
4388 | |
4389 | @node Err | |
4390 | @section @code{.err} | |
4391 | @cindex @code{err} directive | |
a4fb0134 SC |
4392 | If @command{@value{AS}} assembles a @code{.err} directive, it will print an error |
4393 | message and, unless the @option{-Z} option was used, it will not generate an | |
f9eb6721 | 4394 | object file. This can be used to signal an error in conditionally compiled code. |
252b5132 | 4395 | |
d190d046 HPN |
4396 | @node Error |
4397 | @section @code{.error "@var{string}"} | |
4398 | @cindex error directive | |
4399 | ||
4400 | Similarly to @code{.err}, this directive emits an error, but you can specify a | |
4401 | string that will be emitted as the error message. If you don't specify the | |
4402 | message, it defaults to @code{".error directive invoked in source file"}. | |
4403 | @xref{Errors, ,Error and Warning Messages}. | |
4404 | ||
4405 | @smallexample | |
4406 | .error "This code has not been assembled and tested." | |
4407 | @end smallexample | |
4408 | ||
252b5132 RH |
4409 | @node Exitm |
4410 | @section @code{.exitm} | |
4411 | Exit early from the current macro definition. @xref{Macro}. | |
4412 | ||
4413 | @node Extern | |
4414 | @section @code{.extern} | |
4415 | ||
4416 | @cindex @code{extern} directive | |
4417 | @code{.extern} is accepted in the source program---for compatibility | |
a4fb0134 | 4418 | with other assemblers---but it is ignored. @command{@value{AS}} treats |
252b5132 RH |
4419 | all undefined symbols as external. |
4420 | ||
4421 | @node Fail | |
4422 | @section @code{.fail @var{expression}} | |
4423 | ||
4424 | @cindex @code{fail} directive | |
4425 | Generates an error or a warning. If the value of the @var{expression} is 500 | |
a4fb0134 SC |
4426 | or more, @command{@value{AS}} will print a warning message. If the value is less |
4427 | than 500, @command{@value{AS}} will print an error message. The message will | |
252b5132 RH |
4428 | include the value of @var{expression}. This can occasionally be useful inside |
4429 | complex nested macros or conditional assembly. | |
4430 | ||
4431 | @ifclear no-file-dir | |
4432 | @node File | |
4433 | @section @code{.file @var{string}} | |
4434 | ||
4435 | @cindex @code{file} directive | |
4436 | @cindex logical file name | |
4437 | @cindex file name, logical | |
a4fb0134 | 4438 | @code{.file} tells @command{@value{AS}} that we are about to start a new logical |
252b5132 RH |
4439 | file. @var{string} is the new file name. In general, the filename is |
4440 | recognized whether or not it is surrounded by quotes @samp{"}; but if you wish | |
4441 | to specify an empty file name, you must give the quotes--@code{""}. This | |
4442 | statement may go away in future: it is only recognized to be compatible with | |
a4fb0134 | 4443 | old @command{@value{AS}} programs. |
252b5132 RH |
4444 | @end ifclear |
4445 | ||
4446 | @node Fill | |
4447 | @section @code{.fill @var{repeat} , @var{size} , @var{value}} | |
4448 | ||
4449 | @cindex @code{fill} directive | |
4450 | @cindex writing patterns in memory | |
4451 | @cindex patterns, writing in memory | |
bc64be0c | 4452 | @var{repeat}, @var{size} and @var{value} are absolute expressions. |
252b5132 RH |
4453 | This emits @var{repeat} copies of @var{size} bytes. @var{Repeat} |
4454 | may be zero or more. @var{Size} may be zero or more, but if it is | |
4455 | more than 8, then it is deemed to have the value 8, compatible with | |
4456 | other people's assemblers. The contents of each @var{repeat} bytes | |
4457 | is taken from an 8-byte number. The highest order 4 bytes are | |
4458 | zero. The lowest order 4 bytes are @var{value} rendered in the | |
a4fb0134 | 4459 | byte-order of an integer on the computer @command{@value{AS}} is assembling for. |
252b5132 RH |
4460 | Each @var{size} bytes in a repetition is taken from the lowest order |
4461 | @var{size} bytes of this number. Again, this bizarre behavior is | |
4462 | compatible with other people's assemblers. | |
4463 | ||
4464 | @var{size} and @var{value} are optional. | |
4465 | If the second comma and @var{value} are absent, @var{value} is | |
4466 | assumed zero. If the first comma and following tokens are absent, | |
4467 | @var{size} is assumed to be 1. | |
4468 | ||
4469 | @node Float | |
4470 | @section @code{.float @var{flonums}} | |
4471 | ||
4472 | @cindex floating point numbers (single) | |
4473 | @cindex @code{float} directive | |
4474 | This directive assembles zero or more flonums, separated by commas. It | |
4475 | has the same effect as @code{.single}. | |
4476 | @ifset GENERIC | |
4477 | The exact kind of floating point numbers emitted depends on how | |
a4fb0134 | 4478 | @command{@value{AS}} is configured. |
252b5132 RH |
4479 | @xref{Machine Dependencies}. |
4480 | @end ifset | |
4481 | @ifclear GENERIC | |
4482 | @ifset IEEEFLOAT | |
4483 | On the @value{TARGET} family, @code{.float} emits 32-bit floating point numbers | |
4484 | in @sc{ieee} format. | |
4485 | @end ifset | |
4486 | @end ifclear | |
4487 | ||
4488 | @node Func | |
4489 | @section @code{.func @var{name}[,@var{label}]} | |
4490 | @cindex @code{func} directive | |
4491 | @code{.func} emits debugging information to denote function @var{name}, and | |
4492 | is ignored unless the file is assembled with debugging enabled. | |
05da4302 | 4493 | Only @samp{--gstabs[+]} is currently supported. |
252b5132 RH |
4494 | @var{label} is the entry point of the function and if omitted @var{name} |
4495 | prepended with the @samp{leading char} is used. | |
4496 | @samp{leading char} is usually @code{_} or nothing, depending on the target. | |
4497 | All functions are currently defined to have @code{void} return type. | |
4498 | The function must be terminated with @code{.endfunc}. | |
4499 | ||
4500 | @node Global | |
4501 | @section @code{.global @var{symbol}}, @code{.globl @var{symbol}} | |
4502 | ||
4503 | @cindex @code{global} directive | |
4504 | @cindex symbol, making visible to linker | |
4505 | @code{.global} makes the symbol visible to @code{@value{LD}}. If you define | |
4506 | @var{symbol} in your partial program, its value is made available to | |
4507 | other partial programs that are linked with it. Otherwise, | |
4508 | @var{symbol} takes its attributes from a symbol of the same name | |
4509 | from another file linked into the same program. | |
4510 | ||
4511 | Both spellings (@samp{.globl} and @samp{.global}) are accepted, for | |
4512 | compatibility with other assemblers. | |
4513 | ||
4514 | @ifset HPPA | |
4515 | On the HPPA, @code{.global} is not always enough to make it accessible to other | |
4516 | partial programs. You may need the HPPA-only @code{.EXPORT} directive as well. | |
96e9638b | 4517 | @xref{HPPA Directives, ,HPPA Assembler Directives}. |
252b5132 RH |
4518 | @end ifset |
4519 | ||
c91d2e08 NC |
4520 | @ifset ELF |
4521 | @node Hidden | |
4522 | @section @code{.hidden @var{names}} | |
4523 | ||
c1253627 NC |
4524 | @cindex @code{hidden} directive |
4525 | @cindex visibility | |
ed9589d4 | 4526 | This is one of the ELF visibility directives. The other two are |
a349d9dd PB |
4527 | @code{.internal} (@pxref{Internal,,@code{.internal}}) and |
4528 | @code{.protected} (@pxref{Protected,,@code{.protected}}). | |
c91d2e08 NC |
4529 | |
4530 | This directive overrides the named symbols default visibility (which is set by | |
4531 | their binding: local, global or weak). The directive sets the visibility to | |
4532 | @code{hidden} which means that the symbols are not visible to other components. | |
4533 | Such symbols are always considered to be @code{protected} as well. | |
4534 | @end ifset | |
4535 | ||
252b5132 RH |
4536 | @node hword |
4537 | @section @code{.hword @var{expressions}} | |
4538 | ||
4539 | @cindex @code{hword} directive | |
4540 | @cindex integers, 16-bit | |
4541 | @cindex numbers, 16-bit | |
4542 | @cindex sixteen bit integers | |
4543 | This expects zero or more @var{expressions}, and emits | |
4544 | a 16 bit number for each. | |
4545 | ||
4546 | @ifset GENERIC | |
4547 | This directive is a synonym for @samp{.short}; depending on the target | |
4548 | architecture, it may also be a synonym for @samp{.word}. | |
4549 | @end ifset | |
4550 | @ifclear GENERIC | |
4551 | @ifset W32 | |
4552 | This directive is a synonym for @samp{.short}. | |
4553 | @end ifset | |
4554 | @ifset W16 | |
4555 | This directive is a synonym for both @samp{.short} and @samp{.word}. | |
4556 | @end ifset | |
4557 | @end ifclear | |
4558 | ||
4559 | @node Ident | |
4560 | @section @code{.ident} | |
4561 | ||
4562 | @cindex @code{ident} directive | |
cb4c78d6 BE |
4563 | |
4564 | This directive is used by some assemblers to place tags in object files. The | |
4565 | behavior of this directive varies depending on the target. When using the | |
4566 | a.out object file format, @command{@value{AS}} simply accepts the directive for | |
4567 | source-file compatibility with existing assemblers, but does not emit anything | |
4568 | for it. When using COFF, comments are emitted to the @code{.comment} or | |
4569 | @code{.rdata} section, depending on the target. When using ELF, comments are | |
4570 | emitted to the @code{.comment} section. | |
252b5132 RH |
4571 | |
4572 | @node If | |
4573 | @section @code{.if @var{absolute expression}} | |
4574 | ||
4575 | @cindex conditional assembly | |
4576 | @cindex @code{if} directive | |
4577 | @code{.if} marks the beginning of a section of code which is only | |
4578 | considered part of the source program being assembled if the argument | |
4579 | (which must be an @var{absolute expression}) is non-zero. The end of | |
4580 | the conditional section of code must be marked by @code{.endif} | |
4581 | (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the | |
4582 | alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}). | |
3fd9f047 TW |
4583 | If you have several conditions to check, @code{.elseif} may be used to avoid |
4584 | nesting blocks if/else within each subsequent @code{.else} block. | |
252b5132 RH |
4585 | |
4586 | The following variants of @code{.if} are also supported: | |
4587 | @table @code | |
4588 | @cindex @code{ifdef} directive | |
4589 | @item .ifdef @var{symbol} | |
4590 | Assembles the following section of code if the specified @var{symbol} | |
8dfa0188 NC |
4591 | has been defined. Note a symbol which has been referenced but not yet defined |
4592 | is considered to be undefined. | |
252b5132 | 4593 | |
26aca5f6 JB |
4594 | @cindex @code{ifb} directive |
4595 | @item .ifb @var{text} | |
4596 | Assembles the following section of code if the operand is blank (empty). | |
4597 | ||
252b5132 RH |
4598 | @cindex @code{ifc} directive |
4599 | @item .ifc @var{string1},@var{string2} | |
4600 | Assembles the following section of code if the two strings are the same. The | |
4601 | strings may be optionally quoted with single quotes. If they are not quoted, | |
4602 | the first string stops at the first comma, and the second string stops at the | |
4603 | end of the line. Strings which contain whitespace should be quoted. The | |
4604 | string comparison is case sensitive. | |
4605 | ||
4606 | @cindex @code{ifeq} directive | |
4607 | @item .ifeq @var{absolute expression} | |
4608 | Assembles the following section of code if the argument is zero. | |
4609 | ||
4610 | @cindex @code{ifeqs} directive | |
4611 | @item .ifeqs @var{string1},@var{string2} | |
4612 | Another form of @code{.ifc}. The strings must be quoted using double quotes. | |
4613 | ||
4614 | @cindex @code{ifge} directive | |
4615 | @item .ifge @var{absolute expression} | |
4616 | Assembles the following section of code if the argument is greater than or | |
4617 | equal to zero. | |
4618 | ||
4619 | @cindex @code{ifgt} directive | |
4620 | @item .ifgt @var{absolute expression} | |
4621 | Assembles the following section of code if the argument is greater than zero. | |
4622 | ||
4623 | @cindex @code{ifle} directive | |
4624 | @item .ifle @var{absolute expression} | |
4625 | Assembles the following section of code if the argument is less than or equal | |
4626 | to zero. | |
4627 | ||
4628 | @cindex @code{iflt} directive | |
4629 | @item .iflt @var{absolute expression} | |
4630 | Assembles the following section of code if the argument is less than zero. | |
4631 | ||
26aca5f6 JB |
4632 | @cindex @code{ifnb} directive |
4633 | @item .ifnb @var{text} | |
4634 | Like @code{.ifb}, but the sense of the test is reversed: this assembles the | |
4635 | following section of code if the operand is non-blank (non-empty). | |
4636 | ||
252b5132 RH |
4637 | @cindex @code{ifnc} directive |
4638 | @item .ifnc @var{string1},@var{string2}. | |
4639 | Like @code{.ifc}, but the sense of the test is reversed: this assembles the | |
4640 | following section of code if the two strings are not the same. | |
4641 | ||
4642 | @cindex @code{ifndef} directive | |
4643 | @cindex @code{ifnotdef} directive | |
4644 | @item .ifndef @var{symbol} | |
4645 | @itemx .ifnotdef @var{symbol} | |
4646 | Assembles the following section of code if the specified @var{symbol} | |
8dfa0188 NC |
4647 | has not been defined. Both spelling variants are equivalent. Note a symbol |
4648 | which has been referenced but not yet defined is considered to be undefined. | |
252b5132 RH |
4649 | |
4650 | @cindex @code{ifne} directive | |
4651 | @item .ifne @var{absolute expression} | |
4652 | Assembles the following section of code if the argument is not equal to zero | |
4653 | (in other words, this is equivalent to @code{.if}). | |
4654 | ||
4655 | @cindex @code{ifnes} directive | |
4656 | @item .ifnes @var{string1},@var{string2} | |
4657 | Like @code{.ifeqs}, but the sense of the test is reversed: this assembles the | |
4658 | following section of code if the two strings are not the same. | |
4659 | @end table | |
4660 | ||
7e005732 NC |
4661 | @node Incbin |
4662 | @section @code{.incbin "@var{file}"[,@var{skip}[,@var{count}]]} | |
4663 | ||
4664 | @cindex @code{incbin} directive | |
4665 | @cindex binary files, including | |
4666 | The @code{incbin} directive includes @var{file} verbatim at the current | |
4667 | location. You can control the search paths used with the @samp{-I} command-line | |
4668 | option (@pxref{Invoking,,Command-Line Options}). Quotation marks are required | |
4669 | around @var{file}. | |
4670 | ||
4671 | The @var{skip} argument skips a number of bytes from the start of the | |
4672 | @var{file}. The @var{count} argument indicates the maximum number of bytes to | |
15dcfbc3 NC |
4673 | read. Note that the data is not aligned in any way, so it is the user's |
4674 | responsibility to make sure that proper alignment is provided both before and | |
4675 | after the @code{incbin} directive. | |
7e005732 | 4676 | |
252b5132 RH |
4677 | @node Include |
4678 | @section @code{.include "@var{file}"} | |
4679 | ||
4680 | @cindex @code{include} directive | |
4681 | @cindex supporting files, including | |
4682 | @cindex files, including | |
4683 | This directive provides a way to include supporting files at specified | |
4684 | points in your source program. The code from @var{file} is assembled as | |
4685 | if it followed the point of the @code{.include}; when the end of the | |
4686 | included file is reached, assembly of the original file continues. You | |
4687 | can control the search paths used with the @samp{-I} command-line option | |
4688 | (@pxref{Invoking,,Command-Line Options}). Quotation marks are required | |
4689 | around @var{file}. | |
4690 | ||
4691 | @node Int | |
4692 | @section @code{.int @var{expressions}} | |
4693 | ||
4694 | @cindex @code{int} directive | |
4695 | @cindex integers, 32-bit | |
4696 | Expect zero or more @var{expressions}, of any section, separated by commas. | |
4697 | For each expression, emit a number that, at run time, is the value of that | |
4698 | expression. The byte order and bit size of the number depends on what kind | |
4699 | of target the assembly is for. | |
4700 | ||
4701 | @ifclear GENERIC | |
4702 | @ifset H8 | |
7be1c489 | 4703 | On most forms of the H8/300, @code{.int} emits 16-bit |
c2dcd04e | 4704 | integers. On the H8/300H and the Renesas SH, however, @code{.int} emits |
252b5132 RH |
4705 | 32-bit integers. |
4706 | @end ifset | |
4707 | @end ifclear | |
4708 | ||
c91d2e08 NC |
4709 | @ifset ELF |
4710 | @node Internal | |
4711 | @section @code{.internal @var{names}} | |
4712 | ||
c1253627 NC |
4713 | @cindex @code{internal} directive |
4714 | @cindex visibility | |
ed9589d4 | 4715 | This is one of the ELF visibility directives. The other two are |
a349d9dd PB |
4716 | @code{.hidden} (@pxref{Hidden,,@code{.hidden}}) and |
4717 | @code{.protected} (@pxref{Protected,,@code{.protected}}). | |
c91d2e08 NC |
4718 | |
4719 | This directive overrides the named symbols default visibility (which is set by | |
4720 | their binding: local, global or weak). The directive sets the visibility to | |
4721 | @code{internal} which means that the symbols are considered to be @code{hidden} | |
c1253627 | 4722 | (i.e., not visible to other components), and that some extra, processor specific |
c91d2e08 NC |
4723 | processing must also be performed upon the symbols as well. |
4724 | @end ifset | |
4725 | ||
252b5132 RH |
4726 | @node Irp |
4727 | @section @code{.irp @var{symbol},@var{values}}@dots{} | |
4728 | ||
4729 | @cindex @code{irp} directive | |
4730 | Evaluate a sequence of statements assigning different values to @var{symbol}. | |
4731 | The sequence of statements starts at the @code{.irp} directive, and is | |
4732 | terminated by an @code{.endr} directive. For each @var{value}, @var{symbol} is | |
4733 | set to @var{value}, and the sequence of statements is assembled. If no | |
4734 | @var{value} is listed, the sequence of statements is assembled once, with | |
4735 | @var{symbol} set to the null string. To refer to @var{symbol} within the | |
4736 | sequence of statements, use @var{\symbol}. | |
4737 | ||
4738 | For example, assembling | |
4739 | ||
4740 | @example | |
4741 | .irp param,1,2,3 | |
4742 | move d\param,sp@@- | |
4743 | .endr | |
4744 | @end example | |
4745 | ||
4746 | is equivalent to assembling | |
4747 | ||
4748 | @example | |
4749 | move d1,sp@@- | |
4750 | move d2,sp@@- | |
4751 | move d3,sp@@- | |
4752 | @end example | |
4753 | ||
96e9638b | 4754 | For some caveats with the spelling of @var{symbol}, see also @ref{Macro}. |
5e75c3ab | 4755 | |
252b5132 RH |
4756 | @node Irpc |
4757 | @section @code{.irpc @var{symbol},@var{values}}@dots{} | |
4758 | ||
4759 | @cindex @code{irpc} directive | |
4760 | Evaluate a sequence of statements assigning different values to @var{symbol}. | |
4761 | The sequence of statements starts at the @code{.irpc} directive, and is | |
4762 | terminated by an @code{.endr} directive. For each character in @var{value}, | |
4763 | @var{symbol} is set to the character, and the sequence of statements is | |
4764 | assembled. If no @var{value} is listed, the sequence of statements is | |
4765 | assembled once, with @var{symbol} set to the null string. To refer to | |
4766 | @var{symbol} within the sequence of statements, use @var{\symbol}. | |
4767 | ||
4768 | For example, assembling | |
4769 | ||
4770 | @example | |
4771 | .irpc param,123 | |
4772 | move d\param,sp@@- | |
4773 | .endr | |
4774 | @end example | |
4775 | ||
4776 | is equivalent to assembling | |
4777 | ||
4778 | @example | |
4779 | move d1,sp@@- | |
4780 | move d2,sp@@- | |
4781 | move d3,sp@@- | |
4782 | @end example | |
4783 | ||
5e75c3ab JB |
4784 | For some caveats with the spelling of @var{symbol}, see also the discussion |
4785 | at @xref{Macro}. | |
4786 | ||
252b5132 RH |
4787 | @node Lcomm |
4788 | @section @code{.lcomm @var{symbol} , @var{length}} | |
4789 | ||
4790 | @cindex @code{lcomm} directive | |
4791 | @cindex local common symbols | |
4792 | @cindex symbols, local common | |
4793 | Reserve @var{length} (an absolute expression) bytes for a local common | |
4794 | denoted by @var{symbol}. The section and value of @var{symbol} are | |
4795 | those of the new local common. The addresses are allocated in the bss | |
4796 | section, so that at run-time the bytes start off zeroed. @var{Symbol} | |
4797 | is not declared global (@pxref{Global,,@code{.global}}), so is normally | |
4798 | not visible to @code{@value{LD}}. | |
4799 | ||
4800 | @ifset GENERIC | |
4801 | Some targets permit a third argument to be used with @code{.lcomm}. This | |
4802 | argument specifies the desired alignment of the symbol in the bss section. | |
4803 | @end ifset | |
4804 | ||
4805 | @ifset HPPA | |
4806 | The syntax for @code{.lcomm} differs slightly on the HPPA. The syntax is | |
4807 | @samp{@var{symbol} .lcomm, @var{length}}; @var{symbol} is optional. | |
4808 | @end ifset | |
4809 | ||
4810 | @node Lflags | |
4811 | @section @code{.lflags} | |
4812 | ||
4813 | @cindex @code{lflags} directive (ignored) | |
a4fb0134 | 4814 | @command{@value{AS}} accepts this directive, for compatibility with other |
252b5132 RH |
4815 | assemblers, but ignores it. |
4816 | ||
4817 | @ifclear no-line-dir | |
4818 | @node Line | |
4819 | @section @code{.line @var{line-number}} | |
4820 | ||
4821 | @cindex @code{line} directive | |
4822 | @end ifclear | |
4823 | @ifset no-line-dir | |
4824 | @node Ln | |
4825 | @section @code{.ln @var{line-number}} | |
4826 | ||
4827 | @cindex @code{ln} directive | |
4828 | @end ifset | |
4829 | @cindex logical line number | |
4830 | @ifset aout-bout | |
4831 | Change the logical line number. @var{line-number} must be an absolute | |
4832 | expression. The next line has that logical line number. Therefore any other | |
4833 | statements on the current line (after a statement separator character) are | |
4834 | reported as on logical line number @var{line-number} @minus{} 1. One day | |
a4fb0134 | 4835 | @command{@value{AS}} will no longer support this directive: it is recognized only |
252b5132 RH |
4836 | for compatibility with existing assembler programs. |
4837 | ||
252b5132 RH |
4838 | @end ifset |
4839 | ||
4840 | @ifclear no-line-dir | |
4841 | Even though this is a directive associated with the @code{a.out} or | |
a4fb0134 | 4842 | @code{b.out} object-code formats, @command{@value{AS}} still recognizes it |
252b5132 RH |
4843 | when producing COFF output, and treats @samp{.line} as though it |
4844 | were the COFF @samp{.ln} @emph{if} it is found outside a | |
4845 | @code{.def}/@code{.endef} pair. | |
4846 | ||
4847 | Inside a @code{.def}, @samp{.line} is, instead, one of the directives | |
4848 | used by compilers to generate auxiliary symbol information for | |
4849 | debugging. | |
4850 | @end ifclear | |
4851 | ||
4852 | @node Linkonce | |
4853 | @section @code{.linkonce [@var{type}]} | |
4854 | @cindex COMDAT | |
4855 | @cindex @code{linkonce} directive | |
4856 | @cindex common sections | |
4857 | Mark the current section so that the linker only includes a single copy of it. | |
4858 | This may be used to include the same section in several different object files, | |
4859 | but ensure that the linker will only include it once in the final output file. | |
4860 | The @code{.linkonce} pseudo-op must be used for each instance of the section. | |
4861 | Duplicate sections are detected based on the section name, so it should be | |
4862 | unique. | |
4863 | ||
4864 | This directive is only supported by a few object file formats; as of this | |
4865 | writing, the only object file format which supports it is the Portable | |
4866 | Executable format used on Windows NT. | |
4867 | ||
4868 | The @var{type} argument is optional. If specified, it must be one of the | |
4869 | following strings. For example: | |
4870 | @smallexample | |
4871 | .linkonce same_size | |
4872 | @end smallexample | |
4873 | Not all types may be supported on all object file formats. | |
4874 | ||
4875 | @table @code | |
4876 | @item discard | |
4877 | Silently discard duplicate sections. This is the default. | |
4878 | ||
4879 | @item one_only | |
4880 | Warn if there are duplicate sections, but still keep only one copy. | |
4881 | ||
4882 | @item same_size | |
4883 | Warn if any of the duplicates have different sizes. | |
4884 | ||
4885 | @item same_contents | |
4886 | Warn if any of the duplicates do not have exactly the same contents. | |
4887 | @end table | |
4888 | ||
4889 | @node Ln | |
4890 | @section @code{.ln @var{line-number}} | |
4891 | ||
4892 | @cindex @code{ln} directive | |
4893 | @ifclear no-line-dir | |
4894 | @samp{.ln} is a synonym for @samp{.line}. | |
4895 | @end ifclear | |
4896 | @ifset no-line-dir | |
a4fb0134 | 4897 | Tell @command{@value{AS}} to change the logical line number. @var{line-number} |
252b5132 RH |
4898 | must be an absolute expression. The next line has that logical |
4899 | line number, so any other statements on the current line (after a | |
4900 | statement separator character @code{;}) are reported as on logical | |
4901 | line number @var{line-number} @minus{} 1. | |
4902 | @ifset BOUT | |
4903 | ||
a4fb0134 | 4904 | This directive is accepted, but ignored, when @command{@value{AS}} is |
252b5132 RH |
4905 | configured for @code{b.out}; its effect is only associated with COFF |
4906 | output format. | |
4907 | @end ifset | |
4908 | @end ifset | |
4909 | ||
4910 | @node MRI | |
4911 | @section @code{.mri @var{val}} | |
4912 | ||
4913 | @cindex @code{mri} directive | |
4914 | @cindex MRI mode, temporarily | |
a4fb0134 SC |
4915 | If @var{val} is non-zero, this tells @command{@value{AS}} to enter MRI mode. If |
4916 | @var{val} is zero, this tells @command{@value{AS}} to exit MRI mode. This change | |
252b5132 RH |
4917 | affects code assembled until the next @code{.mri} directive, or until the end |
4918 | of the file. @xref{M, MRI mode, MRI mode}. | |
4919 | ||
4920 | @node List | |
4921 | @section @code{.list} | |
4922 | ||
4923 | @cindex @code{list} directive | |
4924 | @cindex listing control, turning on | |
4925 | Control (in conjunction with the @code{.nolist} directive) whether or | |
4926 | not assembly listings are generated. These two directives maintain an | |
4927 | internal counter (which is zero initially). @code{.list} increments the | |
4928 | counter, and @code{.nolist} decrements it. Assembly listings are | |
4929 | generated whenever the counter is greater than zero. | |
4930 | ||
4931 | By default, listings are disabled. When you enable them (with the | |
4932 | @samp{-a} command line option; @pxref{Invoking,,Command-Line Options}), | |
4933 | the initial value of the listing counter is one. | |
4934 | ||
4935 | @node Long | |
4936 | @section @code{.long @var{expressions}} | |
4937 | ||
4938 | @cindex @code{long} directive | |
96e9638b | 4939 | @code{.long} is the same as @samp{.int}. @xref{Int,,@code{.int}}. |
252b5132 RH |
4940 | |
4941 | @ignore | |
4942 | @c no one seems to know what this is for or whether this description is | |
4943 | @c what it really ought to do | |
4944 | @node Lsym | |
4945 | @section @code{.lsym @var{symbol}, @var{expression}} | |
4946 | ||
4947 | @cindex @code{lsym} directive | |
4948 | @cindex symbol, not referenced in assembly | |
4949 | @code{.lsym} creates a new symbol named @var{symbol}, but does not put it in | |
4950 | the hash table, ensuring it cannot be referenced by name during the | |
4951 | rest of the assembly. This sets the attributes of the symbol to be | |
4952 | the same as the expression value: | |
4953 | @smallexample | |
4954 | @var{other} = @var{descriptor} = 0 | |
4955 | @var{type} = @r{(section of @var{expression})} | |
4956 | @var{value} = @var{expression} | |
4957 | @end smallexample | |
4958 | @noindent | |
4959 | The new symbol is not flagged as external. | |
4960 | @end ignore | |
4961 | ||
4962 | @node Macro | |
4963 | @section @code{.macro} | |
4964 | ||
4965 | @cindex macros | |
4966 | The commands @code{.macro} and @code{.endm} allow you to define macros that | |
4967 | generate assembly output. For example, this definition specifies a macro | |
4968 | @code{sum} that puts a sequence of numbers into memory: | |
4969 | ||
4970 | @example | |
4971 | .macro sum from=0, to=5 | |
4972 | .long \from | |
4973 | .if \to-\from | |
4974 | sum "(\from+1)",\to | |
4975 | .endif | |
4976 | .endm | |
4977 | @end example | |
4978 | ||
4979 | @noindent | |
4980 | With that definition, @samp{SUM 0,5} is equivalent to this assembly input: | |
4981 | ||
4982 | @example | |
4983 | .long 0 | |
4984 | .long 1 | |
4985 | .long 2 | |
4986 | .long 3 | |
4987 | .long 4 | |
4988 | .long 5 | |
4989 | @end example | |
4990 | ||
4991 | @ftable @code | |
4992 | @item .macro @var{macname} | |
4993 | @itemx .macro @var{macname} @var{macargs} @dots{} | |
4994 | @cindex @code{macro} directive | |
4995 | Begin the definition of a macro called @var{macname}. If your macro | |
4996 | definition requires arguments, specify their names after the macro name, | |
6eaeac8a JB |
4997 | separated by commas or spaces. You can qualify the macro argument to |
4998 | indicate whether all invocations must specify a non-blank value (through | |
4999 | @samp{:@code{req}}), or whether it takes all of the remaining arguments | |
5000 | (through @samp{:@code{vararg}}). You can supply a default value for any | |
fffeaa5f JB |
5001 | macro argument by following the name with @samp{=@var{deflt}}. You |
5002 | cannot define two macros with the same @var{macname} unless it has been | |
96e9638b | 5003 | subject to the @code{.purgem} directive (@pxref{Purgem}) between the two |
fffeaa5f | 5004 | definitions. For example, these are all valid @code{.macro} statements: |
252b5132 RH |
5005 | |
5006 | @table @code | |
5007 | @item .macro comm | |
5008 | Begin the definition of a macro called @code{comm}, which takes no | |
5009 | arguments. | |
5010 | ||
6258339f | 5011 | @item .macro plus1 p, p1 |
252b5132 RH |
5012 | @itemx .macro plus1 p p1 |
5013 | Either statement begins the definition of a macro called @code{plus1}, | |
5014 | which takes two arguments; within the macro definition, write | |
5015 | @samp{\p} or @samp{\p1} to evaluate the arguments. | |
5016 | ||
5017 | @item .macro reserve_str p1=0 p2 | |
5018 | Begin the definition of a macro called @code{reserve_str}, with two | |
5019 | arguments. The first argument has a default value, but not the second. | |
5020 | After the definition is complete, you can call the macro either as | |
5021 | @samp{reserve_str @var{a},@var{b}} (with @samp{\p1} evaluating to | |
5022 | @var{a} and @samp{\p2} evaluating to @var{b}), or as @samp{reserve_str | |
5023 | ,@var{b}} (with @samp{\p1} evaluating as the default, in this case | |
5024 | @samp{0}, and @samp{\p2} evaluating to @var{b}). | |
252b5132 | 5025 | |
6eaeac8a JB |
5026 | @item .macro m p1:req, p2=0, p3:vararg |
5027 | Begin the definition of a macro called @code{m}, with at least three | |
5028 | arguments. The first argument must always have a value specified, but | |
5029 | not the second, which instead has a default value. The third formal | |
5030 | will get assigned all remaining arguments specified at invocation time. | |
5031 | ||
252b5132 RH |
5032 | When you call a macro, you can specify the argument values either by |
5033 | position, or by keyword. For example, @samp{sum 9,17} is equivalent to | |
5034 | @samp{sum to=17, from=9}. | |
5035 | ||
6258339f NC |
5036 | @end table |
5037 | ||
5e75c3ab JB |
5038 | Note that since each of the @var{macargs} can be an identifier exactly |
5039 | as any other one permitted by the target architecture, there may be | |
5040 | occasional problems if the target hand-crafts special meanings to certain | |
6258339f | 5041 | characters when they occur in a special position. For example, if the colon |
5e75c3ab | 5042 | (@code{:}) is generally permitted to be part of a symbol name, but the |
6258339f | 5043 | architecture specific code special-cases it when occurring as the final |
5e75c3ab JB |
5044 | character of a symbol (to denote a label), then the macro parameter |
5045 | replacement code will have no way of knowing that and consider the whole | |
5046 | construct (including the colon) an identifier, and check only this | |
6258339f NC |
5047 | identifier for being the subject to parameter substitution. So for example |
5048 | this macro definition: | |
5049 | ||
5050 | @example | |
5051 | .macro label l | |
5052 | \l: | |
5053 | .endm | |
5054 | @end example | |
5055 | ||
5056 | might not work as expected. Invoking @samp{label foo} might not create a label | |
5057 | called @samp{foo} but instead just insert the text @samp{\l:} into the | |
5058 | assembler source, probably generating an error about an unrecognised | |
5059 | identifier. | |
5060 | ||
5061 | Similarly problems might occur with the period character (@samp{.}) | |
5062 | which is often allowed inside opcode names (and hence identifier names). So | |
5063 | for example constructing a macro to build an opcode from a base name and a | |
5064 | length specifier like this: | |
5065 | ||
5066 | @example | |
5067 | .macro opcode base length | |
5068 | \base.\length | |
5069 | .endm | |
5070 | @end example | |
5071 | ||
5072 | and invoking it as @samp{opcode store l} will not create a @samp{store.l} | |
5073 | instruction but instead generate some kind of error as the assembler tries to | |
5074 | interpret the text @samp{\base.\length}. | |
5075 | ||
5076 | There are several possible ways around this problem: | |
5077 | ||
5078 | @table @code | |
5079 | @item Insert white space | |
5080 | If it is possible to use white space characters then this is the simplest | |
5081 | solution. eg: | |
5082 | ||
5083 | @example | |
5084 | .macro label l | |
5085 | \l : | |
5086 | .endm | |
5087 | @end example | |
5088 | ||
5089 | @item Use @samp{\()} | |
5090 | The string @samp{\()} can be used to separate the end of a macro argument from | |
5091 | the following text. eg: | |
5092 | ||
5093 | @example | |
5094 | .macro opcode base length | |
5095 | \base\().\length | |
5096 | .endm | |
5097 | @end example | |
5098 | ||
5099 | @item Use the alternate macro syntax mode | |
5100 | In the alternative macro syntax mode the ampersand character (@samp{&}) can be | |
5101 | used as a separator. eg: | |
5e75c3ab JB |
5102 | |
5103 | @example | |
5104 | .altmacro | |
5105 | .macro label l | |
5106 | l&: | |
5107 | .endm | |
5108 | @end example | |
6258339f | 5109 | @end table |
5e75c3ab | 5110 | |
96e9638b BW |
5111 | Note: this problem of correctly identifying string parameters to pseudo ops |
5112 | also applies to the identifiers used in @code{.irp} (@pxref{Irp}) | |
5113 | and @code{.irpc} (@pxref{Irpc}) as well. | |
5e75c3ab | 5114 | |
252b5132 RH |
5115 | @item .endm |
5116 | @cindex @code{endm} directive | |
5117 | Mark the end of a macro definition. | |
5118 | ||
5119 | @item .exitm | |
5120 | @cindex @code{exitm} directive | |
5121 | Exit early from the current macro definition. | |
5122 | ||
5123 | @cindex number of macros executed | |
5124 | @cindex macros, count executed | |
5125 | @item \@@ | |
a4fb0134 | 5126 | @command{@value{AS}} maintains a counter of how many macros it has |
252b5132 RH |
5127 | executed in this pseudo-variable; you can copy that number to your |
5128 | output with @samp{\@@}, but @emph{only within a macro definition}. | |
5129 | ||
252b5132 RH |
5130 | @item LOCAL @var{name} [ , @dots{} ] |
5131 | @emph{Warning: @code{LOCAL} is only available if you select ``alternate | |
caa32fe5 NC |
5132 | macro syntax'' with @samp{--alternate} or @code{.altmacro}.} |
5133 | @xref{Altmacro,,@code{.altmacro}}. | |
5134 | @end ftable | |
252b5132 | 5135 | |
caa32fe5 NC |
5136 | @node Altmacro |
5137 | @section @code{.altmacro} | |
5138 | Enable alternate macro mode, enabling: | |
5139 | ||
5140 | @ftable @code | |
5141 | @item LOCAL @var{name} [ , @dots{} ] | |
5142 | One additional directive, @code{LOCAL}, is available. It is used to | |
5143 | generate a string replacement for each of the @var{name} arguments, and | |
252b5132 RH |
5144 | replace any instances of @var{name} in each macro expansion. The |
5145 | replacement string is unique in the assembly, and different for each | |
5146 | separate macro expansion. @code{LOCAL} allows you to write macros that | |
5147 | define symbols, without fear of conflict between separate macro expansions. | |
caa32fe5 NC |
5148 | |
5149 | @item String delimiters | |
5150 | You can write strings delimited in these other ways besides | |
5151 | @code{"@var{string}"}: | |
5152 | ||
5153 | @table @code | |
5154 | @item '@var{string}' | |
b45619c0 | 5155 | You can delimit strings with single-quote characters. |
caa32fe5 NC |
5156 | |
5157 | @item <@var{string}> | |
5158 | You can delimit strings with matching angle brackets. | |
5159 | @end table | |
5160 | ||
5161 | @item single-character string escape | |
5162 | To include any single character literally in a string (even if the | |
5163 | character would otherwise have some special meaning), you can prefix the | |
5164 | character with @samp{!} (an exclamation mark). For example, you can | |
5165 | write @samp{<4.3 !> 5.4!!>} to get the literal text @samp{4.3 > 5.4!}. | |
5166 | ||
5167 | @item Expression results as strings | |
5168 | You can write @samp{%@var{expr}} to evaluate the expression @var{expr} | |
5169 | and use the result as a string. | |
252b5132 RH |
5170 | @end ftable |
5171 | ||
caa32fe5 NC |
5172 | @node Noaltmacro |
5173 | @section @code{.noaltmacro} | |
96e9638b | 5174 | Disable alternate macro mode. @xref{Altmacro}. |
caa32fe5 | 5175 | |
252b5132 RH |
5176 | @node Nolist |
5177 | @section @code{.nolist} | |
5178 | ||
5179 | @cindex @code{nolist} directive | |
5180 | @cindex listing control, turning off | |
5181 | Control (in conjunction with the @code{.list} directive) whether or | |
5182 | not assembly listings are generated. These two directives maintain an | |
5183 | internal counter (which is zero initially). @code{.list} increments the | |
5184 | counter, and @code{.nolist} decrements it. Assembly listings are | |
5185 | generated whenever the counter is greater than zero. | |
5186 | ||
5187 | @node Octa | |
5188 | @section @code{.octa @var{bignums}} | |
5189 | ||
5190 | @c FIXME: double size emitted for "octa" on i960, others? Or warn? | |
5191 | @cindex @code{octa} directive | |
5192 | @cindex integer, 16-byte | |
5193 | @cindex sixteen byte integer | |
5194 | This directive expects zero or more bignums, separated by commas. For each | |
5195 | bignum, it emits a 16-byte integer. | |
5196 | ||
5197 | The term ``octa'' comes from contexts in which a ``word'' is two bytes; | |
5198 | hence @emph{octa}-word for 16 bytes. | |
5199 | ||
5200 | @node Org | |
5201 | @section @code{.org @var{new-lc} , @var{fill}} | |
5202 | ||
5203 | @cindex @code{org} directive | |
5204 | @cindex location counter, advancing | |
5205 | @cindex advancing location counter | |
5206 | @cindex current address, advancing | |
5207 | Advance the location counter of the current section to | |
5208 | @var{new-lc}. @var{new-lc} is either an absolute expression or an | |
5209 | expression with the same section as the current subsection. That is, | |
5210 | you can't use @code{.org} to cross sections: if @var{new-lc} has the | |
5211 | wrong section, the @code{.org} directive is ignored. To be compatible | |
5212 | with former assemblers, if the section of @var{new-lc} is absolute, | |
a4fb0134 | 5213 | @command{@value{AS}} issues a warning, then pretends the section of @var{new-lc} |
252b5132 RH |
5214 | is the same as the current subsection. |
5215 | ||
5216 | @code{.org} may only increase the location counter, or leave it | |
5217 | unchanged; you cannot use @code{.org} to move the location counter | |
5218 | backwards. | |
5219 | ||
5220 | @c double negative used below "not undefined" because this is a specific | |
5221 | @c reference to "undefined" (as SEG_UNKNOWN is called in this manual) | |
5222 | @c section. doc@cygnus.com 18feb91 | |
a4fb0134 | 5223 | Because @command{@value{AS}} tries to assemble programs in one pass, @var{new-lc} |
252b5132 RH |
5224 | may not be undefined. If you really detest this restriction we eagerly await |
5225 | a chance to share your improved assembler. | |
5226 | ||
5227 | Beware that the origin is relative to the start of the section, not | |
5228 | to the start of the subsection. This is compatible with other | |
5229 | people's assemblers. | |
5230 | ||
5231 | When the location counter (of the current subsection) is advanced, the | |
5232 | intervening bytes are filled with @var{fill} which should be an | |
5233 | absolute expression. If the comma and @var{fill} are omitted, | |
5234 | @var{fill} defaults to zero. | |
5235 | ||
5236 | @node P2align | |
5237 | @section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}} | |
5238 | ||
5239 | @cindex padding the location counter given a power of two | |
5240 | @cindex @code{p2align} directive | |
5241 | Pad the location counter (in the current subsection) to a particular | |
5242 | storage boundary. The first expression (which must be absolute) is the | |
5243 | number of low-order zero bits the location counter must have after | |
5244 | advancement. For example @samp{.p2align 3} advances the location | |
5245 | counter until it a multiple of 8. If the location counter is already a | |
5246 | multiple of 8, no change is needed. | |
5247 | ||
5248 | The second expression (also absolute) gives the fill value to be stored in the | |
5249 | padding bytes. It (and the comma) may be omitted. If it is omitted, the | |
5250 | padding bytes are normally zero. However, on some systems, if the section is | |
5251 | marked as containing code and the fill value is omitted, the space is filled | |
5252 | with no-op instructions. | |
5253 | ||
5254 | The third expression is also absolute, and is also optional. If it is present, | |
5255 | it is the maximum number of bytes that should be skipped by this alignment | |
5256 | directive. If doing the alignment would require skipping more bytes than the | |
5257 | specified maximum, then the alignment is not done at all. You can omit the | |
5258 | fill value (the second argument) entirely by simply using two commas after the | |
5259 | required alignment; this can be useful if you want the alignment to be filled | |
5260 | with no-op instructions when appropriate. | |
5261 | ||
5262 | @cindex @code{p2alignw} directive | |
5263 | @cindex @code{p2alignl} directive | |
5264 | The @code{.p2alignw} and @code{.p2alignl} directives are variants of the | |
5265 | @code{.p2align} directive. The @code{.p2alignw} directive treats the fill | |
5266 | pattern as a two byte word value. The @code{.p2alignl} directives treats the | |
5267 | fill pattern as a four byte longword value. For example, @code{.p2alignw | |
5268 | 2,0x368d} will align to a multiple of 4. If it skips two bytes, they will be | |
5269 | filled in with the value 0x368d (the exact placement of the bytes depends upon | |
5270 | the endianness of the processor). If it skips 1 or 3 bytes, the fill value is | |
5271 | undefined. | |
5272 | ||
c91d2e08 NC |
5273 | @ifset ELF |
5274 | @node Previous | |
5275 | @section @code{.previous} | |
5276 | ||
c1253627 | 5277 | @cindex @code{previous} directive |
c91d2e08 NC |
5278 | @cindex Section Stack |
5279 | This is one of the ELF section stack manipulation directives. The others are | |
a349d9dd PB |
5280 | @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}), |
5281 | @code{.pushsection} (@pxref{PushSection}), and @code{.popsection} | |
5282 | (@pxref{PopSection}). | |
c91d2e08 NC |
5283 | |
5284 | This directive swaps the current section (and subsection) with most recently | |
5285 | referenced section (and subsection) prior to this one. Multiple | |
5286 | @code{.previous} directives in a row will flip between two sections (and their | |
5287 | subsections). | |
5288 | ||
5289 | In terms of the section stack, this directive swaps the current section with | |
5290 | the top section on the section stack. | |
5291 | @end ifset | |
5292 | ||
5293 | @ifset ELF | |
5294 | @node PopSection | |
5295 | @section @code{.popsection} | |
5296 | ||
c1253627 | 5297 | @cindex @code{popsection} directive |
c91d2e08 NC |
5298 | @cindex Section Stack |
5299 | This is one of the ELF section stack manipulation directives. The others are | |
a349d9dd PB |
5300 | @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}), |
5301 | @code{.pushsection} (@pxref{PushSection}), and @code{.previous} | |
5302 | (@pxref{Previous}). | |
c91d2e08 NC |
5303 | |
5304 | This directive replaces the current section (and subsection) with the top | |
5305 | section (and subsection) on the section stack. This section is popped off the | |
5306 | stack. | |
c91d2e08 NC |
5307 | @end ifset |
5308 | ||
252b5132 RH |
5309 | @node Print |
5310 | @section @code{.print @var{string}} | |
5311 | ||
5312 | @cindex @code{print} directive | |
a4fb0134 | 5313 | @command{@value{AS}} will print @var{string} on the standard output during |
252b5132 RH |
5314 | assembly. You must put @var{string} in double quotes. |
5315 | ||
c91d2e08 NC |
5316 | @ifset ELF |
5317 | @node Protected | |
5318 | @section @code{.protected @var{names}} | |
5319 | ||
c1253627 NC |
5320 | @cindex @code{protected} directive |
5321 | @cindex visibility | |
ed9589d4 | 5322 | This is one of the ELF visibility directives. The other two are |
a349d9dd | 5323 | @code{.hidden} (@pxref{Hidden}) and @code{.internal} (@pxref{Internal}). |
c91d2e08 NC |
5324 | |
5325 | This directive overrides the named symbols default visibility (which is set by | |
5326 | their binding: local, global or weak). The directive sets the visibility to | |
5327 | @code{protected} which means that any references to the symbols from within the | |
5328 | components that defines them must be resolved to the definition in that | |
5329 | component, even if a definition in another component would normally preempt | |
5330 | this. | |
5331 | @end ifset | |
5332 | ||
252b5132 RH |
5333 | @node Psize |
5334 | @section @code{.psize @var{lines} , @var{columns}} | |
5335 | ||
5336 | @cindex @code{psize} directive | |
5337 | @cindex listing control: paper size | |
5338 | @cindex paper size, for listings | |
5339 | Use this directive to declare the number of lines---and, optionally, the | |
5340 | number of columns---to use for each page, when generating listings. | |
5341 | ||
5342 | If you do not use @code{.psize}, listings use a default line-count | |
5343 | of 60. You may omit the comma and @var{columns} specification; the | |
5344 | default width is 200 columns. | |
5345 | ||
a4fb0134 | 5346 | @command{@value{AS}} generates formfeeds whenever the specified number of |
252b5132 RH |
5347 | lines is exceeded (or whenever you explicitly request one, using |
5348 | @code{.eject}). | |
5349 | ||
5350 | If you specify @var{lines} as @code{0}, no formfeeds are generated save | |
5351 | those explicitly specified with @code{.eject}. | |
5352 | ||
5353 | @node Purgem | |
5354 | @section @code{.purgem @var{name}} | |
5355 | ||
5356 | @cindex @code{purgem} directive | |
5357 | Undefine the macro @var{name}, so that later uses of the string will not be | |
5358 | expanded. @xref{Macro}. | |
5359 | ||
c91d2e08 NC |
5360 | @ifset ELF |
5361 | @node PushSection | |
5362 | @section @code{.pushsection @var{name} , @var{subsection}} | |
5363 | ||
c1253627 | 5364 | @cindex @code{pushsection} directive |
c91d2e08 NC |
5365 | @cindex Section Stack |
5366 | This is one of the ELF section stack manipulation directives. The others are | |
a349d9dd PB |
5367 | @code{.section} (@pxref{Section}), @code{.subsection} (@pxref{SubSection}), |
5368 | @code{.popsection} (@pxref{PopSection}), and @code{.previous} | |
5369 | (@pxref{Previous}). | |
c91d2e08 | 5370 | |
e9863d7f DJ |
5371 | This directive pushes the current section (and subsection) onto the |
5372 | top of the section stack, and then replaces the current section and | |
5373 | subsection with @code{name} and @code{subsection}. | |
c91d2e08 NC |
5374 | @end ifset |
5375 | ||
252b5132 RH |
5376 | @node Quad |
5377 | @section @code{.quad @var{bignums}} | |
5378 | ||
5379 | @cindex @code{quad} directive | |
5380 | @code{.quad} expects zero or more bignums, separated by commas. For | |
5381 | each bignum, it emits | |
5382 | @ifclear bignum-16 | |
5383 | an 8-byte integer. If the bignum won't fit in 8 bytes, it prints a | |
5384 | warning message; and just takes the lowest order 8 bytes of the bignum. | |
5385 | @cindex eight-byte integer | |
5386 | @cindex integer, 8-byte | |
5387 | ||
5388 | The term ``quad'' comes from contexts in which a ``word'' is two bytes; | |
5389 | hence @emph{quad}-word for 8 bytes. | |
5390 | @end ifclear | |
5391 | @ifset bignum-16 | |
5392 | a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a | |
5393 | warning message; and just takes the lowest order 16 bytes of the bignum. | |
5394 | @cindex sixteen-byte integer | |
5395 | @cindex integer, 16-byte | |
5396 | @end ifset | |
5397 | ||
5398 | @node Rept | |
5399 | @section @code{.rept @var{count}} | |
5400 | ||
5401 | @cindex @code{rept} directive | |
5402 | Repeat the sequence of lines between the @code{.rept} directive and the next | |
5403 | @code{.endr} directive @var{count} times. | |
5404 | ||
5405 | For example, assembling | |
5406 | ||
5407 | @example | |
5408 | .rept 3 | |
5409 | .long 0 | |
5410 | .endr | |
5411 | @end example | |
5412 | ||
5413 | is equivalent to assembling | |
5414 | ||
5415 | @example | |
5416 | .long 0 | |
5417 | .long 0 | |
5418 | .long 0 | |
5419 | @end example | |
5420 | ||
5421 | @node Sbttl | |
5422 | @section @code{.sbttl "@var{subheading}"} | |
5423 | ||
5424 | @cindex @code{sbttl} directive | |
5425 | @cindex subtitles for listings | |
5426 | @cindex listing control: subtitle | |
5427 | Use @var{subheading} as the title (third line, immediately after the | |
5428 | title line) when generating assembly listings. | |
5429 | ||
5430 | This directive affects subsequent pages, as well as the current page if | |
5431 | it appears within ten lines of the top of a page. | |
5432 | ||
5433 | @ifset COFF | |
5434 | @node Scl | |
5435 | @section @code{.scl @var{class}} | |
5436 | ||
5437 | @cindex @code{scl} directive | |
5438 | @cindex symbol storage class (COFF) | |
5439 | @cindex COFF symbol storage class | |
5440 | Set the storage-class value for a symbol. This directive may only be | |
5441 | used inside a @code{.def}/@code{.endef} pair. Storage class may flag | |
5442 | whether a symbol is static or external, or it may record further | |
5443 | symbolic debugging information. | |
5444 | @ifset BOUT | |
5445 | ||
5446 | The @samp{.scl} directive is primarily associated with COFF output; when | |
a4fb0134 | 5447 | configured to generate @code{b.out} output format, @command{@value{AS}} |
252b5132 RH |
5448 | accepts this directive but ignores it. |
5449 | @end ifset | |
5450 | @end ifset | |
5451 | ||
c1253627 | 5452 | @ifset COFF-ELF |
252b5132 | 5453 | @node Section |
c1253627 | 5454 | @section @code{.section @var{name}} |
252b5132 | 5455 | |
252b5132 RH |
5456 | @cindex named section |
5457 | Use the @code{.section} directive to assemble the following code into a section | |
5458 | named @var{name}. | |
5459 | ||
5460 | This directive is only supported for targets that actually support arbitrarily | |
5461 | named sections; on @code{a.out} targets, for example, it is not accepted, even | |
5462 | with a standard @code{a.out} section name. | |
5463 | ||
c1253627 NC |
5464 | @ifset COFF |
5465 | @ifset ELF | |
5466 | @c only print the extra heading if both COFF and ELF are set | |
5467 | @subheading COFF Version | |
5468 | @end ifset | |
5469 | ||
5470 | @cindex @code{section} directive (COFF version) | |
252b5132 RH |
5471 | For COFF targets, the @code{.section} directive is used in one of the following |
5472 | ways: | |
c91d2e08 | 5473 | |
252b5132 RH |
5474 | @smallexample |
5475 | .section @var{name}[, "@var{flags}"] | |
5476 | .section @var{name}[, @var{subsegment}] | |
5477 | @end smallexample | |
5478 | ||
5479 | If the optional argument is quoted, it is taken as flags to use for the | |
5480 | section. Each flag is a single character. The following flags are recognized: | |
5481 | @table @code | |
5482 | @item b | |
5483 | bss section (uninitialized data) | |
5484 | @item n | |
5485 | section is not loaded | |
5486 | @item w | |
5487 | writable section | |
5488 | @item d | |
5489 | data section | |
5490 | @item r | |
5491 | read-only section | |
5492 | @item x | |
5493 | executable section | |
2dcc60be ILT |
5494 | @item s |
5495 | shared section (meaningful for PE targets) | |
6ff96af6 NC |
5496 | @item a |
5497 | ignored. (For compatibility with the ELF version) | |
252b5132 RH |
5498 | @end table |
5499 | ||
5500 | If no flags are specified, the default flags depend upon the section name. If | |
5501 | the section name is not recognized, the default will be for the section to be | |
7e84d676 NC |
5502 | loaded and writable. Note the @code{n} and @code{w} flags remove attributes |
5503 | from the section, rather than adding them, so if they are used on their own it | |
5504 | will be as if no flags had been specified at all. | |
252b5132 RH |
5505 | |
5506 | If the optional argument to the @code{.section} directive is not quoted, it is | |
5507 | taken as a subsegment number (@pxref{Sub-Sections}). | |
c1253627 | 5508 | @end ifset |
252b5132 RH |
5509 | |
5510 | @ifset ELF | |
c1253627 NC |
5511 | @ifset COFF |
5512 | @c only print the extra heading if both COFF and ELF are set | |
5513 | @subheading ELF Version | |
5514 | @end ifset | |
5515 | ||
c91d2e08 NC |
5516 | @cindex Section Stack |
5517 | This is one of the ELF section stack manipulation directives. The others are | |
a349d9dd PB |
5518 | @code{.subsection} (@pxref{SubSection}), @code{.pushsection} |
5519 | (@pxref{PushSection}), @code{.popsection} (@pxref{PopSection}), and | |
5520 | @code{.previous} (@pxref{Previous}). | |
c91d2e08 | 5521 | |
c1253627 | 5522 | @cindex @code{section} directive (ELF version) |
252b5132 | 5523 | For ELF targets, the @code{.section} directive is used like this: |
c91d2e08 | 5524 | |
252b5132 | 5525 | @smallexample |
7047dd1e | 5526 | .section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]] |
252b5132 | 5527 | @end smallexample |
c91d2e08 | 5528 | |
252b5132 | 5529 | The optional @var{flags} argument is a quoted string which may contain any |
a349d9dd | 5530 | combination of the following characters: |
252b5132 RH |
5531 | @table @code |
5532 | @item a | |
5533 | section is allocatable | |
5534 | @item w | |
5535 | section is writable | |
5536 | @item x | |
5537 | section is executable | |
ec38dd05 JJ |
5538 | @item M |
5539 | section is mergeable | |
5540 | @item S | |
5541 | section contains zero terminated strings | |
22fe14ad NC |
5542 | @item G |
5543 | section is a member of a section group | |
5544 | @item T | |
5545 | section is used for thread-local-storage | |
252b5132 RH |
5546 | @end table |
5547 | ||
5548 | The optional @var{type} argument may contain one of the following constants: | |
5549 | @table @code | |
5550 | @item @@progbits | |
5551 | section contains data | |
5552 | @item @@nobits | |
5553 | section does not contain data (i.e., section only occupies space) | |
22fe14ad NC |
5554 | @item @@note |
5555 | section contains data which is used by things other than the program | |
10b016c2 PB |
5556 | @item @@init_array |
5557 | section contains an array of pointers to init functions | |
5558 | @item @@fini_array | |
5559 | section contains an array of pointers to finish functions | |
5560 | @item @@preinit_array | |
5561 | section contains an array of pointers to pre-init functions | |
252b5132 RH |
5562 | @end table |
5563 | ||
10b016c2 PB |
5564 | Many targets only support the first three section types. |
5565 | ||
ececec60 NC |
5566 | Note on targets where the @code{@@} character is the start of a comment (eg |
5567 | ARM) then another character is used instead. For example the ARM port uses the | |
5568 | @code{%} character. | |
5569 | ||
22fe14ad | 5570 | If @var{flags} contains the @code{M} symbol then the @var{type} argument must |
96e9638b | 5571 | be specified as well as an extra argument---@var{entsize}---like this: |
22fe14ad NC |
5572 | |
5573 | @smallexample | |
5574 | .section @var{name} , "@var{flags}"M, @@@var{type}, @var{entsize} | |
5575 | @end smallexample | |
5576 | ||
5577 | Sections with the @code{M} flag but not @code{S} flag must contain fixed size | |
5578 | constants, each @var{entsize} octets long. Sections with both @code{M} and | |
5579 | @code{S} must contain zero terminated strings where each character is | |
5580 | @var{entsize} bytes long. The linker may remove duplicates within sections with | |
5581 | the same name, same entity size and same flags. @var{entsize} must be an | |
5582 | absolute expression. | |
5583 | ||
5584 | If @var{flags} contains the @code{G} symbol then the @var{type} argument must | |
5585 | be present along with an additional field like this: | |
5586 | ||
5587 | @smallexample | |
5588 | .section @var{name} , "@var{flags}"G, @@@var{type}, @var{GroupName}[, @var{linkage}] | |
5589 | @end smallexample | |
5590 | ||
5591 | The @var{GroupName} field specifies the name of the section group to which this | |
5592 | particular section belongs. The optional linkage field can contain: | |
5593 | @table @code | |
5594 | @item comdat | |
5595 | indicates that only one copy of this section should be retained | |
5596 | @item .gnu.linkonce | |
5597 | an alias for comdat | |
5598 | @end table | |
5599 | ||
96e9638b | 5600 | Note: if both the @var{M} and @var{G} flags are present then the fields for |
22fe14ad NC |
5601 | the Merge flag should come first, like this: |
5602 | ||
5603 | @smallexample | |
5604 | .section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}] | |
5605 | @end smallexample | |
ec38dd05 | 5606 | |
252b5132 RH |
5607 | If no flags are specified, the default flags depend upon the section name. If |
5608 | the section name is not recognized, the default will be for the section to have | |
5609 | none of the above flags: it will not be allocated in memory, nor writable, nor | |
5610 | executable. The section will contain data. | |
5611 | ||
5612 | For ELF targets, the assembler supports another type of @code{.section} | |
5613 | directive for compatibility with the Solaris assembler: | |
c91d2e08 | 5614 | |
252b5132 RH |
5615 | @smallexample |
5616 | .section "@var{name}"[, @var{flags}...] | |
5617 | @end smallexample | |
c91d2e08 | 5618 | |
252b5132 RH |
5619 | Note that the section name is quoted. There may be a sequence of comma |
5620 | separated flags: | |
5621 | @table @code | |
5622 | @item #alloc | |
5623 | section is allocatable | |
5624 | @item #write | |
5625 | section is writable | |
5626 | @item #execinstr | |
5627 | section is executable | |
22fe14ad NC |
5628 | @item #tls |
5629 | section is used for thread local storage | |
252b5132 | 5630 | @end table |
c91d2e08 | 5631 | |
e9863d7f DJ |
5632 | This directive replaces the current section and subsection. See the |
5633 | contents of the gas testsuite directory @code{gas/testsuite/gas/elf} for | |
5634 | some examples of how this directive and the other section stack directives | |
5635 | work. | |
c1253627 NC |
5636 | @end ifset |
5637 | @end ifset | |
252b5132 RH |
5638 | |
5639 | @node Set | |
5640 | @section @code{.set @var{symbol}, @var{expression}} | |
5641 | ||
5642 | @cindex @code{set} directive | |
5643 | @cindex symbol value, setting | |
5644 | Set the value of @var{symbol} to @var{expression}. This | |
5645 | changes @var{symbol}'s value and type to conform to | |
5646 | @var{expression}. If @var{symbol} was flagged as external, it remains | |
5647 | flagged (@pxref{Symbol Attributes}). | |
5648 | ||
5649 | You may @code{.set} a symbol many times in the same assembly. | |
5650 | ||
5651 | If you @code{.set} a global symbol, the value stored in the object | |
5652 | file is the last value stored into it. | |
5653 | ||
5654 | @ifset HPPA | |
5655 | The syntax for @code{set} on the HPPA is | |
5656 | @samp{@var{symbol} .set @var{expression}}. | |
5657 | @end ifset | |
5658 | ||
3c9b82ba NC |
5659 | @ifset Z80 |
5660 | On Z80 @code{set} is a real instruction, use | |
5661 | @samp{@var{symbol} defl @var{expression}} instead. | |
5662 | @end ifset | |
5663 | ||
252b5132 RH |
5664 | @node Short |
5665 | @section @code{.short @var{expressions}} | |
5666 | ||
5667 | @cindex @code{short} directive | |
5668 | @ifset GENERIC | |
5669 | @code{.short} is normally the same as @samp{.word}. | |
5670 | @xref{Word,,@code{.word}}. | |
5671 | ||
5672 | In some configurations, however, @code{.short} and @code{.word} generate | |
96e9638b | 5673 | numbers of different lengths. @xref{Machine Dependencies}. |
252b5132 RH |
5674 | @end ifset |
5675 | @ifclear GENERIC | |
5676 | @ifset W16 | |
5677 | @code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}. | |
5678 | @end ifset | |
5679 | @ifset W32 | |
5680 | This expects zero or more @var{expressions}, and emits | |
5681 | a 16 bit number for each. | |
5682 | @end ifset | |
5683 | @end ifclear | |
5684 | ||
5685 | @node Single | |
5686 | @section @code{.single @var{flonums}} | |
5687 | ||
5688 | @cindex @code{single} directive | |
5689 | @cindex floating point numbers (single) | |
5690 | This directive assembles zero or more flonums, separated by commas. It | |
5691 | has the same effect as @code{.float}. | |
5692 | @ifset GENERIC | |
5693 | The exact kind of floating point numbers emitted depends on how | |
a4fb0134 | 5694 | @command{@value{AS}} is configured. @xref{Machine Dependencies}. |
252b5132 RH |
5695 | @end ifset |
5696 | @ifclear GENERIC | |
5697 | @ifset IEEEFLOAT | |
5698 | On the @value{TARGET} family, @code{.single} emits 32-bit floating point | |
5699 | numbers in @sc{ieee} format. | |
5700 | @end ifset | |
5701 | @end ifclear | |
5702 | ||
c1253627 | 5703 | @ifset COFF-ELF |
252b5132 | 5704 | @node Size |
c1253627 | 5705 | @section @code{.size} |
c91d2e08 | 5706 | |
c1253627 NC |
5707 | This directive is used to set the size associated with a symbol. |
5708 | ||
5709 | @ifset COFF | |
5710 | @ifset ELF | |
5711 | @c only print the extra heading if both COFF and ELF are set | |
5712 | @subheading COFF Version | |
5713 | @end ifset | |
5714 | ||
5715 | @cindex @code{size} directive (COFF version) | |
5716 | For COFF targets, the @code{.size} directive is only permitted inside | |
5717 | @code{.def}/@code{.endef} pairs. It is used like this: | |
5718 | ||
5719 | @smallexample | |
5720 | .size @var{expression} | |
5721 | @end smallexample | |
252b5132 | 5722 | |
c91d2e08 | 5723 | @ifset BOUT |
252b5132 | 5724 | @samp{.size} is only meaningful when generating COFF format output; when |
a4fb0134 | 5725 | @command{@value{AS}} is generating @code{b.out}, it accepts this directive but |
252b5132 RH |
5726 | ignores it. |
5727 | @end ifset | |
c1253627 | 5728 | @end ifset |
c91d2e08 | 5729 | |
c1253627 NC |
5730 | @ifset ELF |
5731 | @ifset COFF | |
5732 | @c only print the extra heading if both COFF and ELF are set | |
5733 | @subheading ELF Version | |
5734 | @end ifset | |
5735 | ||
5736 | @cindex @code{size} directive (ELF version) | |
5737 | For ELF targets, the @code{.size} directive is used like this: | |
c91d2e08 | 5738 | |
c1253627 NC |
5739 | @smallexample |
5740 | .size @var{name} , @var{expression} | |
5741 | @end smallexample | |
5742 | ||
5743 | This directive sets the size associated with a symbol @var{name}. | |
c91d2e08 NC |
5744 | The size in bytes is computed from @var{expression} which can make use of label |
5745 | arithmetic. This directive is typically used to set the size of function | |
5746 | symbols. | |
c1253627 NC |
5747 | @end ifset |
5748 | @end ifset | |
252b5132 RH |
5749 | |
5750 | @node Sleb128 | |
5751 | @section @code{.sleb128 @var{expressions}} | |
5752 | ||
5753 | @cindex @code{sleb128} directive | |
5754 | @var{sleb128} stands for ``signed little endian base 128.'' This is a | |
5755 | compact, variable length representation of numbers used by the DWARF | |
96e9638b | 5756 | symbolic debugging format. @xref{Uleb128, ,@code{.uleb128}}. |
252b5132 RH |
5757 | |
5758 | @ifclear no-space-dir | |
5759 | @node Skip | |
5760 | @section @code{.skip @var{size} , @var{fill}} | |
5761 | ||
5762 | @cindex @code{skip} directive | |
5763 | @cindex filling memory | |
5764 | This directive emits @var{size} bytes, each of value @var{fill}. Both | |
5765 | @var{size} and @var{fill} are absolute expressions. If the comma and | |
5766 | @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same as | |
5767 | @samp{.space}. | |
5768 | ||
5769 | @node Space | |
5770 | @section @code{.space @var{size} , @var{fill}} | |
5771 | ||
5772 | @cindex @code{space} directive | |
5773 | @cindex filling memory | |
5774 | This directive emits @var{size} bytes, each of value @var{fill}. Both | |
5775 | @var{size} and @var{fill} are absolute expressions. If the comma | |
5776 | and @var{fill} are omitted, @var{fill} is assumed to be zero. This is the same | |
5777 | as @samp{.skip}. | |
5778 | ||
5779 | @ifset HPPA | |
5780 | @quotation | |
5781 | @emph{Warning:} @code{.space} has a completely different meaning for HPPA | |
5782 | targets; use @code{.block} as a substitute. See @cite{HP9000 Series 800 | |
5783 | Assembly Language Reference Manual} (HP 92432-90001) for the meaning of the | |
5784 | @code{.space} directive. @xref{HPPA Directives,,HPPA Assembler Directives}, | |
5785 | for a summary. | |
5786 | @end quotation | |
5787 | @end ifset | |
5788 | @end ifclear | |
5789 | ||
252b5132 RH |
5790 | @ifset have-stabs |
5791 | @node Stab | |
5792 | @section @code{.stabd, .stabn, .stabs} | |
5793 | ||
5794 | @cindex symbolic debuggers, information for | |
5795 | @cindex @code{stab@var{x}} directives | |
5796 | There are three directives that begin @samp{.stab}. | |
5797 | All emit symbols (@pxref{Symbols}), for use by symbolic debuggers. | |
a4fb0134 | 5798 | The symbols are not entered in the @command{@value{AS}} hash table: they |
252b5132 RH |
5799 | cannot be referenced elsewhere in the source file. |
5800 | Up to five fields are required: | |
5801 | ||
5802 | @table @var | |
5803 | @item string | |
5804 | This is the symbol's name. It may contain any character except | |
5805 | @samp{\000}, so is more general than ordinary symbol names. Some | |
5806 | debuggers used to code arbitrarily complex structures into symbol names | |
5807 | using this field. | |
5808 | ||
5809 | @item type | |
5810 | An absolute expression. The symbol's type is set to the low 8 bits of | |
5811 | this expression. Any bit pattern is permitted, but @code{@value{LD}} | |
5812 | and debuggers choke on silly bit patterns. | |
5813 | ||
5814 | @item other | |
5815 | An absolute expression. The symbol's ``other'' attribute is set to the | |
5816 | low 8 bits of this expression. | |
5817 | ||
5818 | @item desc | |
5819 | An absolute expression. The symbol's descriptor is set to the low 16 | |
5820 | bits of this expression. | |
5821 | ||
5822 | @item value | |
5823 | An absolute expression which becomes the symbol's value. | |
5824 | @end table | |
5825 | ||
5826 | If a warning is detected while reading a @code{.stabd}, @code{.stabn}, | |
5827 | or @code{.stabs} statement, the symbol has probably already been created; | |
5828 | you get a half-formed symbol in your object file. This is | |
5829 | compatible with earlier assemblers! | |
5830 | ||
5831 | @table @code | |
5832 | @cindex @code{stabd} directive | |
5833 | @item .stabd @var{type} , @var{other} , @var{desc} | |
5834 | ||
5835 | The ``name'' of the symbol generated is not even an empty string. | |
5836 | It is a null pointer, for compatibility. Older assemblers used a | |
5837 | null pointer so they didn't waste space in object files with empty | |
5838 | strings. | |
5839 | ||
5840 | The symbol's value is set to the location counter, | |
5841 | relocatably. When your program is linked, the value of this symbol | |
5842 | is the address of the location counter when the @code{.stabd} was | |
5843 | assembled. | |
5844 | ||
5845 | @cindex @code{stabn} directive | |
5846 | @item .stabn @var{type} , @var{other} , @var{desc} , @var{value} | |
5847 | The name of the symbol is set to the empty string @code{""}. | |
5848 | ||
5849 | @cindex @code{stabs} directive | |
5850 | @item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value} | |
5851 | All five fields are specified. | |
5852 | @end table | |
5853 | @end ifset | |
5854 | @c end have-stabs | |
5855 | ||
5856 | @node String | |
5857 | @section @code{.string} "@var{str}" | |
5858 | ||
5859 | @cindex string, copying to object file | |
5860 | @cindex @code{string} directive | |
5861 | ||
5862 | Copy the characters in @var{str} to the object file. You may specify more than | |
5863 | one string to copy, separated by commas. Unless otherwise specified for a | |
5864 | particular machine, the assembler marks the end of each string with a 0 byte. | |
5865 | You can use any of the escape sequences described in @ref{Strings,,Strings}. | |
5866 | ||
5867 | @node Struct | |
5868 | @section @code{.struct @var{expression}} | |
5869 | ||
5870 | @cindex @code{struct} directive | |
5871 | Switch to the absolute section, and set the section offset to @var{expression}, | |
5872 | which must be an absolute expression. You might use this as follows: | |
5873 | @smallexample | |
5874 | .struct 0 | |
5875 | field1: | |
5876 | .struct field1 + 4 | |
5877 | field2: | |
5878 | .struct field2 + 4 | |
5879 | field3: | |
5880 | @end smallexample | |
5881 | This would define the symbol @code{field1} to have the value 0, the symbol | |
5882 | @code{field2} to have the value 4, and the symbol @code{field3} to have the | |
5883 | value 8. Assembly would be left in the absolute section, and you would need to | |
5884 | use a @code{.section} directive of some sort to change to some other section | |
5885 | before further assembly. | |
5886 | ||
c91d2e08 NC |
5887 | @ifset ELF |
5888 | @node SubSection | |
5889 | @section @code{.subsection @var{name}} | |
5890 | ||
c1253627 | 5891 | @cindex @code{subsection} directive |
c91d2e08 NC |
5892 | @cindex Section Stack |
5893 | This is one of the ELF section stack manipulation directives. The others are | |
a349d9dd PB |
5894 | @code{.section} (@pxref{Section}), @code{.pushsection} (@pxref{PushSection}), |
5895 | @code{.popsection} (@pxref{PopSection}), and @code{.previous} | |
5896 | (@pxref{Previous}). | |
c91d2e08 NC |
5897 | |
5898 | This directive replaces the current subsection with @code{name}. The current | |
5899 | section is not changed. The replaced subsection is put onto the section stack | |
5900 | in place of the then current top of stack subsection. | |
c91d2e08 NC |
5901 | @end ifset |
5902 | ||
252b5132 RH |
5903 | @ifset ELF |
5904 | @node Symver | |
5905 | @section @code{.symver} | |
5906 | @cindex @code{symver} directive | |
5907 | @cindex symbol versioning | |
5908 | @cindex versions of symbols | |
5909 | Use the @code{.symver} directive to bind symbols to specific version nodes | |
5910 | within a source file. This is only supported on ELF platforms, and is | |
5911 | typically used when assembling files to be linked into a shared library. | |
5912 | There are cases where it may make sense to use this in objects to be bound | |
5913 | into an application itself so as to override a versioned symbol from a | |
5914 | shared library. | |
5915 | ||
79082ff0 | 5916 | For ELF targets, the @code{.symver} directive can be used like this: |
252b5132 RH |
5917 | @smallexample |
5918 | .symver @var{name}, @var{name2@@nodename} | |
5919 | @end smallexample | |
339681c0 | 5920 | If the symbol @var{name} is defined within the file |
79082ff0 | 5921 | being assembled, the @code{.symver} directive effectively creates a symbol |
252b5132 RH |
5922 | alias with the name @var{name2@@nodename}, and in fact the main reason that we |
5923 | just don't try and create a regular alias is that the @var{@@} character isn't | |
5924 | permitted in symbol names. The @var{name2} part of the name is the actual name | |
5925 | of the symbol by which it will be externally referenced. The name @var{name} | |
5926 | itself is merely a name of convenience that is used so that it is possible to | |
5927 | have definitions for multiple versions of a function within a single source | |
5928 | file, and so that the compiler can unambiguously know which version of a | |
5929 | function is being mentioned. The @var{nodename} portion of the alias should be | |
5930 | the name of a node specified in the version script supplied to the linker when | |
5931 | building a shared library. If you are attempting to override a versioned | |
5932 | symbol from a shared library, then @var{nodename} should correspond to the | |
5933 | nodename of the symbol you are trying to override. | |
339681c0 L |
5934 | |
5935 | If the symbol @var{name} is not defined within the file being assembled, all | |
5936 | references to @var{name} will be changed to @var{name2@@nodename}. If no | |
5937 | reference to @var{name} is made, @var{name2@@nodename} will be removed from the | |
5938 | symbol table. | |
79082ff0 L |
5939 | |
5940 | Another usage of the @code{.symver} directive is: | |
5941 | @smallexample | |
5942 | .symver @var{name}, @var{name2@@@@nodename} | |
5943 | @end smallexample | |
5944 | In this case, the symbol @var{name} must exist and be defined within | |
a349d9dd | 5945 | the file being assembled. It is similar to @var{name2@@nodename}. The |
79082ff0 L |
5946 | difference is @var{name2@@@@nodename} will also be used to resolve |
5947 | references to @var{name2} by the linker. | |
5948 | ||
5949 | The third usage of the @code{.symver} directive is: | |
5950 | @smallexample | |
5951 | .symver @var{name}, @var{name2@@@@@@nodename} | |
5952 | @end smallexample | |
5953 | When @var{name} is not defined within the | |
5954 | file being assembled, it is treated as @var{name2@@nodename}. When | |
5955 | @var{name} is defined within the file being assembled, the symbol | |
5956 | name, @var{name}, will be changed to @var{name2@@@@nodename}. | |
252b5132 RH |
5957 | @end ifset |
5958 | ||
5959 | @ifset COFF | |
5960 | @node Tag | |
5961 | @section @code{.tag @var{structname}} | |
5962 | ||
5963 | @cindex COFF structure debugging | |
5964 | @cindex structure debugging, COFF | |
5965 | @cindex @code{tag} directive | |
5966 | This directive is generated by compilers to include auxiliary debugging | |
5967 | information in the symbol table. It is only permitted inside | |
5968 | @code{.def}/@code{.endef} pairs. Tags are used to link structure | |
5969 | definitions in the symbol table with instances of those structures. | |
5970 | @ifset BOUT | |
5971 | ||
5972 | @samp{.tag} is only used when generating COFF format output; when | |
a4fb0134 | 5973 | @command{@value{AS}} is generating @code{b.out}, it accepts this directive but |
252b5132 RH |
5974 | ignores it. |
5975 | @end ifset | |
5976 | @end ifset | |
5977 | ||
5978 | @node Text | |
5979 | @section @code{.text @var{subsection}} | |
5980 | ||
5981 | @cindex @code{text} directive | |
a4fb0134 | 5982 | Tells @command{@value{AS}} to assemble the following statements onto the end of |
252b5132 RH |
5983 | the text subsection numbered @var{subsection}, which is an absolute |
5984 | expression. If @var{subsection} is omitted, subsection number zero | |
5985 | is used. | |
5986 | ||
5987 | @node Title | |
5988 | @section @code{.title "@var{heading}"} | |
5989 | ||
5990 | @cindex @code{title} directive | |
5991 | @cindex listing control: title line | |
5992 | Use @var{heading} as the title (second line, immediately after the | |
5993 | source file name and pagenumber) when generating assembly listings. | |
5994 | ||
5995 | This directive affects subsequent pages, as well as the current page if | |
5996 | it appears within ten lines of the top of a page. | |
5997 | ||
c1253627 | 5998 | @ifset COFF-ELF |
252b5132 | 5999 | @node Type |
c1253627 NC |
6000 | @section @code{.type} |
6001 | ||
6002 | This directive is used to set the type of a symbol. | |
6003 | ||
6004 | @ifset COFF | |
6005 | @ifset ELF | |
6006 | @c only print the extra heading if both COFF and ELF are set | |
6007 | @subheading COFF Version | |
6008 | @end ifset | |
252b5132 RH |
6009 | |
6010 | @cindex COFF symbol type | |
6011 | @cindex symbol type, COFF | |
c1253627 NC |
6012 | @cindex @code{type} directive (COFF version) |
6013 | For COFF targets, this directive is permitted only within | |
6014 | @code{.def}/@code{.endef} pairs. It is used like this: | |
6015 | ||
6016 | @smallexample | |
6017 | .type @var{int} | |
6018 | @end smallexample | |
6019 | ||
6020 | This records the integer @var{int} as the type attribute of a symbol table | |
6021 | entry. | |
252b5132 | 6022 | |
c91d2e08 | 6023 | @ifset BOUT |
252b5132 | 6024 | @samp{.type} is associated only with COFF format output; when |
a4fb0134 | 6025 | @command{@value{AS}} is configured for @code{b.out} output, it accepts this |
252b5132 RH |
6026 | directive but ignores it. |
6027 | @end ifset | |
c1253627 | 6028 | @end ifset |
c91d2e08 | 6029 | |
c1253627 NC |
6030 | @ifset ELF |
6031 | @ifset COFF | |
6032 | @c only print the extra heading if both COFF and ELF are set | |
6033 | @subheading ELF Version | |
6034 | @end ifset | |
c91d2e08 NC |
6035 | |
6036 | @cindex ELF symbol type | |
6037 | @cindex symbol type, ELF | |
c1253627 NC |
6038 | @cindex @code{type} directive (ELF version) |
6039 | For ELF targets, the @code{.type} directive is used like this: | |
6040 | ||
6041 | @smallexample | |
6042 | .type @var{name} , @var{type description} | |
6043 | @end smallexample | |
6044 | ||
6045 | This sets the type of symbol @var{name} to be either a | |
a349d9dd | 6046 | function symbol or an object symbol. There are five different syntaxes |
c91d2e08 | 6047 | supported for the @var{type description} field, in order to provide |
28c9d252 | 6048 | compatibility with various other assemblers. |
58ab4f3d MM |
6049 | |
6050 | Because some of the characters used in these syntaxes (such as @samp{@@} and | |
6051 | @samp{#}) are comment characters for some architectures, some of the syntaxes | |
6052 | below do not work on all architectures. The first variant will be accepted by | |
6053 | the GNU assembler on all architectures so that variant should be used for | |
6054 | maximum portability, if you do not need to assemble your code with other | |
6055 | assemblers. | |
6056 | ||
6057 | The syntaxes supported are: | |
c91d2e08 NC |
6058 | |
6059 | @smallexample | |
58ab4f3d MM |
6060 | .type <name> STT_FUNCTION |
6061 | .type <name> STT_OBJECT | |
6062 | ||
c91d2e08 NC |
6063 | .type <name>,#function |
6064 | .type <name>,#object | |
6065 | ||
6066 | .type <name>,@@function | |
6067 | .type <name>,@@object | |
6068 | ||
6069 | .type <name>,%function | |
6070 | .type <name>,%object | |
6071 | ||
6072 | .type <name>,"function" | |
6073 | .type <name>,"object" | |
c91d2e08 | 6074 | @end smallexample |
c1253627 NC |
6075 | @end ifset |
6076 | @end ifset | |
c91d2e08 NC |
6077 | |
6078 | @node Uleb128 | |
6079 | @section @code{.uleb128 @var{expressions}} | |
6080 | ||
6081 | @cindex @code{uleb128} directive | |
6082 | @var{uleb128} stands for ``unsigned little endian base 128.'' This is a | |
6083 | compact, variable length representation of numbers used by the DWARF | |
96e9638b | 6084 | symbolic debugging format. @xref{Sleb128, ,@code{.sleb128}}. |
252b5132 RH |
6085 | |
6086 | @ifset COFF | |
6087 | @node Val | |
6088 | @section @code{.val @var{addr}} | |
6089 | ||
6090 | @cindex @code{val} directive | |
6091 | @cindex COFF value attribute | |
6092 | @cindex value attribute, COFF | |
6093 | This directive, permitted only within @code{.def}/@code{.endef} pairs, | |
6094 | records the address @var{addr} as the value attribute of a symbol table | |
6095 | entry. | |
6096 | @ifset BOUT | |
6097 | ||
a4fb0134 | 6098 | @samp{.val} is used only for COFF output; when @command{@value{AS}} is |
252b5132 RH |
6099 | configured for @code{b.out}, it accepts this directive but ignores it. |
6100 | @end ifset | |
6101 | @end ifset | |
6102 | ||
2e13b764 | 6103 | @ifset ELF |
c91d2e08 NC |
6104 | @node Version |
6105 | @section @code{.version "@var{string}"} | |
2e13b764 | 6106 | |
c1253627 | 6107 | @cindex @code{version} directive |
c91d2e08 NC |
6108 | This directive creates a @code{.note} section and places into it an ELF |
6109 | formatted note of type NT_VERSION. The note's name is set to @code{string}. | |
9a297610 | 6110 | @end ifset |
2e13b764 | 6111 | |
c91d2e08 NC |
6112 | @ifset ELF |
6113 | @node VTableEntry | |
6114 | @section @code{.vtable_entry @var{table}, @var{offset}} | |
2e13b764 | 6115 | |
653cfe85 | 6116 | @cindex @code{vtable_entry} directive |
c91d2e08 NC |
6117 | This directive finds or creates a symbol @code{table} and creates a |
6118 | @code{VTABLE_ENTRY} relocation for it with an addend of @code{offset}. | |
2e13b764 | 6119 | |
c91d2e08 NC |
6120 | @node VTableInherit |
6121 | @section @code{.vtable_inherit @var{child}, @var{parent}} | |
2e13b764 | 6122 | |
653cfe85 | 6123 | @cindex @code{vtable_inherit} directive |
c91d2e08 NC |
6124 | This directive finds the symbol @code{child} and finds or creates the symbol |
6125 | @code{parent} and then creates a @code{VTABLE_INHERIT} relocation for the | |
a349d9dd | 6126 | parent whose addend is the value of the child symbol. As a special case the |
96e9638b | 6127 | parent name of @code{0} is treated as referring to the @code{*ABS*} section. |
c91d2e08 | 6128 | @end ifset |
2e13b764 | 6129 | |
d190d046 HPN |
6130 | @node Warning |
6131 | @section @code{.warning "@var{string}"} | |
6132 | @cindex warning directive | |
6133 | Similar to the directive @code{.error} | |
6134 | (@pxref{Error,,@code{.error "@var{string}"}}), but just emits a warning. | |
6135 | ||
c91d2e08 NC |
6136 | @node Weak |
6137 | @section @code{.weak @var{names}} | |
2e13b764 | 6138 | |
c1253627 | 6139 | @cindex @code{weak} directive |
a349d9dd | 6140 | This directive sets the weak attribute on the comma separated list of symbol |
c91d2e08 | 6141 | @code{names}. If the symbols do not already exist, they will be created. |
c87db184 | 6142 | |
977cdf5a NC |
6143 | On COFF targets other than PE, weak symbols are a GNU extension. This |
6144 | directive sets the weak attribute on the comma separated list of symbol | |
c87db184 CF |
6145 | @code{names}. If the symbols do not already exist, they will be created. |
6146 | ||
977cdf5a NC |
6147 | On the PE target, weak symbols are supported natively as weak aliases. |
6148 | When a weak symbol is created that is not an alias, GAS creates an | |
6149 | alternate symbol to hold the default value. | |
2e13b764 | 6150 | |
06e77878 AO |
6151 | @node Weakref |
6152 | @section @code{.weakref @var{alias}, @var{target}} | |
6153 | ||
6154 | @cindex @code{weakref} directive | |
6155 | This directive creates an alias to the target symbol that enables the symbol to | |
6156 | be referenced with weak-symbol semantics, but without actually making it weak. | |
6157 | If direct references or definitions of the symbol are present, then the symbol | |
6158 | will not be weak, but if all references to it are through weak references, the | |
6159 | symbol will be marked as weak in the symbol table. | |
6160 | ||
6161 | The effect is equivalent to moving all references to the alias to a separate | |
6162 | assembly source file, renaming the alias to the symbol in it, declaring the | |
6163 | symbol as weak there, and running a reloadable link to merge the object files | |
6164 | resulting from the assembly of the new source file and the old source file that | |
6165 | had the references to the alias removed. | |
6166 | ||
6167 | The alias itself never makes to the symbol table, and is entirely handled | |
6168 | within the assembler. | |
6169 | ||
252b5132 RH |
6170 | @node Word |
6171 | @section @code{.word @var{expressions}} | |
6172 | ||
6173 | @cindex @code{word} directive | |
6174 | This directive expects zero or more @var{expressions}, of any section, | |
6175 | separated by commas. | |
6176 | @ifclear GENERIC | |
6177 | @ifset W32 | |
a4fb0134 | 6178 | For each expression, @command{@value{AS}} emits a 32-bit number. |
252b5132 RH |
6179 | @end ifset |
6180 | @ifset W16 | |
a4fb0134 | 6181 | For each expression, @command{@value{AS}} emits a 16-bit number. |
252b5132 RH |
6182 | @end ifset |
6183 | @end ifclear | |
6184 | @ifset GENERIC | |
6185 | ||
6186 | The size of the number emitted, and its byte order, | |
6187 | depend on what target computer the assembly is for. | |
6188 | @end ifset | |
6189 | ||
6190 | @c on amd29k, i960, sparc the "special treatment to support compilers" doesn't | |
6191 | @c happen---32-bit addressability, period; no long/short jumps. | |
6192 | @ifset DIFF-TBL-KLUGE | |
6193 | @cindex difference tables altered | |
6194 | @cindex altered difference tables | |
6195 | @quotation | |
6196 | @emph{Warning: Special Treatment to support Compilers} | |
6197 | @end quotation | |
6198 | ||
6199 | @ifset GENERIC | |
6200 | Machines with a 32-bit address space, but that do less than 32-bit | |
6201 | addressing, require the following special treatment. If the machine of | |
6202 | interest to you does 32-bit addressing (or doesn't require it; | |
6203 | @pxref{Machine Dependencies}), you can ignore this issue. | |
6204 | ||
6205 | @end ifset | |
6206 | In order to assemble compiler output into something that works, | |
a4fb0134 | 6207 | @command{@value{AS}} occasionally does strange things to @samp{.word} directives. |
252b5132 | 6208 | Directives of the form @samp{.word sym1-sym2} are often emitted by |
a4fb0134 | 6209 | compilers as part of jump tables. Therefore, when @command{@value{AS}} assembles a |
252b5132 | 6210 | directive of the form @samp{.word sym1-sym2}, and the difference between |
a4fb0134 | 6211 | @code{sym1} and @code{sym2} does not fit in 16 bits, @command{@value{AS}} |
252b5132 RH |
6212 | creates a @dfn{secondary jump table}, immediately before the next label. |
6213 | This secondary jump table is preceded by a short-jump to the | |
6214 | first byte after the secondary table. This short-jump prevents the flow | |
6215 | of control from accidentally falling into the new table. Inside the | |
6216 | table is a long-jump to @code{sym2}. The original @samp{.word} | |
6217 | contains @code{sym1} minus the address of the long-jump to | |
6218 | @code{sym2}. | |
6219 | ||
6220 | If there were several occurrences of @samp{.word sym1-sym2} before the | |
6221 | secondary jump table, all of them are adjusted. If there was a | |
6222 | @samp{.word sym3-sym4}, that also did not fit in sixteen bits, a | |
6223 | long-jump to @code{sym4} is included in the secondary jump table, | |
6224 | and the @code{.word} directives are adjusted to contain @code{sym3} | |
6225 | minus the address of the long-jump to @code{sym4}; and so on, for as many | |
6226 | entries in the original jump table as necessary. | |
6227 | ||
6228 | @ifset INTERNALS | |
a4fb0134 | 6229 | @emph{This feature may be disabled by compiling @command{@value{AS}} with the |
252b5132 RH |
6230 | @samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse |
6231 | assembly language programmers. | |
6232 | @end ifset | |
6233 | @end ifset | |
6234 | @c end DIFF-TBL-KLUGE | |
6235 | ||
6236 | @node Deprecated | |
6237 | @section Deprecated Directives | |
6238 | ||
6239 | @cindex deprecated directives | |
6240 | @cindex obsolescent directives | |
6241 | One day these directives won't work. | |
6242 | They are included for compatibility with older assemblers. | |
6243 | @table @t | |
6244 | @item .abort | |
6245 | @item .line | |
6246 | @end table | |
6247 | ||
6248 | @ifset GENERIC | |
6249 | @node Machine Dependencies | |
6250 | @chapter Machine Dependent Features | |
6251 | ||
6252 | @cindex machine dependencies | |
6253 | The machine instruction sets are (almost by definition) different on | |
a4fb0134 SC |
6254 | each machine where @command{@value{AS}} runs. Floating point representations |
6255 | vary as well, and @command{@value{AS}} often supports a few additional | |
252b5132 RH |
6256 | directives or command-line options for compatibility with other |
6257 | assemblers on a particular platform. Finally, some versions of | |
a4fb0134 | 6258 | @command{@value{AS}} support special pseudo-instructions for branch |
252b5132 RH |
6259 | optimization. |
6260 | ||
6261 | This chapter discusses most of these differences, though it does not | |
6262 | include details on any machine's instruction set. For details on that | |
6263 | subject, see the hardware manufacturer's manual. | |
6264 | ||
6265 | @menu | |
625e1353 RH |
6266 | @ifset ALPHA |
6267 | * Alpha-Dependent:: Alpha Dependent Features | |
6268 | @end ifset | |
252b5132 RH |
6269 | @ifset ARC |
6270 | * ARC-Dependent:: ARC Dependent Features | |
6271 | @end ifset | |
6272 | @ifset ARM | |
6273 | * ARM-Dependent:: ARM Dependent Features | |
6274 | @end ifset | |
8473f7a4 DC |
6275 | @ifset AVR |
6276 | * AVR-Dependent:: AVR Dependent Features | |
6277 | @end ifset | |
07c1b327 CM |
6278 | @ifset BFIN |
6279 | * BFIN-Dependent:: BFIN Dependent Features | |
6280 | @end ifset | |
8bf549a8 | 6281 | @ifset CRIS |
328eb32e HPN |
6282 | * CRIS-Dependent:: CRIS Dependent Features |
6283 | @end ifset | |
252b5132 RH |
6284 | @ifset D10V |
6285 | * D10V-Dependent:: D10V Dependent Features | |
6286 | @end ifset | |
6287 | @ifset D30V | |
6288 | * D30V-Dependent:: D30V Dependent Features | |
6289 | @end ifset | |
6290 | @ifset H8/300 | |
c2dcd04e | 6291 | * H8/300-Dependent:: Renesas H8/300 Dependent Features |
252b5132 | 6292 | @end ifset |
252b5132 RH |
6293 | @ifset HPPA |
6294 | * HPPA-Dependent:: HPPA Dependent Features | |
6295 | @end ifset | |
5b93d8bb AM |
6296 | @ifset I370 |
6297 | * ESA/390-Dependent:: IBM ESA/390 Dependent Features | |
6298 | @end ifset | |
252b5132 | 6299 | @ifset I80386 |
55b62671 | 6300 | * i386-Dependent:: Intel 80386 and AMD x86-64 Dependent Features |
252b5132 | 6301 | @end ifset |
e3308d0d JE |
6302 | @ifset I860 |
6303 | * i860-Dependent:: Intel 80860 Dependent Features | |
6304 | @end ifset | |
252b5132 RH |
6305 | @ifset I960 |
6306 | * i960-Dependent:: Intel 80960 Dependent Features | |
6307 | @end ifset | |
5cb53c21 L |
6308 | @ifset IA64 |
6309 | * IA-64-Dependent:: Intel IA-64 Dependent Features | |
6310 | @end ifset | |
a40cbfa3 NC |
6311 | @ifset IP2K |
6312 | * IP2K-Dependent:: IP2K Dependent Features | |
6313 | @end ifset | |
49f58d10 JB |
6314 | @ifset M32C |
6315 | * M32C-Dependent:: M32C Dependent Features | |
6316 | @end ifset | |
ec694b89 NC |
6317 | @ifset M32R |
6318 | * M32R-Dependent:: M32R Dependent Features | |
6319 | @end ifset | |
252b5132 RH |
6320 | @ifset M680X0 |
6321 | * M68K-Dependent:: M680x0 Dependent Features | |
6322 | @end ifset | |
60bcf0fa NC |
6323 | @ifset M68HC11 |
6324 | * M68HC11-Dependent:: M68HC11 and 68HC12 Dependent Features | |
6325 | @end ifset | |
252b5132 RH |
6326 | @ifset MIPS |
6327 | * MIPS-Dependent:: MIPS Dependent Features | |
6328 | @end ifset | |
3c3bdf30 NC |
6329 | @ifset MMIX |
6330 | * MMIX-Dependent:: MMIX Dependent Features | |
6331 | @end ifset | |
2469cfa2 NC |
6332 | @ifset MSP430 |
6333 | * MSP430-Dependent:: MSP430 Dependent Features | |
6334 | @end ifset | |
252b5132 | 6335 | @ifset SH |
ef230218 JR |
6336 | * SH-Dependent:: Renesas / SuperH SH Dependent Features |
6337 | * SH64-Dependent:: SuperH SH64 Dependent Features | |
252b5132 | 6338 | @end ifset |
e135f41b NC |
6339 | @ifset PDP11 |
6340 | * PDP-11-Dependent:: PDP-11 Dependent Features | |
6341 | @end ifset | |
041dd5a9 ILT |
6342 | @ifset PJ |
6343 | * PJ-Dependent:: picoJava Dependent Features | |
6344 | @end ifset | |
418c1742 MG |
6345 | @ifset PPC |
6346 | * PPC-Dependent:: PowerPC Dependent Features | |
6347 | @end ifset | |
252b5132 RH |
6348 | @ifset SPARC |
6349 | * Sparc-Dependent:: SPARC Dependent Features | |
6350 | @end ifset | |
39bec121 TW |
6351 | @ifset TIC54X |
6352 | * TIC54X-Dependent:: TI TMS320C54x Dependent Features | |
6353 | @end ifset | |
252b5132 RH |
6354 | @ifset V850 |
6355 | * V850-Dependent:: V850 Dependent Features | |
6356 | @end ifset | |
e0001a05 NC |
6357 | @ifset XTENSA |
6358 | * Xtensa-Dependent:: Xtensa Dependent Features | |
6359 | @end ifset | |
3c9b82ba NC |
6360 | @ifset Z80 |
6361 | * Z80-Dependent:: Z80 Dependent Features | |
6362 | @end ifset | |
252b5132 RH |
6363 | @ifset Z8000 |
6364 | * Z8000-Dependent:: Z8000 Dependent Features | |
6365 | @end ifset | |
6366 | @ifset VAX | |
6367 | * Vax-Dependent:: VAX Dependent Features | |
6368 | @end ifset | |
6369 | @end menu | |
6370 | ||
6371 | @lowersections | |
6372 | @end ifset | |
6373 | ||
6374 | @c The following major nodes are *sections* in the GENERIC version, *chapters* | |
6375 | @c in single-cpu versions. This is mainly achieved by @lowersections. There is a | |
6376 | @c peculiarity: to preserve cross-references, there must be a node called | |
6377 | @c "Machine Dependencies". Hence the conditional nodenames in each | |
6378 | @c major node below. Node defaulting in makeinfo requires adjacency of | |
6379 | @c node and sectioning commands; hence the repetition of @chapter BLAH | |
6380 | @c in both conditional blocks. | |
6381 | ||
625e1353 RH |
6382 | @ifset ALPHA |
6383 | @include c-alpha.texi | |
6384 | @end ifset | |
6385 | ||
6386 | @ifset ARC | |
6387 | @include c-arc.texi | |
6388 | @end ifset | |
6389 | ||
252b5132 RH |
6390 | @ifset ARM |
6391 | @include c-arm.texi | |
6392 | @end ifset | |
6393 | ||
8473f7a4 DC |
6394 | @ifset AVR |
6395 | @include c-avr.texi | |
6396 | @end ifset | |
6397 | ||
07c1b327 CM |
6398 | @ifset BFIN |
6399 | @include c-bfin.texi | |
6400 | @end ifset | |
6401 | ||
328eb32e HPN |
6402 | @ifset CRIS |
6403 | @include c-cris.texi | |
6404 | @end ifset | |
6405 | ||
c2dcd04e | 6406 | @ifset Renesas-all |
252b5132 RH |
6407 | @ifclear GENERIC |
6408 | @node Machine Dependencies | |
6409 | @chapter Machine Dependent Features | |
6410 | ||
c2dcd04e | 6411 | The machine instruction sets are different on each Renesas chip family, |
252b5132 | 6412 | and there are also some syntax differences among the families. This |
a4fb0134 | 6413 | chapter describes the specific @command{@value{AS}} features for each |
252b5132 RH |
6414 | family. |
6415 | ||
6416 | @menu | |
c2dcd04e | 6417 | * H8/300-Dependent:: Renesas H8/300 Dependent Features |
c2dcd04e | 6418 | * SH-Dependent:: Renesas SH Dependent Features |
252b5132 RH |
6419 | @end menu |
6420 | @lowersections | |
6421 | @end ifclear | |
6422 | @end ifset | |
6423 | ||
6424 | @ifset D10V | |
6425 | @include c-d10v.texi | |
6426 | @end ifset | |
6427 | ||
6428 | @ifset D30V | |
6429 | @include c-d30v.texi | |
6430 | @end ifset | |
6431 | ||
6432 | @ifset H8/300 | |
6433 | @include c-h8300.texi | |
6434 | @end ifset | |
6435 | ||
252b5132 RH |
6436 | @ifset HPPA |
6437 | @include c-hppa.texi | |
6438 | @end ifset | |
6439 | ||
5b93d8bb AM |
6440 | @ifset I370 |
6441 | @include c-i370.texi | |
6442 | @end ifset | |
6443 | ||
252b5132 RH |
6444 | @ifset I80386 |
6445 | @include c-i386.texi | |
6446 | @end ifset | |
6447 | ||
e3308d0d JE |
6448 | @ifset I860 |
6449 | @include c-i860.texi | |
6450 | @end ifset | |
6451 | ||
252b5132 RH |
6452 | @ifset I960 |
6453 | @include c-i960.texi | |
6454 | @end ifset | |
6455 | ||
9e32ca89 NC |
6456 | @ifset IA64 |
6457 | @include c-ia64.texi | |
6458 | @end ifset | |
6459 | ||
a40cbfa3 NC |
6460 | @ifset IP2K |
6461 | @include c-ip2k.texi | |
6462 | @end ifset | |
6463 | ||
49f58d10 JB |
6464 | @ifset M32C |
6465 | @include c-m32c.texi | |
6466 | @end ifset | |
6467 | ||
ec694b89 NC |
6468 | @ifset M32R |
6469 | @include c-m32r.texi | |
6470 | @end ifset | |
252b5132 RH |
6471 | |
6472 | @ifset M680X0 | |
6473 | @include c-m68k.texi | |
6474 | @end ifset | |
6475 | ||
60bcf0fa NC |
6476 | @ifset M68HC11 |
6477 | @include c-m68hc11.texi | |
6478 | @end ifset | |
6479 | ||
252b5132 RH |
6480 | @ifset MIPS |
6481 | @include c-mips.texi | |
6482 | @end ifset | |
6483 | ||
3c3bdf30 NC |
6484 | @ifset MMIX |
6485 | @include c-mmix.texi | |
6486 | @end ifset | |
6487 | ||
2469cfa2 NC |
6488 | @ifset MSP430 |
6489 | @include c-msp430.texi | |
6490 | @end ifset | |
6491 | ||
252b5132 RH |
6492 | @ifset NS32K |
6493 | @include c-ns32k.texi | |
6494 | @end ifset | |
6495 | ||
e135f41b NC |
6496 | @ifset PDP11 |
6497 | @include c-pdp11.texi | |
6498 | @end ifset | |
6499 | ||
041dd5a9 ILT |
6500 | @ifset PJ |
6501 | @include c-pj.texi | |
6502 | @end ifset | |
6503 | ||
418c1742 MG |
6504 | @ifset PPC |
6505 | @include c-ppc.texi | |
6506 | @end ifset | |
6507 | ||
252b5132 RH |
6508 | @ifset SH |
6509 | @include c-sh.texi | |
324bfcf3 | 6510 | @include c-sh64.texi |
252b5132 RH |
6511 | @end ifset |
6512 | ||
6513 | @ifset SPARC | |
6514 | @include c-sparc.texi | |
6515 | @end ifset | |
6516 | ||
39bec121 TW |
6517 | @ifset TIC54X |
6518 | @include c-tic54x.texi | |
6519 | @end ifset | |
6520 | ||
3c9b82ba NC |
6521 | @ifset Z80 |
6522 | @include c-z80.texi | |
6523 | @end ifset | |
6524 | ||
252b5132 RH |
6525 | @ifset Z8000 |
6526 | @include c-z8k.texi | |
6527 | @end ifset | |
6528 | ||
6529 | @ifset VAX | |
6530 | @include c-vax.texi | |
6531 | @end ifset | |
6532 | ||
6533 | @ifset V850 | |
6534 | @include c-v850.texi | |
6535 | @end ifset | |
6536 | ||
e0001a05 NC |
6537 | @ifset XTENSA |
6538 | @include c-xtensa.texi | |
6539 | @end ifset | |
6540 | ||
252b5132 RH |
6541 | @ifset GENERIC |
6542 | @c reverse effect of @down at top of generic Machine-Dep chapter | |
6543 | @raisesections | |
6544 | @end ifset | |
6545 | ||
6546 | @node Reporting Bugs | |
6547 | @chapter Reporting Bugs | |
6548 | @cindex bugs in assembler | |
6549 | @cindex reporting bugs in assembler | |
6550 | ||
a4fb0134 | 6551 | Your bug reports play an essential role in making @command{@value{AS}} reliable. |
252b5132 RH |
6552 | |
6553 | Reporting a bug may help you by bringing a solution to your problem, or it may | |
6554 | not. But in any case the principal function of a bug report is to help the | |
a4fb0134 SC |
6555 | entire community by making the next version of @command{@value{AS}} work better. |
6556 | Bug reports are your contribution to the maintenance of @command{@value{AS}}. | |
252b5132 RH |
6557 | |
6558 | In order for a bug report to serve its purpose, you must include the | |
6559 | information that enables us to fix the bug. | |
6560 | ||
6561 | @menu | |
6562 | * Bug Criteria:: Have you found a bug? | |
6563 | * Bug Reporting:: How to report bugs | |
6564 | @end menu | |
6565 | ||
6566 | @node Bug Criteria | |
c1253627 | 6567 | @section Have You Found a Bug? |
252b5132 RH |
6568 | @cindex bug criteria |
6569 | ||
6570 | If you are not sure whether you have found a bug, here are some guidelines: | |
6571 | ||
6572 | @itemize @bullet | |
6573 | @cindex fatal signal | |
6574 | @cindex assembler crash | |
6575 | @cindex crash of assembler | |
6576 | @item | |
6577 | If the assembler gets a fatal signal, for any input whatever, that is a | |
a4fb0134 | 6578 | @command{@value{AS}} bug. Reliable assemblers never crash. |
252b5132 RH |
6579 | |
6580 | @cindex error on valid input | |
6581 | @item | |
a4fb0134 | 6582 | If @command{@value{AS}} produces an error message for valid input, that is a bug. |
252b5132 RH |
6583 | |
6584 | @cindex invalid input | |
6585 | @item | |
a4fb0134 | 6586 | If @command{@value{AS}} does not produce an error message for invalid input, that |
252b5132 RH |
6587 | is a bug. However, you should note that your idea of ``invalid input'' might |
6588 | be our idea of ``an extension'' or ``support for traditional practice''. | |
6589 | ||
6590 | @item | |
6591 | If you are an experienced user of assemblers, your suggestions for improvement | |
a4fb0134 | 6592 | of @command{@value{AS}} are welcome in any case. |
252b5132 RH |
6593 | @end itemize |
6594 | ||
6595 | @node Bug Reporting | |
c1253627 | 6596 | @section How to Report Bugs |
252b5132 RH |
6597 | @cindex bug reports |
6598 | @cindex assembler bugs, reporting | |
6599 | ||
6600 | A number of companies and individuals offer support for @sc{gnu} products. If | |
a4fb0134 | 6601 | you obtained @command{@value{AS}} from a support organization, we recommend you |
252b5132 RH |
6602 | contact that organization first. |
6603 | ||
6604 | You can find contact information for many support companies and | |
6605 | individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs | |
6606 | distribution. | |
6607 | ||
a4fb0134 | 6608 | In any event, we also recommend that you send bug reports for @command{@value{AS}} |
46a04e3a | 6609 | to @samp{bug-binutils@@gnu.org}. |
252b5132 RH |
6610 | |
6611 | The fundamental principle of reporting bugs usefully is this: | |
6612 | @strong{report all the facts}. If you are not sure whether to state a | |
6613 | fact or leave it out, state it! | |
6614 | ||
6615 | Often people omit facts because they think they know what causes the problem | |
6616 | and assume that some details do not matter. Thus, you might assume that the | |
6617 | name of a symbol you use in an example does not matter. Well, probably it does | |
6618 | not, but one cannot be sure. Perhaps the bug is a stray memory reference which | |
6619 | happens to fetch from the location where that name is stored in memory; | |
6620 | perhaps, if the name were different, the contents of that location would fool | |
6621 | the assembler into doing the right thing despite the bug. Play it safe and | |
6622 | give a specific, complete example. That is the easiest thing for you to do, | |
6623 | and the most helpful. | |
6624 | ||
6625 | Keep in mind that the purpose of a bug report is to enable us to fix the bug if | |
6626 | it is new to us. Therefore, always write your bug reports on the assumption | |
6627 | that the bug has not been reported previously. | |
6628 | ||
6629 | Sometimes people give a few sketchy facts and ask, ``Does this ring a | |
c1253627 NC |
6630 | bell?'' This cannot help us fix a bug, so it is basically useless. We |
6631 | respond by asking for enough details to enable us to investigate. | |
6632 | You might as well expedite matters by sending them to begin with. | |
252b5132 RH |
6633 | |
6634 | To enable us to fix the bug, you should include all these things: | |
6635 | ||
6636 | @itemize @bullet | |
6637 | @item | |
a4fb0134 | 6638 | The version of @command{@value{AS}}. @command{@value{AS}} announces it if you start |
252b5132 RH |
6639 | it with the @samp{--version} argument. |
6640 | ||
6641 | Without this, we will not know whether there is any point in looking for | |
a4fb0134 | 6642 | the bug in the current version of @command{@value{AS}}. |
252b5132 RH |
6643 | |
6644 | @item | |
a4fb0134 | 6645 | Any patches you may have applied to the @command{@value{AS}} source. |
252b5132 RH |
6646 | |
6647 | @item | |
6648 | The type of machine you are using, and the operating system name and | |
6649 | version number. | |
6650 | ||
6651 | @item | |
a4fb0134 | 6652 | What compiler (and its version) was used to compile @command{@value{AS}}---e.g. |
252b5132 RH |
6653 | ``@code{gcc-2.7}''. |
6654 | ||
6655 | @item | |
6656 | The command arguments you gave the assembler to assemble your example and | |
6657 | observe the bug. To guarantee you will not omit something important, list them | |
6658 | all. A copy of the Makefile (or the output from make) is sufficient. | |
6659 | ||
6660 | If we were to try to guess the arguments, we would probably guess wrong | |
6661 | and then we might not encounter the bug. | |
6662 | ||
6663 | @item | |
6664 | A complete input file that will reproduce the bug. If the bug is observed when | |
6665 | the assembler is invoked via a compiler, send the assembler source, not the | |
6666 | high level language source. Most compilers will produce the assembler source | |
6667 | when run with the @samp{-S} option. If you are using @code{@value{GCC}}, use | |
6668 | the options @samp{-v --save-temps}; this will save the assembler source in a | |
6669 | file with an extension of @file{.s}, and also show you exactly how | |
a4fb0134 | 6670 | @command{@value{AS}} is being run. |
252b5132 RH |
6671 | |
6672 | @item | |
6673 | A description of what behavior you observe that you believe is | |
6674 | incorrect. For example, ``It gets a fatal signal.'' | |
6675 | ||
a4fb0134 | 6676 | Of course, if the bug is that @command{@value{AS}} gets a fatal signal, then we |
252b5132 RH |
6677 | will certainly notice it. But if the bug is incorrect output, we might not |
6678 | notice unless it is glaringly wrong. You might as well not give us a chance to | |
6679 | make a mistake. | |
6680 | ||
6681 | Even if the problem you experience is a fatal signal, you should still say so | |
6682 | explicitly. Suppose something strange is going on, such as, your copy of | |
b45619c0 | 6683 | @command{@value{AS}} is out of sync, or you have encountered a bug in the C |
252b5132 RH |
6684 | library on your system. (This has happened!) Your copy might crash and ours |
6685 | would not. If you told us to expect a crash, then when ours fails to crash, we | |
6686 | would know that the bug was not happening for us. If you had not told us to | |
6687 | expect a crash, then we would not be able to draw any conclusion from our | |
6688 | observations. | |
6689 | ||
6690 | @item | |
a4fb0134 | 6691 | If you wish to suggest changes to the @command{@value{AS}} source, send us context |
252b5132 RH |
6692 | diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p} |
6693 | option. Always send diffs from the old file to the new file. If you even | |
a4fb0134 | 6694 | discuss something in the @command{@value{AS}} source, refer to it by context, not |
252b5132 RH |
6695 | by line number. |
6696 | ||
6697 | The line numbers in our development sources will not match those in your | |
6698 | sources. Your line numbers would convey no useful information to us. | |
6699 | @end itemize | |
6700 | ||
6701 | Here are some things that are not necessary: | |
6702 | ||
6703 | @itemize @bullet | |
6704 | @item | |
6705 | A description of the envelope of the bug. | |
6706 | ||
6707 | Often people who encounter a bug spend a lot of time investigating | |
6708 | which changes to the input file will make the bug go away and which | |
6709 | changes will not affect it. | |
6710 | ||
6711 | This is often time consuming and not very useful, because the way we | |
6712 | will find the bug is by running a single example under the debugger | |
6713 | with breakpoints, not by pure deduction from a series of examples. | |
6714 | We recommend that you save your time for something else. | |
6715 | ||
6716 | Of course, if you can find a simpler example to report @emph{instead} | |
6717 | of the original one, that is a convenience for us. Errors in the | |
6718 | output will be easier to spot, running under the debugger will take | |
6719 | less time, and so on. | |
6720 | ||
6721 | However, simplification is not vital; if you do not want to do this, | |
6722 | report the bug anyway and send us the entire test case you used. | |
6723 | ||
6724 | @item | |
6725 | A patch for the bug. | |
6726 | ||
6727 | A patch for the bug does help us if it is a good one. But do not omit | |
6728 | the necessary information, such as the test case, on the assumption that | |
6729 | a patch is all we need. We might see problems with your patch and decide | |
6730 | to fix the problem another way, or we might not understand it at all. | |
6731 | ||
a4fb0134 | 6732 | Sometimes with a program as complicated as @command{@value{AS}} it is very hard to |
252b5132 RH |
6733 | construct an example that will make the program follow a certain path through |
6734 | the code. If you do not send us the example, we will not be able to construct | |
6735 | one, so we will not be able to verify that the bug is fixed. | |
6736 | ||
6737 | And if we cannot understand what bug you are trying to fix, or why your | |
6738 | patch should be an improvement, we will not install it. A test case will | |
6739 | help us to understand. | |
6740 | ||
6741 | @item | |
6742 | A guess about what the bug is or what it depends on. | |
6743 | ||
6744 | Such guesses are usually wrong. Even we cannot guess right about such | |
6745 | things without first using the debugger to find the facts. | |
6746 | @end itemize | |
6747 | ||
6748 | @node Acknowledgements | |
6749 | @chapter Acknowledgements | |
6750 | ||
653cfe85 | 6751 | If you have contributed to GAS and your name isn't listed here, |
252b5132 RH |
6752 | it is not meant as a slight. We just don't know about it. Send mail to the |
6753 | maintainer, and we'll correct the situation. Currently | |
6754 | @c (January 1994), | |
6755 | the maintainer is Ken Raeburn (email address @code{raeburn@@cygnus.com}). | |
6756 | ||
6757 | Dean Elsner wrote the original @sc{gnu} assembler for the VAX.@footnote{Any | |
6758 | more details?} | |
6759 | ||
6760 | Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug | |
6761 | information and the 68k series machines, most of the preprocessing pass, and | |
6762 | extensive changes in @file{messages.c}, @file{input-file.c}, @file{write.c}. | |
6763 | ||
6764 | K. Richard Pixley maintained GAS for a while, adding various enhancements and | |
6765 | many bug fixes, including merging support for several processors, breaking GAS | |
6766 | up to handle multiple object file format back ends (including heavy rewrite, | |
6767 | testing, an integration of the coff and b.out back ends), adding configuration | |
6768 | including heavy testing and verification of cross assemblers and file splits | |
6769 | and renaming, converted GAS to strictly ANSI C including full prototypes, added | |
6770 | support for m680[34]0 and cpu32, did considerable work on i960 including a COFF | |
6771 | port (including considerable amounts of reverse engineering), a SPARC opcode | |
6772 | file rewrite, DECstation, rs6000, and hp300hpux host ports, updated ``know'' | |
6773 | assertions and made them work, much other reorganization, cleanup, and lint. | |
6774 | ||
6775 | Ken Raeburn wrote the high-level BFD interface code to replace most of the code | |
6776 | in format-specific I/O modules. | |
6777 | ||
6778 | The original VMS support was contributed by David L. Kashtan. Eric Youngdale | |
6779 | has done much work with it since. | |
6780 | ||
6781 | The Intel 80386 machine description was written by Eliot Dresselhaus. | |
6782 | ||
6783 | Minh Tran-Le at IntelliCorp contributed some AIX 386 support. | |
6784 | ||
6785 | The Motorola 88k machine description was contributed by Devon Bowen of Buffalo | |
6786 | University and Torbjorn Granlund of the Swedish Institute of Computer Science. | |
6787 | ||
6788 | Keith Knowles at the Open Software Foundation wrote the original MIPS back end | |
6789 | (@file{tc-mips.c}, @file{tc-mips.h}), and contributed Rose format support | |
6790 | (which hasn't been merged in yet). Ralph Campbell worked with the MIPS code to | |
6791 | support a.out format. | |
6792 | ||
7be1c489 AM |
6793 | Support for the Zilog Z8k and Renesas H8/300 processors (tc-z8k, |
6794 | tc-h8300), and IEEE 695 object file format (obj-ieee), was written by | |
252b5132 RH |
6795 | Steve Chamberlain of Cygnus Support. Steve also modified the COFF back end to |
6796 | use BFD for some low-level operations, for use with the H8/300 and AMD 29k | |
6797 | targets. | |
6798 | ||
6799 | John Gilmore built the AMD 29000 support, added @code{.include} support, and | |
6800 | simplified the configuration of which versions accept which directives. He | |
6801 | updated the 68k machine description so that Motorola's opcodes always produced | |
c1253627 | 6802 | fixed-size instructions (e.g., @code{jsr}), while synthetic instructions |
252b5132 RH |
6803 | remained shrinkable (@code{jbsr}). John fixed many bugs, including true tested |
6804 | cross-compilation support, and one bug in relaxation that took a week and | |
6805 | required the proverbial one-bit fix. | |
6806 | ||
6807 | Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the | |
6808 | 68k, completed support for some COFF targets (68k, i386 SVR3, and SCO Unix), | |
6809 | added support for MIPS ECOFF and ELF targets, wrote the initial RS/6000 and | |
6810 | PowerPC assembler, and made a few other minor patches. | |
6811 | ||
653cfe85 | 6812 | Steve Chamberlain made GAS able to generate listings. |
252b5132 RH |
6813 | |
6814 | Hewlett-Packard contributed support for the HP9000/300. | |
6815 | ||
6816 | Jeff Law wrote GAS and BFD support for the native HPPA object format (SOM) | |
6817 | along with a fairly extensive HPPA testsuite (for both SOM and ELF object | |
6818 | formats). This work was supported by both the Center for Software Science at | |
6819 | the University of Utah and Cygnus Support. | |
6820 | ||
6821 | Support for ELF format files has been worked on by Mark Eichin of Cygnus | |
6822 | Support (original, incomplete implementation for SPARC), Pete Hoogenboom and | |
6823 | Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open | |
6824 | Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc, | |
6825 | and some initial 64-bit support). | |
6826 | ||
c1253627 | 6827 | Linas Vepstas added GAS support for the ESA/390 ``IBM 370'' architecture. |
5b93d8bb | 6828 | |
252b5132 RH |
6829 | Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD |
6830 | support for openVMS/Alpha. | |
6831 | ||
39bec121 TW |
6832 | Timothy Wall, Michael Hayes, and Greg Smart contributed to the various tic* |
6833 | flavors. | |
6834 | ||
e0001a05 | 6835 | David Heine, Sterling Augustine, Bob Wilson and John Ruttenberg from Tensilica, |
b45619c0 | 6836 | Inc.@: added support for Xtensa processors. |
e0001a05 | 6837 | |
252b5132 RH |
6838 | Several engineers at Cygnus Support have also provided many small bug fixes and |
6839 | configuration enhancements. | |
6840 | ||
6841 | Many others have contributed large or small bugfixes and enhancements. If | |
6842 | you have contributed significant work and are not mentioned on this list, and | |
6843 | want to be, let us know. Some of the history has been lost; we are not | |
6844 | intentionally leaving anyone out. | |
6845 | ||
c1253627 | 6846 | @include fdl.texi |
cf055d54 | 6847 | |
370b66a1 CD |
6848 | @node AS Index |
6849 | @unnumbered AS Index | |
252b5132 RH |
6850 | |
6851 | @printindex cp | |
6852 | ||
6853 | @contents | |
6854 | @bye | |
6855 | @c Local Variables: | |
6856 | @c fill-column: 79 | |
6857 | @c End: |