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