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