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