You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Symbol-Names.html 10KB

3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Symbol Names (Using as)</title>
  16. <meta name="description" content="Symbol Names (Using as)">
  17. <meta name="keywords" content="Symbol Names (Using as)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Symbols.html#Symbols" rel="up" title="Symbols">
  25. <link href="Dot.html#Dot" rel="next" title="Dot">
  26. <link href="Setting-Symbols.html#Setting-Symbols" rel="prev" title="Setting Symbols">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="Symbol-Names"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Dot.html#Dot" accesskey="n" rel="next">Dot</a>, Previous: <a href="Setting-Symbols.html#Setting-Symbols" accesskey="p" rel="prev">Setting Symbols</a>, Up: <a href="Symbols.html#Symbols" accesskey="u" rel="up">Symbols</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="Symbol-Names-1"></a>
  63. <h3 class="section">5.3 Symbol Names</h3>
  64. <a name="index-symbol-names"></a>
  65. <a name="index-names_002c-symbol"></a>
  66. <p>Symbol names begin with a letter or with one of &lsquo;<samp>._</samp>&rsquo;. On most
  67. machines, you can also use <code>$</code> in symbol names; exceptions are
  68. noted in <a href="Machine-Dependencies.html#Machine-Dependencies">Machine Dependencies</a>. That character may be followed by any
  69. string of digits, letters, dollar signs (unless otherwise noted for a
  70. particular target machine), and underscores.
  71. </p>
  72. <p>Case of letters is significant: <code>foo</code> is a different symbol name
  73. than <code>Foo</code>.
  74. </p>
  75. <p>Symbol names do not start with a digit. An exception to this rule is made for
  76. Local Labels. See below.
  77. </p>
  78. <p>Multibyte characters are supported. To generate a symbol name containing
  79. multibyte characters enclose it within double quotes and use escape codes. cf
  80. See <a href="Strings.html#Strings">Strings</a>. Generating a multibyte symbol name from a label is not
  81. currently supported.
  82. </p>
  83. <p>Each symbol has exactly one name. Each name in an assembly language program
  84. refers to exactly one symbol. You may use that symbol name any number of times
  85. in a program.
  86. </p>
  87. <a name="Local-Symbol-Names"></a>
  88. <h4 class="subheading">Local Symbol Names</h4>
  89. <a name="index-local-symbol-names"></a>
  90. <a name="index-symbol-names_002c-local"></a>
  91. <p>A local symbol is any symbol beginning with certain local label prefixes.
  92. By default, the local label prefix is &lsquo;<samp>.L</samp>&rsquo; for ELF systems or
  93. &lsquo;<samp>L</samp>&rsquo; for traditional a.out systems, but each target may have its own
  94. set of local label prefixes.
  95. On the HPPA local symbols begin with &lsquo;<samp>L$</samp>&rsquo;.
  96. </p>
  97. <p>Local symbols are defined and used within the assembler, but they are
  98. normally not saved in object files. Thus, they are not visible when debugging.
  99. You may use the &lsquo;<samp>-L</samp>&rsquo; option (see <a href="L.html#L">Include Local Symbols</a>)
  100. to retain the local symbols in the object files.
  101. </p>
  102. <a name="Local-Labels-1"></a>
  103. <h4 class="subheading">Local Labels</h4>
  104. <a name="index-local-labels"></a>
  105. <a name="index-temporary-symbol-names"></a>
  106. <a name="index-symbol-names_002c-temporary"></a>
  107. <p>Local labels are different from local symbols. Local labels help compilers and
  108. programmers use names temporarily. They create symbols which are guaranteed to
  109. be unique over the entire scope of the input source code and which can be
  110. referred to by a simple notation. To define a local label, write a label of
  111. the form &lsquo;<samp><b>N</b>:</samp>&rsquo; (where <b>N</b> represents any non-negative integer).
  112. To refer to the most recent previous definition of that label write
  113. &lsquo;<samp><b>N</b>b</samp>&rsquo;, using the same number as when you defined the label. To refer
  114. to the next definition of a local label, write &lsquo;<samp><b>N</b>f</samp>&rsquo;. The &lsquo;<samp>b</samp>&rsquo;
  115. stands for &ldquo;backwards&rdquo; and the &lsquo;<samp>f</samp>&rsquo; stands for &ldquo;forwards&rdquo;.
  116. </p>
  117. <p>There is no restriction on how you can use these labels, and you can reuse them
  118. too. So that it is possible to repeatedly define the same local label (using
  119. the same number &lsquo;<samp><b>N</b></samp>&rsquo;), although you can only refer to the most recently
  120. defined local label of that number (for a backwards reference) or the next
  121. definition of a specific local label for a forward reference. It is also worth
  122. noting that the first 10 local labels (&lsquo;<samp><b>0:</b></samp>&rsquo;&hellip;&lsquo;<samp><b>9:</b></samp>&rsquo;) are
  123. implemented in a slightly more efficient manner than the others.
  124. </p>
  125. <p>Here is an example:
  126. </p>
  127. <div class="smallexample">
  128. <pre class="smallexample">1: branch 1f
  129. 2: branch 1b
  130. 1: branch 2f
  131. 2: branch 1b
  132. </pre></div>
  133. <p>Which is the equivalent of:
  134. </p>
  135. <div class="smallexample">
  136. <pre class="smallexample">label_1: branch label_3
  137. label_2: branch label_1
  138. label_3: branch label_4
  139. label_4: branch label_3
  140. </pre></div>
  141. <p>Local label names are only a notational device. They are immediately
  142. transformed into more conventional symbol names before the assembler uses them.
  143. The symbol names are stored in the symbol table, appear in error messages, and
  144. are optionally emitted to the object file. The names are constructed using
  145. these parts:
  146. </p>
  147. <dl compact="compact">
  148. <dt><code><em>local label prefix</em></code></dt>
  149. <dd><p>All local symbols begin with the system-specific local label prefix.
  150. Normally both <code>as</code> and <code>ld</code> forget symbols
  151. that start with the local label prefix. These labels are
  152. used for symbols you are never intended to see. If you use the
  153. &lsquo;<samp>-L</samp>&rsquo; option then <code>as</code> retains these symbols in the
  154. object file. If you also instruct <code>ld</code> to retain these symbols,
  155. you may use them in debugging.
  156. </p>
  157. </dd>
  158. <dt><code><var>number</var></code></dt>
  159. <dd><p>This is the number that was used in the local label definition. So if the
  160. label is written &lsquo;<samp>55:</samp>&rsquo; then the number is &lsquo;<samp>55</samp>&rsquo;.
  161. </p>
  162. </dd>
  163. <dt><code><kbd>C-B</kbd></code></dt>
  164. <dd><p>This unusual character is included so you do not accidentally invent a symbol
  165. of the same name. The character has ASCII value of &lsquo;<samp>\002</samp>&rsquo; (control-B).
  166. </p>
  167. </dd>
  168. <dt><code><em>ordinal number</em></code></dt>
  169. <dd><p>This is a serial number to keep the labels distinct. The first definition of
  170. &lsquo;<samp>0:</samp>&rsquo; gets the number &lsquo;<samp>1</samp>&rsquo;. The 15th definition of &lsquo;<samp>0:</samp>&rsquo; gets the
  171. number &lsquo;<samp>15</samp>&rsquo;, and so on. Likewise the first definition of &lsquo;<samp>1:</samp>&rsquo; gets
  172. the number &lsquo;<samp>1</samp>&rsquo; and its 15th definition gets &lsquo;<samp>15</samp>&rsquo; as well.
  173. </p></dd>
  174. </dl>
  175. <p>So for example, the first <code>1:</code> may be named <code>.L1<kbd>C-B</kbd>1</code>, and
  176. the 44th <code>3:</code> may be named <code>.L3<kbd>C-B</kbd>44</code>.
  177. </p>
  178. <a name="Dollar-Local-Labels"></a>
  179. <h4 class="subheading">Dollar Local Labels</h4>
  180. <a name="index-dollar-local-symbols"></a>
  181. <p>On some targets <code>as</code> also supports an even more local form of
  182. local labels called dollar labels. These labels go out of scope (i.e., they
  183. become undefined) as soon as a non-local label is defined. Thus they remain
  184. valid for only a small region of the input source code. Normal local labels,
  185. by contrast, remain in scope for the entire file, or until they are redefined
  186. by another occurrence of the same local label.
  187. </p>
  188. <p>Dollar labels are defined in exactly the same way as ordinary local labels,
  189. except that they have a dollar sign suffix to their numeric value, e.g.,
  190. &lsquo;<samp><b>55$:</b></samp>&rsquo;.
  191. </p>
  192. <p>They can also be distinguished from ordinary local labels by their transformed
  193. names which use ASCII character &lsquo;<samp>\001</samp>&rsquo; (control-A) as the magic character
  194. to distinguish them from ordinary labels. For example, the fifth definition of
  195. &lsquo;<samp>6$</samp>&rsquo; may be named &lsquo;<samp>.L6<kbd>C-A</kbd>5</samp>&rsquo;.
  196. </p>
  197. <hr>
  198. <div class="header">
  199. <p>
  200. Next: <a href="Dot.html#Dot" accesskey="n" rel="next">Dot</a>, Previous: <a href="Setting-Symbols.html#Setting-Symbols" accesskey="p" rel="prev">Setting Symbols</a>, Up: <a href="Symbols.html#Symbols" accesskey="u" rel="up">Symbols</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  201. </div>
  202. </body>
  203. </html>