You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
8.3 KiB
HTML
159 lines
8.3 KiB
HTML
15 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Symbol Names - Using as</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="Using as">
|
||
|
<meta name="generator" content="makeinfo 4.7">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="Symbols.html#Symbols" title="Symbols">
|
||
|
<link rel="prev" href="Setting-Symbols.html#Setting-Symbols" title="Setting Symbols">
|
||
|
<link rel="next" href="Dot.html#Dot" title="Dot">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
This file documents the GNU Assembler "as".
|
||
|
|
||
|
Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002,
|
||
|
2006, 2007 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.1
|
||
|
or any later version published by the Free Software Foundation;
|
||
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||
|
Back-Cover Texts. A copy of the license is included in the
|
||
|
section entitled ``GNU Free Documentation License''.
|
||
|
|
||
|
man end-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family: serif; font-weight: normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<p>
|
||
|
<a name="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-Symbols">Setting Symbols</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Symbols.html#Symbols">Symbols</a>
|
||
|
<hr><br>
|
||
|
</div>
|
||
|
|
||
|
<h3 class="section">5.3 Symbol Names</h3>
|
||
|
|
||
|
<p><a name="index-symbol-names-213"></a><a name="index-names_002c-symbol-214"></a>Symbol names begin with a letter or with one of <span class="samp">._</span>. On most
|
||
|
machines, you can also use <code>$</code> in symbol names; exceptions are
|
||
|
noted in <a href="Machine-Dependencies.html#Machine-Dependencies">Machine Dependencies</a>. That character may be followed by any
|
||
|
string of digits, letters, dollar signs (unless otherwise noted for a
|
||
|
particular target machine), and underscores.
|
||
|
|
||
|
<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><a name="index-local-symbol-names-215"></a><a name="index-symbol-names_002c-local-216"></a>A local symbol is any symbol beginning with certain local label prefixes.
|
||
|
By default, the local label prefix is <span class="samp">.L</span> for ELF systems or
|
||
|
<span class="samp">L</span> for traditional a.out systems, but each target may have its own
|
||
|
set of local label prefixes.
|
||
|
On the HPPA local symbols begin with <span class="samp">L$</span>.
|
||
|
|
||
|
<p>Local symbols are defined and used within the assembler, but they are
|
||
|
normally not saved in object files. Thus, they are not visible when debugging.
|
||
|
You may use the <span class="samp">-L</span> option (see <a href="L.html#L">Include Local Symbols: <span class="option">-L</span></a>) to retain the local symbols in the object files.
|
||
|
|
||
|
<h4 class="subheading">Local Labels</h4>
|
||
|
|
||
|
<p><a name="index-local-labels-217"></a><a name="index-temporary-symbol-names-218"></a><a name="index-symbol-names_002c-temporary-219"></a>Local labels 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 label, write a label of the form <b>N</b><span class="samp">:</span> (where <b>N</b>
|
||
|
represents any positive integer). To refer to the most recent previous
|
||
|
definition of that label write <b>N</b><span class="samp">b</span>, using the same number as when
|
||
|
you defined the label. To refer to the next definition of a local label, write
|
||
|
<b>N</b><span class="samp">f</span>—the <span class="samp">b</span> stands for “backwards” and the <span class="samp">f</span> 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 <b>N</b>), 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 (<b>0:</b><small class="dots">...</small><b>9:</b>) 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 label names are only a notational device. They are immediately
|
||
|
transformed into more conventional symbol names before the assembler uses them.
|
||
|
The symbol names are stored in the symbol table, appear in error messages, and
|
||
|
are optionally emitted to the object file. The names are constructed using
|
||
|
these parts:
|
||
|
|
||
|
<dl>
|
||
|
<dt><em>local label prefix</em><dd>All local symbols begin with the system-specific local label prefix.
|
||
|
Normally both <span class="command">as</span> and <code>ld</code> forget symbols
|
||
|
that start with the local label prefix. These labels are
|
||
|
used for symbols you are never intended to see. If you use the
|
||
|
<span class="samp">-L</span> option then <span class="command">as</span> 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><var>number</var><dd>This is the number that was used in the local label definition. So if the
|
||
|
label is written <span class="samp">55:</span> then the number is <span class="samp">55</span>.
|
||
|
|
||
|
<br><dt><kbd>C-B</kbd><dd>This unusual character is included so you do not accidentally invent a symbol
|
||
|
of the same name. The character has ASCII value of <span class="samp">\002</span> (control-B).
|
||
|
|
||
|
<br><dt><em>ordinal number</em><dd>This is a serial number to keep the labels distinct. The first definition of
|
||
|
<span class="samp">0:</span> gets the number <span class="samp">1</span>. The 15th definition of <span class="samp">0:</span> gets the
|
||
|
number <span class="samp">15</span>, and so on. Likewise the first definition of <span class="samp">1:</span> gets
|
||
|
the number <span class="samp">1</span> and its 15th definition gets <span class="samp">15</span> as well.
|
||
|
</dl>
|
||
|
|
||
|
<p>So for example, the first <code>1:</code> may be named <code>.L1</code><kbd>C-B</kbd><code>1</code>, and
|
||
|
the 44th <code>3:</code> may be named <code>.L3</code><kbd>C-B</kbd><code>44</code>.
|
||
|
|
||
|
<h4 class="subheading">Dollar Local Labels</h4>
|
||
|
|
||
|
<p><a name="index-dollar-local-symbols-220"></a>
|
||
|
<code>as</code> also supports an even more local form of local labels called
|
||
|
dollar labels. These labels go out of scope (i.e., 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, e.g., <b>55$</b>.
|
||
|
|
||
|
<p>They can also be distinguished from ordinary local labels by their transformed
|
||
|
names which use ASCII character <span class="samp">\001</span> (control-A) as the magic character
|
||
|
to distinguish them from ordinary labels. For example, the fifth definition of
|
||
|
<span class="samp">6$</span> may be named <span class="samp">.L6</span><kbd>C-A</kbd><span class="samp">5</span>.
|
||
|
|
||
|
</body></html>
|
||
|
|