📄 symbol-names.html
字号:
<html lang="en">
<head>
<title>Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
</head>
<body>
<div class="node">
<p>
Node:<a name="Symbol%20Names">Symbol Names</a>,
Next:<a rel="next" accesskey="n" href="Dot.html#Dot">Dot</a>,
Previous:<a rel="previous" accesskey="p" href="Setting-Symbols.html#Setting%20Symbols">Setting Symbols</a>,
Up:<a rel="up" accesskey="u" href="Symbols.html#Symbols">Symbols</a>
<hr><br>
</div>
<h3 class="section">Symbol Names</h3>
<p>Symbol names begin with a letter or with one of <code>._</code>. On most
machines, you can also use <code>$</code> in symbol names; exceptions are
noted in <a href="Machine-Dependencies.html#Machine%20Dependencies">Machine Dependencies</a>. That character may be followed by any
string of digits, letters, dollar signs (unless otherwise noted in
<a href="Machine-Dependencies.html#Machine%20Dependencies">Machine Dependencies</a>), and underscores.
For the AMD 29K family, <code>?</code> is also allowed in the
body of a symbol name, though not at its beginning.
<p>Case of letters is significant: <code>foo</code> is a different symbol name
than <code>Foo</code>.
<p>Each symbol has exactly one name. Each name in an assembly language program
refers to exactly one symbol. You may use that symbol name any number of times
in a program.
<h4 class="subheading">Local Symbol Names</h4>
<p>Local symbols help compilers and programmers use names temporarily.
They create symbols which are guaranteed to be unique over the entire scope of
the input source code and which can be referred to by a simple notation.
To define a local symbol, write a label of the form <code></code><b>N</b><code>:</code> (where <b>N</b>
represents any positive integer). To refer to the most recent previous
definition of that symbol write <code></code><b>N</b><code>b</code>, using the same number as when
you defined the label. To refer to the next definition of a local label, write
<code></code><b>N</b><code>f</code>-- The <code>b</code> stands for"backwards" and the <code>f</code> stands
for "forwards".
<p>There is no restriction on how you can use these labels, and you can reuse them
too. So that it is possible to repeatedly define the same local label (using
the same number <code></code><b>N</b><code></code>), although you can only refer to the most recently
defined local label of that number (for a backwards reference) or the next
definition of a specific local label for a forward reference. It is also worth
noting that the first 10 local labels (<code></code><b>0:</b><code></code><small class="dots">...</small><code></code><b>9:</b><code></code>) are
implemented in a slightly more efficient manner than the others.
<p>Here is an example:
<pre class="smallexample"> 1: branch 1f
2: branch 1b
1: branch 2f
2: branch 1b
</pre>
<p>Which is the equivalent of:
<pre class="smallexample"> label_1: branch label_3
label_2: branch label_1
label_3: branch label_4
label_4: branch label_3
</pre>
<p>Local symbol names are only a notational device. They are immediately
transformed into more conventional symbol names before the assembler uses them.
The symbol names stored in the symbol table, appearing in error messages and
optionally emitted to the object file. The names are constructed using these
parts:
<dl>
<dt><code>L</code>
<dd>All local labels begin with <code>L</code>. Normally both <code>as</code> and
<code>ld</code> forget symbols that start with <code>L</code>. These labels are
used for symbols you are never intended to see. If you use the
<code>-L</code> option then <code>as</code> retains these symbols in the
object file. If you also instruct <code>ld</code> to retain these symbols,
you may use them in debugging.
<br><dt><code></code><var>number</var><code></code>
<dd>This is the number that was used in the local label definition. So if the
label is written <code>55:</code> then the number is <code>55</code>.
<br><dt><code></code><kbd>C-B</kbd><code></code>
<dd>This unusual character is included so you do not accidentally invent a symbol
of the same name. The character has ASCII value of <code>\002</code> (control-B).
<br><dt><code></code><em>ordinal number</em><code></code>
<dd>This is a serial number to keep the labels distinct. The first definition of
<code>0:</code> gets the number <code>1</code>. The 15th definition of <code>0:</code> gets the
number <code>15</code>, and so on. Likewise the first definition of <code>1:</code> gets
the number <code>1</code> and its 15th defintion gets <code>15</code> as well.
</dl>
<p>So for example, the first <code>1:</code> is named <code>L1</code><kbd>C-B</kbd><code>1</code>, the 44th
<code>3:</code> is named <code>L3</code><kbd>C-B</kbd><code>44</code>.
<h4 class="subheading">Dollar Local Labels</h4>
<p><code>as</code> also supports an even more local form of local labels called
dollar labels. These labels go out of scope (ie they become undefined) as soon
as a non-local label is defined. Thus they remain valid for only a small
region of the input source code. Normal local labels, by contrast, remain in
scope for the entire file, or until they are redefined by another occurrence of
the same local label.
<p>Dollar labels are defined in exactly the same way as ordinary local labels,
except that instead of being terminated by a colon, they are terminated by a
dollar sign. eg <code></code><b>55$</b><code></code>.
<p>They can also be distinguished from ordinary local labels by their transformed
name which uses ASCII character <code>\001</code> (control-A) as the magic character
to distinguish them from ordinary labels. Thus the 5th defintion of <code>6$</code>
is named <code>L6</code><kbd>C-A</kbd><code>5</code>.
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -