| 1 | This is as.info, produced by makeinfo version 4.3 from as.texinfo. | 
|---|
| 2 |  | 
|---|
| 3 | START-INFO-DIR-ENTRY | 
|---|
| 4 | * As: (as).                     The GNU assembler. | 
|---|
| 5 | * Gas: (as).                    The GNU assembler. | 
|---|
| 6 | END-INFO-DIR-ENTRY | 
|---|
| 7 |  | 
|---|
| 8 | This file documents the GNU Assembler "as". | 
|---|
| 9 |  | 
|---|
| 10 | Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 | 
|---|
| 11 | Free Software Foundation, Inc. | 
|---|
| 12 |  | 
|---|
| 13 | Permission is granted to copy, distribute and/or modify this document | 
|---|
| 14 | under the terms of the GNU Free Documentation License, Version 1.1 or | 
|---|
| 15 | any later version published by the Free Software Foundation; with no | 
|---|
| 16 | Invariant Sections, with no Front-Cover Texts, and with no Back-Cover | 
|---|
| 17 | Texts.  A copy of the license is included in the section entitled "GNU | 
|---|
| 18 | Free Documentation License". | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | File: as.info,  Node: HPPA Directives,  Next: HPPA Opcodes,  Prev: HPPA Floating Point,  Up: HPPA-Dependent | 
|---|
| 22 |  | 
|---|
| 23 | HPPA Assembler Directives | 
|---|
| 24 | ------------------------- | 
|---|
| 25 |  | 
|---|
| 26 | `as' for the HPPA supports many additional directives for | 
|---|
| 27 | compatibility with the native assembler.  This section describes them | 
|---|
| 28 | only briefly.  For detailed information on HPPA-specific assembler | 
|---|
| 29 | directives, see `HP9000 Series 800 Assembly Language Reference Manual' | 
|---|
| 30 | (HP 92432-90001). | 
|---|
| 31 |  | 
|---|
| 32 | `as' does _not_ support the following assembler directives described | 
|---|
| 33 | in the HP manual: | 
|---|
| 34 |  | 
|---|
| 35 | .endm           .liston | 
|---|
| 36 | .enter          .locct | 
|---|
| 37 | .leave          .macro | 
|---|
| 38 | .listoff | 
|---|
| 39 |  | 
|---|
| 40 | Beyond those implemented for compatibility, `as' supports one | 
|---|
| 41 | additional assembler directive for the HPPA: `.param'.  It conveys | 
|---|
| 42 | register argument locations for static functions.  Its syntax closely | 
|---|
| 43 | follows the `.export' directive. | 
|---|
| 44 |  | 
|---|
| 45 | These are the additional directives in `as' for the HPPA: | 
|---|
| 46 |  | 
|---|
| 47 | `.block N' | 
|---|
| 48 | `.blockz N' | 
|---|
| 49 | Reserve N bytes of storage, and initialize them to zero. | 
|---|
| 50 |  | 
|---|
| 51 | `.call' | 
|---|
| 52 | Mark the beginning of a procedure call.  Only the special case | 
|---|
| 53 | with _no arguments_ is allowed. | 
|---|
| 54 |  | 
|---|
| 55 | `.callinfo [ PARAM=VALUE, ... ]  [ FLAG, ... ]' | 
|---|
| 56 | Specify a number of parameters and flags that define the | 
|---|
| 57 | environment for a procedure. | 
|---|
| 58 |  | 
|---|
| 59 | PARAM may be any of `frame' (frame size), `entry_gr' (end of | 
|---|
| 60 | general register range), `entry_fr' (end of float register range), | 
|---|
| 61 | `entry_sr' (end of space register range). | 
|---|
| 62 |  | 
|---|
| 63 | The values for FLAG are `calls' or `caller' (proc has | 
|---|
| 64 | subroutines), `no_calls' (proc does not call subroutines), | 
|---|
| 65 | `save_rp' (preserve return pointer), `save_sp' (proc preserves | 
|---|
| 66 | stack pointer), `no_unwind' (do not unwind this proc), `hpux_int' | 
|---|
| 67 | (proc is interrupt routine). | 
|---|
| 68 |  | 
|---|
| 69 | `.code' | 
|---|
| 70 | Assemble into the standard section called `$TEXT$', subsection | 
|---|
| 71 | `$CODE$'. | 
|---|
| 72 |  | 
|---|
| 73 | `.copyright "STRING"' | 
|---|
| 74 | In the SOM object format, insert STRING into the object code, | 
|---|
| 75 | marked as a copyright string. | 
|---|
| 76 |  | 
|---|
| 77 | `.copyright "STRING"' | 
|---|
| 78 | In the ELF object format, insert STRING into the object code, | 
|---|
| 79 | marked as a version string. | 
|---|
| 80 |  | 
|---|
| 81 | `.enter' | 
|---|
| 82 | Not yet supported; the assembler rejects programs containing this | 
|---|
| 83 | directive. | 
|---|
| 84 |  | 
|---|
| 85 | `.entry' | 
|---|
| 86 | Mark the beginning of a procedure. | 
|---|
| 87 |  | 
|---|
| 88 | `.exit' | 
|---|
| 89 | Mark the end of a procedure. | 
|---|
| 90 |  | 
|---|
| 91 | `.export NAME [ ,TYP ]  [ ,PARAM=R ]' | 
|---|
| 92 | Make a procedure NAME available to callers.  TYP, if present, must | 
|---|
| 93 | be one of `absolute', `code' (ELF only, not SOM), `data', `entry', | 
|---|
| 94 | `data', `entry', `millicode', `plabel', `pri_prog', or `sec_prog'. | 
|---|
| 95 |  | 
|---|
| 96 | PARAM, if present, provides either relocation information for the | 
|---|
| 97 | procedure arguments and result, or a privilege level.  PARAM may be | 
|---|
| 98 | `argwN' (where N ranges from `0' to `3', and indicates one of four | 
|---|
| 99 | one-word arguments); `rtnval' (the procedure's result); or | 
|---|
| 100 | `priv_lev' (privilege level).  For arguments or the result, R | 
|---|
| 101 | specifies how to relocate, and must be one of `no' (not | 
|---|
| 102 | relocatable), `gr' (argument is in general register), `fr' (in | 
|---|
| 103 | floating point register), or `fu' (upper half of float register). | 
|---|
| 104 | For `priv_lev', R is an integer. | 
|---|
| 105 |  | 
|---|
| 106 | `.half N' | 
|---|
| 107 | Define a two-byte integer constant N; synonym for the portable | 
|---|
| 108 | `as' directive `.short'. | 
|---|
| 109 |  | 
|---|
| 110 | `.import NAME [ ,TYP ]' | 
|---|
| 111 | Converse of `.export'; make a procedure available to call.  The | 
|---|
| 112 | arguments use the same conventions as the first two arguments for | 
|---|
| 113 | `.export'. | 
|---|
| 114 |  | 
|---|
| 115 | `.label NAME' | 
|---|
| 116 | Define NAME as a label for the current assembly location. | 
|---|
| 117 |  | 
|---|
| 118 | `.leave' | 
|---|
| 119 | Not yet supported; the assembler rejects programs containing this | 
|---|
| 120 | directive. | 
|---|
| 121 |  | 
|---|
| 122 | `.origin LC' | 
|---|
| 123 | Advance location counter to LC. Synonym for the `{No value for | 
|---|
| 124 | `as'}' portable directive `.org'. | 
|---|
| 125 |  | 
|---|
| 126 | `.param NAME [ ,TYP ]  [ ,PARAM=R ]' | 
|---|
| 127 | Similar to `.export', but used for static procedures. | 
|---|
| 128 |  | 
|---|
| 129 | `.proc' | 
|---|
| 130 | Use preceding the first statement of a procedure. | 
|---|
| 131 |  | 
|---|
| 132 | `.procend' | 
|---|
| 133 | Use following the last statement of a procedure. | 
|---|
| 134 |  | 
|---|
| 135 | `LABEL .reg EXPR' | 
|---|
| 136 | Synonym for `.equ'; define LABEL with the absolute expression EXPR | 
|---|
| 137 | as its value. | 
|---|
| 138 |  | 
|---|
| 139 | `.space SECNAME [ ,PARAMS ]' | 
|---|
| 140 | Switch to section SECNAME, creating a new section by that name if | 
|---|
| 141 | necessary.  You may only use PARAMS when creating a new section, | 
|---|
| 142 | not when switching to an existing one.  SECNAME may identify a | 
|---|
| 143 | section by number rather than by name. | 
|---|
| 144 |  | 
|---|
| 145 | If specified, the list PARAMS declares attributes of the section, | 
|---|
| 146 | identified by keywords.  The keywords recognized are `spnum=EXP' | 
|---|
| 147 | (identify this section by the number EXP, an absolute expression), | 
|---|
| 148 | `sort=EXP' (order sections according to this sort key when linking; | 
|---|
| 149 | EXP is an absolute expression), `unloadable' (section contains no | 
|---|
| 150 | loadable data), `notdefined' (this section defined elsewhere), and | 
|---|
| 151 | `private' (data in this section not available to other programs). | 
|---|
| 152 |  | 
|---|
| 153 | `.spnum SECNAM' | 
|---|
| 154 | Allocate four bytes of storage, and initialize them with the | 
|---|
| 155 | section number of the section named SECNAM.  (You can define the | 
|---|
| 156 | section number with the HPPA `.space' directive.) | 
|---|
| 157 |  | 
|---|
| 158 | `.string "STR"' | 
|---|
| 159 | Copy the characters in the string STR to the object file.  *Note | 
|---|
| 160 | Strings: Strings, for information on escape sequences you can use | 
|---|
| 161 | in `as' strings. | 
|---|
| 162 |  | 
|---|
| 163 | _Warning!_ The HPPA version of `.string' differs from the usual | 
|---|
| 164 | `as' definition: it does _not_ write a zero byte after copying STR. | 
|---|
| 165 |  | 
|---|
| 166 | `.stringz "STR"' | 
|---|
| 167 | Like `.string', but appends a zero byte after copying STR to object | 
|---|
| 168 | file. | 
|---|
| 169 |  | 
|---|
| 170 | `.subspa NAME [ ,PARAMS ]' | 
|---|
| 171 | `.nsubspa NAME [ ,PARAMS ]' | 
|---|
| 172 | Similar to `.space', but selects a subsection NAME within the | 
|---|
| 173 | current section.  You may only specify PARAMS when you create a | 
|---|
| 174 | subsection (in the first instance of `.subspa' for this NAME). | 
|---|
| 175 |  | 
|---|
| 176 | If specified, the list PARAMS declares attributes of the | 
|---|
| 177 | subsection, identified by keywords.  The keywords recognized are | 
|---|
| 178 | `quad=EXPR' ("quadrant" for this subsection), `align=EXPR' | 
|---|
| 179 | (alignment for beginning of this subsection; a power of two), | 
|---|
| 180 | `access=EXPR' (value for "access rights" field), `sort=EXPR' | 
|---|
| 181 | (sorting order for this subspace in link), `code_only' (subsection | 
|---|
| 182 | contains only code), `unloadable' (subsection cannot be loaded | 
|---|
| 183 | into memory), `common' (subsection is common block), `dup_comm' | 
|---|
| 184 | (initialized data may have duplicate names), or `zero' (subsection | 
|---|
| 185 | is all zeros, do not write in object file). | 
|---|
| 186 |  | 
|---|
| 187 | `.nsubspa' always creates a new subspace with the given name, even | 
|---|
| 188 | if one with the same name already exists. | 
|---|
| 189 |  | 
|---|
| 190 | `.version "STR"' | 
|---|
| 191 | Write STR as version identifier in object code. | 
|---|
| 192 |  | 
|---|
| 193 |  | 
|---|
| 194 | File: as.info,  Node: HPPA Opcodes,  Prev: HPPA Directives,  Up: HPPA-Dependent | 
|---|
| 195 |  | 
|---|
| 196 | Opcodes | 
|---|
| 197 | ------- | 
|---|
| 198 |  | 
|---|
| 199 | For detailed information on the HPPA machine instruction set, see | 
|---|
| 200 | `PA-RISC Architecture and Instruction Set Reference Manual' (HP | 
|---|
| 201 | 09740-90039). | 
|---|
| 202 |  | 
|---|
| 203 |  | 
|---|
| 204 | File: as.info,  Node: ESA/390-Dependent,  Next: i386-Dependent,  Prev: HPPA-Dependent,  Up: Machine Dependencies | 
|---|
| 205 |  | 
|---|
| 206 | ESA/390 Dependent Features | 
|---|
| 207 | ========================== | 
|---|
| 208 |  | 
|---|
| 209 | * Menu: | 
|---|
| 210 |  | 
|---|
| 211 | * ESA/390 Notes::                Notes | 
|---|
| 212 | * ESA/390 Options::              Options | 
|---|
| 213 | * ESA/390 Syntax::               Syntax | 
|---|
| 214 | * ESA/390 Floating Point::       Floating Point | 
|---|
| 215 | * ESA/390 Directives::           ESA/390 Machine Directives | 
|---|
| 216 | * ESA/390 Opcodes::              Opcodes | 
|---|
| 217 |  | 
|---|
| 218 |  | 
|---|
| 219 | File: as.info,  Node: ESA/390 Notes,  Next: ESA/390 Options,  Up: ESA/390-Dependent | 
|---|
| 220 |  | 
|---|
| 221 | Notes | 
|---|
| 222 | ----- | 
|---|
| 223 |  | 
|---|
| 224 | The ESA/390 `as' port is currently intended to be a back-end for the | 
|---|
| 225 | GNU CC compiler.  It is not HLASM compatible, although it does support | 
|---|
| 226 | a subset of some of the HLASM directives.  The only supported binary | 
|---|
| 227 | file format is ELF; none of the usual MVS/VM/OE/USS object file | 
|---|
| 228 | formats, such as ESD or XSD, are supported. | 
|---|
| 229 |  | 
|---|
| 230 | When used with the GNU CC compiler, the ESA/390 `as' will produce | 
|---|
| 231 | correct, fully relocated, functional binaries, and has been used to | 
|---|
| 232 | compile and execute large projects.  However, many aspects should still | 
|---|
| 233 | be considered experimental; these include shared library support, | 
|---|
| 234 | dynamically loadable objects, and any relocation other than the 31-bit | 
|---|
| 235 | relocation. | 
|---|
| 236 |  | 
|---|
| 237 |  | 
|---|
| 238 | File: as.info,  Node: ESA/390 Options,  Next: ESA/390 Syntax,  Prev: ESA/390 Notes,  Up: ESA/390-Dependent | 
|---|
| 239 |  | 
|---|
| 240 | Options | 
|---|
| 241 | ------- | 
|---|
| 242 |  | 
|---|
| 243 | `as' has no machine-dependent command-line options for the ESA/390. | 
|---|
| 244 |  | 
|---|
| 245 |  | 
|---|
| 246 | File: as.info,  Node: ESA/390 Syntax,  Next: ESA/390 Floating Point,  Prev: ESA/390 Options,  Up: ESA/390-Dependent | 
|---|
| 247 |  | 
|---|
| 248 | Syntax | 
|---|
| 249 | ------ | 
|---|
| 250 |  | 
|---|
| 251 | The opcode/operand syntax follows the ESA/390 Principles of Operation | 
|---|
| 252 | manual; assembler directives and general syntax are loosely based on the | 
|---|
| 253 | prevailing AT&T/SVR4/ELF/Solaris style notation.  HLASM-style directives | 
|---|
| 254 | are _not_ supported for the most part, with the exception of those | 
|---|
| 255 | described herein. | 
|---|
| 256 |  | 
|---|
| 257 | A leading dot in front of directives is optional, and the case of | 
|---|
| 258 | directives is ignored; thus for example, .using and USING have the same | 
|---|
| 259 | effect. | 
|---|
| 260 |  | 
|---|
| 261 | A colon may immediately follow a label definition.  This is simply | 
|---|
| 262 | for compatibility with how most assembly language programmers write | 
|---|
| 263 | code. | 
|---|
| 264 |  | 
|---|
| 265 | `#' is the line comment character. | 
|---|
| 266 |  | 
|---|
| 267 | `;' can be used instead of a newline to separate statements. | 
|---|
| 268 |  | 
|---|
| 269 | Since `$' has no special meaning, you may use it in symbol names. | 
|---|
| 270 |  | 
|---|
| 271 | Registers can be given the symbolic names r0..r15, fp0, fp2, fp4, | 
|---|
| 272 | fp6.  By using thesse symbolic names, `as' can detect simple syntax | 
|---|
| 273 | errors. The name rarg or r.arg is a synonym for r11, rtca or r.tca for | 
|---|
| 274 | r12, sp, r.sp, dsa r.dsa for r13, lr or r.lr for r14, rbase or r.base | 
|---|
| 275 | for r3 and rpgt or r.pgt for r4. | 
|---|
| 276 |  | 
|---|
| 277 | `*' is the current location counter.  Unlike `.' it is always | 
|---|
| 278 | relative to the last USING directive.  Note that this means that | 
|---|
| 279 | expressions cannot use multiplication, as any occurrence of `*' will be | 
|---|
| 280 | interpreted as a location counter. | 
|---|
| 281 |  | 
|---|
| 282 | All labels are relative to the last USING.  Thus, branches to a label | 
|---|
| 283 | always imply the use of base+displacement. | 
|---|
| 284 |  | 
|---|
| 285 | Many of the usual forms of address constants / address literals are | 
|---|
| 286 | supported.  Thus, | 
|---|
| 287 | .using  *,r3 | 
|---|
| 288 | L       r15,=A(some_routine) | 
|---|
| 289 | LM      r6,r7,=V(some_longlong_extern) | 
|---|
| 290 | A       r1,=F'12' | 
|---|
| 291 | AH      r0,=H'42' | 
|---|
| 292 | ME      r6,=E'3.1416' | 
|---|
| 293 | MD      r6,=D'3.14159265358979' | 
|---|
| 294 | O       r6,=XL4'cacad0d0' | 
|---|
| 295 | .ltorg | 
|---|
| 296 | should all behave as expected: that is, an entry in the literal pool | 
|---|
| 297 | will be created (or reused if it already exists), and the instruction | 
|---|
| 298 | operands will be the displacement into the literal pool using the | 
|---|
| 299 | current base register (as last declared with the `.using' directive). | 
|---|
| 300 |  | 
|---|
| 301 |  | 
|---|
| 302 | File: as.info,  Node: ESA/390 Floating Point,  Next: ESA/390 Directives,  Prev: ESA/390 Syntax,  Up: ESA/390-Dependent | 
|---|
| 303 |  | 
|---|
| 304 | Floating Point | 
|---|
| 305 | -------------- | 
|---|
| 306 |  | 
|---|
| 307 | The assembler generates only IEEE floating-point numbers.  The older | 
|---|
| 308 | floating point formats are not supported. | 
|---|
| 309 |  | 
|---|
| 310 |  | 
|---|
| 311 | File: as.info,  Node: ESA/390 Directives,  Next: ESA/390 Opcodes,  Prev: ESA/390 Floating Point,  Up: ESA/390-Dependent | 
|---|
| 312 |  | 
|---|
| 313 | ESA/390 Assembler Directives | 
|---|
| 314 | ---------------------------- | 
|---|
| 315 |  | 
|---|
| 316 | `as' for the ESA/390 supports all of the standard ELF/SVR4 assembler | 
|---|
| 317 | directives that are documented in the main part of this documentation. | 
|---|
| 318 | Several additional directives are supported in order to implement the | 
|---|
| 319 | ESA/390 addressing model.  The most important of these are `.using' and | 
|---|
| 320 | `.ltorg' | 
|---|
| 321 |  | 
|---|
| 322 | These are the additional directives in `as' for the ESA/390: | 
|---|
| 323 |  | 
|---|
| 324 | `.dc' | 
|---|
| 325 | A small subset of the usual DC directive is supported. | 
|---|
| 326 |  | 
|---|
| 327 | `.drop REGNO' | 
|---|
| 328 | Stop using REGNO as the base register.  The REGNO must have been | 
|---|
| 329 | previously declared with a `.using' directive in the same section | 
|---|
| 330 | as the current section. | 
|---|
| 331 |  | 
|---|
| 332 | `.ebcdic STRING' | 
|---|
| 333 | Emit the EBCDIC equivalent of the indicated string.  The emitted | 
|---|
| 334 | string will be null terminated.  Note that the directives | 
|---|
| 335 | `.string' etc. emit ascii strings by default. | 
|---|
| 336 |  | 
|---|
| 337 | `EQU' | 
|---|
| 338 | The standard HLASM-style EQU directive is not supported; however, | 
|---|
| 339 | the standard `as' directive .equ can be used to the same effect. | 
|---|
| 340 |  | 
|---|
| 341 | `.ltorg' | 
|---|
| 342 | Dump the literal pool accumulated so far; begin a new literal pool. | 
|---|
| 343 | The literal pool will be written in the current section; in order | 
|---|
| 344 | to generate correct assembly, a `.using' must have been previously | 
|---|
| 345 | specified in the same section. | 
|---|
| 346 |  | 
|---|
| 347 | `.using EXPR,REGNO' | 
|---|
| 348 | Use REGNO as the base register for all subsequent RX, RS, and SS | 
|---|
| 349 | form instructions. The EXPR will be evaluated to obtain the base | 
|---|
| 350 | address; usually, EXPR will merely be `*'. | 
|---|
| 351 |  | 
|---|
| 352 | This assembler allows two `.using' directives to be simultaneously | 
|---|
| 353 | outstanding, one in the `.text' section, and one in another section | 
|---|
| 354 | (typically, the `.data' section).  This feature allows dynamically | 
|---|
| 355 | loaded objects to be implemented in a relatively straightforward | 
|---|
| 356 | way.  A `.using' directive must always be specified in the `.text' | 
|---|
| 357 | section; this will specify the base register that will be used for | 
|---|
| 358 | branches in the `.text' section.  A second `.using' may be | 
|---|
| 359 | specified in another section; this will specify the base register | 
|---|
| 360 | that is used for non-label address literals.  When a second | 
|---|
| 361 | `.using' is specified, then the subsequent `.ltorg' must be put in | 
|---|
| 362 | the same section; otherwise an error will result. | 
|---|
| 363 |  | 
|---|
| 364 | Thus, for example, the following code uses `r3' to address branch | 
|---|
| 365 | targets and `r4' to address the literal pool, which has been | 
|---|
| 366 | written to the `.data' section.  The is, the constants | 
|---|
| 367 | `=A(some_routine)', `=H'42'' and `=E'3.1416'' will all appear in | 
|---|
| 368 | the `.data' section. | 
|---|
| 369 |  | 
|---|
| 370 | .data | 
|---|
| 371 | .using  LITPOOL,r4 | 
|---|
| 372 | .text | 
|---|
| 373 | BASR    r3,0 | 
|---|
| 374 | .using  *,r3 | 
|---|
| 375 | B       START | 
|---|
| 376 | .long   LITPOOL | 
|---|
| 377 | START: | 
|---|
| 378 | L       r4,4(,r3) | 
|---|
| 379 | L       r15,=A(some_routine) | 
|---|
| 380 | LTR     r15,r15 | 
|---|
| 381 | BNE     LABEL | 
|---|
| 382 | AH      r0,=H'42' | 
|---|
| 383 | LABEL: | 
|---|
| 384 | ME      r6,=E'3.1416' | 
|---|
| 385 | .data | 
|---|
| 386 | LITPOOL: | 
|---|
| 387 | .ltorg | 
|---|
| 388 |  | 
|---|
| 389 | Note that this dual-`.using' directive semantics extends and is | 
|---|
| 390 | not compatible with HLASM semantics.  Note that this assembler | 
|---|
| 391 | directive does not support the full range of HLASM semantics. | 
|---|
| 392 |  | 
|---|
| 393 |  | 
|---|
| 394 | File: as.info,  Node: ESA/390 Opcodes,  Prev: ESA/390 Directives,  Up: ESA/390-Dependent | 
|---|
| 395 |  | 
|---|
| 396 | Opcodes | 
|---|
| 397 | ------- | 
|---|
| 398 |  | 
|---|
| 399 | For detailed information on the ESA/390 machine instruction set, see | 
|---|
| 400 | `ESA/390 Principles of Operation' (IBM Publication Number DZ9AR004). | 
|---|
| 401 |  | 
|---|
| 402 |  | 
|---|
| 403 | File: as.info,  Node: i386-Dependent,  Next: i860-Dependent,  Prev: ESA/390-Dependent,  Up: Machine Dependencies | 
|---|
| 404 |  | 
|---|
| 405 | 80386 Dependent Features | 
|---|
| 406 | ======================== | 
|---|
| 407 |  | 
|---|
| 408 | The i386 version `as' supports both the original Intel 386 | 
|---|
| 409 | architecture in both 16 and 32-bit mode as well as AMD x86-64 | 
|---|
| 410 | architecture extending the Intel architecture to 64-bits. | 
|---|
| 411 |  | 
|---|
| 412 | * Menu: | 
|---|
| 413 |  | 
|---|
| 414 | * i386-Options::                Options | 
|---|
| 415 | * i386-Syntax::                 AT&T Syntax versus Intel Syntax | 
|---|
| 416 | * i386-Mnemonics::              Instruction Naming | 
|---|
| 417 | * i386-Regs::                   Register Naming | 
|---|
| 418 | * i386-Prefixes::               Instruction Prefixes | 
|---|
| 419 | * i386-Memory::                 Memory References | 
|---|
| 420 | * i386-Jumps::                  Handling of Jump Instructions | 
|---|
| 421 | * i386-Float::                  Floating Point | 
|---|
| 422 | * i386-SIMD::                   Intel's MMX and AMD's 3DNow! SIMD Operations | 
|---|
| 423 | * i386-16bit::                  Writing 16-bit Code | 
|---|
| 424 | * i386-Arch::                   Specifying an x86 CPU architecture | 
|---|
| 425 | * i386-Bugs::                   AT&T Syntax bugs | 
|---|
| 426 | * i386-Notes::                  Notes | 
|---|
| 427 |  | 
|---|
| 428 |  | 
|---|
| 429 | File: as.info,  Node: i386-Options,  Next: i386-Syntax,  Up: i386-Dependent | 
|---|
| 430 |  | 
|---|
| 431 | Options | 
|---|
| 432 | ------- | 
|---|
| 433 |  | 
|---|
| 434 | The i386 version of `as' has a few machine dependent options: | 
|---|
| 435 |  | 
|---|
| 436 | `--32 | --64' | 
|---|
| 437 | Select the word size, either 32 bits or 64 bits. Selecting 32-bit | 
|---|
| 438 | implies Intel i386 architecture, while 64-bit implies AMD x86-64 | 
|---|
| 439 | architecture. | 
|---|
| 440 |  | 
|---|
| 441 | These options are only available with the ELF object file format, | 
|---|
| 442 | and require that the necessary BFD support has been included (on a | 
|---|
| 443 | 32-bit platform you have to add -enable-64-bit-bfd to configure | 
|---|
| 444 | enable 64-bit usage and use x86-64 as target platform). | 
|---|
| 445 |  | 
|---|
| 446 |  | 
|---|
| 447 | File: as.info,  Node: i386-Syntax,  Next: i386-Mnemonics,  Prev: i386-Options,  Up: i386-Dependent | 
|---|
| 448 |  | 
|---|
| 449 | AT&T Syntax versus Intel Syntax | 
|---|
| 450 | ------------------------------- | 
|---|
| 451 |  | 
|---|
| 452 | `as' now supports assembly using Intel assembler syntax. | 
|---|
| 453 | `.intel_syntax' selects Intel mode, and `.att_syntax' switches back to | 
|---|
| 454 | the usual AT&T mode for compatibility with the output of `gcc'.  Either | 
|---|
| 455 | of these directives may have an optional argument, `prefix', or | 
|---|
| 456 | `noprefix' specifying whether registers require a `%' prefix.  AT&T | 
|---|
| 457 | System V/386 assembler syntax is quite different from Intel syntax.  We | 
|---|
| 458 | mention these differences because almost all 80386 documents use Intel | 
|---|
| 459 | syntax.  Notable differences between the two syntaxes are: | 
|---|
| 460 |  | 
|---|
| 461 | * AT&T immediate operands are preceded by `$'; Intel immediate | 
|---|
| 462 | operands are undelimited (Intel `push 4' is AT&T `pushl $4'). | 
|---|
| 463 | AT&T register operands are preceded by `%'; Intel register operands | 
|---|
| 464 | are undelimited.  AT&T absolute (as opposed to PC relative) | 
|---|
| 465 | jump/call operands are prefixed by `*'; they are undelimited in | 
|---|
| 466 | Intel syntax. | 
|---|
| 467 |  | 
|---|
| 468 | * AT&T and Intel syntax use the opposite order for source and | 
|---|
| 469 | destination operands.  Intel `add eax, 4' is `addl $4, %eax'.  The | 
|---|
| 470 | `source, dest' convention is maintained for compatibility with | 
|---|
| 471 | previous Unix assemblers.  Note that instructions with more than | 
|---|
| 472 | one source operand, such as the `enter' instruction, do _not_ have | 
|---|
| 473 | reversed order.  *Note i386-Bugs::. | 
|---|
| 474 |  | 
|---|
| 475 | * In AT&T syntax the size of memory operands is determined from the | 
|---|
| 476 | last character of the instruction mnemonic.  Mnemonic suffixes of | 
|---|
| 477 | `b', `w', `l' and `q' specify byte (8-bit), word (16-bit), long | 
|---|
| 478 | (32-bit) and quadruple word (64-bit) memory references.  Intel | 
|---|
| 479 | syntax accomplishes this by prefixing memory operands (_not_ the | 
|---|
| 480 | instruction mnemonics) with `byte ptr', `word ptr', `dword ptr' | 
|---|
| 481 | and `qword ptr'.  Thus, Intel `mov al, byte ptr FOO' is `movb FOO, | 
|---|
| 482 | %al' in AT&T syntax. | 
|---|
| 483 |  | 
|---|
| 484 | * Immediate form long jumps and calls are `lcall/ljmp $SECTION, | 
|---|
| 485 | $OFFSET' in AT&T syntax; the Intel syntax is `call/jmp far | 
|---|
| 486 | SECTION:OFFSET'.  Also, the far return instruction is `lret | 
|---|
| 487 | $STACK-ADJUST' in AT&T syntax; Intel syntax is `ret far | 
|---|
| 488 | STACK-ADJUST'. | 
|---|
| 489 |  | 
|---|
| 490 | * The AT&T assembler does not provide support for multiple section | 
|---|
| 491 | programs.  Unix style systems expect all programs to be single | 
|---|
| 492 | sections. | 
|---|
| 493 |  | 
|---|
| 494 |  | 
|---|
| 495 | File: as.info,  Node: i386-Mnemonics,  Next: i386-Regs,  Prev: i386-Syntax,  Up: i386-Dependent | 
|---|
| 496 |  | 
|---|
| 497 | Instruction Naming | 
|---|
| 498 | ------------------ | 
|---|
| 499 |  | 
|---|
| 500 | Instruction mnemonics are suffixed with one character modifiers which | 
|---|
| 501 | specify the size of operands.  The letters `b', `w', `l' and `q' | 
|---|
| 502 | specify byte, word, long and quadruple word operands.  If no suffix is | 
|---|
| 503 | specified by an instruction then `as' tries to fill in the missing | 
|---|
| 504 | suffix based on the destination register operand (the last one by | 
|---|
| 505 | convention).  Thus, `mov %ax, %bx' is equivalent to `movw %ax, %bx'; | 
|---|
| 506 | also, `mov $1, %bx' is equivalent to `movw $1, bx'.  Note that this is | 
|---|
| 507 | incompatible with the AT&T Unix assembler which assumes that a missing | 
|---|
| 508 | mnemonic suffix implies long operand size.  (This incompatibility does | 
|---|
| 509 | not affect compiler output since compilers always explicitly specify | 
|---|
| 510 | the mnemonic suffix.) | 
|---|
| 511 |  | 
|---|
| 512 | Almost all instructions have the same names in AT&T and Intel format. | 
|---|
| 513 | There are a few exceptions.  The sign extend and zero extend | 
|---|
| 514 | instructions need two sizes to specify them.  They need a size to | 
|---|
| 515 | sign/zero extend _from_ and a size to zero extend _to_.  This is | 
|---|
| 516 | accomplished by using two instruction mnemonic suffixes in AT&T syntax. | 
|---|
| 517 | Base names for sign extend and zero extend are `movs...' and `movz...' | 
|---|
| 518 | in AT&T syntax (`movsx' and `movzx' in Intel syntax).  The instruction | 
|---|
| 519 | mnemonic suffixes are tacked on to this base name, the _from_ suffix | 
|---|
| 520 | before the _to_ suffix.  Thus, `movsbl %al, %edx' is AT&T syntax for | 
|---|
| 521 | "move sign extend _from_ %al _to_ %edx."  Possible suffixes, thus, are | 
|---|
| 522 | `bl' (from byte to long), `bw' (from byte to word), `wl' (from word to | 
|---|
| 523 | long), `bq' (from byte to quadruple word), `wq' (from word to quadruple | 
|---|
| 524 | word), and `lq' (from long to quadruple word). | 
|---|
| 525 |  | 
|---|
| 526 | The Intel-syntax conversion instructions | 
|---|
| 527 |  | 
|---|
| 528 | * `cbw' -- sign-extend byte in `%al' to word in `%ax', | 
|---|
| 529 |  | 
|---|
| 530 | * `cwde' -- sign-extend word in `%ax' to long in `%eax', | 
|---|
| 531 |  | 
|---|
| 532 | * `cwd' -- sign-extend word in `%ax' to long in `%dx:%ax', | 
|---|
| 533 |  | 
|---|
| 534 | * `cdq' -- sign-extend dword in `%eax' to quad in `%edx:%eax', | 
|---|
| 535 |  | 
|---|
| 536 | * `cdqe' -- sign-extend dword in `%eax' to quad in `%rax' (x86-64 | 
|---|
| 537 | only), | 
|---|
| 538 |  | 
|---|
| 539 | * `cdo' -- sign-extend quad in `%rax' to octuple in `%rdx:%rax' | 
|---|
| 540 | (x86-64 only), | 
|---|
| 541 |  | 
|---|
| 542 | are called `cbtw', `cwtl', `cwtd', `cltd', `cltq', and `cqto' in AT&T | 
|---|
| 543 | naming.  `as' accepts either naming for these instructions. | 
|---|
| 544 |  | 
|---|
| 545 | Far call/jump instructions are `lcall' and `ljmp' in AT&T syntax, | 
|---|
| 546 | but are `call far' and `jump far' in Intel convention. | 
|---|
| 547 |  | 
|---|
| 548 |  | 
|---|
| 549 | File: as.info,  Node: i386-Regs,  Next: i386-Prefixes,  Prev: i386-Mnemonics,  Up: i386-Dependent | 
|---|
| 550 |  | 
|---|
| 551 | Register Naming | 
|---|
| 552 | --------------- | 
|---|
| 553 |  | 
|---|
| 554 | Register operands are always prefixed with `%'.  The 80386 registers | 
|---|
| 555 | consist of | 
|---|
| 556 |  | 
|---|
| 557 | * the 8 32-bit registers `%eax' (the accumulator), `%ebx', `%ecx', | 
|---|
| 558 | `%edx', `%edi', `%esi', `%ebp' (the frame pointer), and `%esp' | 
|---|
| 559 | (the stack pointer). | 
|---|
| 560 |  | 
|---|
| 561 | * the 8 16-bit low-ends of these: `%ax', `%bx', `%cx', `%dx', `%di', | 
|---|
| 562 | `%si', `%bp', and `%sp'. | 
|---|
| 563 |  | 
|---|
| 564 | * the 8 8-bit registers: `%ah', `%al', `%bh', `%bl', `%ch', `%cl', | 
|---|
| 565 | `%dh', and `%dl' (These are the high-bytes and low-bytes of `%ax', | 
|---|
| 566 | `%bx', `%cx', and `%dx') | 
|---|
| 567 |  | 
|---|
| 568 | * the 6 section registers `%cs' (code section), `%ds' (data | 
|---|
| 569 | section), `%ss' (stack section), `%es', `%fs', and `%gs'. | 
|---|
| 570 |  | 
|---|
| 571 | * the 3 processor control registers `%cr0', `%cr2', and `%cr3'. | 
|---|
| 572 |  | 
|---|
| 573 | * the 6 debug registers `%db0', `%db1', `%db2', `%db3', `%db6', and | 
|---|
| 574 | `%db7'. | 
|---|
| 575 |  | 
|---|
| 576 | * the 2 test registers `%tr6' and `%tr7'. | 
|---|
| 577 |  | 
|---|
| 578 | * the 8 floating point register stack `%st' or equivalently | 
|---|
| 579 | `%st(0)', `%st(1)', `%st(2)', `%st(3)', `%st(4)', `%st(5)', | 
|---|
| 580 | `%st(6)', and `%st(7)'.  These registers are overloaded by 8 MMX | 
|---|
| 581 | registers `%mm0', `%mm1', `%mm2', `%mm3', `%mm4', `%mm5', `%mm6' | 
|---|
| 582 | and `%mm7'. | 
|---|
| 583 |  | 
|---|
| 584 | * the 8 SSE registers registers `%xmm0', `%xmm1', `%xmm2', `%xmm3', | 
|---|
| 585 | `%xmm4', `%xmm5', `%xmm6' and `%xmm7'. | 
|---|
| 586 |  | 
|---|
| 587 | The AMD x86-64 architecture extends the register set by: | 
|---|
| 588 |  | 
|---|
| 589 | * enhancing the 8 32-bit registers to 64-bit: `%rax' (the | 
|---|
| 590 | accumulator), `%rbx', `%rcx', `%rdx', `%rdi', `%rsi', `%rbp' (the | 
|---|
| 591 | frame pointer), `%rsp' (the stack pointer) | 
|---|
| 592 |  | 
|---|
| 593 | * the 8 extended registers `%r8'-`%r15'. | 
|---|
| 594 |  | 
|---|
| 595 | * the 8 32-bit low ends of the extended registers: `%r8d'-`%r15d' | 
|---|
| 596 |  | 
|---|
| 597 | * the 8 16-bit low ends of the extended registers: `%r8w'-`%r15w' | 
|---|
| 598 |  | 
|---|
| 599 | * the 8 8-bit low ends of the extended registers: `%r8b'-`%r15b' | 
|---|
| 600 |  | 
|---|
| 601 | * the 4 8-bit registers: `%sil', `%dil', `%bpl', `%spl'. | 
|---|
| 602 |  | 
|---|
| 603 | * the 8 debug registers: `%db8'-`%db15'. | 
|---|
| 604 |  | 
|---|
| 605 | * the 8 SSE registers: `%xmm8'-`%xmm15'. | 
|---|
| 606 |  | 
|---|
| 607 |  | 
|---|
| 608 | File: as.info,  Node: i386-Prefixes,  Next: i386-Memory,  Prev: i386-Regs,  Up: i386-Dependent | 
|---|
| 609 |  | 
|---|
| 610 | Instruction Prefixes | 
|---|
| 611 | -------------------- | 
|---|
| 612 |  | 
|---|
| 613 | Instruction prefixes are used to modify the following instruction. | 
|---|
| 614 | They are used to repeat string instructions, to provide section | 
|---|
| 615 | overrides, to perform bus lock operations, and to change operand and | 
|---|
| 616 | address sizes.  (Most instructions that normally operate on 32-bit | 
|---|
| 617 | operands will use 16-bit operands if the instruction has an "operand | 
|---|
| 618 | size" prefix.)  Instruction prefixes are best written on the same line | 
|---|
| 619 | as the instruction they act upon. For example, the `scas' (scan string) | 
|---|
| 620 | instruction is repeated with: | 
|---|
| 621 |  | 
|---|
| 622 | repne scas %es:(%edi),%al | 
|---|
| 623 |  | 
|---|
| 624 | You may also place prefixes on the lines immediately preceding the | 
|---|
| 625 | instruction, but this circumvents checks that `as' does with prefixes, | 
|---|
| 626 | and will not work with all prefixes. | 
|---|
| 627 |  | 
|---|
| 628 | Here is a list of instruction prefixes: | 
|---|
| 629 |  | 
|---|
| 630 | * Section override prefixes `cs', `ds', `ss', `es', `fs', `gs'. | 
|---|
| 631 | These are automatically added by specifying using the | 
|---|
| 632 | SECTION:MEMORY-OPERAND form for memory references. | 
|---|
| 633 |  | 
|---|
| 634 | * Operand/Address size prefixes `data16' and `addr16' change 32-bit | 
|---|
| 635 | operands/addresses into 16-bit operands/addresses, while `data32' | 
|---|
| 636 | and `addr32' change 16-bit ones (in a `.code16' section) into | 
|---|
| 637 | 32-bit operands/addresses.  These prefixes _must_ appear on the | 
|---|
| 638 | same line of code as the instruction they modify. For example, in | 
|---|
| 639 | a 16-bit `.code16' section, you might write: | 
|---|
| 640 |  | 
|---|
| 641 | addr32 jmpl *(%ebx) | 
|---|
| 642 |  | 
|---|
| 643 | * The bus lock prefix `lock' inhibits interrupts during execution of | 
|---|
| 644 | the instruction it precedes.  (This is only valid with certain | 
|---|
| 645 | instructions; see a 80386 manual for details). | 
|---|
| 646 |  | 
|---|
| 647 | * The wait for coprocessor prefix `wait' waits for the coprocessor to | 
|---|
| 648 | complete the current instruction.  This should never be needed for | 
|---|
| 649 | the 80386/80387 combination. | 
|---|
| 650 |  | 
|---|
| 651 | * The `rep', `repe', and `repne' prefixes are added to string | 
|---|
| 652 | instructions to make them repeat `%ecx' times (`%cx' times if the | 
|---|
| 653 | current address size is 16-bits). | 
|---|
| 654 |  | 
|---|
| 655 | * The `rex' family of prefixes is used by x86-64 to encode | 
|---|
| 656 | extensions to i386 instruction set.  The `rex' prefix has four | 
|---|
| 657 | bits -- an operand size overwrite (`64') used to change operand | 
|---|
| 658 | size from 32-bit to 64-bit and X, Y and Z extensions bits used to | 
|---|
| 659 | extend the register set. | 
|---|
| 660 |  | 
|---|
| 661 | You may write the `rex' prefixes directly. The `rex64xyz' | 
|---|
| 662 | instruction emits `rex' prefix with all the bits set.  By omitting | 
|---|
| 663 | the `64', `x', `y' or `z' you may write other prefixes as well. | 
|---|
| 664 | Normally, there is no need to write the prefixes explicitly, since | 
|---|
| 665 | gas will automatically generate them based on the instruction | 
|---|
| 666 | operands. | 
|---|
| 667 |  | 
|---|
| 668 |  | 
|---|
| 669 | File: as.info,  Node: i386-Memory,  Next: i386-Jumps,  Prev: i386-Prefixes,  Up: i386-Dependent | 
|---|
| 670 |  | 
|---|
| 671 | Memory References | 
|---|
| 672 | ----------------- | 
|---|
| 673 |  | 
|---|
| 674 | An Intel syntax indirect memory reference of the form | 
|---|
| 675 |  | 
|---|
| 676 | SECTION:[BASE + INDEX*SCALE + DISP] | 
|---|
| 677 |  | 
|---|
| 678 | is translated into the AT&T syntax | 
|---|
| 679 |  | 
|---|
| 680 | SECTION:DISP(BASE, INDEX, SCALE) | 
|---|
| 681 |  | 
|---|
| 682 | where BASE and INDEX are the optional 32-bit base and index registers, | 
|---|
| 683 | DISP is the optional displacement, and SCALE, taking the values 1, 2, | 
|---|
| 684 | 4, and 8, multiplies INDEX to calculate the address of the operand.  If | 
|---|
| 685 | no SCALE is specified, SCALE is taken to be 1.  SECTION specifies the | 
|---|
| 686 | optional section register for the memory operand, and may override the | 
|---|
| 687 | default section register (see a 80386 manual for section register | 
|---|
| 688 | defaults). Note that section overrides in AT&T syntax _must_ be | 
|---|
| 689 | preceded by a `%'.  If you specify a section override which coincides | 
|---|
| 690 | with the default section register, `as' does _not_ output any section | 
|---|
| 691 | register override prefixes to assemble the given instruction.  Thus, | 
|---|
| 692 | section overrides can be specified to emphasize which section register | 
|---|
| 693 | is used for a given memory operand. | 
|---|
| 694 |  | 
|---|
| 695 | Here are some examples of Intel and AT&T style memory references: | 
|---|
| 696 |  | 
|---|
| 697 | AT&T: `-4(%ebp)', Intel:  `[ebp - 4]' | 
|---|
| 698 | BASE is `%ebp'; DISP is `-4'. SECTION is missing, and the default | 
|---|
| 699 | section is used (`%ss' for addressing with `%ebp' as the base | 
|---|
| 700 | register).  INDEX, SCALE are both missing. | 
|---|
| 701 |  | 
|---|
| 702 | AT&T: `foo(,%eax,4)', Intel: `[foo + eax*4]' | 
|---|
| 703 | INDEX is `%eax' (scaled by a SCALE 4); DISP is `foo'.  All other | 
|---|
| 704 | fields are missing.  The section register here defaults to `%ds'. | 
|---|
| 705 |  | 
|---|
| 706 | AT&T: `foo(,1)'; Intel `[foo]' | 
|---|
| 707 | This uses the value pointed to by `foo' as a memory operand.  Note | 
|---|
| 708 | that BASE and INDEX are both missing, but there is only _one_ `,'. | 
|---|
| 709 | This is a syntactic exception. | 
|---|
| 710 |  | 
|---|
| 711 | AT&T: `%gs:foo'; Intel `gs:foo' | 
|---|
| 712 | This selects the contents of the variable `foo' with section | 
|---|
| 713 | register SECTION being `%gs'. | 
|---|
| 714 |  | 
|---|
| 715 | Absolute (as opposed to PC relative) call and jump operands must be | 
|---|
| 716 | prefixed with `*'.  If no `*' is specified, `as' always chooses PC | 
|---|
| 717 | relative addressing for jump/call labels. | 
|---|
| 718 |  | 
|---|
| 719 | Any instruction that has a memory operand, but no register operand, | 
|---|
| 720 | _must_ specify its size (byte, word, long, or quadruple) with an | 
|---|
| 721 | instruction mnemonic suffix (`b', `w', `l' or `q', respectively). | 
|---|
| 722 |  | 
|---|
| 723 | The x86-64 architecture adds an RIP (instruction pointer relative) | 
|---|
| 724 | addressing.  This addressing mode is specified by using `rip' as a base | 
|---|
| 725 | register.  Only constant offsets are valid. For example: | 
|---|
| 726 |  | 
|---|
| 727 | AT&T: `1234(%rip)', Intel: `[rip + 1234]' | 
|---|
| 728 | Points to the address 1234 bytes past the end of the current | 
|---|
| 729 | instruction. | 
|---|
| 730 |  | 
|---|
| 731 | AT&T: `symbol(%rip)', Intel: `[rip + symbol]' | 
|---|
| 732 | Points to the `symbol' in RIP relative way, this is shorter than | 
|---|
| 733 | the default absolute addressing. | 
|---|
| 734 |  | 
|---|
| 735 | Other addressing modes remain unchanged in x86-64 architecture, | 
|---|
| 736 | except registers used are 64-bit instead of 32-bit. | 
|---|
| 737 |  | 
|---|
| 738 |  | 
|---|
| 739 | File: as.info,  Node: i386-Jumps,  Next: i386-Float,  Prev: i386-Memory,  Up: i386-Dependent | 
|---|
| 740 |  | 
|---|
| 741 | Handling of Jump Instructions | 
|---|
| 742 | ----------------------------- | 
|---|
| 743 |  | 
|---|
| 744 | Jump instructions are always optimized to use the smallest possible | 
|---|
| 745 | displacements.  This is accomplished by using byte (8-bit) displacement | 
|---|
| 746 | jumps whenever the target is sufficiently close.  If a byte displacement | 
|---|
| 747 | is insufficient a long displacement is used.  We do not support word | 
|---|
| 748 | (16-bit) displacement jumps in 32-bit mode (i.e. prefixing the jump | 
|---|
| 749 | instruction with the `data16' instruction prefix), since the 80386 | 
|---|
| 750 | insists upon masking `%eip' to 16 bits after the word displacement is | 
|---|
| 751 | added. (See also *note i386-Arch::) | 
|---|
| 752 |  | 
|---|
| 753 | Note that the `jcxz', `jecxz', `loop', `loopz', `loope', `loopnz' | 
|---|
| 754 | and `loopne' instructions only come in byte displacements, so that if | 
|---|
| 755 | you use these instructions (`gcc' does not use them) you may get an | 
|---|
| 756 | error message (and incorrect code).  The AT&T 80386 assembler tries to | 
|---|
| 757 | get around this problem by expanding `jcxz foo' to | 
|---|
| 758 |  | 
|---|
| 759 | jcxz cx_zero | 
|---|
| 760 | jmp cx_nonzero | 
|---|
| 761 | cx_zero: jmp foo | 
|---|
| 762 | cx_nonzero: | 
|---|
| 763 |  | 
|---|
| 764 |  | 
|---|
| 765 | File: as.info,  Node: i386-Float,  Next: i386-SIMD,  Prev: i386-Jumps,  Up: i386-Dependent | 
|---|
| 766 |  | 
|---|
| 767 | Floating Point | 
|---|
| 768 | -------------- | 
|---|
| 769 |  | 
|---|
| 770 | All 80387 floating point types except packed BCD are supported. | 
|---|
| 771 | (BCD support may be added without much difficulty).  These data types | 
|---|
| 772 | are 16-, 32-, and 64- bit integers, and single (32-bit), double | 
|---|
| 773 | (64-bit), and extended (80-bit) precision floating point.  Each | 
|---|
| 774 | supported type has an instruction mnemonic suffix and a constructor | 
|---|
| 775 | associated with it.  Instruction mnemonic suffixes specify the operand's | 
|---|
| 776 | data type.  Constructors build these data types into memory. | 
|---|
| 777 |  | 
|---|
| 778 | * Floating point constructors are `.float' or `.single', `.double', | 
|---|
| 779 | and `.tfloat' for 32-, 64-, and 80-bit formats.  These correspond | 
|---|
| 780 | to instruction mnemonic suffixes `s', `l', and `t'. `t' stands for | 
|---|
| 781 | 80-bit (ten byte) real.  The 80387 only supports this format via | 
|---|
| 782 | the `fldt' (load 80-bit real to stack top) and `fstpt' (store | 
|---|
| 783 | 80-bit real and pop stack) instructions. | 
|---|
| 784 |  | 
|---|
| 785 | * Integer constructors are `.word', `.long' or `.int', and `.quad' | 
|---|
| 786 | for the 16-, 32-, and 64-bit integer formats.  The corresponding | 
|---|
| 787 | instruction mnemonic suffixes are `s' (single), `l' (long), and | 
|---|
| 788 | `q' (quad).  As with the 80-bit real format, the 64-bit `q' format | 
|---|
| 789 | is only present in the `fildq' (load quad integer to stack top) | 
|---|
| 790 | and `fistpq' (store quad integer and pop stack) instructions. | 
|---|
| 791 |  | 
|---|
| 792 | Register to register operations should not use instruction mnemonic | 
|---|
| 793 | suffixes.  `fstl %st, %st(1)' will give a warning, and be assembled as | 
|---|
| 794 | if you wrote `fst %st, %st(1)', since all register to register | 
|---|
| 795 | operations use 80-bit floating point operands. (Contrast this with | 
|---|
| 796 | `fstl %st, mem', which converts `%st' from 80-bit to 64-bit floating | 
|---|
| 797 | point format, then stores the result in the 4 byte location `mem') | 
|---|
| 798 |  | 
|---|
| 799 |  | 
|---|
| 800 | File: as.info,  Node: i386-SIMD,  Next: i386-16bit,  Prev: i386-Float,  Up: i386-Dependent | 
|---|
| 801 |  | 
|---|
| 802 | Intel's MMX and AMD's 3DNow! SIMD Operations | 
|---|
| 803 | -------------------------------------------- | 
|---|
| 804 |  | 
|---|
| 805 | `as' supports Intel's MMX instruction set (SIMD instructions for | 
|---|
| 806 | integer data), available on Intel's Pentium MMX processors and Pentium | 
|---|
| 807 | II processors, AMD's K6 and K6-2 processors, Cyrix' M2 processor, and | 
|---|
| 808 | probably others.  It also supports AMD's 3DNow!  instruction set (SIMD | 
|---|
| 809 | instructions for 32-bit floating point data) available on AMD's K6-2 | 
|---|
| 810 | processor and possibly others in the future. | 
|---|
| 811 |  | 
|---|
| 812 | Currently, `as' does not support Intel's floating point SIMD, Katmai | 
|---|
| 813 | (KNI). | 
|---|
| 814 |  | 
|---|
| 815 | The eight 64-bit MMX operands, also used by 3DNow!, are called | 
|---|
| 816 | `%mm0', `%mm1', ... `%mm7'.  They contain eight 8-bit integers, four | 
|---|
| 817 | 16-bit integers, two 32-bit integers, one 64-bit integer, or two 32-bit | 
|---|
| 818 | floating point values.  The MMX registers cannot be used at the same | 
|---|
| 819 | time as the floating point stack. | 
|---|
| 820 |  | 
|---|
| 821 | See Intel and AMD documentation, keeping in mind that the operand | 
|---|
| 822 | order in instructions is reversed from the Intel syntax. | 
|---|
| 823 |  | 
|---|
| 824 |  | 
|---|
| 825 | File: as.info,  Node: i386-16bit,  Next: i386-Arch,  Prev: i386-SIMD,  Up: i386-Dependent | 
|---|
| 826 |  | 
|---|
| 827 | Writing 16-bit Code | 
|---|
| 828 | ------------------- | 
|---|
| 829 |  | 
|---|
| 830 | While `as' normally writes only "pure" 32-bit i386 code or 64-bit | 
|---|
| 831 | x86-64 code depending on the default configuration, it also supports | 
|---|
| 832 | writing code to run in real mode or in 16-bit protected mode code | 
|---|
| 833 | segments.  To do this, put a `.code16' or `.code16gcc' directive before | 
|---|
| 834 | the assembly language instructions to be run in 16-bit mode.  You can | 
|---|
| 835 | switch `as' back to writing normal 32-bit code with the `.code32' | 
|---|
| 836 | directive. | 
|---|
| 837 |  | 
|---|
| 838 | `.code16gcc' provides experimental support for generating 16-bit | 
|---|
| 839 | code from gcc, and differs from `.code16' in that `call', `ret', | 
|---|
| 840 | `enter', `leave', `push', `pop', `pusha', `popa', `pushf', and `popf' | 
|---|
| 841 | instructions default to 32-bit size.  This is so that the stack pointer | 
|---|
| 842 | is manipulated in the same way over function calls, allowing access to | 
|---|
| 843 | function parameters at the same stack offsets as in 32-bit mode. | 
|---|
| 844 | `.code16gcc' also automatically adds address size prefixes where | 
|---|
| 845 | necessary to use the 32-bit addressing modes that gcc generates. | 
|---|
| 846 |  | 
|---|
| 847 | The code which `as' generates in 16-bit mode will not necessarily | 
|---|
| 848 | run on a 16-bit pre-80386 processor.  To write code that runs on such a | 
|---|
| 849 | processor, you must refrain from using _any_ 32-bit constructs which | 
|---|
| 850 | require `as' to output address or operand size prefixes. | 
|---|
| 851 |  | 
|---|
| 852 | Note that writing 16-bit code instructions by explicitly specifying a | 
|---|
| 853 | prefix or an instruction mnemonic suffix within a 32-bit code section | 
|---|
| 854 | generates different machine instructions than those generated for a | 
|---|
| 855 | 16-bit code segment.  In a 32-bit code section, the following code | 
|---|
| 856 | generates the machine opcode bytes `66 6a 04', which pushes the value | 
|---|
| 857 | `4' onto the stack, decrementing `%esp' by 2. | 
|---|
| 858 |  | 
|---|
| 859 | pushw $4 | 
|---|
| 860 |  | 
|---|
| 861 | The same code in a 16-bit code section would generate the machine | 
|---|
| 862 | opcode bytes `6a 04' (ie. without the operand size prefix), which is | 
|---|
| 863 | correct since the processor default operand size is assumed to be 16 | 
|---|
| 864 | bits in a 16-bit code section. | 
|---|
| 865 |  | 
|---|
| 866 |  | 
|---|
| 867 | File: as.info,  Node: i386-Bugs,  Next: i386-Notes,  Prev: i386-Arch,  Up: i386-Dependent | 
|---|
| 868 |  | 
|---|
| 869 | AT&T Syntax bugs | 
|---|
| 870 | ---------------- | 
|---|
| 871 |  | 
|---|
| 872 | The UnixWare assembler, and probably other AT&T derived ix86 Unix | 
|---|
| 873 | assemblers, generate floating point instructions with reversed source | 
|---|
| 874 | and destination registers in certain cases.  Unfortunately, gcc and | 
|---|
| 875 | possibly many other programs use this reversed syntax, so we're stuck | 
|---|
| 876 | with it. | 
|---|
| 877 |  | 
|---|
| 878 | For example | 
|---|
| 879 |  | 
|---|
| 880 | fsub %st,%st(3) | 
|---|
| 881 |  | 
|---|
| 882 | results in `%st(3)' being updated to `%st - %st(3)' rather than the | 
|---|
| 883 | expected `%st(3) - %st'.  This happens with all the non-commutative | 
|---|
| 884 | arithmetic floating point operations with two register operands where | 
|---|
| 885 | the source register is `%st' and the destination register is `%st(i)'. | 
|---|
| 886 |  | 
|---|
| 887 |  | 
|---|
| 888 | File: as.info,  Node: i386-Arch,  Next: i386-Bugs,  Prev: i386-16bit,  Up: i386-Dependent | 
|---|
| 889 |  | 
|---|
| 890 | Specifying CPU Architecture | 
|---|
| 891 | --------------------------- | 
|---|
| 892 |  | 
|---|
| 893 | `as' may be told to assemble for a particular CPU architecture with | 
|---|
| 894 | the `.arch CPU_TYPE' directive.  This directive enables a warning when | 
|---|
| 895 | gas detects an instruction that is not supported on the CPU specified. | 
|---|
| 896 | The choices for CPU_TYPE are: | 
|---|
| 897 |  | 
|---|
| 898 | `i8086'        `i186'         `i286'         `i386' | 
|---|
| 899 | `i486'         `i586'         `i686'         `pentium' | 
|---|
| 900 | `pentiumpro'   `pentium4'     `k6'           `athlon' | 
|---|
| 901 | `sledgehammer' | 
|---|
| 902 |  | 
|---|
| 903 | Apart from the warning, there are only two other effects on `as' | 
|---|
| 904 | operation;  Firstly, if you specify a CPU other than `i486', then shift | 
|---|
| 905 | by one instructions such as `sarl $1, %eax' will automatically use a | 
|---|
| 906 | two byte opcode sequence.  The larger three byte opcode sequence is | 
|---|
| 907 | used on the 486 (and when no architecture is specified) because it | 
|---|
| 908 | executes faster on the 486.  Note that you can explicitly request the | 
|---|
| 909 | two byte opcode by writing `sarl %eax'.  Secondly, if you specify | 
|---|
| 910 | `i8086', `i186', or `i286', _and_ `.code16' or `.code16gcc' then byte | 
|---|
| 911 | offset conditional jumps will be promoted when necessary to a two | 
|---|
| 912 | instruction sequence consisting of a conditional jump of the opposite | 
|---|
| 913 | sense around an unconditional jump to the target. | 
|---|
| 914 |  | 
|---|
| 915 | Following the CPU architecture, you may specify `jumps' or `nojumps' | 
|---|
| 916 | to control automatic promotion of conditional jumps.  `jumps' is the | 
|---|
| 917 | default, and enables jump promotion;  All external jumps will be of the | 
|---|
| 918 | long variety, and file-local jumps will be promoted as necessary. | 
|---|
| 919 | (*note i386-Jumps::)  `nojumps' leaves external conditional jumps as | 
|---|
| 920 | byte offset jumps, and warns about file-local conditional jumps that | 
|---|
| 921 | `as' promotes.  Unconditional jumps are treated as for `jumps'. | 
|---|
| 922 |  | 
|---|
| 923 | For example | 
|---|
| 924 |  | 
|---|
| 925 | .arch i8086,nojumps | 
|---|
| 926 |  | 
|---|
| 927 |  | 
|---|
| 928 | File: as.info,  Node: i386-Notes,  Prev: i386-Bugs,  Up: i386-Dependent | 
|---|
| 929 |  | 
|---|
| 930 | Notes | 
|---|
| 931 | ----- | 
|---|
| 932 |  | 
|---|
| 933 | There is some trickery concerning the `mul' and `imul' instructions | 
|---|
| 934 | that deserves mention.  The 16-, 32-, 64- and 128-bit expanding | 
|---|
| 935 | multiplies (base opcode `0xf6'; extension 4 for `mul' and 5 for `imul') | 
|---|
| 936 | can be output only in the one operand form.  Thus, `imul %ebx, %eax' | 
|---|
| 937 | does _not_ select the expanding multiply; the expanding multiply would | 
|---|
| 938 | clobber the `%edx' register, and this would confuse `gcc' output.  Use | 
|---|
| 939 | `imul %ebx' to get the 64-bit product in `%edx:%eax'. | 
|---|
| 940 |  | 
|---|
| 941 | We have added a two operand form of `imul' when the first operand is | 
|---|
| 942 | an immediate mode expression and the second operand is a register. | 
|---|
| 943 | This is just a shorthand, so that, multiplying `%eax' by 69, for | 
|---|
| 944 | example, can be done with `imul $69, %eax' rather than `imul $69, %eax, | 
|---|
| 945 | %eax'. | 
|---|
| 946 |  | 
|---|
| 947 |  | 
|---|
| 948 | File: as.info,  Node: i860-Dependent,  Next: i960-Dependent,  Prev: i386-Dependent,  Up: Machine Dependencies | 
|---|
| 949 |  | 
|---|
| 950 | Intel i860 Dependent Features | 
|---|
| 951 | ============================= | 
|---|
| 952 |  | 
|---|
| 953 | * Menu: | 
|---|
| 954 |  | 
|---|
| 955 | * Notes-i860::                  i860 Notes | 
|---|
| 956 | * Options-i860::                i860 Command-line Options | 
|---|
| 957 | * Directives-i860::             i860 Machine Directives | 
|---|
| 958 | * Opcodes for i860::            i860 Opcodes | 
|---|
| 959 |  | 
|---|
| 960 |  | 
|---|
| 961 | File: as.info,  Node: Notes-i860,  Next: Options-i860,  Up: i860-Dependent | 
|---|
| 962 |  | 
|---|
| 963 | i860 Notes | 
|---|
| 964 | ---------- | 
|---|
| 965 |  | 
|---|
| 966 | This is a fairly complete i860 assembler which is compatible with the | 
|---|
| 967 | UNIX System V/860 Release 4 assembler. However, it does not currently | 
|---|
| 968 | support SVR4 PIC (i.e., `@GOT, @GOTOFF, @PLT'). | 
|---|
| 969 |  | 
|---|
| 970 | Like the SVR4/860 assembler, the output object format is ELF32. | 
|---|
| 971 | Currently, this is the only supported object format. If there is | 
|---|
| 972 | sufficient interest, other formats such as COFF may be implemented. | 
|---|
| 973 |  | 
|---|
| 974 |  | 
|---|
| 975 | File: as.info,  Node: Options-i860,  Next: Directives-i860,  Prev: Notes-i860,  Up: i860-Dependent | 
|---|
| 976 |  | 
|---|
| 977 | i860 Command-line Options | 
|---|
| 978 | ------------------------- | 
|---|
| 979 |  | 
|---|
| 980 | SVR4 compatibility options | 
|---|
| 981 | .......................... | 
|---|
| 982 |  | 
|---|
| 983 | `-V' | 
|---|
| 984 | Print assembler version. | 
|---|
| 985 |  | 
|---|
| 986 | `-Qy' | 
|---|
| 987 | Ignored. | 
|---|
| 988 |  | 
|---|
| 989 | `-Qn' | 
|---|
| 990 | Ignored. | 
|---|
| 991 |  | 
|---|
| 992 | Other options | 
|---|
| 993 | ............. | 
|---|
| 994 |  | 
|---|
| 995 | `-EL' | 
|---|
| 996 | Select little endian output (this is the default). | 
|---|
| 997 |  | 
|---|
| 998 | `-EB' | 
|---|
| 999 | Select big endian output. Note that the i860 always reads | 
|---|
| 1000 | instructions as little endian data, so this option only effects | 
|---|
| 1001 | data and not instructions. | 
|---|
| 1002 |  | 
|---|
| 1003 | `-mwarn-expand' | 
|---|
| 1004 | Emit a warning message if any pseudo-instruction expansions | 
|---|
| 1005 | occurred.  For example, a `or' instruction with an immediate | 
|---|
| 1006 | larger than 16-bits will be expanded into two instructions. This | 
|---|
| 1007 | is a very undesirable feature to rely on, so this flag can help | 
|---|
| 1008 | detect any code where it happens. One use of it, for instance, has | 
|---|
| 1009 | been to find and eliminate any place where `gcc' may emit these | 
|---|
| 1010 | pseudo-instructions. | 
|---|
| 1011 |  | 
|---|
| 1012 |  | 
|---|
| 1013 | File: as.info,  Node: Directives-i860,  Next: Opcodes for i860,  Prev: Options-i860,  Up: i860-Dependent | 
|---|
| 1014 |  | 
|---|
| 1015 | i860 Machine Directives | 
|---|
| 1016 | ----------------------- | 
|---|
| 1017 |  | 
|---|
| 1018 | `.dual' | 
|---|
| 1019 | Enter dual instruction mode. While this directive is supported, the | 
|---|
| 1020 | preferred way to use dual instruction mode is to explicitly code | 
|---|
| 1021 | the dual bit with the `d.' prefix. | 
|---|
| 1022 |  | 
|---|
| 1023 | `.enddual' | 
|---|
| 1024 | Exit dual instruction mode. While this directive is supported, the | 
|---|
| 1025 | preferred way to use dual instruction mode is to explicitly code | 
|---|
| 1026 | the dual bit with the `d.' prefix. | 
|---|
| 1027 |  | 
|---|
| 1028 | `.atmp' | 
|---|
| 1029 | Change the temporary register used when expanding pseudo | 
|---|
| 1030 | operations. The default register is `r31'. | 
|---|
| 1031 |  | 
|---|
| 1032 |  | 
|---|
| 1033 | File: as.info,  Node: Opcodes for i860,  Prev: Directives-i860,  Up: i860-Dependent | 
|---|
| 1034 |  | 
|---|
| 1035 | i860 Opcodes | 
|---|
| 1036 | ------------ | 
|---|
| 1037 |  | 
|---|
| 1038 | All of the Intel i860 machine instructions are supported. Please see | 
|---|
| 1039 | either _i860 Microprocessor Programmer's Reference Manual_ or _i860 | 
|---|
| 1040 | Microprocessor Architecture_ for more information. | 
|---|
| 1041 |  | 
|---|
| 1042 | Other instruction support (pseudo-instructions) | 
|---|
| 1043 | ............................................... | 
|---|
| 1044 |  | 
|---|
| 1045 | For compatibility with some other i860 assemblers, a number of | 
|---|
| 1046 | pseudo-instructions are supported. While these are supported, they are | 
|---|
| 1047 | a very undesirable feature that should be avoided - in particular, when | 
|---|
| 1048 | they result in an expansion to multiple actual i860 instructions. Below | 
|---|
| 1049 | are the pseudo-instructions that result in expansions. | 
|---|
| 1050 | * Load large immediate into general register: | 
|---|
| 1051 |  | 
|---|
| 1052 | The pseudo-instruction `mov imm,%rn' (where the immediate does not | 
|---|
| 1053 | fit within a signed 16-bit field) will be expanded into: | 
|---|
| 1054 | orh large_imm@h,%r0,%rn | 
|---|
| 1055 | or large_imm@l,%rn,%rn | 
|---|
| 1056 |  | 
|---|
| 1057 | * Load/store with relocatable address expression: | 
|---|
| 1058 |  | 
|---|
| 1059 | For example, the pseudo-instruction `ld.b addr,%rn' will be | 
|---|
| 1060 | expanded into: | 
|---|
| 1061 | orh addr_exp@ha,%r0,%r31 | 
|---|
| 1062 | ld.l addr_exp@l(%r31),%rn | 
|---|
| 1063 |  | 
|---|
| 1064 | The analogous expansions apply to `ld.x, st.x, fld.x, pfld.x, | 
|---|
| 1065 | fst.x', and `pst.x' as well. | 
|---|
| 1066 |  | 
|---|
| 1067 | * Signed large immediate with add/subtract: | 
|---|
| 1068 |  | 
|---|
| 1069 | If any of the arithmetic operations `adds, addu, subs, subu' are | 
|---|
| 1070 | used with an immediate larger than 16-bits (signed), then they | 
|---|
| 1071 | will be expanded.  For instance, the pseudo-instruction `adds | 
|---|
| 1072 | large_imm,%rx,%rn' expands to: | 
|---|
| 1073 | orh large_imm@h,%r0,%r31 | 
|---|
| 1074 | or large_imm@l,%r31,%r31 | 
|---|
| 1075 | adds %r31,%rx,%rn | 
|---|
| 1076 |  | 
|---|
| 1077 | * Unsigned large immediate with logical operations: | 
|---|
| 1078 |  | 
|---|
| 1079 | Logical operations (`or, andnot, or, xor') also result in | 
|---|
| 1080 | expansions.  The pseudo-instruction `or large_imm,%rx,%rn' results | 
|---|
| 1081 | in: | 
|---|
| 1082 | orh large_imm@h,%rx,%r31 | 
|---|
| 1083 | or large_imm@l,%r31,%rn | 
|---|
| 1084 |  | 
|---|
| 1085 | Similarly for the others, except for `and' which expands to: | 
|---|
| 1086 | andnot (-1 - large_imm)@h,%rx,%r31 | 
|---|
| 1087 | andnot (-1 - large_imm)@l,%r31,%rn | 
|---|
| 1088 |  | 
|---|
| 1089 |  | 
|---|
| 1090 | File: as.info,  Node: i960-Dependent,  Next: IP2K-Dependent,  Prev: i860-Dependent,  Up: Machine Dependencies | 
|---|
| 1091 |  | 
|---|
| 1092 | Intel 80960 Dependent Features | 
|---|
| 1093 | ============================== | 
|---|
| 1094 |  | 
|---|
| 1095 | * Menu: | 
|---|
| 1096 |  | 
|---|
| 1097 | * Options-i960::                i960 Command-line Options | 
|---|
| 1098 | * Floating Point-i960::         Floating Point | 
|---|
| 1099 | * Directives-i960::             i960 Machine Directives | 
|---|
| 1100 | * Opcodes for i960::            i960 Opcodes | 
|---|
| 1101 |  | 
|---|
| 1102 |  | 
|---|
| 1103 | File: as.info,  Node: Options-i960,  Next: Floating Point-i960,  Up: i960-Dependent | 
|---|
| 1104 |  | 
|---|
| 1105 | i960 Command-line Options | 
|---|
| 1106 | ------------------------- | 
|---|
| 1107 |  | 
|---|
| 1108 | `-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC' | 
|---|
| 1109 | Select the 80960 architecture.  Instructions or features not | 
|---|
| 1110 | supported by the selected architecture cause fatal errors. | 
|---|
| 1111 |  | 
|---|
| 1112 | `-ACA' is equivalent to `-ACA_A'; `-AKC' is equivalent to `-AMC'. | 
|---|
| 1113 | Synonyms are provided for compatibility with other tools. | 
|---|
| 1114 |  | 
|---|
| 1115 | If you do not specify any of these options, `as' generates code | 
|---|
| 1116 | for any instruction or feature that is supported by _some_ version | 
|---|
| 1117 | of the 960 (even if this means mixing architectures!).  In | 
|---|
| 1118 | principle, `as' attempts to deduce the minimal sufficient | 
|---|
| 1119 | processor type if none is specified; depending on the object code | 
|---|
| 1120 | format, the processor type may be recorded in the object file.  If | 
|---|
| 1121 | it is critical that the `as' output match a specific architecture, | 
|---|
| 1122 | specify that architecture explicitly. | 
|---|
| 1123 |  | 
|---|
| 1124 | `-b' | 
|---|
| 1125 | Add code to collect information about conditional branches taken, | 
|---|
| 1126 | for later optimization using branch prediction bits.  (The | 
|---|
| 1127 | conditional branch instructions have branch prediction bits in the | 
|---|
| 1128 | CA, CB, and CC architectures.)  If BR represents a conditional | 
|---|
| 1129 | branch instruction, the following represents the code generated by | 
|---|
| 1130 | the assembler when `-b' is specified: | 
|---|
| 1131 |  | 
|---|
| 1132 | call    INCREMENT ROUTINE | 
|---|
| 1133 | .word   0       # pre-counter | 
|---|
| 1134 | Label:  BR | 
|---|
| 1135 | call    INCREMENT ROUTINE | 
|---|
| 1136 | .word   0       # post-counter | 
|---|
| 1137 |  | 
|---|
| 1138 | The counter following a branch records the number of times that | 
|---|
| 1139 | branch was _not_ taken; the differenc between the two counters is | 
|---|
| 1140 | the number of times the branch _was_ taken. | 
|---|
| 1141 |  | 
|---|
| 1142 | A table of every such `Label' is also generated, so that the | 
|---|
| 1143 | external postprocessor `gbr960' (supplied by Intel) can locate all | 
|---|
| 1144 | the counters.  This table is always labeled `__BRANCH_TABLE__'; | 
|---|
| 1145 | this is a local symbol to permit collecting statistics for many | 
|---|
| 1146 | separate object files.  The table is word aligned, and begins with | 
|---|
| 1147 | a two-word header.  The first word, initialized to 0, is used in | 
|---|
| 1148 | maintaining linked lists of branch tables.  The second word is a | 
|---|
| 1149 | count of the number of entries in the table, which follow | 
|---|
| 1150 | immediately: each is a word, pointing to one of the labels | 
|---|
| 1151 | illustrated above. | 
|---|
| 1152 |  | 
|---|
| 1153 | +------------+------------+------------+ ... +------------+ | 
|---|
| 1154 | |            |            |            |     |            | | 
|---|
| 1155 | |  *NEXT     |  COUNT: N  | *BRLAB 1   |     | *BRLAB N   | | 
|---|
| 1156 | |            |            |            |     |            | | 
|---|
| 1157 | +------------+------------+------------+ ... +------------+ | 
|---|
| 1158 |  | 
|---|
| 1159 | __BRANCH_TABLE__ layout | 
|---|
| 1160 |  | 
|---|
| 1161 | The first word of the header is used to locate multiple branch | 
|---|
| 1162 | tables, since each object file may contain one. Normally the links | 
|---|
| 1163 | are maintained with a call to an initialization routine, placed at | 
|---|
| 1164 | the beginning of each function in the file.  The GNU C compiler | 
|---|
| 1165 | generates these calls automatically when you give it a `-b' option. | 
|---|
| 1166 | For further details, see the documentation of `gbr960'. | 
|---|
| 1167 |  | 
|---|
| 1168 | `-no-relax' | 
|---|
| 1169 | Normally, Compare-and-Branch instructions with targets that require | 
|---|
| 1170 | displacements greater than 13 bits (or that have external targets) | 
|---|
| 1171 | are replaced with the corresponding compare (or `chkbit') and | 
|---|
| 1172 | branch instructions.  You can use the `-no-relax' option to | 
|---|
| 1173 | specify that `as' should generate errors instead, if the target | 
|---|
| 1174 | displacement is larger than 13 bits. | 
|---|
| 1175 |  | 
|---|
| 1176 | This option does not affect the Compare-and-Jump instructions; the | 
|---|
| 1177 | code emitted for them is _always_ adjusted when necessary | 
|---|
| 1178 | (depending on displacement size), regardless of whether you use | 
|---|
| 1179 | `-no-relax'. | 
|---|
| 1180 |  | 
|---|
| 1181 |  | 
|---|
| 1182 | File: as.info,  Node: Floating Point-i960,  Next: Directives-i960,  Prev: Options-i960,  Up: i960-Dependent | 
|---|
| 1183 |  | 
|---|
| 1184 | Floating Point | 
|---|
| 1185 | -------------- | 
|---|
| 1186 |  | 
|---|
| 1187 | `as' generates IEEE floating-point numbers for the directives | 
|---|
| 1188 | `.float', `.double', `.extended', and `.single'. | 
|---|
| 1189 |  | 
|---|
| 1190 |  | 
|---|
| 1191 | File: as.info,  Node: Directives-i960,  Next: Opcodes for i960,  Prev: Floating Point-i960,  Up: i960-Dependent | 
|---|
| 1192 |  | 
|---|
| 1193 | i960 Machine Directives | 
|---|
| 1194 | ----------------------- | 
|---|
| 1195 |  | 
|---|
| 1196 | `.bss SYMBOL, LENGTH, ALIGN' | 
|---|
| 1197 | Reserve LENGTH bytes in the bss section for a local SYMBOL, | 
|---|
| 1198 | aligned to the power of two specified by ALIGN.  LENGTH and ALIGN | 
|---|
| 1199 | must be positive absolute expressions.  This directive differs | 
|---|
| 1200 | from `.lcomm' only in that it permits you to specify an alignment. | 
|---|
| 1201 | *Note `.lcomm': Lcomm. | 
|---|
| 1202 |  | 
|---|
| 1203 | `.extended FLONUMS' | 
|---|
| 1204 | `.extended' expects zero or more flonums, separated by commas; for | 
|---|
| 1205 | each flonum, `.extended' emits an IEEE extended-format (80-bit) | 
|---|
| 1206 | floating-point number. | 
|---|
| 1207 |  | 
|---|
| 1208 | `.leafproc CALL-LAB, BAL-LAB' | 
|---|
| 1209 | You can use the `.leafproc' directive in conjunction with the | 
|---|
| 1210 | optimized `callj' instruction to enable faster calls of leaf | 
|---|
| 1211 | procedures.  If a procedure is known to call no other procedures, | 
|---|
| 1212 | you may define an entry point that skips procedure prolog code | 
|---|
| 1213 | (and that does not depend on system-supplied saved context), and | 
|---|
| 1214 | declare it as the BAL-LAB using `.leafproc'.  If the procedure | 
|---|
| 1215 | also has an entry point that goes through the normal prolog, you | 
|---|
| 1216 | can specify that entry point as CALL-LAB. | 
|---|
| 1217 |  | 
|---|
| 1218 | A `.leafproc' declaration is meant for use in conjunction with the | 
|---|
| 1219 | optimized call instruction `callj'; the directive records the data | 
|---|
| 1220 | needed later to choose between converting the `callj' into a `bal' | 
|---|
| 1221 | or a `call'. | 
|---|
| 1222 |  | 
|---|
| 1223 | CALL-LAB is optional; if only one argument is present, or if the | 
|---|
| 1224 | two arguments are identical, the single argument is assumed to be | 
|---|
| 1225 | the `bal' entry point. | 
|---|
| 1226 |  | 
|---|
| 1227 | `.sysproc NAME, INDEX' | 
|---|
| 1228 | The `.sysproc' directive defines a name for a system procedure. | 
|---|
| 1229 | After you define it using `.sysproc', you can use NAME to refer to | 
|---|
| 1230 | the system procedure identified by INDEX when calling procedures | 
|---|
| 1231 | with the optimized call instruction `callj'. | 
|---|
| 1232 |  | 
|---|
| 1233 | Both arguments are required; INDEX must be between 0 and 31 | 
|---|
| 1234 | (inclusive). | 
|---|
| 1235 |  | 
|---|
| 1236 |  | 
|---|
| 1237 | File: as.info,  Node: Opcodes for i960,  Prev: Directives-i960,  Up: i960-Dependent | 
|---|
| 1238 |  | 
|---|
| 1239 | i960 Opcodes | 
|---|
| 1240 | ------------ | 
|---|
| 1241 |  | 
|---|
| 1242 | All Intel 960 machine instructions are supported; *note i960 | 
|---|
| 1243 | Command-line Options: Options-i960. for a discussion of selecting the | 
|---|
| 1244 | instruction subset for a particular 960 architecture. | 
|---|
| 1245 |  | 
|---|
| 1246 | Some opcodes are processed beyond simply emitting a single | 
|---|
| 1247 | corresponding instruction: `callj', and Compare-and-Branch or | 
|---|
| 1248 | Compare-and-Jump instructions with target displacements larger than 13 | 
|---|
| 1249 | bits. | 
|---|
| 1250 |  | 
|---|
| 1251 | * Menu: | 
|---|
| 1252 |  | 
|---|
| 1253 | * callj-i960::                  `callj' | 
|---|
| 1254 | * Compare-and-branch-i960::     Compare-and-Branch | 
|---|
| 1255 |  | 
|---|