122 lines
7.7 KiB
HTML
122 lines
7.7 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Strings - Using as</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="Using as">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Characters.html#Characters" title="Characters">
|
|
<link rel="next" href="Chars.html#Chars" title="Chars">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
This file documents the GNU Assembler "as".
|
|
|
|
Copyright (C) 1991-2019 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.3
|
|
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''.
|
|
|
|
-->
|
|
<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; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Strings"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Chars.html#Chars">Chars</a>,
|
|
Up: <a rel="up" accesskey="u" href="Characters.html#Characters">Characters</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h5 class="subsubsection">3.6.1.1 Strings</h5>
|
|
|
|
<p><a name="index-string-constants-144"></a><a name="index-constants_002c-string-145"></a>A <dfn>string</dfn> is written between double-quotes. It may contain
|
|
double-quotes or null characters. The way to get special characters
|
|
into a string is to <dfn>escape</dfn> these characters: precede them with
|
|
a backslash ‘<samp><span class="samp">\</span></samp>’ character. For example ‘<samp><span class="samp">\\</span></samp>’ represents
|
|
one backslash: the first <code>\</code> is an escape which tells
|
|
<samp><span class="command">as</span></samp> to interpret the second character literally as a backslash
|
|
(which prevents <samp><span class="command">as</span></samp> from recognizing the second <code>\</code> as an
|
|
escape character). The complete list of escapes follows.
|
|
|
|
<p><a name="index-escape-codes_002c-character-146"></a><a name="index-character-escape-codes-147"></a><!-- NOTE: Cindex entries must not start with a backlash character. -->
|
|
<!-- NOTE: This confuses the pdf2texi script when it is creating the -->
|
|
<!-- NOTE: index based upon the first character and so it generates: -->
|
|
<!-- NOTE: \initial {\\} -->
|
|
<!-- NOTE: which then results in the error message: -->
|
|
<!-- NOTE: Argument of \\ has an extra }. -->
|
|
<!-- NOTE: So in the index entries below a space character has been -->
|
|
<!-- NOTE: prepended to avoid this problem. -->
|
|
<dl>
|
|
<!-- @item \a -->
|
|
<!-- Mnemonic for ACKnowledge; for ASCII this is octal code 007. -->
|
|
<a name="index-g_t_0040code_007b-_005cb_007d-_0028backspace-character_0029-148"></a><a name="index-backspace-_0028_0040code_007b_005cb_007d_0029-149"></a><dt><kbd>\b</kbd><dd>Mnemonic for backspace; for ASCII this is octal code 010.
|
|
|
|
<!-- @item \e -->
|
|
<!-- Mnemonic for EOText; for ASCII this is octal code 004. -->
|
|
<p><a name="index-g_t_0040code_007b-_005cf_007d-_0028formfeed-character_0029-150"></a><a name="index-formfeed-_0028_0040code_007b_005cf_007d_0029-151"></a><br><dt><kbd>backslash-f</kbd><dd>Mnemonic for FormFeed; for ASCII this is octal code 014.
|
|
|
|
<p><a name="index-g_t_0040code_007b-_005cn_007d-_0028newline-character_0029-152"></a><a name="index-newline-_0028_0040code_007b_005cn_007d_0029-153"></a><br><dt><kbd>\n</kbd><dd>Mnemonic for newline; for ASCII this is octal code 012.
|
|
|
|
<!-- @item \p -->
|
|
<!-- Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}. -->
|
|
<p><a name="index-g_t_0040code_007b-_005cr_007d-_0028carriage-return-character_0029-154"></a><a name="index-carriage-return-_0028_0040code_007bbackslash_002dr_007d_0029-155"></a><br><dt><kbd>\r</kbd><dd>Mnemonic for carriage-Return; for ASCII this is octal code 015.
|
|
|
|
<!-- @item \s -->
|
|
<!-- Mnemonic for space; for ASCII this is octal code 040. Included for compliance with -->
|
|
<!-- other assemblers. -->
|
|
<p><a name="index-g_t_0040code_007b-_005ct_007d-_0028tab_0029-156"></a><a name="index-tab-_0028_0040code_007b_005ct_007d_0029-157"></a><br><dt><kbd>\t</kbd><dd>Mnemonic for horizontal Tab; for ASCII this is octal code 011.
|
|
|
|
<!-- @item \v -->
|
|
<!-- Mnemonic for Vertical tab; for ASCII this is octal code 013. -->
|
|
<!-- @item \x @var{digit} @var{digit} @var{digit} -->
|
|
<!-- A hexadecimal character code. The numeric code is 3 hexadecimal digits. -->
|
|
<p><a name="index-g_t_0040code_007b-_005c_0040var_007bddd_007d_007d-_0028octal-character-code_0029-158"></a><a name="index-octal-character-code-_0028_0040code_007b_005c_0040var_007bddd_007d_007d_0029-159"></a><br><dt><kbd>\ </kbd><var>digit</var> <var>digit</var> <var>digit</var><dd>An octal character code. The numeric code is 3 octal digits.
|
|
For compatibility with other Unix systems, 8 and 9 are accepted as digits:
|
|
for example, <code>\008</code> has the value 010, and <code>\009</code> the value 011.
|
|
|
|
<p><a name="index-g_t_0040code_007b-_005c_0040var_007bxd_002e_002e_002e_007d_007d-_0028hex-character-code_0029-160"></a><a name="index-hex-character-code-_0028_0040code_007b_005c_0040var_007bxd_002e_002e_002e_007d_007d_0029-161"></a><br><dt><kbd>\</kbd><code>x</code> <var>hex-digits...</var><dd>A hex character code. All trailing hex digits are combined. Either upper or
|
|
lower case <code>x</code> works.
|
|
|
|
<p><a name="index-g_t_0040code_007b-_005c_005c_007d-_0028_0040samp_007b_005c_007d-character_0029-162"></a><a name="index-backslash-_0028_0040code_007b_005c_005c_007d_0029-163"></a><br><dt><kbd>\\</kbd><dd>Represents one ‘<samp><span class="samp">\</span></samp>’ character.
|
|
|
|
<!-- @item \' -->
|
|
<!-- Represents one @samp{'} (accent acute) character. -->
|
|
<!-- This is needed in single character literals -->
|
|
<!-- (@xref{Characters,,Character Constants}.) to represent -->
|
|
<!-- a @samp{'}. -->
|
|
<p><a name="index-g_t_0040code_007b-_005c_0022_007d-_0028doublequote-character_0029-164"></a><a name="index-doublequote-_0028_0040code_007b_005c_0022_007d_0029-165"></a><br><dt><kbd>\"</kbd><dd>Represents one ‘<samp><span class="samp">"</span></samp>’ character. Needed in strings to represent
|
|
this character, because an unescaped ‘<samp><span class="samp">"</span></samp>’ would end the string.
|
|
|
|
<br><dt><kbd>\ </kbd><var>anything-else</var><dd>Any other character when escaped by <kbd>\</kbd> gives a warning, but
|
|
assembles as if the ‘<samp><span class="samp">\</span></samp>’ was not present. The idea is that if
|
|
you used an escape sequence you clearly didn't want the literal
|
|
interpretation of the following character. However <samp><span class="command">as</span></samp> has no
|
|
other interpretation, so <samp><span class="command">as</span></samp> knows it is giving you the wrong
|
|
code and warns you of the fact.
|
|
</dl>
|
|
|
|
<p>Which characters are escapable, and what those escapes represent,
|
|
varies widely among assemblers. The current set is what we think
|
|
the BSD 4.2 assembler recognizes, and is a subset of what most C
|
|
compilers recognize. If you are in doubt, do not use an escape
|
|
sequence.
|
|
|
|
</body></html>
|
|
|