home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / gas / doc / as.info-1 (.txt) < prev    next >
GNU Info File  |  1996-09-28  |  50KB  |  943 lines

  1. This is Info file as.info, produced by Makeinfo-1.55 from the input
  2. file ./as.texinfo.
  3. START-INFO-DIR-ENTRY
  4. * As: (as).                     The GNU assembler.
  5. END-INFO-DIR-ENTRY
  6.    This file documents the GNU Assembler "as".
  7.    Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation,
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided that
  13. the entire resulting derived work is distributed under the terms of a
  14. permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions.
  18. File: as.info,  Node: Top,  Next: Overview,  Prev: (DIR),  Up: (DIR)
  19. Using as
  20. ********
  21.    This file is a user guide to the GNU assembler `as'.
  22. * Menu:
  23. * Overview::                    Overview
  24. * Invoking::                    Command-Line Options
  25. * Syntax::                      Syntax
  26. * Sections::                    Sections and Relocation
  27. * Symbols::                     Symbols
  28. * Expressions::                 Expressions
  29. * Pseudo Ops::                  Assembler Directives
  30. * Machine Dependencies::        Machine Dependent Features
  31. * Acknowledgements::            Who Did What
  32. * Index::                       Index
  33. File: as.info,  Node: Overview,  Next: Invoking,  Prev: Top,  Up: Top
  34. Overview
  35. ********
  36.    Here is a brief summary of how to invoke `as'.  For details, *note
  37. Comand-Line Options: Invoking..
  38.      as [ -a[dhlns][=file] ] [ -D ]  [ --defsym SYM=VAL ]
  39.       [ -f ] [ --help ] [ -I DIR ] [ -J ] [ -K ] [ -L ]
  40.       [ -o OBJFILE ] [ -R ] [ --statistics ] [ -v ] [ -version ]
  41.       [ --version ] [ -W ] [ -w ] [ -x ] [ -Z ]
  42.       [ -Av6 | -Av7 | -Av8 | -Asparclite | -Av9 | -Av9a ]
  43.       [ -xarch=v8plus | -xarch=v8plusa ] [ -bump ]
  44.       [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
  45.       [ -b ] [ -no-relax ]
  46.       [ -l ] [ -m68000 | -m68010 | -m68020 | ... ]
  47.       [ -nocpp ] [ -EL ] [ -EB ] [ -G NUM ] [ -mcpu=CPU ]
  48.       [ -mips1 ] [ -mips2 ] [ -mips3 ] [ -m4650 ] [ -no-m4650 ]
  49.       [ --trap ] [ --break ]
  50.       [ --emulation=NAME ]
  51.       [ -- | FILES ... ]
  52. `-a[dhlns]'
  53.      Turn on listings, in any of a variety of ways:
  54.     `-ad'
  55.           omit debugging directives
  56.     `-ah'
  57.           include high-level source
  58.     `-al'
  59.           include assembly
  60.     `-an'
  61.           omit forms processing
  62.     `-as'
  63.           include symbols
  64.     `=file'
  65.           set the name of the listing file
  66.      You may combine these options; for example, use `-aln' for assembly
  67.      listing without forms processing.  The `=file' option, if used,
  68.      must be the last one.  By itself, `-a' defaults to `-ahls'--that
  69.      is, all listings turned on.
  70.      Ignored.  This option is accepted for script compatibility with
  71.      calls to other assemblers.
  72. `--defsym SYM=VALUE'
  73.      Define the symbol SYM to be VALUE before assembling the input file.
  74.      vALUE must be an integer constant.  As in C, a leading `0x'
  75.      indicates a hexadecimal value, and a leading `0' indicates an
  76.      octal value.
  77.      "fast"--skip whitespace and comment preprocessing (assume source is
  78.      compiler output).
  79. `--help'
  80.      Print a summary of the command line options and exit.
  81. `-I DIR'
  82.      Add directory DIR to the search list for `.include' directives.
  83.      Don't warn about signed overflow.
  84.      Issue warnings when difference tables altered for long
  85.      displacements.
  86.      Keep (in the symbol table) local symbols, starting with `L'.
  87. `-o OBJFILE'
  88.      Name the object-file output from `as' OBJFILE.
  89.      Fold the data section into the text section.
  90. `--statistics'
  91.      Print the maximum space (in bytes) and total time (in seconds)
  92.      used by assembly.
  93. `-version'
  94.      Print the `as' version.
  95. `--version'
  96.      Print the `as' version and exit.
  97.      Suppress warning messages.
  98.      Ignored.
  99.      Ignored.
  100.      Generate an object file even after errors.
  101. `-- | FILES ...'
  102.      Standard input, or source files to assemble.
  103.    The following options are available when as is configured for the
  104. Intel 80960 processor.
  105. `-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC'
  106.      Specify which variant of the 960 architecture is the target.
  107.      Add code to collect statistics about branches taken.
  108. `-no-relax'
  109.      Do not alter compare-and-branch instructions for long
  110.      displacements; error if necessary.
  111.    The following options are available when as is configured for the
  112. Motorola 68000 series.
  113.      Shorten references to undefined symbols, to one word instead of
  114.      two.
  115. `-m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040'
  116. `| -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32'
  117.      Specify what processor in the 68000 family is the target.  The
  118.      default is normally the 68020, but this can be changed at
  119.      configuration time.
  120. `-m68881 | -m68882 | -mno-68881 | -mno-68882'
  121.      The target machine does (or does not) have a floating-point
  122.      coprocessor.  The default is to assume a coprocessor for 68020,
  123.      68030, and cpu32.  Although the basic 68000 is not compatible with
  124.      the 68881, a combination of the two can be specified, since it's
  125.      possible to do emulation of the coprocessor instructions with the
  126.      main processor.
  127. `-m68851 | -mno-68851'
  128.      The target machine does (or does not) have a memory-management
  129.      unit coprocessor.  The default is to assume an MMU for 68020 and
  130.      up.
  131.    The following options are available when `as' is configured for the
  132. SPARC architecture:
  133. `-Av6 | -Av7 | -Av8 | -Asparclite | -Av9 | -Av9a'
  134.      Explicitly select a variant of the SPARC architecture.
  135. `-xarch=v8plus | -xarch=v8plusa'
  136.      For compatibility with the Solaris v9 assembler.  These options are
  137.      equivalent to -Av9 and -Av9a, respectively.
  138. `-bump'
  139.      Warn when the assembler switches to another architecture.
  140.    The following options are available when as is configured for a MIPS
  141. processor.
  142. `-G NUM'
  143.      This option sets the largest size of an object that can be
  144.      referenced implicitly with the `gp' register.  It is only accepted
  145.      for targets that use ECOFF format, such as a DECstation running
  146.      Ultrix.  The default value is 8.
  147. `-EB'
  148.      Generate "big endian" format output.
  149. `-EL'
  150.      Generate "little endian" format output.
  151. `-mips1'
  152. `-mips2'
  153. `-mips3'
  154.      Generate code for a particular MIPS Instruction Set Architecture
  155.      level.  `-mips1' corresponds to the R2000 and R3000 processors,
  156.      `-mips2' to the R6000 processor, and `-mips3' to the R4000
  157.      processor.
  158. `-m4650'
  159. `-no-m4650'
  160.      Generate code for the MIPS R4650 chip.  This tells the assembler
  161.      to accept the `mad' and `madu' instruction, and to not schedule
  162.      `nop' instructions around accesses to the `HI' and `LO' registers.
  163.      `-no-m4650' turns off this option.
  164. `-mcpu=CPU'
  165.      Generate code for a particular MIPS cpu.  This has little effect
  166.      on the assembler, but it is passed by `gcc'.
  167. `--emulation=NAME'
  168.      This option causes `as' to emulated `as' configured for some other
  169.      target, in all respects, including output format (choosing between
  170.      ELF and ECOFF only), handling of pseudo-opcodes which may generate
  171.      debugging information or store symbol table information, and
  172.      default endianness.  The available configuration names are:
  173.      `mipsecoff', `mipself', `mipslecoff', `mipsbecoff', `mipslelf',
  174.      `mipsbelf'.  The first two do not alter the default endianness
  175.      from that of the primary target for which the assembler was
  176.      configured; the others change the default to little- or big-endian
  177.      as indicated by the `b' or `l' in the name.  Using `-EB' or `-EL'
  178.      will override the endianness selection in any case.
  179.      This option is currently supported only when the primary target
  180.      `as' is configured for is a MIPS ELF or ECOFF target.
  181.      Furthermore, the primary target or others specified with
  182.      `--enable-targets=...' at configuration time must include support
  183.      for the other format, if both are to be available.  For example,
  184.      the Irix 5 configuration includes support for both.
  185.      Eventually, this option will support more configurations, with more
  186.      fine-grained control over the assembler's behavior, and will be
  187.      supported for more processors.
  188. `-nocpp'
  189.      `as' ignores this option.  It is accepted for compatibility with
  190.      the native tools.
  191. `--trap'
  192. `--no-trap'
  193. `--break'
  194. `--no-break'
  195.      Control how to deal with multiplication overflow and division by
  196.      zero.  `--trap' or `--no-break' (which are synonyms) take a trap
  197.      exception (and only work for Instruction Set Architecture level 2
  198.      and higher); `--break' or `--no-trap' (also synonyms, and the
  199.      default) take a break exception.
  200. * Menu:
  201. * Manual::                      Structure of this Manual
  202. * GNU Assembler::               as, the GNU Assembler
  203. * Object Formats::              Object File Formats
  204. * Command Line::                Command Line
  205. * Input Files::                 Input Files
  206. * Object::                      Output (Object) File
  207. * Errors::                      Error and Warning Messages
  208. File: as.info,  Node: Manual,  Next: GNU Assembler,  Up: Overview
  209. Structure of this Manual
  210. ========================
  211.    This manual is intended to describe what you need to know to use GNU
  212. `as'.  We cover the syntax expected in source files, including notation
  213. for symbols, constants, and expressions; the directives that `as'
  214. understands; and of course how to invoke `as'.
  215.    This manual also describes some of the machine-dependent features of
  216. various flavors of the assembler.
  217.    On the other hand, this manual is *not* intended as an introduction
  218. to programming in assembly language--let alone programming in general!
  219. In a similar vein, we make no attempt to introduce the machine
  220. architecture; we do *not* describe the instruction set, standard
  221. mnemonics, registers or addressing modes that are standard to a
  222. particular architecture.  You may want to consult the manufacturer's
  223. machine architecture manual for this information.
  224. File: as.info,  Node: GNU Assembler,  Next: Object Formats,  Prev: Manual,  Up: Overview
  225. as, the GNU Assembler
  226. =====================
  227.    GNU `as' is really a family of assemblers.  If you use (or have
  228. used) the GNU assembler on one architecture, you should find a fairly
  229. similar environment when you use it on another architecture.  Each
  230. version has much in common with the others, including object file
  231. formats, most assembler directives (often called "pseudo-ops") and
  232. assembler syntax.
  233.    `as' is primarily intended to assemble the output of the GNU C
  234. compiler `gcc' for use by the linker `ld'.  Nevertheless, we've tried
  235. to make `as' assemble correctly everything that other assemblers for
  236. the same machine would assemble.  Any exceptions are documented
  237. explicitly (*note Machine Dependencies::.).  This doesn't mean `as'
  238. always uses the same syntax as another assembler for the same
  239. architecture; for example, we know of several incompatible versions of
  240. 680x0 assembly language syntax.
  241.    Unlike older assemblers, `as' is designed to assemble a source
  242. program in one pass of the source file.  This has a subtle impact on the
  243. `.org' directive (*note `.org': Org.).
  244. File: as.info,  Node: Object Formats,  Next: Command Line,  Prev: GNU Assembler,  Up: Overview
  245. Object File Formats
  246. ===================
  247.    The GNU assembler can be configured to produce several alternative
  248. object file formats.  For the most part, this does not affect how you
  249. write assembly language programs; but directives for debugging symbols
  250. are typically different in different file formats.  *Note Symbol
  251. Attributes: Symbol Attributes.
  252. File: as.info,  Node: Command Line,  Next: Input Files,  Prev: Object Formats,  Up: Overview
  253. Command Line
  254. ============
  255.    After the program name `as', the command line may contain options
  256. and file names.  Options may appear in any order, and may be before,
  257. after, or between file names.  The order of file names is significant.
  258.    `--' (two hyphens) by itself names the standard input file
  259. explicitly, as one of the files for `as' to assemble.
  260.    Except for `--' any command line argument that begins with a hyphen
  261. (`-') is an option.  Each option changes the behavior of `as'.  No
  262. option changes the way another option works.  An option is a `-'
  263. followed by one or more letters; the case of the letter is important.
  264. All options are optional.
  265.    Some options expect exactly one file name to follow them.  The file
  266. name may either immediately follow the option's letter (compatible with
  267. older assemblers) or it may be the next command argument (GNU
  268. standard).  These two command lines are equivalent:
  269.      as -o my-object-file.o mumble.s
  270.      as -omy-object-file.o mumble.s
  271. File: as.info,  Node: Input Files,  Next: Object,  Prev: Command Line,  Up: Overview
  272. Input Files
  273. ===========
  274.    We use the phrase "source program", abbreviated "source", to
  275. describe the program input to one run of `as'.  The program may be in
  276. one or more files; how the source is partitioned into files doesn't
  277. change the meaning of the source.
  278.    The source program is a concatenation of the text in all the files,
  279. in the order specified.
  280.    Each time you run `as' it assembles exactly one source program.  The
  281. source program is made up of one or more files.  (The standard input is
  282. also a file.)
  283.    You give `as' a command line that has zero or more input file names.
  284. The input files are read (from left file name to right).  A command
  285. line argument (in any position) that has no special meaning is taken to
  286. be an input file name.
  287.    If you give `as' no file names it attempts to read one input file
  288. from the `as' standard input, which is normally your terminal.  You may
  289. have to type ctl-D to tell `as' there is no more program to assemble.
  290.    Use `--' if you need to explicitly name the standard input file in
  291. your command line.
  292.    If the source is empty, `as' produces a small, empty object file.
  293. Filenames and Line-numbers
  294. --------------------------
  295.    There are two ways of locating a line in the input file (or files)
  296. and either may be used in reporting error messages.  One way refers to
  297. a line number in a physical file; the other refers to a line number in a
  298. "logical" file.  *Note Error and Warning Messages: Errors.
  299.    "Physical files" are those files named in the command line given to
  300. `as'.
  301.    "Logical files" are simply names declared explicitly by assembler
  302. directives; they bear no relation to physical files.  Logical file names
  303. help error messages reflect the original source file, when `as' source
  304. is itself synthesized from other files.  *Note `.app-file': App-File.
  305. File: as.info,  Node: Object,  Next: Errors,  Prev: Input Files,  Up: Overview
  306. Output (Object) File
  307. ====================
  308.    Every time you run `as' it produces an output file, which is your
  309. assembly language program translated into numbers.  This file is the
  310. object file.  Its default name is `a.out', or `b.out' when `as' is
  311. configured for the Intel 80960.  You can give it another name by using
  312. the `-o' option.  Conventionally, object file names end with `.o'.  The
  313. default name is used for historical reasons: older assemblers were
  314. capable of assembling self-contained programs directly into a runnable
  315. program.  (For some formats, this isn't currently possible, but it can
  316. be done for the `a.out' format.)
  317.    The object file is meant for input to the linker `ld'.  It contains
  318. assembled program code, information to help `ld' integrate the
  319. assembled program into a runnable file, and (optionally) symbolic
  320. information for the debugger.
  321. File: as.info,  Node: Errors,  Prev: Object,  Up: Overview
  322. Error and Warning Messages
  323. ==========================
  324.    `as' may write warnings and error messages to the standard error
  325. file (usually your terminal).  This should not happen when  a compiler
  326. runs `as' automatically.  Warnings report an assumption made so that
  327. `as' could keep assembling a flawed program; errors report a grave
  328. problem that stops the assembly.
  329.    Warning messages have the format
  330.      file_name:NNN:Warning Message Text
  331. (where NNN is a line number).  If a logical file name has been given
  332. (*note `.app-file': App-File.) it is used for the filename, otherwise
  333. the name of the current input file is used.  If a logical line number
  334. was given (*note `.line': Line.) then it is used to calculate the
  335. number printed, otherwise the actual line in the current source file is
  336. printed.  The message text is intended to be self explanatory (in the
  337. grand Unix tradition).
  338.    Error messages have the format
  339.      file_name:NNN:FATAL:Error Message Text
  340.    The file name and line number are derived as for warning messages.
  341. The actual message text may be rather less explanatory because many of
  342. them aren't supposed to happen.
  343. File: as.info,  Node: Invoking,  Next: Syntax,  Prev: Overview,  Up: Top
  344. Command-Line Options
  345. ********************
  346.    This chapter describes command-line options available in *all*
  347. versions of the GNU assembler; *note Machine Dependencies::., for
  348. options specific to particular machine architectures.
  349.    If you are invoking `as' via the GNU C compiler (version 2), you can
  350. use the `-Wa' option to pass arguments through to the assembler.  The
  351. assembler arguments must be separated from each other (and the `-Wa')
  352. by commas.  For example:
  353.      gcc -c -g -O -Wa,-alh,-L file.c
  354. emits a listing to standard output with high-level and assembly source.
  355.    Usually you do not need to use this `-Wa' mechanism, since many
  356. compiler command-line options are automatically passed to the assembler
  357. by the compiler.  (You can call the GNU compiler driver with the `-v'
  358. option to see precisely what options it passes to each compilation
  359. pass, including the assembler.)
  360. * Menu:
  361. * a::             -a[dhlns] enable listings
  362. * D::             -D for compatibility
  363. * f::             -f to work faster
  364. * I::             -I for .include search path
  365. * K::             -K for difference tables
  366. * L::             -L to retain local labels
  367. * M::          -M or -mri to assemble in MRI compatibility mode
  368. * o::             -o to name the object file
  369. * R::             -R to join data and text sections
  370. * statistics::    -statistics to see statistics about assembly
  371. * v::             -v to announce version
  372. * W::             -W to suppress warnings
  373. * Z::             -Z to make object file even after errors
  374. File: as.info,  Node: a,  Next: D,  Up: Invoking
  375. Enable Listings: `-a[dhlns]'
  376. ============================
  377.    These options enable listing output from the assembler.  By itself,
  378. `-a' requests high-level, assembly, and symbols listing.  You can use
  379. other letters to select specific options for the list: `-ah' requests a
  380. high-level language listing, `-al' requests an output-program assembly
  381. listing, and `-as' requests a symbol table listing.  High-level
  382. listings require that a compiler debugging option like `-g' be used,
  383. and that assembly listings (`-al') be requested also.
  384.    Use the `-ad' option to omit debugging directives from the listing.
  385.    Once you have specified one of these options, you can further control
  386. listing output and its appearance using the directives `.list',
  387. `.nolist', `.psize', `.eject', `.title', and `.sbttl'.  The `-an'
  388. option turns off all forms processing.  If you do not request listing
  389. output with one of the `-a' options, the listing-control directives
  390. have no effect.
  391.    The letters after `-a' may be combined into one option, *e.g.*,
  392. `-aln'.
  393. File: as.info,  Node: D,  Next: f,  Prev: a,  Up: Invoking
  394.    This option has no effect whatsoever, but it is accepted to make it
  395. more likely that scripts written for other assemblers also work with
  396. `as'.
  397. File: as.info,  Node: f,  Next: I,  Prev: D,  Up: Invoking
  398. Work Faster: `-f'
  399. =================
  400.    `-f' should only be used when assembling programs written by a
  401. (trusted) compiler.  `-f' stops the assembler from doing whitespace and
  402. comment preprocessing on the input file(s) before assembling them.
  403. *Note Preprocessing: Preprocessing.
  404.      *Warning:* if you use `-f' when the files actually need to be
  405.      preprocessed (if they contain comments, for example), `as' does
  406.      not work correctly.
  407. File: as.info,  Node: I,  Next: K,  Prev: f,  Up: Invoking
  408. `.include' search path: `-I' PATH
  409. =================================
  410.    Use this option to add a PATH to the list of directories `as'
  411. searches for files specified in `.include' directives (*note
  412. `.include': Include.).  You may use `-I' as many times as necessary to
  413. include a variety of paths.  The current working directory is always
  414. searched first; after that, `as' searches any `-I' directories in the
  415. same order as they were specified (left to right) on the command line.
  416. File: as.info,  Node: K,  Next: L,  Prev: I,  Up: Invoking
  417. Difference Tables: `-K'
  418. =======================
  419.    `as' sometimes alters the code emitted for directives of the form
  420. `.word SYM1-SYM2'; *note `.word': Word..  You can use the `-K' option
  421. if you want a warning issued when this is done.
  422. File: as.info,  Node: L,  Next: M,  Prev: K,  Up: Invoking
  423. Include Local Labels: `-L'
  424. ==========================
  425.    Labels beginning with `L' (upper case only) are called "local
  426. labels". *Note Symbol Names::.  Normally you do not see such labels when
  427. debugging, because they are intended for the use of programs (like
  428. compilers) that compose assembler programs, not for your notice.
  429. Normally both `as' and `ld' discard such labels, so you do not normally
  430. debug with them.
  431.    This option tells `as' to retain those `L...' symbols in the object
  432. file.  Usually if you do this you also tell the linker `ld' to preserve
  433. symbols whose names begin with `L'.
  434.    By default, a local label is any label beginning with `L', but each
  435. target is allowed to redefine the local label prefix.  On the HPPA
  436. local labels begin with `L$'.
  437. File: as.info,  Node: M,  Next: o,  Prev: L,  Up: Invoking
  438. Assemble in MRI Compatibility Mode: `-M'
  439. ========================================
  440.    The `-M' or `--mri' option selects MRI compatibility mode.  This
  441. changes the syntax and pseudo-op handling of `as' to make it compatible
  442. with the `ASM68K' or the `ASM960' (depending upon the configured
  443. target) assembler from Microtec Research.  The exact nature of the MRI
  444. syntax will not be documented here; see the MRI manuals for more
  445. information.  The purpose of this option is to permit assembling
  446. existing MRI assembler code using `as'.
  447.    The MRI compatibility is not complete.  Certain operations of the
  448. MRI assembler depend upon its object file format, and can not be
  449. supported using other object file formats.  Supporting these would
  450. require enhancing each object file format individually.  These are:
  451.    * global symbols in common section
  452.      The m68k MRI assembler supports common sections which are merged
  453.      by the linker.  Other object file formats do not support this.
  454.      `as' handles common sections by treating them as a single common
  455.      symbol.  It permits local symbols to be defined within a common
  456.      section, but it can not support global symbols, since it has no
  457.      way to describe them.
  458.    * complex relocations
  459.      The MRI assemblers support relocations against a negated section
  460.      address, and relocations which combine the start addresses of two
  461.      or more sections.  These are not support by other object file
  462.      formats.
  463.    * `END' pseudo-op specifying start address
  464.      The MRI `END' pseudo-op permits the specification of a start
  465.      address.  This is not supported by other object file formats.  The
  466.      start address may instead be specified using the `-e' option to
  467.      the linker, or in a linker script.
  468.    * `IDNT', `.ident' and `NAME' pseudo-ops
  469.      The MRI `IDNT', `.ident' and `NAME' pseudo-ops assign a module
  470.      name to the output file.  This is not supported by other object
  471.      file formats.
  472.    * `ORG' pseudo-op
  473.      The m68k MRI `ORG' pseudo-op begins an absolute section at a given
  474.      address.  This differs from the usual `as' `.org' pseudo-op, which
  475.      changes the location within the current section.  Absolute
  476.      sections are not supported by other object file formats.  The
  477.      address of a section may be assigned within a linker script.
  478.    There are some other features of the MRI assembler which are not
  479. supported by `as', typically either because they are difficult or
  480. because they seem of little consequence.  Some of these may be
  481. supported in future releases.
  482.    * EBCDIC strings
  483.      EBCDIC strings are not supported.
  484.    * packed binary coded decimal
  485.      Packed binary coded decimal is not supported.  This means that the
  486.      `DC.P' and `DCB.P' pseudo-ops are not supported.
  487.    * `FEQU' pseudo-op
  488.      The m68k `FEQU' pseudo-op is not supported.
  489.    * `NOOBJ' pseudo-op
  490.      The m68k `NOOBJ' pseudo-op is not supported.
  491.    * `OPT' branch control options
  492.      The m68k `OPT' branch control options--`B', `BRS', `BRB', `BRL',
  493.      and `BRW'--are ignored.  `as' automatically relaxes all branches,
  494.      whether forward or backward, to an appropriate size, so these
  495.      options serve no purpose.
  496.    * `OPT' list control options
  497.      The following m68k `OPT' list control options are ignored: `C',
  498.      `CEX', `CL', `CRE', `E', `G', `I', `M', `MEX', `MC', `MD', `X'.
  499.    * other `OPT' options
  500.      The following m68k `OPT' options are ignored: `NEST', `O', `OLD',
  501.      `OP', `P', `PCO', `PCR', `PCS', `R'.
  502.    * `OPT' `D' option is default
  503.      The m68k `OPT' `D' option is the default, unlike the MRI assembler.
  504.      `OPT NOD' may be used to turn it off.
  505.    * `XREF' pseudo-op.
  506.      The m68k `XREF' pseudo-op is ignored.
  507.    * `.debug' pseudo-op
  508.      The i960 `.debug' pseudo-op is not supported.
  509.    * `.extended' pseudo-op
  510.      The i960 `.extended' pseudo-op is not supported.
  511.    * `.list' pseudo-op.
  512.      The various options of the i960 `.list' pseudo-op are not
  513.      supported.
  514.    * `.optimize' pseudo-op
  515.      The i960 `.optimize' pseudo-op is not supported.
  516.    * `.output' pseudo-op
  517.      The i960 `.output' pseudo-op is not supported.
  518.    * `.setreal' pseudo-op
  519.      The i960 `.setreal' pseudo-op is not supported.
  520. File: as.info,  Node: o,  Next: R,  Prev: M,  Up: Invoking
  521. Name the Object File: `-o'
  522. ==========================
  523.    There is always one object file output when you run `as'.  By
  524. default it has the name `a.out' (or `b.out', for Intel 960 targets
  525. only).  You use this option (which takes exactly one filename) to give
  526. the object file a different name.
  527.    Whatever the object file is called, `as' overwrites any existing
  528. file of the same name.
  529. File: as.info,  Node: R,  Next: statistics,  Prev: o,  Up: Invoking
  530. Join Data and Text Sections: `-R'
  531. =================================
  532.    `-R' tells `as' to write the object file as if all data-section data
  533. lives in the text section.  This is only done at the very last moment:
  534. your binary data are the same, but data section parts are relocated
  535. differently.  The data section part of your object file is zero bytes
  536. long because all its bytes are appended to the text section.  (*Note
  537. Sections and Relocation: Sections.)
  538.    When you specify `-R' it would be possible to generate shorter
  539. address displacements (because we do not have to cross between text and
  540. data section).  We refrain from doing this simply for compatibility with
  541. older versions of `as'.  In future, `-R' may work this way.
  542.    When `as' is configured for COFF output, this option is only useful
  543. if you use sections named `.text' and `.data'.
  544.    `-R' is not supported for any of the HPPA targets.  Using `-R'
  545. generates a warning from `as'.
  546. File: as.info,  Node: statistics,  Next: v,  Prev: R,  Up: Invoking
  547. Display Assembly Statistics: `--statistics'
  548. ===========================================
  549.    Use `--statistics' to display two statistics about the resources
  550. used by `as': the maximum amount of space allocated during the assembly
  551. (in bytes), and the total execution time taken for the assembly (in CPU
  552. seconds).
  553. File: as.info,  Node: v,  Next: W,  Prev: statistics,  Up: Invoking
  554. Announce Version: `-v'
  555. ======================
  556.    You can find out what version of as is running by including the
  557. option `-v' (which you can also spell as `-version') on the command
  558. line.
  559. File: as.info,  Node: W,  Next: Z,  Prev: v,  Up: Invoking
  560. Suppress Warnings: `-W'
  561. =======================
  562.    `as' should never give a warning or error message when assembling
  563. compiler output.  But programs written by people often cause `as' to
  564. give a warning that a particular assumption was made.  All such
  565. warnings are directed to the standard error file.  If you use this
  566. option, no warnings are issued.  This option only affects the warning
  567. messages: it does not change any particular of how `as' assembles your
  568. file.  Errors, which stop the assembly, are still reported.
  569. File: as.info,  Node: Z,  Prev: W,  Up: Invoking
  570. Generate Object File in Spite of Errors: `-Z'
  571. =============================================
  572.    After an error message, `as' normally produces no output.  If for
  573. some reason you are interested in object file output even after `as'
  574. gives an error message on your program, use the `-Z' option.  If there
  575. are any errors, `as' continues anyways, and writes an object file after
  576. a final warning message of the form `N errors, M warnings, generating
  577. bad object file.'
  578. File: as.info,  Node: Syntax,  Next: Sections,  Prev: Invoking,  Up: Top
  579. Syntax
  580. ******
  581.    This chapter describes the machine-independent syntax allowed in a
  582. source file.  `as' syntax is similar to what many other assemblers use;
  583. it is inspired by the BSD 4.2 assembler, except that `as' does not
  584. assemble Vax bit-fields.
  585. * Menu:
  586. * Preprocessing::              Preprocessing
  587. * Whitespace::                  Whitespace
  588. * Comments::                    Comments
  589. * Symbol Intro::                Symbols
  590. * Statements::                  Statements
  591. * Constants::                   Constants
  592. File: as.info,  Node: Preprocessing,  Next: Whitespace,  Up: Syntax
  593. Preprocessing
  594. =============
  595.    The `as' internal preprocessor:
  596.    * adjusts and removes extra whitespace.  It leaves one space or tab
  597.      before the keywords on a line, and turns any other whitespace on
  598.      the line into a single space.
  599.    * removes all comments, replacing them with a single space, or an
  600.      appropriate number of newlines.
  601.    * converts character constants into the appropriate numeric values.
  602.    It does not do macro processing, include file handling, or anything
  603. else you may get from your C compiler's preprocessor.  You can do
  604. include file processing with the `.include' directive (*note
  605. `.include': Include.).  You can use the GNU C compiler driver to get
  606. other "CPP" style preprocessing, by giving the input file a `.S'
  607. suffix.  *Note Options Controlling the Kind of Output:
  608. (gcc.info)Overall Options.
  609.    Excess whitespace, comments, and character constants cannot be used
  610. in the portions of the input text that are not preprocessed.
  611.    If the first line of an input file is `#NO_APP' or if you use the
  612. `-f' option, whitespace and comments are not removed from the input
  613. file.  Within an input file, you can ask for whitespace and comment
  614. removal in specific portions of the by putting a line that says `#APP'
  615. before the text that may contain whitespace or comments, and putting a
  616. line that says `#NO_APP' after this text.  This feature is mainly
  617. intend to support `asm' statements in compilers whose output is
  618. otherwise free of comments and whitespace.
  619. File: as.info,  Node: Whitespace,  Next: Comments,  Prev: Preprocessing,  Up: Syntax
  620. Whitespace
  621. ==========
  622.    "Whitespace" is one or more blanks or tabs, in any order.
  623. Whitespace is used to separate symbols, and to make programs neater for
  624. people to read.  Unless within character constants (*note Character
  625. Constants: Characters.), any whitespace means the same as exactly one
  626. space.
  627. File: as.info,  Node: Comments,  Next: Symbol Intro,  Prev: Whitespace,  Up: Syntax
  628. Comments
  629. ========
  630.    There are two ways of rendering comments to `as'.  In both cases the
  631. comment is equivalent to one space.
  632.    Anything from `/*' through the next `*/' is a comment.  This means
  633. you may not nest these comments.
  634.      /*
  635.        The only way to include a newline ('\n') in a comment
  636.        is to use this sort of comment.
  637.      */
  638.      
  639.      /* This sort of comment does not nest. */
  640.    Anything from the "line comment" character to the next newline is
  641. considered a comment and is ignored.  The line comment character is `;'
  642. for the AMD 29K family; `;' for the H8/300 family; `!' for the H8/500
  643. family; `;' for the HPPA; `#' on the i960; `!' for the Hitachi SH; `!'
  644. on the SPARC; `|' on the 680x0; `#' on the Vax; `!' for the Z8000; see
  645. *Note Machine Dependencies::.
  646.    On some machines there are two different line comment characters.
  647. One character only begins a comment if it is the first non-whitespace
  648. character on a line, while the other always begins a comment.
  649.    To be compatible with past assemblers, lines that begin with `#'
  650. have a special interpretation.  Following the `#' should be an absolute
  651. expression (*note Expressions::.): the logical line number of the *next*
  652. line.  Then a string (*note Strings: Strings.) is allowed: if present
  653. it is a new logical file name.  The rest of the line, if any, should be
  654. whitespace.
  655.    If the first non-whitespace characters on the line are not numeric,
  656. the line is ignored.  (Just like a comment.)
  657.                                # This is an ordinary comment.
  658.      # 42-6 "new_file_name"    # New logical file name
  659.                                # This is logical line # 36.
  660.    This feature is deprecated, and may disappear from future versions
  661. of `as'.
  662. File: as.info,  Node: Symbol Intro,  Next: Statements,  Prev: Comments,  Up: Syntax
  663. Symbols
  664. =======
  665.    A "symbol" is one or more characters chosen from the set of all
  666. letters (both upper and lower case), digits and the three characters
  667. `_.$'.  On most machines, you can also use `$' in symbol names;
  668. exceptions are noted in *Note Machine Dependencies::.  No symbol may
  669. begin with a digit.  Case is significant.  There is no length limit:
  670. all characters are significant.  Symbols are delimited by characters
  671. not in that set, or by the beginning of a file (since the source
  672. program must end with a newline, the end of a file is not a possible
  673. symbol delimiter).  *Note Symbols::.
  674. File: as.info,  Node: Statements,  Next: Constants,  Prev: Symbol Intro,  Up: Syntax
  675. Statements
  676. ==========
  677.    A "statement" ends at a newline character (`\n') or line separator
  678. character.  (The line separator is usually `;', unless this conflicts
  679. with the comment character; *note Machine Dependencies::..)  The
  680. newline or separator character is considered part of the preceding
  681. statement.  Newlines and separators within character constants are an
  682. exception: they do not end statements.
  683.    It is an error to end any statement with end-of-file:  the last
  684. character of any input file should be a newline.
  685.    You may write a statement on more than one line if you put a
  686. backslash (`\') immediately in front of any newlines within the
  687. statement.  When `as' reads a backslashed newline both characters are
  688. ignored.  You can even put backslashed newlines in the middle of symbol
  689. names without changing the meaning of your source program.
  690.    An empty statement is allowed, and may include whitespace.  It is
  691. ignored.
  692.    A statement begins with zero or more labels, optionally followed by a
  693. key symbol which determines what kind of statement it is.  The key
  694. symbol determines the syntax of the rest of the statement.  If the
  695. symbol begins with a dot `.' then the statement is an assembler
  696. directive: typically valid for any computer.  If the symbol begins with
  697. a letter the statement is an assembly language "instruction": it
  698. assembles into a machine language instruction.  Different versions of
  699. `as' for different computers recognize different instructions.  In
  700. fact, the same symbol may represent a different instruction in a
  701. different computer's assembly language.
  702.    A label is a symbol immediately followed by a colon (`:').
  703. Whitespace before a label or after a colon is permitted, but you may not
  704. have whitespace between a label's symbol and its colon. *Note Labels::.
  705.    For HPPA targets, labels need not be immediately followed by a
  706. colon, but the definition of a label must begin in column zero.  This
  707. also implies that only one label may be defined on each line.
  708.      label:     .directive    followed by something
  709.      another_label:           # This is an empty statement.
  710.                 instruction   operand_1, operand_2, ...
  711. File: as.info,  Node: Constants,  Prev: Statements,  Up: Syntax
  712. Constants
  713. =========
  714.    A constant is a number, written so that its value is known by
  715. inspection, without knowing any context.  Like this:
  716.      .byte  74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
  717.      .ascii "Ring the bell\7"                  # A string constant.
  718.      .octa  0x123456789abcdef0123456789ABCDEF0 # A bignum.
  719.      .float 0f-314159265358979323846264338327\
  720.      95028841971.693993751E-40                 # - pi, a flonum.
  721. * Menu:
  722. * Characters::                  Character Constants
  723. * Numbers::                     Number Constants
  724. File: as.info,  Node: Characters,  Next: Numbers,  Up: Constants
  725. Character Constants
  726. -------------------
  727.    There are two kinds of character constants.  A "character" stands
  728. for one character in one byte and its value may be used in numeric
  729. expressions.  String constants (properly called string *literals*) are
  730. potentially many bytes and their values may not be used in arithmetic
  731. expressions.
  732. * Menu:
  733. * Strings::                     Strings
  734. * Chars::                       Characters
  735. File: as.info,  Node: Strings,  Next: Chars,  Up: Characters
  736. Strings
  737. .......
  738.    A "string" is written between double-quotes.  It may contain
  739. double-quotes or null characters.  The way to get special characters
  740. into a string is to "escape" these characters: precede them with a
  741. backslash `\' character.  For example `\\' represents one backslash:
  742. the first `\' is an escape which tells `as' to interpret the second
  743. character literally as a backslash (which prevents `as' from
  744. recognizing the second `\' as an escape character).  The complete list
  745. of escapes follows.
  746.      Mnemonic for backspace; for ASCII this is octal code 010.
  747.      Mnemonic for FormFeed; for ASCII this is octal code 014.
  748.      Mnemonic for newline; for ASCII this is octal code 012.
  749.      Mnemonic for carriage-Return; for ASCII this is octal code 015.
  750.      Mnemonic for horizontal Tab; for ASCII this is octal code 011.
  751. `\ DIGIT DIGIT DIGIT'
  752.      An octal character code.  The numeric code is 3 octal digits.  For
  753.      compatibility with other Unix systems, 8 and 9 are accepted as
  754.      digits: for example, `\008' has the value 010, and `\009' the
  755.      value 011.
  756. `\`x' HEX-DIGITS...'
  757.      A hex character code.  All trailing hex digits are combined.
  758.      Either upper or lower case `x' works.
  759.      Represents one `\' character.
  760.      Represents one `"' character.  Needed in strings to represent this
  761.      character, because an unescaped `"' would end the string.
  762. `\ ANYTHING-ELSE'
  763.      Any other character when escaped by `\' gives a warning, but
  764.      assembles as if the `\' was not present.  The idea is that if you
  765.      used an escape sequence you clearly didn't want the literal
  766.      interpretation of the following character.  However `as' has no
  767.      other interpretation, so `as' knows it is giving you the wrong
  768.      code and warns you of the fact.
  769.    Which characters are escapable, and what those escapes represent,
  770. varies widely among assemblers.  The current set is what we think the
  771. BSD 4.2 assembler recognizes, and is a subset of what most C compilers
  772. recognize.  If you are in doubt, do not use an escape sequence.
  773. File: as.info,  Node: Chars,  Prev: Strings,  Up: Characters
  774. Characters
  775. ..........
  776.    A single character may be written as a single quote immediately
  777. followed by that character.  The same escapes apply to characters as to
  778. strings.  So if you want to write the character backslash, you must
  779. write `'\\' where the first `\' escapes the second `\'.  As you can
  780. see, the quote is an acute accent, not a grave accent.  A newline
  781. immediately following an acute accent is taken as a literal character
  782. and does not count as the end of a statement.  The value of a character
  783. constant in a numeric expression is the machine's byte-wide code for
  784. that character.  `as' assumes your character code is ASCII: `'A' means
  785. 65, `'B' means 66, and so on.
  786. File: as.info,  Node: Numbers,  Prev: Characters,  Up: Constants
  787. Number Constants
  788. ----------------
  789.    `as' distinguishes three kinds of numbers according to how they are
  790. stored in the target machine.  *Integers* are numbers that would fit
  791. into an `int' in the C language.  *Bignums* are integers, but they are
  792. stored in more than 32 bits.  *Flonums* are floating point numbers,
  793. described below.
  794. * Menu:
  795. * Integers::                    Integers
  796. * Bignums::                     Bignums
  797. * Flonums::                     Flonums
  798. File: as.info,  Node: Integers,  Next: Bignums,  Up: Numbers
  799. Integers
  800. ........
  801.    A binary integer is `0b' or `0B' followed by zero or more of the
  802. binary digits `01'.
  803.    An octal integer is `0' followed by zero or more of the octal digits
  804. (`01234567').
  805.    A decimal integer starts with a non-zero digit followed by zero or
  806. more digits (`0123456789').
  807.    A hexadecimal integer is `0x' or `0X' followed by one or more
  808. hexadecimal digits chosen from `0123456789abcdefABCDEF'.
  809.    Integers have the usual values.  To denote a negative integer, use
  810. the prefix operator `-' discussed under expressions (*note Prefix
  811. Operators: Prefix Ops.).
  812. File: as.info,  Node: Bignums,  Next: Flonums,  Prev: Integers,  Up: Numbers
  813. Bignums
  814. .......
  815.    A "bignum" has the same syntax and semantics as an integer except
  816. that the number (or its negative) takes more than 32 bits to represent
  817. in binary.  The distinction is made because in some places integers are
  818. permitted while bignums are not.
  819. File: as.info,  Node: Flonums,  Prev: Bignums,  Up: Numbers
  820. Flonums
  821. .......
  822.    A "flonum" represents a floating point number.  The translation is
  823. indirect: a decimal floating point number from the text is converted by
  824. `as' to a generic binary floating point number of more than sufficient
  825. precision.  This generic floating point number is converted to a
  826. particular computer's floating point format (or formats) by a portion
  827. of `as' specialized to that computer.
  828.    A flonum is written by writing (in order)
  829.    * The digit `0'.  (`0' is optional on the HPPA.)
  830.    * A letter, to tell `as' the rest of the number is a flonum.  `e' is
  831.      recommended.  Case is not important.
  832.      On the H8/300, H8/500, Hitachi SH, and AMD 29K architectures, the
  833.      letter must be one of the letters `DFPRSX' (in upper or lower
  834.      case).
  835.      On the Intel 960 architecture, the letter must be one of the
  836.      letters `DFT' (in upper or lower case).
  837.      On the HPPA architecture, the letter must be `E' (upper case only).
  838.    * An optional sign: either `+' or `-'.
  839.    * An optional "integer part": zero or more decimal digits.
  840.    * An optional "fractional part": `.' followed by zero or more
  841.      decimal digits.
  842.    * An optional exponent, consisting of:
  843.         * An `E' or `e'.
  844.         * Optional sign: either `+' or `-'.
  845.         * One or more decimal digits.
  846.    At least one of the integer part or the fractional part must be
  847. present.  The floating point number has the usual base-10 value.
  848.    `as' does all processing using integers.  Flonums are computed
  849. independently of any floating point hardware in the computer running
  850. `as'.
  851. File: as.info,  Node: Sections,  Next: Symbols,  Prev: Syntax,  Up: Top
  852. Sections and Relocation
  853. ***********************
  854. * Menu:
  855. * Secs Background::             Background
  856. * Ld Sections::                 ld Sections
  857. * As Sections::                 as Internal Sections
  858. * Sub-Sections::                Sub-Sections
  859. * bss::                         bss Section
  860. File: as.info,  Node: Secs Background,  Next: Ld Sections,  Up: Sections
  861. Background
  862. ==========
  863.    Roughly, a section is a range of addresses, with no gaps; all data
  864. "in" those addresses is treated the same for some particular purpose.
  865. For example there may be a "read only" section.
  866.    The linker `ld' reads many object files (partial programs) and
  867. combines their contents to form a runnable program.  When `as' emits an
  868. object file, the partial program is assumed to start at address 0.
  869. `ld' assigns the final addresses for the partial program, so that
  870. different partial programs do not overlap.  This is actually an
  871. oversimplification, but it suffices to explain how `as' uses sections.
  872.    `ld' moves blocks of bytes of your program to their run-time
  873. addresses.  These blocks slide to their run-time addresses as rigid
  874. units; their length does not change and neither does the order of bytes
  875. within them.  Such a rigid unit is called a *section*.  Assigning
  876. run-time addresses to sections is called "relocation".  It includes the
  877. task of adjusting mentions of object-file addresses so they refer to
  878. the proper run-time addresses.  For the H8/300 and H8/500, and for the
  879. Hitachi SH, `as' pads sections if needed to ensure they end on a word
  880. (sixteen bit) boundary.
  881.    An object file written by `as' has at least three sections, any of
  882. which may be empty.  These are named "text", "data" and "bss" sections.
  883.    When it generates COFF output, `as' can also generate whatever other
  884. named sections you specify using the `.section' directive (*note
  885. `.section': Section.).  If you do not use any directives that place
  886. output in the `.text' or `.data' sections, these sections still exist,
  887. but are empty.
  888.    When `as' generates SOM or ELF output for the HPPA, `as' can also
  889. generate whatever other named sections you specify using the `.space'
  890. and `.subspace' directives.  See `HP9000 Series 800 Assembly Language
  891. Reference Manual' (HP 92432-90001) for details on the `.space' and
  892. `.subspace' assembler directives.
  893.    Additionally, `as' uses different names for the standard text, data,
  894. and bss sections when generating SOM output.  Program text is placed
  895. into the `$CODE$' section, data into `$DATA$', and BSS into `$BSS$'.
  896.    Within the object file, the text section starts at address `0', the
  897. data section follows, and the bss section follows the data section.
  898.    When generating either SOM or ELF output files on the HPPA, the text
  899. section starts at address `0', the data section at address `0x4000000',
  900. and the bss section follows the data section.
  901.    To let `ld' know which data changes when the sections are relocated,
  902. and how to change that data, `as' also writes to the object file
  903. details of the relocation needed.  To perform relocation `ld' must
  904. know, each time an address in the object file is mentioned:
  905.    * Where in the object file is the beginning of this reference to an
  906.      address?
  907.    * How long (in bytes) is this reference?
  908.    * Which section does the address refer to?  What is the numeric
  909.      value of
  910.           (ADDRESS) - (START-ADDRESS OF SECTION)?
  911.    * Is the reference to an address "Program-Counter relative"?
  912.    In fact, every address `as' ever uses is expressed as
  913.      (SECTION) + (OFFSET INTO SECTION)
  914. Further, most expressions `as' computes have this section-relative
  915. nature.  (For some object formats, such as SOM for the HPPA, some
  916. expressions are symbol-relative instead.)
  917.    In this manual we use the notation {SECNAME N} to mean "offset N
  918. into section SECNAME."
  919.    Apart from text, data and bss sections you need to know about the
  920. "absolute" section.  When `ld' mixes partial programs, addresses in the
  921. absolute section remain unchanged.  For example, address `{absolute 0}'
  922. is "relocated" to run-time address 0 by `ld'.  Although the linker
  923. never arranges two partial programs' data sections with overlapping
  924. addresses after linking, *by definition* their absolute sections must
  925. overlap.  Address `{absolute 239}' in one part of a program is always
  926. the same address when the program is running as address `{absolute
  927. 239}' in any other part of the program.
  928.    The idea of sections is extended to the "undefined" section.  Any
  929. address whose section is unknown at assembly time is by definition
  930. rendered {undefined U}--where U is filled in later.  Since numbers are
  931. always defined, the only way to generate an undefined address is to
  932. mention an undefined symbol.  A reference to a named common block would
  933. be such a symbol: its value is unknown at assembly time so it has
  934. section *undefined*.
  935.    By analogy the word *section* is used to describe groups of sections
  936. in the linked program.  `ld' puts all partial programs' text sections
  937. in contiguous addresses in the linked program.  It is customary to
  938. refer to the *text section* of a program, meaning all the addresses of
  939. all partial programs' text sections.  Likewise for data and bss
  940. sections.
  941.    Some sections are manipulated by `ld'; others are invented for use
  942. of `as' and have no meaning except during assembly.
  943.