1 This is as.info, produced by makeinfo version 4.3 from as.texinfo.
4 * As: (as). The GNU assembler.
5 * Gas: (as). The GNU assembler.
8 This file documents the GNU Assembler "as".
10 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
11 Free Software Foundation, Inc.
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".
21 File: as.info, Node: Statements, Next: Constants, Prev: Symbol Intro, Up: Syntax
26 A "statement" ends at a newline character (`\n') or line separator
27 character. (The line separator is usually `;', unless this conflicts
28 with the comment character; *note Machine Dependencies::.) The newline
29 or separator character is considered part of the preceding statement.
30 Newlines and separators within character constants are an exception:
31 they do not end statements.
33 It is an error to end any statement with end-of-file: the last
34 character of any input file should be a newline.
36 An empty statement is allowed, and may include whitespace. It is
39 A statement begins with zero or more labels, optionally followed by a
40 key symbol which determines what kind of statement it is. The key
41 symbol determines the syntax of the rest of the statement. If the
42 symbol begins with a dot `.' then the statement is an assembler
43 directive: typically valid for any computer. If the symbol begins with
44 a letter the statement is an assembly language "instruction": it
45 assembles into a machine language instruction. Different versions of
46 `as' for different computers recognize different instructions. In
47 fact, the same symbol may represent a different instruction in a
48 different computer's assembly language.
50 A label is a symbol immediately followed by a colon (`:').
51 Whitespace before a label or after a colon is permitted, but you may not
52 have whitespace between a label's symbol and its colon. *Note Labels::.
54 For HPPA targets, labels need not be immediately followed by a
55 colon, but the definition of a label must begin in column zero. This
56 also implies that only one label may be defined on each line.
58 label: .directive followed by something
59 another_label: # This is an empty statement.
60 instruction operand_1, operand_2, ...
63 File: as.info, Node: Constants, Prev: Statements, Up: Syntax
68 A constant is a number, written so that its value is known by
69 inspection, without knowing any context. Like this:
70 .byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
71 .ascii "Ring the bell\7" # A string constant.
72 .octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
73 .float 0f-314159265358979323846264338327\
74 95028841971.693993751E-40 # - pi, a flonum.
78 * Characters:: Character Constants
79 * Numbers:: Number Constants
82 File: as.info, Node: Characters, Next: Numbers, Up: Constants
87 There are two kinds of character constants. A "character" stands
88 for one character in one byte and its value may be used in numeric
89 expressions. String constants (properly called string _literals_) are
90 potentially many bytes and their values may not be used in arithmetic
99 File: as.info, Node: Strings, Next: Chars, Up: Characters
104 A "string" is written between double-quotes. It may contain
105 double-quotes or null characters. The way to get special characters
106 into a string is to "escape" these characters: precede them with a
107 backslash `\' character. For example `\\' represents one backslash:
108 the first `\' is an escape which tells `as' to interpret the second
109 character literally as a backslash (which prevents `as' from
110 recognizing the second `\' as an escape character). The complete list
114 Mnemonic for backspace; for ASCII this is octal code 010.
117 Mnemonic for FormFeed; for ASCII this is octal code 014.
120 Mnemonic for newline; for ASCII this is octal code 012.
123 Mnemonic for carriage-Return; for ASCII this is octal code 015.
126 Mnemonic for horizontal Tab; for ASCII this is octal code 011.
128 `\ DIGIT DIGIT DIGIT'
129 An octal character code. The numeric code is 3 octal digits. For
130 compatibility with other Unix systems, 8 and 9 are accepted as
131 digits: for example, `\008' has the value 010, and `\009' the
135 A hex character code. All trailing hex digits are combined.
136 Either upper or lower case `x' works.
139 Represents one `\' character.
142 Represents one `"' character. Needed in strings to represent this
143 character, because an unescaped `"' would end the string.
146 Any other character when escaped by `\' gives a warning, but
147 assembles as if the `\' was not present. The idea is that if you
148 used an escape sequence you clearly didn't want the literal
149 interpretation of the following character. However `as' has no
150 other interpretation, so `as' knows it is giving you the wrong
151 code and warns you of the fact.
153 Which characters are escapable, and what those escapes represent,
154 varies widely among assemblers. The current set is what we think the
155 BSD 4.2 assembler recognizes, and is a subset of what most C compilers
156 recognize. If you are in doubt, do not use an escape sequence.
159 File: as.info, Node: Chars, Prev: Strings, Up: Characters
164 A single character may be written as a single quote immediately
165 followed by that character. The same escapes apply to characters as to
166 strings. So if you want to write the character backslash, you must
167 write `'\\' where the first `\' escapes the second `\'. As you can
168 see, the quote is an acute accent, not a grave accent. A newline
169 immediately following an acute accent is taken as a literal character
170 and does not count as the end of a statement. The value of a character
171 constant in a numeric expression is the machine's byte-wide code for
172 that character. `as' assumes your character code is ASCII: `'A' means
173 65, `'B' means 66, and so on.
176 File: as.info, Node: Numbers, Prev: Characters, Up: Constants
181 `as' distinguishes three kinds of numbers according to how they are
182 stored in the target machine. _Integers_ are numbers that would fit
183 into an `int' in the C language. _Bignums_ are integers, but they are
184 stored in more than 32 bits. _Flonums_ are floating point numbers,
189 * Integers:: Integers
194 File: as.info, Node: Integers, Next: Bignums, Up: Numbers
199 A binary integer is `0b' or `0B' followed by zero or more of the
202 An octal integer is `0' followed by zero or more of the octal digits
205 A decimal integer starts with a non-zero digit followed by zero or
206 more digits (`0123456789').
208 A hexadecimal integer is `0x' or `0X' followed by one or more
209 hexadecimal digits chosen from `0123456789abcdefABCDEF'.
211 Integers have the usual values. To denote a negative integer, use
212 the prefix operator `-' discussed under expressions (*note Prefix
213 Operators: Prefix Ops.).
216 File: as.info, Node: Bignums, Next: Flonums, Prev: Integers, Up: Numbers
221 A "bignum" has the same syntax and semantics as an integer except
222 that the number (or its negative) takes more than 32 bits to represent
223 in binary. The distinction is made because in some places integers are
224 permitted while bignums are not.
227 File: as.info, Node: Flonums, Prev: Bignums, Up: Numbers
232 A "flonum" represents a floating point number. The translation is
233 indirect: a decimal floating point number from the text is converted by
234 `as' to a generic binary floating point number of more than sufficient
235 precision. This generic floating point number is converted to a
236 particular computer's floating point format (or formats) by a portion
237 of `as' specialized to that computer.
239 A flonum is written by writing (in order)
240 * The digit `0'. (`0' is optional on the HPPA.)
242 * A letter, to tell `as' the rest of the number is a flonum. `e' is
243 recommended. Case is not important.
245 On the H8/300, H8/500, Hitachi SH, and AMD 29K architectures, the
246 letter must be one of the letters `DFPRSX' (in upper or lower
249 On the ARC, the letter must be one of the letters `DFRS' (in upper
252 On the Intel 960 architecture, the letter must be one of the
253 letters `DFT' (in upper or lower case).
255 On the HPPA architecture, the letter must be `E' (upper case only).
257 * An optional sign: either `+' or `-'.
259 * An optional "integer part": zero or more decimal digits.
261 * An optional "fractional part": `.' followed by zero or more
264 * An optional exponent, consisting of:
268 * Optional sign: either `+' or `-'.
270 * One or more decimal digits.
273 At least one of the integer part or the fractional part must be
274 present. The floating point number has the usual base-10 value.
276 `as' does all processing using integers. Flonums are computed
277 independently of any floating point hardware in the computer running
281 File: as.info, Node: Sections, Next: Symbols, Prev: Syntax, Up: Top
283 Sections and Relocation
284 ***********************
288 * Secs Background:: Background
289 * Ld Sections:: Linker Sections
290 * As Sections:: Assembler Internal Sections
291 * Sub-Sections:: Sub-Sections
295 File: as.info, Node: Secs Background, Next: Ld Sections, Up: Sections
300 Roughly, a section is a range of addresses, with no gaps; all data
301 "in" those addresses is treated the same for some particular purpose.
302 For example there may be a "read only" section.
304 The linker `ld' reads many object files (partial programs) and
305 combines their contents to form a runnable program. When `as' emits an
306 object file, the partial program is assumed to start at address 0.
307 `ld' assigns the final addresses for the partial program, so that
308 different partial programs do not overlap. This is actually an
309 oversimplification, but it suffices to explain how `as' uses sections.
311 `ld' moves blocks of bytes of your program to their run-time
312 addresses. These blocks slide to their run-time addresses as rigid
313 units; their length does not change and neither does the order of bytes
314 within them. Such a rigid unit is called a _section_. Assigning
315 run-time addresses to sections is called "relocation". It includes the
316 task of adjusting mentions of object-file addresses so they refer to
317 the proper run-time addresses. For the H8/300 and H8/500, and for the
318 Hitachi SH, `as' pads sections if needed to ensure they end on a word
319 (sixteen bit) boundary.
321 An object file written by `as' has at least three sections, any of
322 which may be empty. These are named "text", "data" and "bss" sections.
324 When it generates COFF output, `as' can also generate whatever other
325 named sections you specify using the `.section' directive (*note
326 `.section': Section.). If you do not use any directives that place
327 output in the `.text' or `.data' sections, these sections still exist,
330 When `as' generates SOM or ELF output for the HPPA, `as' can also
331 generate whatever other named sections you specify using the `.space'
332 and `.subspace' directives. See `HP9000 Series 800 Assembly Language
333 Reference Manual' (HP 92432-90001) for details on the `.space' and
334 `.subspace' assembler directives.
336 Additionally, `as' uses different names for the standard text, data,
337 and bss sections when generating SOM output. Program text is placed
338 into the `$CODE$' section, data into `$DATA$', and BSS into `$BSS$'.
340 Within the object file, the text section starts at address `0', the
341 data section follows, and the bss section follows the data section.
343 When generating either SOM or ELF output files on the HPPA, the text
344 section starts at address `0', the data section at address `0x4000000',
345 and the bss section follows the data section.
347 To let `ld' know which data changes when the sections are relocated,
348 and how to change that data, `as' also writes to the object file
349 details of the relocation needed. To perform relocation `ld' must
350 know, each time an address in the object file is mentioned:
351 * Where in the object file is the beginning of this reference to an
354 * How long (in bytes) is this reference?
356 * Which section does the address refer to? What is the numeric
358 (ADDRESS) - (START-ADDRESS OF SECTION)?
360 * Is the reference to an address "Program-Counter relative"?
362 In fact, every address `as' ever uses is expressed as
363 (SECTION) + (OFFSET INTO SECTION)
365 Further, most expressions `as' computes have this section-relative
366 nature. (For some object formats, such as SOM for the HPPA, some
367 expressions are symbol-relative instead.)
369 In this manual we use the notation {SECNAME N} to mean "offset N
370 into section SECNAME."
372 Apart from text, data and bss sections you need to know about the
373 "absolute" section. When `ld' mixes partial programs, addresses in the
374 absolute section remain unchanged. For example, address `{absolute 0}'
375 is "relocated" to run-time address 0 by `ld'. Although the linker
376 never arranges two partial programs' data sections with overlapping
377 addresses after linking, _by definition_ their absolute sections must
378 overlap. Address `{absolute 239}' in one part of a program is always
379 the same address when the program is running as address `{absolute
380 239}' in any other part of the program.
382 The idea of sections is extended to the "undefined" section. Any
383 address whose section is unknown at assembly time is by definition
384 rendered {undefined U}--where U is filled in later. Since numbers are
385 always defined, the only way to generate an undefined address is to
386 mention an undefined symbol. A reference to a named common block would
387 be such a symbol: its value is unknown at assembly time so it has
390 By analogy the word _section_ is used to describe groups of sections
391 in the linked program. `ld' puts all partial programs' text sections
392 in contiguous addresses in the linked program. It is customary to
393 refer to the _text section_ of a program, meaning all the addresses of
394 all partial programs' text sections. Likewise for data and bss
397 Some sections are manipulated by `ld'; others are invented for use
398 of `as' and have no meaning except during assembly.
401 File: as.info, Node: Ld Sections, Next: As Sections, Prev: Secs Background, Up: Sections
406 `ld' deals with just four kinds of sections, summarized below.
411 These sections hold your program. `as' and `ld' treat them as
412 separate but equal sections. Anything you can say of one section
413 is true another. When the program is running, however, it is
414 customary for the text section to be unalterable. The text
415 section is often shared among processes: it contains instructions,
416 constants and the like. The data section of a running program is
417 usually alterable: for example, C variables would be stored in the
421 This section contains zeroed bytes when your program begins
422 running. It is used to hold uninitialized variables or common
423 storage. The length of each partial program's bss section is
424 important, but because it starts out containing zeroed bytes there
425 is no need to store explicit zero bytes in the object file. The
426 bss section was invented to eliminate those explicit zeros from
430 Address 0 of this section is always "relocated" to runtime address
431 0. This is useful if you want to refer to an address that `ld'
432 must not change when relocating. In this sense we speak of
433 absolute addresses being "unrelocatable": they do not change
437 This "section" is a catch-all for address references to objects
438 not in the preceding sections.
440 An idealized example of three relocatable sections follows. The
441 example uses the traditional section names `.text' and `.data'. Memory
442 addresses are on the horizontal axis.
445 partial program # 1: |ttttt|dddd|00|
452 partial program # 2: |TTT|DDD|000|
455 +--+---+-----+--+----+---+-----+~~
456 linked program: | |TTT|ttttt| |dddd|DDD|00000|
457 +--+---+-----+--+----+---+-----+~~
462 File: as.info, Node: As Sections, Next: Sub-Sections, Prev: Ld Sections, Up: Sections
464 Assembler Internal Sections
465 ===========================
467 These sections are meant only for the internal use of `as'. They
468 have no meaning at run-time. You do not really need to know about these
469 sections for most purposes; but they can be mentioned in `as' warning
470 messages, so it might be helpful to have an idea of their meanings to
471 `as'. These sections are used to permit the value of every expression
472 in your assembly language program to be a section-relative address.
474 ASSEMBLER-INTERNAL-LOGIC-ERROR!
475 An internal assembler logic error has been found. This means
476 there is a bug in the assembler.
479 The assembler stores complex expression internally as combinations
480 of symbols. When it needs to represent an expression as a symbol,
481 it puts it in the expr section.
484 File: as.info, Node: Sub-Sections, Next: bss, Prev: As Sections, Up: Sections
489 Assembled bytes conventionally fall into two sections: text and data.
490 You may have separate groups of data in named sections that you want to
491 end up near to each other in the object file, even though they are not
492 contiguous in the assembler source. `as' allows you to use
493 "subsections" for this purpose. Within each section, there can be
494 numbered subsections with values from 0 to 8192. Objects assembled
495 into the same subsection go into the object file together with other
496 objects in the same subsection. For example, a compiler might want to
497 store constants in the text section, but might not want to have them
498 interspersed with the program being assembled. In this case, the
499 compiler could issue a `.text 0' before each section of code being
500 output, and a `.text 1' before each group of constants being output.
502 Subsections are optional. If you do not use subsections, everything
503 goes in subsection number zero.
505 Each subsection is zero-padded up to a multiple of four bytes.
506 (Subsections may be padded a different amount on different flavors of
509 Subsections appear in your object file in numeric order, lowest
510 numbered to highest. (All this to be compatible with other people's
511 assemblers.) The object file contains no representation of
512 subsections; `ld' and other programs that manipulate object files see
513 no trace of them. They just see all your text subsections as a text
514 section, and all your data subsections as a data section.
516 To specify which subsection you want subsequent statements assembled
517 into, use a numeric argument to specify it, in a `.text EXPRESSION' or
518 a `.data EXPRESSION' statement. When generating COFF output, you can
519 also use an extra subsection argument with arbitrary named sections:
520 `.section NAME, EXPRESSION'. EXPRESSION should be an absolute
521 expression. (*Note Expressions::.) If you just say `.text' then
522 `.text 0' is assumed. Likewise `.data' means `.data 0'. Assembly
523 begins in `text 0'. For instance:
524 .text 0 # The default subsection is text 0 anyway.
525 .ascii "This lives in the first text subsection. *"
527 .ascii "But this lives in the second text subsection."
529 .ascii "This lives in the data section,"
530 .ascii "in the first data subsection."
532 .ascii "This lives in the first text section,"
533 .ascii "immediately following the asterisk (*)."
535 Each section has a "location counter" incremented by one for every
536 byte assembled into that section. Because subsections are merely a
537 convenience restricted to `as' there is no concept of a subsection
538 location counter. There is no way to directly manipulate a location
539 counter--but the `.align' directive changes it, and any label
540 definition captures its current value. The location counter of the
541 section where statements are being assembled is said to be the "active"
545 File: as.info, Node: bss, Prev: Sub-Sections, Up: Sections
550 The bss section is used for local common variable storage. You may
551 allocate address space in the bss section, but you may not dictate data
552 to load into it before your program executes. When your program starts
553 running, all the contents of the bss section are zeroed bytes.
555 The `.lcomm' pseudo-op defines a symbol in the bss section; see
556 *Note `.lcomm': Lcomm.
558 The `.comm' pseudo-op may be used to declare a common symbol, which
559 is another form of uninitialized symbol; see *Note `.comm': Comm.
561 When assembling for a target which supports multiple sections, such
562 as ELF or COFF, you may switch into the `.bss' section and define
563 symbols as usual; see *Note `.section': Section. You may only assemble
564 zero values into the section. Typically the section will only contain
565 symbol definitions and `.skip' directives (*note `.skip': Skip.).
568 File: as.info, Node: Symbols, Next: Expressions, Prev: Sections, Up: Top
573 Symbols are a central concept: the programmer uses symbols to name
574 things, the linker uses symbols to link, and the debugger uses symbols
577 _Warning:_ `as' does not place symbols in the object file in the
578 same order they were declared. This may break some debuggers.
583 * Setting Symbols:: Giving Symbols Other Values
584 * Symbol Names:: Symbol Names
585 * Dot:: The Special Dot Symbol
586 * Symbol Attributes:: Symbol Attributes
589 File: as.info, Node: Labels, Next: Setting Symbols, Up: Symbols
594 A "label" is written as a symbol immediately followed by a colon
595 `:'. The symbol then represents the current value of the active
596 location counter, and is, for example, a suitable instruction operand.
597 You are warned if you use the same symbol to represent two different
598 locations: the first definition overrides any other definitions.
600 On the HPPA, the usual form for a label need not be immediately
601 followed by a colon, but instead must start in column zero. Only one
602 label may be defined on a single line. To work around this, the HPPA
603 version of `as' also provides a special directive `.label' for defining
604 labels more flexibly.
607 File: as.info, Node: Setting Symbols, Next: Symbol Names, Prev: Labels, Up: Symbols
609 Giving Symbols Other Values
610 ===========================
612 A symbol can be given an arbitrary value by writing a symbol,
613 followed by an equals sign `=', followed by an expression (*note
614 Expressions::). This is equivalent to using the `.set' directive.
618 File: as.info, Node: Symbol Names, Next: Dot, Prev: Setting Symbols, Up: Symbols
623 Symbol names begin with a letter or with one of `._'. On most
624 machines, you can also use `$' in symbol names; exceptions are noted in
625 *Note Machine Dependencies::. That character may be followed by any
626 string of digits, letters, dollar signs (unless otherwise noted in
627 *Note Machine Dependencies::), and underscores. For the AMD 29K
628 family, `?' is also allowed in the body of a symbol name, though not at
631 Case of letters is significant: `foo' is a different symbol name
634 Each symbol has exactly one name. Each name in an assembly language
635 program refers to exactly one symbol. You may use that symbol name any
636 number of times in a program.
641 Local symbols help compilers and programmers use names temporarily.
642 They create symbols which are guaranteed to be unique over the entire
643 scope of the input source code and which can be referred to by a simple
644 notation. To define a local symbol, write a label of the form `N:'
645 (where N represents any positive integer). To refer to the most recent
646 previous definition of that symbol write `Nb', using the same number as
647 when you defined the label. To refer to the next definition of a local
648 label, write `Nf'-- The `b' stands for"backwards" and the `f' stands
651 There is no restriction on how you can use these labels, and you can
652 reuse them too. So that it is possible to repeatedly define the same
653 local label (using the same number `N'), although you can only refer to
654 the most recently defined local label of that number (for a backwards
655 reference) or the next definition of a specific local label for a
656 forward reference. It is also worth noting that the first 10 local
657 labels (`0:'...`9:') are implemented in a slightly more efficient
658 manner than the others.
667 Which is the equivalent of:
669 label_1: branch label_3
670 label_2: branch label_1
671 label_3: branch label_4
672 label_4: branch label_3
674 Local symbol names are only a notational device. They are
675 immediately transformed into more conventional symbol names before the
676 assembler uses them. The symbol names stored in the symbol table,
677 appearing in error messages and optionally emitted to the object file.
678 The names are constructed using these parts:
681 All local labels begin with `L'. Normally both `as' and `ld'
682 forget symbols that start with `L'. These labels are used for
683 symbols you are never intended to see. If you use the `-L' option
684 then `as' retains these symbols in the object file. If you also
685 instruct `ld' to retain these symbols, you may use them in
689 This is the number that was used in the local label definition.
690 So if the label is written `55:' then the number is `55'.
693 This unusual character is included so you do not accidentally
694 invent a symbol of the same name. The character has ASCII value
695 of `\002' (control-B).
698 This is a serial number to keep the labels distinct. The first
699 definition of `0:' gets the number `1'. The 15th definition of
700 `0:' gets the number `15', and so on. Likewise the first
701 definition of `1:' gets the number `1' and its 15th defintion gets
704 So for example, the first `1:' is named `L1C-B1', the 44th `3:' is
710 `as' also supports an even more local form of local labels called
711 dollar labels. These labels go out of scope (ie they become undefined)
712 as soon as a non-local label is defined. Thus they remain valid for
713 only a small region of the input source code. Normal local labels, by
714 contrast, remain in scope for the entire file, or until they are
715 redefined by another occurrence of the same local label.
717 Dollar labels are defined in exactly the same way as ordinary local
718 labels, except that instead of being terminated by a colon, they are
719 terminated by a dollar sign. eg `55$'.
721 They can also be distinguished from ordinary local labels by their
722 transformed name which uses ASCII character `\001' (control-A) as the
723 magic character to distinguish them from ordinary labels. Thus the 5th
724 defintion of `6$' is named `L6C-A5'.
727 File: as.info, Node: Dot, Next: Symbol Attributes, Prev: Symbol Names, Up: Symbols
729 The Special Dot Symbol
730 ======================
732 The special symbol `.' refers to the current address that `as' is
733 assembling into. Thus, the expression `melvin: .long .' defines
734 `melvin' to contain its own address. Assigning a value to `.' is
735 treated the same as a `.org' directive. Thus, the expression `.=.+4'
736 is the same as saying `.space 4'.
739 File: as.info, Node: Symbol Attributes, Prev: Dot, Up: Symbols
744 Every symbol has, as well as its name, the attributes "Value" and
745 "Type". Depending on output format, symbols can also have auxiliary
748 If you use a symbol without defining it, `as' assumes zero for all
749 these attributes, and probably won't warn you. This makes the symbol
750 an externally defined symbol, which is generally what you would want.
754 * Symbol Value:: Value
758 * a.out Symbols:: Symbol Attributes: `a.out'
760 * COFF Symbols:: Symbol Attributes for COFF
762 * SOM Symbols:: Symbol Attributes for SOM
765 File: as.info, Node: Symbol Value, Next: Symbol Type, Up: Symbol Attributes
770 The value of a symbol is (usually) 32 bits. For a symbol which
771 labels a location in the text, data, bss or absolute sections the value
772 is the number of addresses from the start of that section to the label.
773 Naturally for text, data and bss sections the value of a symbol changes
774 as `ld' changes section base addresses during linking. Absolute
775 symbols' values do not change during linking: that is why they are
778 The value of an undefined symbol is treated in a special way. If it
779 is 0 then the symbol is not defined in this assembler source file, and
780 `ld' tries to determine its value from other files linked into the same
781 program. You make this kind of symbol simply by mentioning a symbol
782 name without defining it. A non-zero value represents a `.comm' common
783 declaration. The value is how much common storage to reserve, in bytes
784 (addresses). The symbol refers to the first address of the allocated
788 File: as.info, Node: Symbol Type, Next: a.out Symbols, Prev: Symbol Value, Up: Symbol Attributes
793 The type attribute of a symbol contains relocation (section)
794 information, any flag settings indicating that a symbol is external, and
795 (optionally), other information for linkers and debuggers. The exact
796 format depends on the object-code output format in use.
799 File: as.info, Node: a.out Symbols, Next: COFF Symbols, Prev: Symbol Type, Up: Symbol Attributes
801 Symbol Attributes: `a.out'
802 --------------------------
806 * Symbol Desc:: Descriptor
807 * Symbol Other:: Other
810 File: as.info, Node: Symbol Desc, Next: Symbol Other, Up: a.out Symbols
815 This is an arbitrary 16-bit value. You may establish a symbol's
816 descriptor value by using a `.desc' statement (*note `.desc': Desc.).
817 A descriptor value means nothing to `as'.
820 File: as.info, Node: Symbol Other, Prev: Symbol Desc, Up: a.out Symbols
825 This is an arbitrary 8-bit value. It means nothing to `as'.
828 File: as.info, Node: COFF Symbols, Next: SOM Symbols, Prev: a.out Symbols, Up: Symbol Attributes
830 Symbol Attributes for COFF
831 --------------------------
833 The COFF format supports a multitude of auxiliary symbol attributes;
834 like the primary symbol attributes, they are set between `.def' and
840 The symbol name is set with `.def'; the value and type,
841 respectively, with `.val' and `.type'.
846 The `as' directives `.dim', `.line', `.scl', `.size', and `.tag' can
847 generate auxiliary symbol table information for COFF.
850 File: as.info, Node: SOM Symbols, Prev: COFF Symbols, Up: Symbol Attributes
852 Symbol Attributes for SOM
853 -------------------------
855 The SOM format for the HPPA supports a multitude of symbol
856 attributes set with the `.EXPORT' and `.IMPORT' directives.
858 The attributes are described in `HP9000 Series 800 Assembly Language
859 Reference Manual' (HP 92432-90001) under the `IMPORT' and `EXPORT'
860 assembler directive documentation.
863 File: as.info, Node: Expressions, Next: Pseudo Ops, Prev: Symbols, Up: Top
868 An "expression" specifies an address or numeric value. Whitespace
869 may precede and/or follow an expression.
871 The result of an expression must be an absolute number, or else an
872 offset into a particular section. If an expression is not absolute,
873 and there is not enough information when `as' sees the expression to
874 know its section, a second pass over the source program might be
875 necessary to interpret the expression--but the second pass is currently
876 not implemented. `as' aborts with an error message in this situation.
880 * Empty Exprs:: Empty Expressions
881 * Integer Exprs:: Integer Expressions
884 File: as.info, Node: Empty Exprs, Next: Integer Exprs, Up: Expressions
889 An empty expression has no value: it is just whitespace or null.
890 Wherever an absolute expression is required, you may omit the
891 expression, and `as' assumes a value of (absolute) 0. This is
892 compatible with other assemblers.
895 File: as.info, Node: Integer Exprs, Prev: Empty Exprs, Up: Expressions
900 An "integer expression" is one or more _arguments_ delimited by
905 * Arguments:: Arguments
906 * Operators:: Operators
907 * Prefix Ops:: Prefix Operators
908 * Infix Ops:: Infix Operators
911 File: as.info, Node: Arguments, Next: Operators, Up: Integer Exprs
916 "Arguments" are symbols, numbers or subexpressions. In other
917 contexts arguments are sometimes called "arithmetic operands". In this
918 manual, to avoid confusing them with the "instruction operands" of the
919 machine language, we use the term "argument" to refer to parts of
920 expressions only, reserving the word "operand" to refer only to machine
921 instruction operands.
923 Symbols are evaluated to yield {SECTION NNN} where SECTION is one of
924 text, data, bss, absolute, or undefined. NNN is a signed, 2's
925 complement 32 bit integer.
927 Numbers are usually integers.
929 A number can be a flonum or bignum. In this case, you are warned
930 that only the low order 32 bits are used, and `as' pretends these 32
931 bits are an integer. You may write integer-manipulating instructions
932 that act on exotic constants, compatible with other assemblers.
934 Subexpressions are a left parenthesis `(' followed by an integer
935 expression, followed by a right parenthesis `)'; or a prefix operator
936 followed by an argument.
939 File: as.info, Node: Operators, Next: Prefix Ops, Prev: Arguments, Up: Integer Exprs
944 "Operators" are arithmetic functions, like `+' or `%'. Prefix
945 operators are followed by an argument. Infix operators appear between
946 their arguments. Operators may be preceded and/or followed by
950 File: as.info, Node: Prefix Ops, Next: Infix Ops, Prev: Operators, Up: Integer Exprs
955 `as' has the following "prefix operators". They each take one
956 argument, which must be absolute.
959 "Negation". Two's complement negation.
962 "Complementation". Bitwise not.
965 File: as.info, Node: Infix Ops, Prev: Prefix Ops, Up: Integer Exprs
970 "Infix operators" take two arguments, one on either side. Operators
971 have precedence, but operations with equal precedence are performed left
972 to right. Apart from `+' or `-', both arguments must be absolute, and
973 the result is absolute.
975 1. Highest Precedence
981 "Division". Truncation is the same as the C operator `/'
988 "Shift Left". Same as the C operator `<<'.
992 "Shift Right". Same as the C operator `>>'.
994 2. Intermediate precedence
997 "Bitwise Inclusive Or".
1003 "Bitwise Exclusive Or".
1011 "Addition". If either argument is absolute, the result has
1012 the section of the other argument. You may not add together
1013 arguments from different sections.
1016 "Subtraction". If the right argument is absolute, the result
1017 has the section of the left argument. If both arguments are
1018 in the same section, the result is absolute. You may not
1019 subtract arguments from different sections.
1034 "Is Greater Than Or Equal To"
1037 "Is Less Than Or Equal To"
1039 The comparison operators can be used as infix operators. A
1040 true results has a value of -1 whereas a false result has a
1041 value of 0. Note, these operators perform signed
1044 4. Lowest Precedence
1052 These two logical operations can be used to combine the
1053 results of sub expressions. Note, unlike the comparison
1054 operators a true result returns a value of 1 but a false
1055 results does still return 0. Also note that the logical or
1056 operator has a slightly lower precedence than logical and.
1059 In short, it's only meaningful to add or subtract the _offsets_ in an
1060 address; you can only have a defined section in one of the two
1064 File: as.info, Node: Pseudo Ops, Next: Machine Dependencies, Prev: Expressions, Up: Top
1066 Assembler Directives
1067 ********************
1069 All assembler directives have names that begin with a period (`.').
1070 The rest of the name is letters, usually in lower case.
1072 This chapter discusses directives that are available regardless of
1073 the target machine configuration for the GNU assembler. Some machine
1074 configurations provide additional directives. *Note Machine
1083 * Align:: `.align ABS-EXPR , ABS-EXPR'
1084 * Ascii:: `.ascii "STRING"'...
1085 * Asciz:: `.asciz "STRING"'...
1086 * Balign:: `.balign ABS-EXPR , ABS-EXPR'
1087 * Byte:: `.byte EXPRESSIONS'
1088 * Comm:: `.comm SYMBOL , LENGTH '
1089 * Data:: `.data SUBSECTION'
1093 * Desc:: `.desc SYMBOL, ABS-EXPRESSION'
1097 * Double:: `.double FLONUMS'
1100 * Elseif:: `.elseif'
1105 * Endfunc:: `.endfunc'
1107 * Equ:: `.equ SYMBOL, EXPRESSION'
1108 * Equiv:: `.equiv SYMBOL, EXPRESSION'
1111 * Extern:: `.extern'
1114 * File:: `.file STRING'
1116 * Fill:: `.fill REPEAT , SIZE , VALUE'
1117 * Float:: `.float FLONUMS'
1119 * Global:: `.global SYMBOL', `.globl SYMBOL'
1121 * Hidden:: `.hidden NAMES'
1123 * hword:: `.hword EXPRESSIONS'
1125 * If:: `.if ABSOLUTE EXPRESSION'
1126 * Incbin:: `.incbin "FILE"[,SKIP[,COUNT]]'
1127 * Include:: `.include "FILE"'
1128 * Int:: `.int EXPRESSIONS'
1130 * Internal:: `.internal NAMES'
1132 * Irp:: `.irp SYMBOL,VALUES'...
1133 * Irpc:: `.irpc SYMBOL,VALUES'...
1134 * Lcomm:: `.lcomm SYMBOL , LENGTH'
1135 * Lflags:: `.lflags'
1137 * Line:: `.line LINE-NUMBER'
1139 * Ln:: `.ln LINE-NUMBER'
1140 * Linkonce:: `.linkonce [TYPE]'
1142 * Long:: `.long EXPRESSIONS'
1144 * Macro:: `.macro NAME ARGS'...
1146 * Nolist:: `.nolist'
1147 * Octa:: `.octa BIGNUMS'
1148 * Org:: `.org NEW-LC , FILL'
1149 * P2align:: `.p2align ABS-EXPR , ABS-EXPR'
1151 * PopSection:: `.popsection'
1152 * Previous:: `.previous'
1154 * Print:: `.print STRING'
1156 * Protected:: `.protected NAMES'
1158 * Psize:: `.psize LINES, COLUMNS'
1159 * Purgem:: `.purgem NAME'
1161 * PushSection:: `.pushsection NAME'
1163 * Quad:: `.quad BIGNUMS'
1164 * Rept:: `.rept COUNT'
1165 * Sbttl:: `.sbttl "SUBHEADING"'
1167 * Scl:: `.scl CLASS'
1168 * Section:: `.section NAME, SUBSECTION'
1170 * Set:: `.set SYMBOL, EXPRESSION'
1171 * Short:: `.short EXPRESSIONS'
1172 * Single:: `.single FLONUMS'
1173 * Size:: `.size [NAME , EXPRESSION]'
1174 * Skip:: `.skip SIZE , FILL'
1175 * Sleb128:: `.sleb128 EXPRESSIONS'
1176 * Space:: `.space SIZE , FILL'
1178 * Stab:: `.stabd, .stabn, .stabs'
1180 * String:: `.string "STR"'
1181 * Struct:: `.struct EXPRESSION'
1183 * SubSection:: `.subsection'
1184 * Symver:: `.symver NAME,NAME2@NODENAME'
1187 * Tag:: `.tag STRUCTNAME'
1189 * Text:: `.text SUBSECTION'
1190 * Title:: `.title "HEADING"'
1191 * Type:: `.type <INT | NAME , TYPE DESCRIPTION>'
1192 * Uleb128:: `.uleb128 EXPRESSIONS'
1197 * Version:: `.version "STRING"'
1198 * VTableEntry:: `.vtable_entry TABLE, OFFSET'
1199 * VTableInherit:: `.vtable_inherit CHILD, PARENT'
1200 * Weak:: `.weak NAMES'
1202 * Word:: `.word EXPRESSIONS'
1203 * Deprecated:: Deprecated Directives
1206 File: as.info, Node: Abort, Next: ABORT, Up: Pseudo Ops
1211 This directive stops the assembly immediately. It is for
1212 compatibility with other assemblers. The original idea was that the
1213 assembly language source would be piped into the assembler. If the
1214 sender of the source quit, it could use this directive tells `as' to
1215 quit also. One day `.abort' will not be supported.
1218 File: as.info, Node: ABORT, Next: Align, Prev: Abort, Up: Pseudo Ops
1223 When producing COFF output, `as' accepts this directive as a synonym
1226 When producing `b.out' output, `as' accepts this directive, but
1230 File: as.info, Node: Align, Next: Ascii, Prev: ABORT, Up: Pseudo Ops
1232 `.align ABS-EXPR, ABS-EXPR, ABS-EXPR'
1233 =====================================
1235 Pad the location counter (in the current subsection) to a particular
1236 storage boundary. The first expression (which must be absolute) is the
1237 alignment required, as described below.
1239 The second expression (also absolute) gives the fill value to be
1240 stored in the padding bytes. It (and the comma) may be omitted. If it
1241 is omitted, the padding bytes are normally zero. However, on some
1242 systems, if the section is marked as containing code and the fill value
1243 is omitted, the space is filled with no-op instructions.
1245 The third expression is also absolute, and is also optional. If it
1246 is present, it is the maximum number of bytes that should be skipped by
1247 this alignment directive. If doing the alignment would require
1248 skipping more bytes than the specified maximum, then the alignment is
1249 not done at all. You can omit the fill value (the second argument)
1250 entirely by simply using two commas after the required alignment; this
1251 can be useful if you want the alignment to be filled with no-op
1252 instructions when appropriate.
1254 The way the required alignment is specified varies from system to
1255 system. For the a29k, hppa, m68k, m88k, w65, sparc, and Hitachi SH,
1256 and i386 using ELF format, the first expression is the alignment
1257 request in bytes. For example `.align 8' advances the location counter
1258 until it is a multiple of 8. If the location counter is already a
1259 multiple of 8, no change is needed.
1261 For other systems, including the i386 using a.out format, and the
1262 arm and strongarm, it is the number of low-order zero bits the location
1263 counter must have after advancement. For example `.align 3' advances
1264 the location counter until it a multiple of 8. If the location counter
1265 is already a multiple of 8, no change is needed.
1267 This inconsistency is due to the different behaviors of the various
1268 native assemblers for these systems which GAS must emulate. GAS also
1269 provides `.balign' and `.p2align' directives, described later, which
1270 have a consistent behavior across all architectures (but are specific
1274 File: as.info, Node: Ascii, Next: Asciz, Prev: Align, Up: Pseudo Ops
1276 `.ascii "STRING"'...
1277 ====================
1279 `.ascii' expects zero or more string literals (*note Strings::)
1280 separated by commas. It assembles each string (with no automatic
1281 trailing zero byte) into consecutive addresses.
1284 File: as.info, Node: Asciz, Next: Balign, Prev: Ascii, Up: Pseudo Ops
1286 `.asciz "STRING"'...
1287 ====================
1289 `.asciz' is just like `.ascii', but each string is followed by a
1290 zero byte. The "z" in `.asciz' stands for "zero".
1293 File: as.info, Node: Balign, Next: Byte, Prev: Asciz, Up: Pseudo Ops
1295 `.balign[wl] ABS-EXPR, ABS-EXPR, ABS-EXPR'
1296 ==========================================
1298 Pad the location counter (in the current subsection) to a particular
1299 storage boundary. The first expression (which must be absolute) is the
1300 alignment request in bytes. For example `.balign 8' advances the
1301 location counter until it is a multiple of 8. If the location counter
1302 is already a multiple of 8, no change is needed.
1304 The second expression (also absolute) gives the fill value to be
1305 stored in the padding bytes. It (and the comma) may be omitted. If it
1306 is omitted, the padding bytes are normally zero. However, on some
1307 systems, if the section is marked as containing code and the fill value
1308 is omitted, the space is filled with no-op instructions.
1310 The third expression is also absolute, and is also optional. If it
1311 is present, it is the maximum number of bytes that should be skipped by
1312 this alignment directive. If doing the alignment would require
1313 skipping more bytes than the specified maximum, then the alignment is
1314 not done at all. You can omit the fill value (the second argument)
1315 entirely by simply using two commas after the required alignment; this
1316 can be useful if you want the alignment to be filled with no-op
1317 instructions when appropriate.
1319 The `.balignw' and `.balignl' directives are variants of the
1320 `.balign' directive. The `.balignw' directive treats the fill pattern
1321 as a two byte word value. The `.balignl' directives treats the fill
1322 pattern as a four byte longword value. For example, `.balignw
1323 4,0x368d' will align to a multiple of 4. If it skips two bytes, they
1324 will be filled in with the value 0x368d (the exact placement of the
1325 bytes depends upon the endianness of the processor). If it skips 1 or
1326 3 bytes, the fill value is undefined.
1329 File: as.info, Node: Byte, Next: Comm, Prev: Balign, Up: Pseudo Ops
1334 `.byte' expects zero or more expressions, separated by commas. Each
1335 expression is assembled into the next byte.
1338 File: as.info, Node: Comm, Next: Data, Prev: Byte, Up: Pseudo Ops
1340 `.comm SYMBOL , LENGTH '
1341 ========================
1343 `.comm' declares a common symbol named SYMBOL. When linking, a
1344 common symbol in one object file may be merged with a defined or common
1345 symbol of the same name in another object file. If `ld' does not see a
1346 definition for the symbol-just one or more common symbols-then it will
1347 allocate LENGTH bytes of uninitialized memory. LENGTH must be an
1348 absolute expression. If `ld' sees multiple common symbols with the
1349 same name, and they do not all have the same size, it will allocate
1350 space using the largest size.
1352 When using ELF, the `.comm' directive takes an optional third
1353 argument. This is the desired alignment of the symbol, specified as a
1354 byte boundary (for example, an alignment of 16 means that the least
1355 significant 4 bits of the address should be zero). The alignment must
1356 be an absolute expression, and it must be a power of two. If `ld'
1357 allocates uninitialized memory for the common symbol, it will use the
1358 alignment when placing the symbol. If no alignment is specified, `as'
1359 will set the alignment to the largest power of two less than or equal
1360 to the size of the symbol, up to a maximum of 16.
1362 The syntax for `.comm' differs slightly on the HPPA. The syntax is
1363 `SYMBOL .comm, LENGTH'; SYMBOL is optional.
1366 File: as.info, Node: Data, Next: Def, Prev: Comm, Up: Pseudo Ops
1371 `.data' tells `as' to assemble the following statements onto the end
1372 of the data subsection numbered SUBSECTION (which is an absolute
1373 expression). If SUBSECTION is omitted, it defaults to zero.