| 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: VAX-branch,  Next: VAX-operands,  Prev: VAX-opcodes,  Up: Vax-Dependent | 
|---|
| 22 |  | 
|---|
| 23 | VAX Branch Improvement | 
|---|
| 24 | ---------------------- | 
|---|
| 25 |  | 
|---|
| 26 | Certain pseudo opcodes are permitted.  They are for branch | 
|---|
| 27 | instructions.  They expand to the shortest branch instruction that | 
|---|
| 28 | reaches the target.  Generally these mnemonics are made by substituting | 
|---|
| 29 | `j' for `b' at the start of a DEC mnemonic.  This feature is included | 
|---|
| 30 | both for compatibility and to help compilers.  If you do not need this | 
|---|
| 31 | feature, avoid these opcodes.  Here are the mnemonics, and the code | 
|---|
| 32 | they can expand into. | 
|---|
| 33 |  | 
|---|
| 34 | `jbsb' | 
|---|
| 35 | `Jsb' is already an instruction mnemonic, so we chose `jbsb'. | 
|---|
| 36 | (byte displacement) | 
|---|
| 37 | `bsbb ...' | 
|---|
| 38 |  | 
|---|
| 39 | (word displacement) | 
|---|
| 40 | `bsbw ...' | 
|---|
| 41 |  | 
|---|
| 42 | (long displacement) | 
|---|
| 43 | `jsb ...' | 
|---|
| 44 |  | 
|---|
| 45 | `jbr' | 
|---|
| 46 | `jr' | 
|---|
| 47 | Unconditional branch. | 
|---|
| 48 | (byte displacement) | 
|---|
| 49 | `brb ...' | 
|---|
| 50 |  | 
|---|
| 51 | (word displacement) | 
|---|
| 52 | `brw ...' | 
|---|
| 53 |  | 
|---|
| 54 | (long displacement) | 
|---|
| 55 | `jmp ...' | 
|---|
| 56 |  | 
|---|
| 57 | `jCOND' | 
|---|
| 58 | COND may be any one of the conditional branches `neq', `nequ', | 
|---|
| 59 | `eql', `eqlu', `gtr', `geq', `lss', `gtru', `lequ', `vc', `vs', | 
|---|
| 60 | `gequ', `cc', `lssu', `cs'.  COND may also be one of the bit tests | 
|---|
| 61 | `bs', `bc', `bss', `bcs', `bsc', `bcc', `bssi', `bcci', `lbs', | 
|---|
| 62 | `lbc'.  NOTCOND is the opposite condition to COND. | 
|---|
| 63 | (byte displacement) | 
|---|
| 64 | `bCOND ...' | 
|---|
| 65 |  | 
|---|
| 66 | (word displacement) | 
|---|
| 67 | `bNOTCOND foo ; brw ... ; foo:' | 
|---|
| 68 |  | 
|---|
| 69 | (long displacement) | 
|---|
| 70 | `bNOTCOND foo ; jmp ... ; foo:' | 
|---|
| 71 |  | 
|---|
| 72 | `jacbX' | 
|---|
| 73 | X may be one of `b d f g h l w'. | 
|---|
| 74 | (word displacement) | 
|---|
| 75 | `OPCODE ...' | 
|---|
| 76 |  | 
|---|
| 77 | (long displacement) | 
|---|
| 78 | OPCODE ..., foo ; | 
|---|
| 79 | brb bar ; | 
|---|
| 80 | foo: jmp ... ; | 
|---|
| 81 | bar: | 
|---|
| 82 |  | 
|---|
| 83 | `jaobYYY' | 
|---|
| 84 | YYY may be one of `lss leq'. | 
|---|
| 85 |  | 
|---|
| 86 | `jsobZZZ' | 
|---|
| 87 | ZZZ may be one of `geq gtr'. | 
|---|
| 88 | (byte displacement) | 
|---|
| 89 | `OPCODE ...' | 
|---|
| 90 |  | 
|---|
| 91 | (word displacement) | 
|---|
| 92 | OPCODE ..., foo ; | 
|---|
| 93 | brb bar ; | 
|---|
| 94 | foo: brw DESTINATION ; | 
|---|
| 95 | bar: | 
|---|
| 96 |  | 
|---|
| 97 | (long displacement) | 
|---|
| 98 | OPCODE ..., foo ; | 
|---|
| 99 | brb bar ; | 
|---|
| 100 | foo: jmp DESTINATION ; | 
|---|
| 101 | bar: | 
|---|
| 102 |  | 
|---|
| 103 | `aobleq' | 
|---|
| 104 | `aoblss' | 
|---|
| 105 | `sobgeq' | 
|---|
| 106 | `sobgtr' | 
|---|
| 107 |  | 
|---|
| 108 | (byte displacement) | 
|---|
| 109 | `OPCODE ...' | 
|---|
| 110 |  | 
|---|
| 111 | (word displacement) | 
|---|
| 112 | OPCODE ..., foo ; | 
|---|
| 113 | brb bar ; | 
|---|
| 114 | foo: brw DESTINATION ; | 
|---|
| 115 | bar: | 
|---|
| 116 |  | 
|---|
| 117 | (long displacement) | 
|---|
| 118 | OPCODE ..., foo ; | 
|---|
| 119 | brb bar ; | 
|---|
| 120 | foo: jmp DESTINATION ; | 
|---|
| 121 | bar: | 
|---|
| 122 |  | 
|---|
| 123 |  | 
|---|
| 124 | File: as.info,  Node: VAX-operands,  Next: VAX-no,  Prev: VAX-branch,  Up: Vax-Dependent | 
|---|
| 125 |  | 
|---|
| 126 | VAX Operands | 
|---|
| 127 | ------------ | 
|---|
| 128 |  | 
|---|
| 129 | The immediate character is `$' for Unix compatibility, not `#' as | 
|---|
| 130 | DEC writes it. | 
|---|
| 131 |  | 
|---|
| 132 | The indirect character is `*' for Unix compatibility, not `@' as DEC | 
|---|
| 133 | writes it. | 
|---|
| 134 |  | 
|---|
| 135 | The displacement sizing character is ``' (an accent grave) for Unix | 
|---|
| 136 | compatibility, not `^' as DEC writes it.  The letter preceding ``' may | 
|---|
| 137 | have either case.  `G' is not understood, but all other letters (`b i l | 
|---|
| 138 | s w') are understood. | 
|---|
| 139 |  | 
|---|
| 140 | Register names understood are `r0 r1 r2 ... r15 ap fp sp pc'.  Upper | 
|---|
| 141 | and lower case letters are equivalent. | 
|---|
| 142 |  | 
|---|
| 143 | For instance | 
|---|
| 144 | tstb *w`$4(r5) | 
|---|
| 145 |  | 
|---|
| 146 | Any expression is permitted in an operand.  Operands are comma | 
|---|
| 147 | separated. | 
|---|
| 148 |  | 
|---|
| 149 |  | 
|---|
| 150 | File: as.info,  Node: VAX-no,  Prev: VAX-operands,  Up: Vax-Dependent | 
|---|
| 151 |  | 
|---|
| 152 | Not Supported on VAX | 
|---|
| 153 | -------------------- | 
|---|
| 154 |  | 
|---|
| 155 | Vax bit fields can not be assembled with `as'.  Someone can add the | 
|---|
| 156 | required code if they really need it. | 
|---|
| 157 |  | 
|---|
| 158 |  | 
|---|
| 159 | File: as.info,  Node: V850-Dependent,  Next: Xtensa-Dependent,  Prev: TIC54X-Dependent,  Up: Machine Dependencies | 
|---|
| 160 |  | 
|---|
| 161 | v850 Dependent Features | 
|---|
| 162 | ======================= | 
|---|
| 163 |  | 
|---|
| 164 | * Menu: | 
|---|
| 165 |  | 
|---|
| 166 | * V850 Options::              Options | 
|---|
| 167 | * V850 Syntax::               Syntax | 
|---|
| 168 | * V850 Floating Point::       Floating Point | 
|---|
| 169 | * V850 Directives::           V850 Machine Directives | 
|---|
| 170 | * V850 Opcodes::              Opcodes | 
|---|
| 171 |  | 
|---|
| 172 |  | 
|---|
| 173 | File: as.info,  Node: V850 Options,  Next: V850 Syntax,  Up: V850-Dependent | 
|---|
| 174 |  | 
|---|
| 175 | Options | 
|---|
| 176 | ------- | 
|---|
| 177 |  | 
|---|
| 178 | `as' supports the following additional command-line options for the | 
|---|
| 179 | V850 processor family: | 
|---|
| 180 |  | 
|---|
| 181 | `-wsigned_overflow' | 
|---|
| 182 | Causes warnings to be produced when signed immediate values | 
|---|
| 183 | overflow the space available for then within their opcodes.  By | 
|---|
| 184 | default this option is disabled as it is possible to receive | 
|---|
| 185 | spurious warnings due to using exact bit patterns as immediate | 
|---|
| 186 | constants. | 
|---|
| 187 |  | 
|---|
| 188 | `-wunsigned_overflow' | 
|---|
| 189 | Causes warnings to be produced when unsigned immediate values | 
|---|
| 190 | overflow the space available for then within their opcodes.  By | 
|---|
| 191 | default this option is disabled as it is possible to receive | 
|---|
| 192 | spurious warnings due to using exact bit patterns as immediate | 
|---|
| 193 | constants. | 
|---|
| 194 |  | 
|---|
| 195 | `-mv850' | 
|---|
| 196 | Specifies that the assembled code should be marked as being | 
|---|
| 197 | targeted at the V850 processor.  This allows the linker to detect | 
|---|
| 198 | attempts to link such code with code assembled for other | 
|---|
| 199 | processors. | 
|---|
| 200 |  | 
|---|
| 201 | `-mv850e' | 
|---|
| 202 | Specifies that the assembled code should be marked as being | 
|---|
| 203 | targeted at the V850E processor.  This allows the linker to detect | 
|---|
| 204 | attempts to link such code with code assembled for other | 
|---|
| 205 | processors. | 
|---|
| 206 |  | 
|---|
| 207 | `-mv850any' | 
|---|
| 208 | Specifies that the assembled code should be marked as being | 
|---|
| 209 | targeted at the V850 processor but support instructions that are | 
|---|
| 210 | specific to the extended variants of the process.  This allows the | 
|---|
| 211 | production of binaries that contain target specific code, but | 
|---|
| 212 | which are also intended to be used in a generic fashion.  For | 
|---|
| 213 | example libgcc.a contains generic routines used by the code | 
|---|
| 214 | produced by GCC for all versions of the v850 architecture, | 
|---|
| 215 | together with support routines only used by the V850E architecture. | 
|---|
| 216 |  | 
|---|
| 217 | `-mrelax' | 
|---|
| 218 | Enables relaxation.  This allows the .longcall and .longjump pseudo | 
|---|
| 219 | ops to be used in the assembler source code.  These ops label | 
|---|
| 220 | sections of code which are either a long function call or a long | 
|---|
| 221 | branch.  The assembler will then flag these sections of code and | 
|---|
| 222 | the linker will attempt to relax them. | 
|---|
| 223 |  | 
|---|
| 224 |  | 
|---|
| 225 | File: as.info,  Node: V850 Syntax,  Next: V850 Floating Point,  Prev: V850 Options,  Up: V850-Dependent | 
|---|
| 226 |  | 
|---|
| 227 | Syntax | 
|---|
| 228 | ------ | 
|---|
| 229 |  | 
|---|
| 230 | * Menu: | 
|---|
| 231 |  | 
|---|
| 232 | * V850-Chars::                Special Characters | 
|---|
| 233 | * V850-Regs::                 Register Names | 
|---|
| 234 |  | 
|---|
| 235 |  | 
|---|
| 236 | File: as.info,  Node: V850-Chars,  Next: V850-Regs,  Up: V850 Syntax | 
|---|
| 237 |  | 
|---|
| 238 | Special Characters | 
|---|
| 239 | .................. | 
|---|
| 240 |  | 
|---|
| 241 | `#' is the line comment character. | 
|---|
| 242 |  | 
|---|
| 243 |  | 
|---|
| 244 | File: as.info,  Node: V850-Regs,  Prev: V850-Chars,  Up: V850 Syntax | 
|---|
| 245 |  | 
|---|
| 246 | Register Names | 
|---|
| 247 | .............. | 
|---|
| 248 |  | 
|---|
| 249 | `as' supports the following names for registers: | 
|---|
| 250 | `general register 0' | 
|---|
| 251 | r0, zero | 
|---|
| 252 |  | 
|---|
| 253 | `general register 1' | 
|---|
| 254 | r1 | 
|---|
| 255 |  | 
|---|
| 256 | `general register 2' | 
|---|
| 257 | r2, hp | 
|---|
| 258 |  | 
|---|
| 259 | `general register 3' | 
|---|
| 260 | r3, sp | 
|---|
| 261 |  | 
|---|
| 262 | `general register 4' | 
|---|
| 263 | r4, gp | 
|---|
| 264 |  | 
|---|
| 265 | `general register 5' | 
|---|
| 266 | r5, tp | 
|---|
| 267 |  | 
|---|
| 268 | `general register 6' | 
|---|
| 269 | r6 | 
|---|
| 270 |  | 
|---|
| 271 | `general register 7' | 
|---|
| 272 | r7 | 
|---|
| 273 |  | 
|---|
| 274 | `general register 8' | 
|---|
| 275 | r8 | 
|---|
| 276 |  | 
|---|
| 277 | `general register 9' | 
|---|
| 278 | r9 | 
|---|
| 279 |  | 
|---|
| 280 | `general register 10' | 
|---|
| 281 | r10 | 
|---|
| 282 |  | 
|---|
| 283 | `general register 11' | 
|---|
| 284 | r11 | 
|---|
| 285 |  | 
|---|
| 286 | `general register 12' | 
|---|
| 287 | r12 | 
|---|
| 288 |  | 
|---|
| 289 | `general register 13' | 
|---|
| 290 | r13 | 
|---|
| 291 |  | 
|---|
| 292 | `general register 14' | 
|---|
| 293 | r14 | 
|---|
| 294 |  | 
|---|
| 295 | `general register 15' | 
|---|
| 296 | r15 | 
|---|
| 297 |  | 
|---|
| 298 | `general register 16' | 
|---|
| 299 | r16 | 
|---|
| 300 |  | 
|---|
| 301 | `general register 17' | 
|---|
| 302 | r17 | 
|---|
| 303 |  | 
|---|
| 304 | `general register 18' | 
|---|
| 305 | r18 | 
|---|
| 306 |  | 
|---|
| 307 | `general register 19' | 
|---|
| 308 | r19 | 
|---|
| 309 |  | 
|---|
| 310 | `general register 20' | 
|---|
| 311 | r20 | 
|---|
| 312 |  | 
|---|
| 313 | `general register 21' | 
|---|
| 314 | r21 | 
|---|
| 315 |  | 
|---|
| 316 | `general register 22' | 
|---|
| 317 | r22 | 
|---|
| 318 |  | 
|---|
| 319 | `general register 23' | 
|---|
| 320 | r23 | 
|---|
| 321 |  | 
|---|
| 322 | `general register 24' | 
|---|
| 323 | r24 | 
|---|
| 324 |  | 
|---|
| 325 | `general register 25' | 
|---|
| 326 | r25 | 
|---|
| 327 |  | 
|---|
| 328 | `general register 26' | 
|---|
| 329 | r26 | 
|---|
| 330 |  | 
|---|
| 331 | `general register 27' | 
|---|
| 332 | r27 | 
|---|
| 333 |  | 
|---|
| 334 | `general register 28' | 
|---|
| 335 | r28 | 
|---|
| 336 |  | 
|---|
| 337 | `general register 29' | 
|---|
| 338 | r29 | 
|---|
| 339 |  | 
|---|
| 340 | `general register 30' | 
|---|
| 341 | r30, ep | 
|---|
| 342 |  | 
|---|
| 343 | `general register 31' | 
|---|
| 344 | r31, lp | 
|---|
| 345 |  | 
|---|
| 346 | `system register 0' | 
|---|
| 347 | eipc | 
|---|
| 348 |  | 
|---|
| 349 | `system register 1' | 
|---|
| 350 | eipsw | 
|---|
| 351 |  | 
|---|
| 352 | `system register 2' | 
|---|
| 353 | fepc | 
|---|
| 354 |  | 
|---|
| 355 | `system register 3' | 
|---|
| 356 | fepsw | 
|---|
| 357 |  | 
|---|
| 358 | `system register 4' | 
|---|
| 359 | ecr | 
|---|
| 360 |  | 
|---|
| 361 | `system register 5' | 
|---|
| 362 | psw | 
|---|
| 363 |  | 
|---|
| 364 | `system register 16' | 
|---|
| 365 | ctpc | 
|---|
| 366 |  | 
|---|
| 367 | `system register 17' | 
|---|
| 368 | ctpsw | 
|---|
| 369 |  | 
|---|
| 370 | `system register 18' | 
|---|
| 371 | dbpc | 
|---|
| 372 |  | 
|---|
| 373 | `system register 19' | 
|---|
| 374 | dbpsw | 
|---|
| 375 |  | 
|---|
| 376 | `system register 20' | 
|---|
| 377 | ctbp | 
|---|
| 378 |  | 
|---|
| 379 |  | 
|---|
| 380 | File: as.info,  Node: V850 Floating Point,  Next: V850 Directives,  Prev: V850 Syntax,  Up: V850-Dependent | 
|---|
| 381 |  | 
|---|
| 382 | Floating Point | 
|---|
| 383 | -------------- | 
|---|
| 384 |  | 
|---|
| 385 | The V850 family uses IEEE floating-point numbers. | 
|---|
| 386 |  | 
|---|
| 387 |  | 
|---|
| 388 | File: as.info,  Node: V850 Directives,  Next: V850 Opcodes,  Prev: V850 Floating Point,  Up: V850-Dependent | 
|---|
| 389 |  | 
|---|
| 390 | V850 Machine Directives | 
|---|
| 391 | ----------------------- | 
|---|
| 392 |  | 
|---|
| 393 | `.offset <EXPRESSION>' | 
|---|
| 394 | Moves the offset into the current section to the specified amount. | 
|---|
| 395 |  | 
|---|
| 396 | `.section "name", <type>' | 
|---|
| 397 | This is an extension to the standard .section directive.  It sets | 
|---|
| 398 | the current section to be <type> and creates an alias for this | 
|---|
| 399 | section called "name". | 
|---|
| 400 |  | 
|---|
| 401 | `.v850' | 
|---|
| 402 | Specifies that the assembled code should be marked as being | 
|---|
| 403 | targeted at the V850 processor.  This allows the linker to detect | 
|---|
| 404 | attempts to link such code with code assembled for other | 
|---|
| 405 | processors. | 
|---|
| 406 |  | 
|---|
| 407 | `.v850e' | 
|---|
| 408 | Specifies that the assembled code should be marked as being | 
|---|
| 409 | targeted at the V850E processor.  This allows the linker to detect | 
|---|
| 410 | attempts to link such code with code assembled for other | 
|---|
| 411 | processors. | 
|---|
| 412 |  | 
|---|
| 413 |  | 
|---|
| 414 | File: as.info,  Node: V850 Opcodes,  Prev: V850 Directives,  Up: V850-Dependent | 
|---|
| 415 |  | 
|---|
| 416 | Opcodes | 
|---|
| 417 | ------- | 
|---|
| 418 |  | 
|---|
| 419 | `as' implements all the standard V850 opcodes. | 
|---|
| 420 |  | 
|---|
| 421 | `as' also implements the following pseudo ops: | 
|---|
| 422 |  | 
|---|
| 423 | `hi0()' | 
|---|
| 424 | Computes the higher 16 bits of the given expression and stores it | 
|---|
| 425 | into the immediate operand field of the given instruction.  For | 
|---|
| 426 | example: | 
|---|
| 427 |  | 
|---|
| 428 | `mulhi hi0(here - there), r5, r6' | 
|---|
| 429 |  | 
|---|
| 430 | computes the difference between the address of labels 'here' and | 
|---|
| 431 | 'there', takes the upper 16 bits of this difference, shifts it | 
|---|
| 432 | down 16 bits and then mutliplies it by the lower 16 bits in | 
|---|
| 433 | register 5, putting the result into register 6. | 
|---|
| 434 |  | 
|---|
| 435 | `lo()' | 
|---|
| 436 | Computes the lower 16 bits of the given expression and stores it | 
|---|
| 437 | into the immediate operand field of the given instruction.  For | 
|---|
| 438 | example: | 
|---|
| 439 |  | 
|---|
| 440 | `addi lo(here - there), r5, r6' | 
|---|
| 441 |  | 
|---|
| 442 | computes the difference between the address of labels 'here' and | 
|---|
| 443 | 'there', takes the lower 16 bits of this difference and adds it to | 
|---|
| 444 | register 5, putting the result into register 6. | 
|---|
| 445 |  | 
|---|
| 446 | `hi()' | 
|---|
| 447 | Computes the higher 16 bits of the given expression and then adds | 
|---|
| 448 | the value of the most significant bit of the lower 16 bits of the | 
|---|
| 449 | expression and stores the result into the immediate operand field | 
|---|
| 450 | of the given instruction.  For example the following code can be | 
|---|
| 451 | used to compute the address of the label 'here' and store it into | 
|---|
| 452 | register 6: | 
|---|
| 453 |  | 
|---|
| 454 | `movhi hi(here), r0, r6'     `movea lo(here), r6, r6' | 
|---|
| 455 |  | 
|---|
| 456 | The reason for this special behaviour is that movea performs a sign | 
|---|
| 457 | extension on its immediate operand.  So for example if the address | 
|---|
| 458 | of 'here' was 0xFFFFFFFF then without the special behaviour of the | 
|---|
| 459 | hi() pseudo-op the movhi instruction would put 0xFFFF0000 into r6, | 
|---|
| 460 | then the movea instruction would takes its immediate operand, | 
|---|
| 461 | 0xFFFF, sign extend it to 32 bits, 0xFFFFFFFF, and then add it | 
|---|
| 462 | into r6 giving 0xFFFEFFFF which is wrong (the fifth nibble is E). | 
|---|
| 463 | With the hi() pseudo op adding in the top bit of the lo() pseudo | 
|---|
| 464 | op, the movhi instruction actually stores 0 into r6 (0xFFFF + 1 = | 
|---|
| 465 | 0x0000), so that the movea instruction stores 0xFFFFFFFF into r6 - | 
|---|
| 466 | the right value. | 
|---|
| 467 |  | 
|---|
| 468 | `hilo()' | 
|---|
| 469 | Computes the 32 bit value of the given expression and stores it | 
|---|
| 470 | into the immediate operand field of the given instruction (which | 
|---|
| 471 | must be a mov instruction).  For example: | 
|---|
| 472 |  | 
|---|
| 473 | `mov hilo(here), r6' | 
|---|
| 474 |  | 
|---|
| 475 | computes the absolute address of label 'here' and puts the result | 
|---|
| 476 | into register 6. | 
|---|
| 477 |  | 
|---|
| 478 | `sdaoff()' | 
|---|
| 479 | Computes the offset of the named variable from the start of the | 
|---|
| 480 | Small Data Area (whoes address is held in register 4, the GP | 
|---|
| 481 | register) and stores the result as a 16 bit signed value in the | 
|---|
| 482 | immediate operand field of the given instruction.  For example: | 
|---|
| 483 |  | 
|---|
| 484 | `ld.w sdaoff(_a_variable)[gp],r6' | 
|---|
| 485 |  | 
|---|
| 486 | loads the contents of the location pointed to by the label | 
|---|
| 487 | '_a_variable' into register 6, provided that the label is located | 
|---|
| 488 | somewhere within +/- 32K of the address held in the GP register. | 
|---|
| 489 | [Note the linker assumes that the GP register contains a fixed | 
|---|
| 490 | address set to the address of the label called '__gp'.  This can | 
|---|
| 491 | either be set up automatically by the linker, or specifically set | 
|---|
| 492 | by using the `--defsym __gp=<value>' command line option]. | 
|---|
| 493 |  | 
|---|
| 494 | `tdaoff()' | 
|---|
| 495 | Computes the offset of the named variable from the start of the | 
|---|
| 496 | Tiny Data Area (whoes address is held in register 30, the EP | 
|---|
| 497 | register) and stores the result as a 4,5, 7 or 8 bit unsigned | 
|---|
| 498 | value in the immediate operand field of the given instruction. | 
|---|
| 499 | For example: | 
|---|
| 500 |  | 
|---|
| 501 | `sld.w tdaoff(_a_variable)[ep],r6' | 
|---|
| 502 |  | 
|---|
| 503 | loads the contents of the location pointed to by the label | 
|---|
| 504 | '_a_variable' into register 6, provided that the label is located | 
|---|
| 505 | somewhere within +256 bytes of the address held in the EP | 
|---|
| 506 | register.  [Note the linker assumes that the EP register contains | 
|---|
| 507 | a fixed address set to the address of the label called '__ep'. | 
|---|
| 508 | This can either be set up automatically by the linker, or | 
|---|
| 509 | specifically set by using the `--defsym __ep=<value>' command line | 
|---|
| 510 | option]. | 
|---|
| 511 |  | 
|---|
| 512 | `zdaoff()' | 
|---|
| 513 | Computes the offset of the named variable from address 0 and | 
|---|
| 514 | stores the result as a 16 bit signed value in the immediate | 
|---|
| 515 | operand field of the given instruction.  For example: | 
|---|
| 516 |  | 
|---|
| 517 | `movea zdaoff(_a_variable),zero,r6' | 
|---|
| 518 |  | 
|---|
| 519 | puts the address of the label '_a_variable' into register 6, | 
|---|
| 520 | assuming that the label is somewhere within the first 32K of | 
|---|
| 521 | memory.  (Strictly speaking it also possible to access the last | 
|---|
| 522 | 32K of memory as well, as the offsets are signed). | 
|---|
| 523 |  | 
|---|
| 524 | `ctoff()' | 
|---|
| 525 | Computes the offset of the named variable from the start of the | 
|---|
| 526 | Call Table Area (whoes address is helg in system register 20, the | 
|---|
| 527 | CTBP register) and stores the result a 6 or 16 bit unsigned value | 
|---|
| 528 | in the immediate field of then given instruction or piece of data. | 
|---|
| 529 | For example: | 
|---|
| 530 |  | 
|---|
| 531 | `callt ctoff(table_func1)' | 
|---|
| 532 |  | 
|---|
| 533 | will put the call the function whoes address is held in the call | 
|---|
| 534 | table at the location labeled 'table_func1'. | 
|---|
| 535 |  | 
|---|
| 536 | `.longcall `name'' | 
|---|
| 537 | Indicates that the following sequence of instructions is a long | 
|---|
| 538 | call to function `name'.  The linker will attempt to shorten this | 
|---|
| 539 | call sequence if `name' is within a 22bit offset of the call.  Only | 
|---|
| 540 | valid if the `-mrelax' command line switch has been enabled. | 
|---|
| 541 |  | 
|---|
| 542 | `.longjump `name'' | 
|---|
| 543 | Indicates that the following sequence of instructions is a long | 
|---|
| 544 | jump to label `name'.  The linker will attempt to shorten this code | 
|---|
| 545 | sequence if `name' is within a 22bit offset of the jump.  Only | 
|---|
| 546 | valid if the `-mrelax' command line switch has been enabled. | 
|---|
| 547 |  | 
|---|
| 548 | For information on the V850 instruction set, see `V850 Family | 
|---|
| 549 | 32-/16-Bit single-Chip Microcontroller Architecture Manual' from NEC. | 
|---|
| 550 | Ltd. | 
|---|
| 551 |  | 
|---|
| 552 |  | 
|---|
| 553 | File: as.info,  Node: Xtensa-Dependent,  Next: Z8000-Dependent,  Prev: V850-Dependent,  Up: Machine Dependencies | 
|---|
| 554 |  | 
|---|
| 555 | Xtensa Dependent Features | 
|---|
| 556 | ========================= | 
|---|
| 557 |  | 
|---|
| 558 | This chapter covers features of the GNU assembler that are specific | 
|---|
| 559 | to the Xtensa architecture.  For details about the Xtensa instruction | 
|---|
| 560 | set, please consult the `Xtensa Instruction Set Architecture (ISA) | 
|---|
| 561 | Reference Manual'. | 
|---|
| 562 |  | 
|---|
| 563 | * Menu: | 
|---|
| 564 |  | 
|---|
| 565 | * Xtensa Options::              Command-line Options. | 
|---|
| 566 | * Xtensa Syntax::               Assembler Syntax for Xtensa Processors. | 
|---|
| 567 | * Xtensa Optimizations::        Assembler Optimizations. | 
|---|
| 568 | * Xtensa Relaxation::           Other Automatic Transformations. | 
|---|
| 569 | * Xtensa Directives::           Directives for Xtensa Processors. | 
|---|
| 570 |  | 
|---|
| 571 |  | 
|---|
| 572 | File: as.info,  Node: Xtensa Options,  Next: Xtensa Syntax,  Up: Xtensa-Dependent | 
|---|
| 573 |  | 
|---|
| 574 | Command Line Options | 
|---|
| 575 | -------------------- | 
|---|
| 576 |  | 
|---|
| 577 | The Xtensa version of the GNU assembler supports these special | 
|---|
| 578 | options: | 
|---|
| 579 |  | 
|---|
| 580 | `--density | --no-density' | 
|---|
| 581 | Enable or disable use of the Xtensa code density option (16-bit | 
|---|
| 582 | instructions).  *Note Using Density Instructions: Density | 
|---|
| 583 | Instructions.  If the processor is configured with the density | 
|---|
| 584 | option, this is enabled by default; otherwise, it is always | 
|---|
| 585 | disabled. | 
|---|
| 586 |  | 
|---|
| 587 | `--relax | --no-relax' | 
|---|
| 588 | Enable or disable relaxation of instructions with immediate | 
|---|
| 589 | operands that are outside the legal range for the instructions. | 
|---|
| 590 | *Note Xtensa Relaxation: Xtensa Relaxation.  The default is | 
|---|
| 591 | `--relax' and this default should almost always be used.  If | 
|---|
| 592 | relaxation is disabled with `--no-relax', instruction operands | 
|---|
| 593 | that are out of range will cause errors.  Note: In the current | 
|---|
| 594 | implementation, these options also control whether assembler | 
|---|
| 595 | optimizations are performed, making these options equivalent to | 
|---|
| 596 | `--generics' and `--no-generics'. | 
|---|
| 597 |  | 
|---|
| 598 | `--generics | --no-generics' | 
|---|
| 599 | Enable or disable all assembler transformations of Xtensa | 
|---|
| 600 | instructions, including both relaxation and optimization.  The | 
|---|
| 601 | default is `--generics'; `--no-generics' should only be used in | 
|---|
| 602 | the rare cases when the instructions must be exactly as specified | 
|---|
| 603 | in the assembly source.  As with `--no-relax', using | 
|---|
| 604 | `--no-generics' causes out of range instruction operands to be | 
|---|
| 605 | errors. | 
|---|
| 606 |  | 
|---|
| 607 | `--text-section-literals | --no-text-section-literals' | 
|---|
| 608 | Control the treatment of literal pools.  The default is | 
|---|
| 609 | `--no-text-section-literals', which places literals in a separate | 
|---|
| 610 | section in the output file.  This allows the literal pool to be | 
|---|
| 611 | placed in a data RAM/ROM, and it also allows the linker to combine | 
|---|
| 612 | literal pools from separate object files to remove redundant | 
|---|
| 613 | literals and improve code size.  With `--text-section-literals', | 
|---|
| 614 | the literals are interspersed in the text section in order to keep | 
|---|
| 615 | them as close as possible to their references.  This may be | 
|---|
| 616 | necessary for large assembly files. | 
|---|
| 617 |  | 
|---|
| 618 | `--target-align | --no-target-align' | 
|---|
| 619 | Enable or disable automatic alignment to reduce branch penalties | 
|---|
| 620 | at some expense in code size.  *Note Automatic Instruction | 
|---|
| 621 | Alignment: Xtensa Automatic Alignment.  This optimization is | 
|---|
| 622 | enabled by default.  Note that the assembler will always align | 
|---|
| 623 | instructions like `LOOP' that have fixed alignment requirements. | 
|---|
| 624 |  | 
|---|
| 625 | `--longcalls | --no-longcalls' | 
|---|
| 626 | Enable or disable transformation of call instructions to allow | 
|---|
| 627 | calls across a greater range of addresses.  *Note Function Call | 
|---|
| 628 | Relaxation: Xtensa Call Relaxation.  This option should be used | 
|---|
| 629 | when call targets can potentially be out of range, but it degrades | 
|---|
| 630 | both code size and performance.  The default is `--no-longcalls'. | 
|---|
| 631 |  | 
|---|
| 632 |  | 
|---|
| 633 | File: as.info,  Node: Xtensa Syntax,  Next: Xtensa Optimizations,  Prev: Xtensa Options,  Up: Xtensa-Dependent | 
|---|
| 634 |  | 
|---|
| 635 | Assembler Syntax | 
|---|
| 636 | ---------------- | 
|---|
| 637 |  | 
|---|
| 638 | Block comments are delimited by `/*' and `*/'.  End of line comments | 
|---|
| 639 | may be introduced with either `#' or `//'. | 
|---|
| 640 |  | 
|---|
| 641 | Instructions consist of a leading opcode or macro name followed by | 
|---|
| 642 | whitespace and an optional comma-separated list of operands: | 
|---|
| 643 |  | 
|---|
| 644 | OPCODE [OPERAND,...] | 
|---|
| 645 |  | 
|---|
| 646 | Instructions must be separated by a newline or semicolon. | 
|---|
| 647 |  | 
|---|
| 648 | * Menu: | 
|---|
| 649 |  | 
|---|
| 650 | * Xtensa Opcodes::              Opcode Naming Conventions. | 
|---|
| 651 | * Xtensa Registers::            Register Naming. | 
|---|
| 652 |  | 
|---|
| 653 |  | 
|---|
| 654 | File: as.info,  Node: Xtensa Opcodes,  Next: Xtensa Registers,  Up: Xtensa Syntax | 
|---|
| 655 |  | 
|---|
| 656 | Opcode Names | 
|---|
| 657 | ............ | 
|---|
| 658 |  | 
|---|
| 659 | See the `Xtensa Instruction Set Architecture (ISA) Reference Manual' | 
|---|
| 660 | for a complete list of opcodes and descriptions of their semantics. | 
|---|
| 661 |  | 
|---|
| 662 | The Xtensa assembler distinguishes between "generic" and "specific" | 
|---|
| 663 | opcodes.  Specific opcodes correspond directly to Xtensa machine | 
|---|
| 664 | instructions.  Prefixing an opcode with an underscore character (`_') | 
|---|
| 665 | identifies it as a specific opcode.  Opcodes without a leading | 
|---|
| 666 | underscore are generic, which means the assembler is required to | 
|---|
| 667 | preserve their semantics but may not translate them directly to the | 
|---|
| 668 | specific opcodes with the same names.  Instead, the assembler may | 
|---|
| 669 | optimize a generic opcode and select a better instruction to use in its | 
|---|
| 670 | place (*note Xtensa Optimizations: Xtensa Optimizations.), or the | 
|---|
| 671 | assembler may relax the instruction to handle operands that are out of | 
|---|
| 672 | range for the corresponding specific opcode (*note Xtensa Relaxation: | 
|---|
| 673 | Xtensa Relaxation.). | 
|---|
| 674 |  | 
|---|
| 675 | Only use specific opcodes when it is essential to select the exact | 
|---|
| 676 | machine instructions produced by the assembler.  Using specific opcodes | 
|---|
| 677 | unnecessarily only makes the code less efficient, by disabling | 
|---|
| 678 | assembler optimization, and less flexible, by disabling relaxation. | 
|---|
| 679 |  | 
|---|
| 680 | Note that this special handling of underscore prefixes only applies | 
|---|
| 681 | to Xtensa opcodes, not to either built-in macros or user-defined macros. | 
|---|
| 682 | When an underscore prefix is used with a macro (e.g., `_NOP'), it | 
|---|
| 683 | refers to a different macro.  The assembler generally provides built-in | 
|---|
| 684 | macros both with and without the underscore prefix, where the underscore | 
|---|
| 685 | versions behave as if the underscore carries through to the instructions | 
|---|
| 686 | in the macros.  For example, `_NOP' expands to `_OR a1,a1,a1'. | 
|---|
| 687 |  | 
|---|
| 688 | The underscore prefix only applies to individual instructions, not to | 
|---|
| 689 | series of instructions.  For example, if a series of instructions have | 
|---|
| 690 | underscore prefixes, the assembler will not transform the individual | 
|---|
| 691 | instructions, but it may insert other instructions between them (e.g., | 
|---|
| 692 | to align a `LOOP' instruction).  To prevent the assembler from | 
|---|
| 693 | modifying a series of instructions as a whole, use the `no-generics' | 
|---|
| 694 | directive.  *Note generics: Generics Directive. | 
|---|
| 695 |  | 
|---|
| 696 |  | 
|---|
| 697 | File: as.info,  Node: Xtensa Registers,  Prev: Xtensa Opcodes,  Up: Xtensa Syntax | 
|---|
| 698 |  | 
|---|
| 699 | Register Names | 
|---|
| 700 | .............. | 
|---|
| 701 |  | 
|---|
| 702 | An initial `$' character is optional in all register names.  General | 
|---|
| 703 | purpose registers are named `a0'...`a15'.  Additional registers may be | 
|---|
| 704 | added by processor configuration options.  In particular, the MAC16 | 
|---|
| 705 | option adds a MR register bank.  Its registers are named `m0'...`m3'. | 
|---|
| 706 |  | 
|---|
| 707 | As a special feature, `sp' is also supported as a synonym for `a1'. | 
|---|
| 708 |  | 
|---|
| 709 |  | 
|---|
| 710 | File: as.info,  Node: Xtensa Optimizations,  Next: Xtensa Relaxation,  Prev: Xtensa Syntax,  Up: Xtensa-Dependent | 
|---|
| 711 |  | 
|---|
| 712 | Xtensa Optimizations | 
|---|
| 713 | -------------------- | 
|---|
| 714 |  | 
|---|
| 715 | The optimizations currently supported by `as' are generation of | 
|---|
| 716 | density instructions where appropriate and automatic branch target | 
|---|
| 717 | alignment. | 
|---|
| 718 |  | 
|---|
| 719 | * Menu: | 
|---|
| 720 |  | 
|---|
| 721 | * Density Instructions::        Using Density Instructions. | 
|---|
| 722 | * Xtensa Automatic Alignment::  Automatic Instruction Alignment. | 
|---|
| 723 |  | 
|---|
| 724 |  | 
|---|
| 725 | File: as.info,  Node: Density Instructions,  Next: Xtensa Automatic Alignment,  Up: Xtensa Optimizations | 
|---|
| 726 |  | 
|---|
| 727 | Using Density Instructions | 
|---|
| 728 | .......................... | 
|---|
| 729 |  | 
|---|
| 730 | The Xtensa instruction set has a code density option that provides | 
|---|
| 731 | 16-bit versions of some of the most commonly used opcodes.  Use of these | 
|---|
| 732 | opcodes can significantly reduce code size.  When possible, the | 
|---|
| 733 | assembler automatically translates generic instructions from the core | 
|---|
| 734 | Xtensa instruction set into equivalent instructions from the Xtensa code | 
|---|
| 735 | density option.  This translation can be disabled by using specific | 
|---|
| 736 | opcodes (*note Opcode Names: Xtensa Opcodes.), by using the | 
|---|
| 737 | `--no-density' command-line option (*note Command Line Options: Xtensa | 
|---|
| 738 | Options.), or by using the `no-density' directive (*note density: | 
|---|
| 739 | Density Directive.). | 
|---|
| 740 |  | 
|---|
| 741 | It is a good idea _not_ to use the density instuctions directly. | 
|---|
| 742 | The assembler will automatically select dense instructions where | 
|---|
| 743 | possible.  If you later need to avoid using the code density option, you | 
|---|
| 744 | can disable it in the assembler without having to modify the code. | 
|---|
| 745 |  | 
|---|
| 746 |  | 
|---|
| 747 | File: as.info,  Node: Xtensa Automatic Alignment,  Prev: Density Instructions,  Up: Xtensa Optimizations | 
|---|
| 748 |  | 
|---|
| 749 | Automatic Instruction Alignment | 
|---|
| 750 | ............................... | 
|---|
| 751 |  | 
|---|
| 752 | The Xtensa assembler will automatically align certain instructions, | 
|---|
| 753 | both to optimize performance and to satisfy architectural requirements. | 
|---|
| 754 |  | 
|---|
| 755 | When the `--target-align' command-line option is enabled (*note | 
|---|
| 756 | Command Line Options: Xtensa Options.), the assembler attempts to widen | 
|---|
| 757 | density instructions preceding a branch target so that the target | 
|---|
| 758 | instruction does not cross a 4-byte boundary.  Similarly, the assembler | 
|---|
| 759 | also attempts to align each instruction following a call instruction. | 
|---|
| 760 | If there are not enough preceding safe density instructions to align a | 
|---|
| 761 | target, no widening will be performed.  This alignment has the | 
|---|
| 762 | potential to reduce branch penalties at some expense in code size.  The | 
|---|
| 763 | assembler will not attempt to align labels with the prefixes `.Ln' and | 
|---|
| 764 | `.LM', since these labels are used for debugging information and are | 
|---|
| 765 | not typically branch targets. | 
|---|
| 766 |  | 
|---|
| 767 | The `LOOP' family of instructions must be aligned on either a 1 or 2 | 
|---|
| 768 | mod 4 byte boundary.  The assembler knows about this restriction and | 
|---|
| 769 | inserts the minimal number of 2 or 3 byte no-op instructions to satisfy | 
|---|
| 770 | it.  When no-op instructions are added, any label immediately preceding | 
|---|
| 771 | the original loop will be moved in order to refer to the loop | 
|---|
| 772 | instruction, not the newly generated no-op instruction. | 
|---|
| 773 |  | 
|---|
| 774 | Similarly, the `ENTRY' instruction must be aligned on a 0 mod 4 byte | 
|---|
| 775 | boundary.  The assembler satisfies this requirement by inserting zero | 
|---|
| 776 | bytes when required.  In addition, labels immediately preceding the | 
|---|
| 777 | `ENTRY' instruction will be moved to the newly aligned instruction | 
|---|
| 778 | location. | 
|---|
| 779 |  | 
|---|
| 780 |  | 
|---|
| 781 | File: as.info,  Node: Xtensa Relaxation,  Next: Xtensa Directives,  Prev: Xtensa Optimizations,  Up: Xtensa-Dependent | 
|---|
| 782 |  | 
|---|
| 783 | Xtensa Relaxation | 
|---|
| 784 | ----------------- | 
|---|
| 785 |  | 
|---|
| 786 | When an instruction operand is outside the range allowed for that | 
|---|
| 787 | particular instruction field, `as' can transform the code to use a | 
|---|
| 788 | functionally-equivalent instruction or sequence of instructions.  This | 
|---|
| 789 | process is known as "relaxation".  This is typically done for branch | 
|---|
| 790 | instructions because the distance of the branch targets is not known | 
|---|
| 791 | until assembly-time.  The Xtensa assembler offers branch relaxation and | 
|---|
| 792 | also extends this concept to function calls, `MOVI' instructions and | 
|---|
| 793 | other instructions with immediate fields. | 
|---|
| 794 |  | 
|---|
| 795 | * Menu: | 
|---|
| 796 |  | 
|---|
| 797 | * Xtensa Branch Relaxation::        Relaxation of Branches. | 
|---|
| 798 | * Xtensa Call Relaxation::          Relaxation of Function Calls. | 
|---|
| 799 | * Xtensa Immediate Relaxation::     Relaxation of other Immediate Fields. | 
|---|
| 800 |  | 
|---|
| 801 |  | 
|---|
| 802 | File: as.info,  Node: Xtensa Branch Relaxation,  Next: Xtensa Call Relaxation,  Up: Xtensa Relaxation | 
|---|
| 803 |  | 
|---|
| 804 | Conditional Branch Relaxation | 
|---|
| 805 | ............................. | 
|---|
| 806 |  | 
|---|
| 807 | When the target of a branch is too far away from the branch itself, | 
|---|
| 808 | i.e., when the offset from the branch to the target is too large to fit | 
|---|
| 809 | in the immediate field of the branch instruction, it may be necessary to | 
|---|
| 810 | replace the branch with a branch around a jump.  For example, | 
|---|
| 811 |  | 
|---|
| 812 | beqz    a2, L | 
|---|
| 813 |  | 
|---|
| 814 | may result in: | 
|---|
| 815 |  | 
|---|
| 816 | bnez.n  a2, M | 
|---|
| 817 | j L | 
|---|
| 818 | M: | 
|---|
| 819 |  | 
|---|
| 820 | (The `BNEZ.N' instruction would be used in this example only if the | 
|---|
| 821 | density option is available.  Otherwise, `BNEZ' would be used.) | 
|---|
| 822 |  | 
|---|
| 823 |  | 
|---|
| 824 | File: as.info,  Node: Xtensa Call Relaxation,  Next: Xtensa Immediate Relaxation,  Prev: Xtensa Branch Relaxation,  Up: Xtensa Relaxation | 
|---|
| 825 |  | 
|---|
| 826 | Function Call Relaxation | 
|---|
| 827 | ........................ | 
|---|
| 828 |  | 
|---|
| 829 | Function calls may require relaxation because the Xtensa immediate | 
|---|
| 830 | call instructions (`CALL0', `CALL4', `CALL8' and `CALL12') provide a | 
|---|
| 831 | PC-relative offset of only 512 Kbytes in either direction.  For larger | 
|---|
| 832 | programs, it may be necessary to use indirect calls (`CALLX0', | 
|---|
| 833 | `CALLX4', `CALLX8' and `CALLX12') where the target address is specified | 
|---|
| 834 | in a register.  The Xtensa assembler can automatically relax immediate | 
|---|
| 835 | call instructions into indirect call instructions.  This relaxation is | 
|---|
| 836 | done by loading the address of the called function into the callee's | 
|---|
| 837 | return address register and then using a `CALLX' instruction.  So, for | 
|---|
| 838 | example: | 
|---|
| 839 |  | 
|---|
| 840 | call8 func | 
|---|
| 841 |  | 
|---|
| 842 | might be relaxed to: | 
|---|
| 843 |  | 
|---|
| 844 | .literal .L1, func | 
|---|
| 845 | l32r    a8, .L1 | 
|---|
| 846 | callx8  a8 | 
|---|
| 847 |  | 
|---|
| 848 | Because the addresses of targets of function calls are not generally | 
|---|
| 849 | known until link-time, the assembler must assume the worst and relax all | 
|---|
| 850 | the calls to functions in other source files, not just those that really | 
|---|
| 851 | will be out of range.  The linker can recognize calls that were | 
|---|
| 852 | unnecessarily relaxed, but it can only partially remove the overhead | 
|---|
| 853 | introduced by the assembler. | 
|---|
| 854 |  | 
|---|
| 855 | Call relaxation has a negative effect on both code size and | 
|---|
| 856 | performance, so this relaxation is disabled by default.  If a program | 
|---|
| 857 | is too large and some of the calls are out of range, function call | 
|---|
| 858 | relaxation can be enabled using the `--longcalls' command-line option | 
|---|
| 859 | or the `longcalls' directive (*note longcalls: Longcalls Directive.). | 
|---|
| 860 |  | 
|---|
| 861 |  | 
|---|
| 862 | File: as.info,  Node: Xtensa Immediate Relaxation,  Prev: Xtensa Call Relaxation,  Up: Xtensa Relaxation | 
|---|
| 863 |  | 
|---|
| 864 | Other Immediate Field Relaxation | 
|---|
| 865 | ................................ | 
|---|
| 866 |  | 
|---|
| 867 | The `MOVI' machine instruction can only materialize values in the | 
|---|
| 868 | range from -2048 to 2047.  Values outside this range are best | 
|---|
| 869 | materalized with `L32R' instructions.  Thus: | 
|---|
| 870 |  | 
|---|
| 871 | movi a0, 100000 | 
|---|
| 872 |  | 
|---|
| 873 | is assembled into the following machine code: | 
|---|
| 874 |  | 
|---|
| 875 | .literal .L1, 100000 | 
|---|
| 876 | l32r a0, .L1 | 
|---|
| 877 |  | 
|---|
| 878 | The `L8UI' machine instruction can only be used with immediate | 
|---|
| 879 | offsets in the range from 0 to 255. The `L16SI' and `L16UI' machine | 
|---|
| 880 | instructions can only be used with offsets from 0 to 510.  The `L32I' | 
|---|
| 881 | machine instruction can only be used with offsets from 0 to 1020.  A | 
|---|
| 882 | load offset outside these ranges can be materalized with an `L32R' | 
|---|
| 883 | instruction if the destination register of the load is different than | 
|---|
| 884 | the source address register.  For example: | 
|---|
| 885 |  | 
|---|
| 886 | l32i a1, a0, 2040 | 
|---|
| 887 |  | 
|---|
| 888 | is translated to: | 
|---|
| 889 |  | 
|---|
| 890 | .literal .L1, 2040 | 
|---|
| 891 | l32r a1, .L1 | 
|---|
| 892 | addi a1, a0, a1 | 
|---|
| 893 | l32i a1, a1, 0 | 
|---|
| 894 |  | 
|---|
| 895 | If the load destination and source address register are the same, an | 
|---|
| 896 | out-of-range offset causes an error. | 
|---|
| 897 |  | 
|---|
| 898 | The Xtensa `ADDI' instruction only allows immediate operands in the | 
|---|
| 899 | range from -128 to 127.  There are a number of alternate instruction | 
|---|
| 900 | sequences for the generic `ADDI' operation.  First, if the immediate is | 
|---|
| 901 | 0, the `ADDI' will be turned into a `MOV.N' instruction (or the | 
|---|
| 902 | equivalent `OR' instruction if the code density option is not | 
|---|
| 903 | available).  If the `ADDI' immediate is outside of the range -128 to | 
|---|
| 904 | 127, but inside the range -32896 to 32639, an `ADDMI' instruction or | 
|---|
| 905 | `ADDMI'/`ADDI' sequence will be used.  Finally, if the immediate is | 
|---|
| 906 | outside of this range and a free register is available, an `L32R'/`ADD' | 
|---|
| 907 | sequence will be used with a literal allocated from the literal pool. | 
|---|
| 908 |  | 
|---|
| 909 | For example: | 
|---|
| 910 |  | 
|---|
| 911 | addi    a5, a6, 0 | 
|---|
| 912 | addi    a5, a6, 512 | 
|---|
| 913 | addi    a5, a6, 513 | 
|---|
| 914 | addi    a5, a6, 50000 | 
|---|
| 915 |  | 
|---|
| 916 | is assembled into the following: | 
|---|
| 917 |  | 
|---|
| 918 | .literal .L1, 50000 | 
|---|
| 919 | mov.n   a5, a6 | 
|---|
| 920 | addmi   a5, a6, 0x200 | 
|---|
| 921 | addmi   a5, a6, 0x200 | 
|---|
| 922 | addi    a5, a5, 1 | 
|---|
| 923 | l32r    a5, .L1 | 
|---|
| 924 | add     a5, a6, a5 | 
|---|
| 925 |  | 
|---|
| 926 |  | 
|---|
| 927 | File: as.info,  Node: Xtensa Directives,  Prev: Xtensa Relaxation,  Up: Xtensa-Dependent | 
|---|
| 928 |  | 
|---|
| 929 | Directives | 
|---|
| 930 | ---------- | 
|---|
| 931 |  | 
|---|
| 932 | The Xtensa assember supports a region-based directive syntax: | 
|---|
| 933 |  | 
|---|
| 934 | .begin DIRECTIVE [OPTIONS] | 
|---|
| 935 | ... | 
|---|
| 936 | .end DIRECTIVE | 
|---|
| 937 |  | 
|---|
| 938 | All the Xtensa-specific directives that apply to a region of code use | 
|---|
| 939 | this syntax. | 
|---|
| 940 |  | 
|---|
| 941 | The directive applies to code between the `.begin' and the `.end'. | 
|---|
| 942 | The state of the option after the `.end' reverts to what it was before | 
|---|
| 943 | the `.begin'.  A nested `.begin'/`.end' region can further change the | 
|---|
| 944 | state of the directive without having to be aware of its outer state. | 
|---|
| 945 | For example, consider: | 
|---|
| 946 |  | 
|---|
| 947 | .begin no-density | 
|---|
| 948 | L:  add a0, a1, a2 | 
|---|
| 949 | .begin density | 
|---|
| 950 | M:  add a0, a1, a2 | 
|---|
| 951 | .end density | 
|---|
| 952 | N:  add a0, a1, a2 | 
|---|
| 953 | .end no-density | 
|---|
| 954 |  | 
|---|
| 955 | The generic `ADD' opcodes at `L' and `N' in the outer `no-density' | 
|---|
| 956 | region both result in `ADD' machine instructions, but the assembler | 
|---|
| 957 | selects an `ADD.N' instruction for the generic `ADD' at `M' in the | 
|---|
| 958 | inner `density' region. | 
|---|
| 959 |  | 
|---|
| 960 | The advantage of this style is that it works well inside macros | 
|---|
| 961 | which can preserve the context of their callers. | 
|---|
| 962 |  | 
|---|
| 963 | When command-line options and assembler directives are used at the | 
|---|
| 964 | same time and conflict, the one that overrides a default behavior takes | 
|---|
| 965 | precedence over one that is the same as the default.  For example, if | 
|---|
| 966 | the code density option is available, the default is to select density | 
|---|
| 967 | instructions whenever possible.  So, if the above is assembled with the | 
|---|
| 968 | `--no-density' flag, which overrides the default, all the generic `ADD' | 
|---|
| 969 | instructions result in `ADD' machine instructions.  If assembled with | 
|---|
| 970 | the `--density' flag, which is already the default, the `no-density' | 
|---|
| 971 | directive takes precedence and only one of the generic `ADD' | 
|---|
| 972 | instructions is optimized to be a `ADD.N' machine instruction.  An | 
|---|
| 973 | underscore prefix identifying a specific opcode always takes precedence | 
|---|
| 974 | over directives and command-line flags. | 
|---|
| 975 |  | 
|---|
| 976 | The following directives are available: | 
|---|
| 977 |  | 
|---|
| 978 | * Menu: | 
|---|
| 979 |  | 
|---|
| 980 | * Density Directive::          Disable Use of Density Instructions. | 
|---|
| 981 | * Relax Directive::            Disable Assembler Relaxation. | 
|---|
| 982 | * Longcalls Directive::        Use Indirect Calls for Greater Range. | 
|---|
| 983 | * Generics Directive::         Disable All Assembler Transformations. | 
|---|
| 984 | * Literal Directive::          Intermix Literals with Instructions. | 
|---|
| 985 | * Literal Position Directive:: Specify Inline Literal Pool Locations. | 
|---|
| 986 | * Literal Prefix Directive::   Specify Literal Section Name Prefix. | 
|---|
| 987 | * Freeregs Directive::         List Registers Available for Assembler Use. | 
|---|
| 988 | * Frame Directive::            Describe a stack frame. | 
|---|
| 989 |  | 
|---|
| 990 |  | 
|---|
| 991 | File: as.info,  Node: Density Directive,  Next: Relax Directive,  Up: Xtensa Directives | 
|---|
| 992 |  | 
|---|
| 993 | density | 
|---|
| 994 | ....... | 
|---|
| 995 |  | 
|---|
| 996 | The `density' and `no-density' directives enable or disable | 
|---|
| 997 | optimization of generic instructions into density instructions within | 
|---|
| 998 | the region.  *Note Using Density Instructions: Density Instructions. | 
|---|
| 999 |  | 
|---|
| 1000 | .begin [no-]density | 
|---|
| 1001 | .end [no-]density | 
|---|
| 1002 |  | 
|---|
| 1003 | This optimization is enabled by default unless the Xtensa | 
|---|
| 1004 | configuration does not support the code density option or the | 
|---|
| 1005 | `--no-density' command-line option was specified. | 
|---|
| 1006 |  | 
|---|
| 1007 |  | 
|---|
| 1008 | File: as.info,  Node: Relax Directive,  Next: Longcalls Directive,  Prev: Density Directive,  Up: Xtensa Directives | 
|---|
| 1009 |  | 
|---|
| 1010 | relax | 
|---|
| 1011 | ..... | 
|---|
| 1012 |  | 
|---|
| 1013 | The `relax' directive enables or disables relaxation within the | 
|---|
| 1014 | region.  *Note Xtensa Relaxation: Xtensa Relaxation.  Note: In the | 
|---|
| 1015 | current implementation, these directives also control whether assembler | 
|---|
| 1016 | optimizations are performed, making them equivalent to the `generics' | 
|---|
| 1017 | and `no-generics' directives. | 
|---|
| 1018 |  | 
|---|
| 1019 | .begin [no-]relax | 
|---|
| 1020 | .end [no-]relax | 
|---|
| 1021 |  | 
|---|
| 1022 | Relaxation is enabled by default unless the `--no-relax' | 
|---|
| 1023 | command-line option was specified. | 
|---|
| 1024 |  | 
|---|
| 1025 |  | 
|---|
| 1026 | File: as.info,  Node: Longcalls Directive,  Next: Generics Directive,  Prev: Relax Directive,  Up: Xtensa Directives | 
|---|
| 1027 |  | 
|---|
| 1028 | longcalls | 
|---|
| 1029 | ......... | 
|---|
| 1030 |  | 
|---|
| 1031 | The `longcalls' directive enables or disables function call | 
|---|
| 1032 | relaxation.  *Note Function Call Relaxation: Xtensa Call Relaxation. | 
|---|
| 1033 |  | 
|---|
| 1034 | .begin [no-]longcalls | 
|---|
| 1035 | .end [no-]longcalls | 
|---|
| 1036 |  | 
|---|
| 1037 | Call relaxation is disabled by default unless the `--longcalls' | 
|---|
| 1038 | command-line option is specified. | 
|---|
| 1039 |  | 
|---|
| 1040 |  | 
|---|
| 1041 | File: as.info,  Node: Generics Directive,  Next: Literal Directive,  Prev: Longcalls Directive,  Up: Xtensa Directives | 
|---|
| 1042 |  | 
|---|
| 1043 | generics | 
|---|
| 1044 | ........ | 
|---|
| 1045 |  | 
|---|
| 1046 | This directive enables or disables all assembler transformation, | 
|---|
| 1047 | including relaxation (*note Xtensa Relaxation: Xtensa Relaxation.) and | 
|---|
| 1048 | optimization (*note Xtensa Optimizations: Xtensa Optimizations.). | 
|---|
| 1049 |  | 
|---|
| 1050 | .begin [no-]generics | 
|---|
| 1051 | .end [no-]generics | 
|---|
| 1052 |  | 
|---|
| 1053 | Disabling generics is roughly equivalent to adding an underscore | 
|---|
| 1054 | prefix to every opcode within the region, so that every opcode is | 
|---|
| 1055 | treated as a specific opcode.  *Note Opcode Names: Xtensa Opcodes.  In | 
|---|
| 1056 | the current implementation of `as', built-in macros are also disabled | 
|---|
| 1057 | within a `no-generics' region. | 
|---|
| 1058 |  | 
|---|
| 1059 |  | 
|---|
| 1060 | File: as.info,  Node: Literal Directive,  Next: Literal Position Directive,  Prev: Generics Directive,  Up: Xtensa Directives | 
|---|
| 1061 |  | 
|---|
| 1062 | literal | 
|---|
| 1063 | ....... | 
|---|
| 1064 |  | 
|---|
| 1065 | The `.literal' directive is used to define literal pool data, i.e., | 
|---|
| 1066 | read-only 32-bit data accessed via `L32R' instructions. | 
|---|
| 1067 |  | 
|---|
| 1068 | .literal LABEL, VALUE[, VALUE...] | 
|---|
| 1069 |  | 
|---|
| 1070 | This directive is similar to the standard `.word' directive, except | 
|---|
| 1071 | that the actual location of the literal data is determined by the | 
|---|
| 1072 | assembler and linker, not by the position of the `.literal' directive. | 
|---|
| 1073 | Using this directive gives the assembler freedom to locate the literal | 
|---|
| 1074 | data in the most appropriate place and possibly to combine identical | 
|---|
| 1075 | literals.  For example, the code: | 
|---|
| 1076 |  | 
|---|
| 1077 | entry sp, 40 | 
|---|
| 1078 | .literal .L1, sym | 
|---|
| 1079 | l32r    a4, .L1 | 
|---|
| 1080 |  | 
|---|
| 1081 | can be used to load a pointer to the symbol `sym' into register | 
|---|
| 1082 | `a4'.  The value of `sym' will not be placed between the `ENTRY' and | 
|---|
| 1083 | `L32R' instructions; instead, the assembler puts the data in a literal | 
|---|
| 1084 | pool. | 
|---|
| 1085 |  | 
|---|
| 1086 | By default literal pools are placed in a separate section; however, | 
|---|
| 1087 | when using the `--text-section-literals' option (*note Command Line | 
|---|
| 1088 | Options: Xtensa Options.), the literal pools are placed in the current | 
|---|
| 1089 | section.  These text section literal pools are created automatically | 
|---|
| 1090 | before `ENTRY' instructions and manually after `.literal_position' | 
|---|
| 1091 | directives (*note literal_position: Literal Position Directive.).  If | 
|---|
| 1092 | there are no preceding `ENTRY' instructions or `.literal_position' | 
|---|
| 1093 | directives, the assembler will print a warning and place the literal | 
|---|
| 1094 | pool at the beginning of the current section.  In such cases, explicit | 
|---|
| 1095 | `.literal_position' directives should be used to place the literal | 
|---|
| 1096 | pools. | 
|---|
| 1097 |  | 
|---|
| 1098 |  | 
|---|
| 1099 | File: as.info,  Node: Literal Position Directive,  Next: Literal Prefix Directive,  Prev: Literal Directive,  Up: Xtensa Directives | 
|---|
| 1100 |  | 
|---|
| 1101 | literal_position | 
|---|
| 1102 | ................ | 
|---|
| 1103 |  | 
|---|
| 1104 | When using `--text-section-literals' to place literals inline in the | 
|---|
| 1105 | section being assembled, the `.literal_position' directive can be used | 
|---|
| 1106 | to mark a potential location for a literal pool. | 
|---|
| 1107 |  | 
|---|
| 1108 | .literal_position | 
|---|
| 1109 |  | 
|---|
| 1110 | The `.literal_position' directive is ignored when the | 
|---|
| 1111 | `--text-section-literals' option is not used. | 
|---|
| 1112 |  | 
|---|
| 1113 | The assembler will automatically place text section literal pools | 
|---|
| 1114 | before `ENTRY' instructions, so the `.literal_position' directive is | 
|---|
| 1115 | only needed to specify some other location for a literal pool.  You may | 
|---|
| 1116 | need to add an explicit jump instruction to skip over an inline literal | 
|---|
| 1117 | pool. | 
|---|
| 1118 |  | 
|---|
| 1119 | For example, an interrupt vector does not begin with an `ENTRY' | 
|---|
| 1120 | instruction so the assembler will be unable to automatically find a good | 
|---|
| 1121 | place to put a literal pool.  Moreover, the code for the interrupt | 
|---|
| 1122 | vector must be at a specific starting address, so the literal pool | 
|---|
| 1123 | cannot come before the start of the code.  The literal pool for the | 
|---|
| 1124 | vector must be explicitly positioned in the middle of the vector (before | 
|---|
| 1125 | any uses of the literals, of course).  The `.literal_position' | 
|---|
| 1126 | directive can be used to do this.  In the following code, the literal | 
|---|
| 1127 | for `M' will automatically be aligned correctly and is placed after the | 
|---|
| 1128 | unconditional jump. | 
|---|
| 1129 |  | 
|---|
| 1130 | .global M | 
|---|
| 1131 | code_start: | 
|---|
| 1132 | j continue | 
|---|
| 1133 | .literal_position | 
|---|
| 1134 | .align 4 | 
|---|
| 1135 | continue: | 
|---|
| 1136 | movi    a4, M | 
|---|
| 1137 |  | 
|---|
| 1138 |  | 
|---|
| 1139 | File: as.info,  Node: Literal Prefix Directive,  Next: Freeregs Directive,  Prev: Literal Position Directive,  Up: Xtensa Directives | 
|---|
| 1140 |  | 
|---|
| 1141 | literal_prefix | 
|---|
| 1142 | .............. | 
|---|
| 1143 |  | 
|---|
| 1144 | The `literal_prefix' directive allows you to specify different | 
|---|
| 1145 | sections to hold literals from different portions of an assembly file. | 
|---|
| 1146 | With this directive, a single assembly file can be used to generate code | 
|---|
| 1147 | into multiple sections, including literals generated by the assembler. | 
|---|
| 1148 |  | 
|---|
| 1149 | .begin literal_prefix [NAME] | 
|---|
| 1150 | .end literal_prefix | 
|---|
| 1151 |  | 
|---|
| 1152 | For the code inside the delimited region, the assembler puts | 
|---|
| 1153 | literals in the section `NAME.literal'. If this section does not yet | 
|---|
| 1154 | exist, the assembler creates it.  The NAME parameter is optional. If | 
|---|
| 1155 | NAME is not specified, the literal prefix is set to the "default" for | 
|---|
| 1156 | the file.  This default is usually `.literal' but can be changed with | 
|---|
| 1157 | the `--rename-section' command-line argument. | 
|---|
| 1158 |  | 
|---|
| 1159 |  | 
|---|
| 1160 | File: as.info,  Node: Freeregs Directive,  Next: Frame Directive,  Prev: Literal Prefix Directive,  Up: Xtensa Directives | 
|---|
| 1161 |  | 
|---|
| 1162 | freeregs | 
|---|
| 1163 | ........ | 
|---|
| 1164 |  | 
|---|
| 1165 | This directive tells the assembler that the given registers are | 
|---|
| 1166 | unused in the region. | 
|---|
| 1167 |  | 
|---|
| 1168 | .begin freeregs RI[,RI...] | 
|---|
| 1169 | .end freeregs | 
|---|
| 1170 |  | 
|---|
| 1171 | This allows the assembler to use these registers for relaxations or | 
|---|
| 1172 | optimizations.  (They are actually only for relaxations at present, but | 
|---|
| 1173 | the possibility of optimizations exists in the future.) | 
|---|
| 1174 |  | 
|---|
| 1175 | Nested `freeregs' directives can be used to add additional registers | 
|---|
| 1176 | to the list of those available to the assembler.  For example: | 
|---|
| 1177 |  | 
|---|
| 1178 | .begin freeregs a3, a4 | 
|---|
| 1179 | .begin freeregs a5 | 
|---|
| 1180 |  | 
|---|
| 1181 | has the effect of declaring `a3', `a4', and `a5' all free. | 
|---|
| 1182 |  | 
|---|
| 1183 |  | 
|---|
| 1184 | File: as.info,  Node: Frame Directive,  Prev: Freeregs Directive,  Up: Xtensa Directives | 
|---|
| 1185 |  | 
|---|
| 1186 | frame | 
|---|
| 1187 | ..... | 
|---|
| 1188 |  | 
|---|
| 1189 | This directive tells the assembler to emit information to allow the | 
|---|
| 1190 | debugger to locate a function's stack frame.  The syntax is: | 
|---|
| 1191 |  | 
|---|
| 1192 | .frame REG, SIZE | 
|---|
| 1193 |  | 
|---|
| 1194 | where REG is the register used to hold the frame pointer (usually | 
|---|
| 1195 | the same as the stack pointer) and SIZE is the size in bytes of the | 
|---|
| 1196 | stack frame.  The `.frame' directive is typically placed immediately | 
|---|
| 1197 | after the `ENTRY' instruction for a function. | 
|---|
| 1198 |  | 
|---|
| 1199 | In almost all circumstances, this information just duplicates the | 
|---|
| 1200 | information given in the function's `ENTRY' instruction; however, there | 
|---|
| 1201 | are two cases where this is not true: | 
|---|
| 1202 |  | 
|---|
| 1203 | 1. The size of the stack frame is too big to fit in the immediate | 
|---|
| 1204 | field of the `ENTRY' instruction. | 
|---|
| 1205 |  | 
|---|
| 1206 | 2. The frame pointer is different than the stack pointer, as with | 
|---|
| 1207 | functions that call `alloca'. | 
|---|
| 1208 |  | 
|---|
| 1209 |  | 
|---|
| 1210 | File: as.info,  Node: Reporting Bugs,  Next: Acknowledgements,  Prev: Machine Dependencies,  Up: Top | 
|---|
| 1211 |  | 
|---|
| 1212 | Reporting Bugs | 
|---|
| 1213 | ************** | 
|---|
| 1214 |  | 
|---|
| 1215 | Your bug reports play an essential role in making `as' reliable. | 
|---|
| 1216 |  | 
|---|
| 1217 | Reporting a bug may help you by bringing a solution to your problem, | 
|---|
| 1218 | or it may not.  But in any case the principal function of a bug report | 
|---|
| 1219 | is to help the entire community by making the next version of `as' work | 
|---|
| 1220 | better.  Bug reports are your contribution to the maintenance of `as'. | 
|---|
| 1221 |  | 
|---|
| 1222 | In order for a bug report to serve its purpose, you must include the | 
|---|
| 1223 | information that enables us to fix the bug. | 
|---|
| 1224 |  | 
|---|
| 1225 | * Menu: | 
|---|
| 1226 |  | 
|---|
| 1227 | * Bug Criteria::                Have you found a bug? | 
|---|
| 1228 | * Bug Reporting::               How to report bugs | 
|---|
| 1229 |  | 
|---|
| 1230 |  | 
|---|
| 1231 | File: as.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: Reporting Bugs | 
|---|
| 1232 |  | 
|---|
| 1233 | Have You Found a Bug? | 
|---|
| 1234 | ===================== | 
|---|
| 1235 |  | 
|---|
| 1236 | If you are not sure whether you have found a bug, here are some | 
|---|
| 1237 | guidelines: | 
|---|
| 1238 |  | 
|---|
| 1239 | * If the assembler gets a fatal signal, for any input whatever, that | 
|---|
| 1240 | is a `as' bug.  Reliable assemblers never crash. | 
|---|
| 1241 |  | 
|---|
| 1242 | * If `as' produces an error message for valid input, that is a bug. | 
|---|
| 1243 |  | 
|---|
| 1244 | * If `as' does not produce an error message for invalid input, that | 
|---|
| 1245 | is a bug.  However, you should note that your idea of "invalid | 
|---|
| 1246 | input" might be our idea of "an extension" or "support for | 
|---|
| 1247 | traditional practice". | 
|---|
| 1248 |  | 
|---|
| 1249 | * If you are an experienced user of assemblers, your suggestions for | 
|---|
| 1250 | improvement of `as' are welcome in any case. | 
|---|
| 1251 |  | 
|---|
| 1252 |  | 
|---|
| 1253 | File: as.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: Reporting Bugs | 
|---|
| 1254 |  | 
|---|
| 1255 | How to Report Bugs | 
|---|
| 1256 | ================== | 
|---|
| 1257 |  | 
|---|
| 1258 | A number of companies and individuals offer support for GNU | 
|---|
| 1259 | products.  If you obtained `as' from a support organization, we | 
|---|
| 1260 | recommend you contact that organization first. | 
|---|
| 1261 |  | 
|---|
| 1262 | You can find contact information for many support companies and | 
|---|
| 1263 | individuals in the file `etc/SERVICE' in the GNU Emacs distribution. | 
|---|
| 1264 |  | 
|---|
| 1265 | In any event, we also recommend that you send bug reports for `as' | 
|---|
| 1266 | to `bug-binutils@gnu.org'. | 
|---|
| 1267 |  | 
|---|
| 1268 | The fundamental principle of reporting bugs usefully is this: | 
|---|
| 1269 | *report all the facts*.  If you are not sure whether to state a fact or | 
|---|
| 1270 | leave it out, state it! | 
|---|
| 1271 |  | 
|---|
| 1272 | Often people omit facts because they think they know what causes the | 
|---|
| 1273 | problem and assume that some details do not matter.  Thus, you might | 
|---|
| 1274 | assume that the name of a symbol you use in an example does not matter. | 
|---|
| 1275 | Well, probably it does not, but one cannot be sure.  Perhaps the bug | 
|---|
| 1276 | is a stray memory reference which happens to fetch from the location | 
|---|
| 1277 | where that name is stored in memory; perhaps, if the name were | 
|---|
| 1278 | different, the contents of that location would fool the assembler into | 
|---|
| 1279 | doing the right thing despite the bug.  Play it safe and give a | 
|---|
| 1280 | specific, complete example.  That is the easiest thing for you to do, | 
|---|
| 1281 | and the most helpful. | 
|---|
| 1282 |  | 
|---|
| 1283 | Keep in mind that the purpose of a bug report is to enable us to fix | 
|---|
| 1284 | the bug if it is new to us.  Therefore, always write your bug reports | 
|---|
| 1285 | on the assumption that the bug has not been reported previously. | 
|---|
| 1286 |  | 
|---|
| 1287 | Sometimes people give a few sketchy facts and ask, "Does this ring a | 
|---|
| 1288 | bell?"  This cannot help us fix a bug, so it is basically useless.  We | 
|---|
| 1289 | respond by asking for enough details to enable us to investigate.  You | 
|---|
| 1290 | might as well expedite matters by sending them to begin with. | 
|---|
| 1291 |  | 
|---|
| 1292 | To enable us to fix the bug, you should include all these things: | 
|---|
| 1293 |  | 
|---|
| 1294 | * The version of `as'.  `as' announces it if you start it with the | 
|---|
| 1295 | `--version' argument. | 
|---|
| 1296 |  | 
|---|
| 1297 | Without this, we will not know whether there is any point in | 
|---|
| 1298 | looking for the bug in the current version of `as'. | 
|---|
| 1299 |  | 
|---|
| 1300 | * Any patches you may have applied to the `as' source. | 
|---|
| 1301 |  | 
|---|
| 1302 | * The type of machine you are using, and the operating system name | 
|---|
| 1303 | and version number. | 
|---|
| 1304 |  | 
|---|
| 1305 | * What compiler (and its version) was used to compile `as'--e.g. | 
|---|
| 1306 | "`gcc-2.7'". | 
|---|
| 1307 |  | 
|---|
| 1308 | * The command arguments you gave the assembler to assemble your | 
|---|
| 1309 | example and observe the bug.  To guarantee you will not omit | 
|---|
| 1310 | something important, list them all.  A copy of the Makefile (or | 
|---|
| 1311 | the output from make) is sufficient. | 
|---|
| 1312 |  | 
|---|
| 1313 | If we were to try to guess the arguments, we would probably guess | 
|---|
| 1314 | wrong and then we might not encounter the bug. | 
|---|
| 1315 |  | 
|---|
| 1316 | * A complete input file that will reproduce the bug.  If the bug is | 
|---|
| 1317 | observed when the assembler is invoked via a compiler, send the | 
|---|
| 1318 | assembler source, not the high level language source.  Most | 
|---|
| 1319 | compilers will produce the assembler source when run with the `-S' | 
|---|
| 1320 | option.  If you are using `gcc', use the options `-v | 
|---|
| 1321 | --save-temps'; this will save the assembler source in a file with | 
|---|
| 1322 | an extension of `.s', and also show you exactly how `as' is being | 
|---|
| 1323 | run. | 
|---|
| 1324 |  | 
|---|
| 1325 | * A description of what behavior you observe that you believe is | 
|---|
| 1326 | incorrect.  For example, "It gets a fatal signal." | 
|---|
| 1327 |  | 
|---|
| 1328 | Of course, if the bug is that `as' gets a fatal signal, then we | 
|---|
| 1329 | will certainly notice it.  But if the bug is incorrect output, we | 
|---|
| 1330 | might not notice unless it is glaringly wrong.  You might as well | 
|---|
| 1331 | not give us a chance to make a mistake. | 
|---|
| 1332 |  | 
|---|
| 1333 | Even if the problem you experience is a fatal signal, you should | 
|---|
| 1334 | still say so explicitly.  Suppose something strange is going on, | 
|---|
| 1335 | such as, your copy of `as' is out of synch, or you have | 
|---|
| 1336 | encountered a bug in the C library on your system.  (This has | 
|---|
| 1337 | happened!)  Your copy might crash and ours would not.  If you told | 
|---|
| 1338 | us to expect a crash, then when ours fails to crash, we would know | 
|---|
| 1339 | that the bug was not happening for us.  If you had not told us to | 
|---|
| 1340 | expect a crash, then we would not be able to draw any conclusion | 
|---|
| 1341 | from our observations. | 
|---|
| 1342 |  | 
|---|
| 1343 | * If you wish to suggest changes to the `as' source, send us context | 
|---|
| 1344 | diffs, as generated by `diff' with the `-u', `-c', or `-p' option. | 
|---|
| 1345 | Always send diffs from the old file to the new file.  If you even | 
|---|
| 1346 | discuss something in the `as' source, refer to it by context, not | 
|---|
| 1347 | by line number. | 
|---|
| 1348 |  | 
|---|
| 1349 | The line numbers in our development sources will not match those | 
|---|
| 1350 | in your sources.  Your line numbers would convey no useful | 
|---|
| 1351 | information to us. | 
|---|
| 1352 |  | 
|---|
| 1353 | Here are some things that are not necessary: | 
|---|
| 1354 |  | 
|---|
| 1355 | * A description of the envelope of the bug. | 
|---|
| 1356 |  | 
|---|
| 1357 | Often people who encounter a bug spend a lot of time investigating | 
|---|
| 1358 | which changes to the input file will make the bug go away and which | 
|---|
| 1359 | changes will not affect it. | 
|---|
| 1360 |  | 
|---|
| 1361 | This is often time consuming and not very useful, because the way | 
|---|
| 1362 | we will find the bug is by running a single example under the | 
|---|
| 1363 | debugger with breakpoints, not by pure deduction from a series of | 
|---|
| 1364 | examples.  We recommend that you save your time for something else. | 
|---|
| 1365 |  | 
|---|
| 1366 | Of course, if you can find a simpler example to report _instead_ | 
|---|
| 1367 | of the original one, that is a convenience for us.  Errors in the | 
|---|
| 1368 | output will be easier to spot, running under the debugger will take | 
|---|
| 1369 | less time, and so on. | 
|---|
| 1370 |  | 
|---|
| 1371 | However, simplification is not vital; if you do not want to do | 
|---|
| 1372 | this, report the bug anyway and send us the entire test case you | 
|---|
| 1373 | used. | 
|---|
| 1374 |  | 
|---|
| 1375 | * A patch for the bug. | 
|---|
| 1376 |  | 
|---|
| 1377 | A patch for the bug does help us if it is a good one.  But do not | 
|---|
| 1378 | omit the necessary information, such as the test case, on the | 
|---|
| 1379 | assumption that a patch is all we need.  We might see problems | 
|---|
| 1380 | with your patch and decide to fix the problem another way, or we | 
|---|
| 1381 | might not understand it at all. | 
|---|
| 1382 |  | 
|---|
| 1383 | Sometimes with a program as complicated as `as' it is very hard to | 
|---|
| 1384 | construct an example that will make the program follow a certain | 
|---|
| 1385 | path through the code.  If you do not send us the example, we will | 
|---|
| 1386 | not be able to construct one, so we will not be able to verify | 
|---|
| 1387 | that the bug is fixed. | 
|---|
| 1388 |  | 
|---|
| 1389 | And if we cannot understand what bug you are trying to fix, or why | 
|---|
| 1390 | your patch should be an improvement, we will not install it.  A | 
|---|
| 1391 | test case will help us to understand. | 
|---|
| 1392 |  | 
|---|
| 1393 | * A guess about what the bug is or what it depends on. | 
|---|
| 1394 |  | 
|---|
| 1395 | Such guesses are usually wrong.  Even we cannot guess right about | 
|---|
| 1396 | such things without first using the debugger to find the facts. | 
|---|
| 1397 |  | 
|---|