Strings.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: Strings</title>
  15. <meta name="description" content="Using as: Strings">
  16. <meta name="keywords" content="Using as: Strings">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Characters.html#Characters" rel="up" title="Characters">
  25. <link href="Chars.html#Chars" rel="next" title="Chars">
  26. <link href="Characters.html#Characters" rel="prev" title="Characters">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="Strings"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Chars.html#Chars" accesskey="n" rel="next">Chars</a>, Up: <a href="Characters.html#Characters" accesskey="u" rel="up">Characters</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>
  61. </div>
  62. <hr>
  63. <a name="Strings-1"></a>
  64. <h4 class="subsubsection">3.6.1.1 Strings</h4>
  65. <a name="index-string-constants"></a>
  66. <a name="index-constants_002c-string"></a>
  67. <p>A <em>string</em> is written between double-quotes. It may contain
  68. double-quotes or null characters. The way to get special characters
  69. into a string is to <em>escape</em> these characters: precede them with
  70. a backslash &lsquo;<samp>\</samp>&rsquo; character. For example &lsquo;<samp>\\</samp>&rsquo; represents
  71. one backslash: the first <code>\</code> is an escape which tells
  72. <code>as</code> to interpret the second character literally as a backslash
  73. (which prevents <code>as</code> from recognizing the second <code>\</code> as an
  74. escape character). The complete list of escapes follows.
  75. </p>
  76. <a name="index-escape-codes_002c-character"></a>
  77. <a name="index-character-escape-codes"></a>
  78. <dl compact="compact">
  79. <dd><a name="index--_005cb-_0028backspace-character_0029"></a>
  80. <a name="index-backspace-_0028_005cb_0029"></a>
  81. </dd>
  82. <dt><kbd>\b</kbd></dt>
  83. <dd><p>Mnemonic for backspace; for ASCII this is octal code 010.
  84. </p>
  85. <a name="index--_005cf-_0028formfeed-character_0029"></a>
  86. <a name="index-formfeed-_0028_005cf_0029"></a>
  87. </dd>
  88. <dt><kbd>backslash-f</kbd></dt>
  89. <dd><p>Mnemonic for FormFeed; for ASCII this is octal code 014.
  90. </p>
  91. <a name="index--_005cn-_0028newline-character_0029"></a>
  92. <a name="index-newline-_0028_005cn_0029"></a>
  93. </dd>
  94. <dt><kbd>\n</kbd></dt>
  95. <dd><p>Mnemonic for newline; for ASCII this is octal code 012.
  96. </p>
  97. <a name="index--_005cr-_0028carriage-return-character_0029"></a>
  98. <a name="index-carriage-return-_0028backslash_002dr_0029"></a>
  99. </dd>
  100. <dt><kbd>\r</kbd></dt>
  101. <dd><p>Mnemonic for carriage-Return; for ASCII this is octal code 015.
  102. </p>
  103. <a name="index--_005ct-_0028tab_0029"></a>
  104. <a name="index-tab-_0028_005ct_0029"></a>
  105. </dd>
  106. <dt><kbd>\t</kbd></dt>
  107. <dd><p>Mnemonic for horizontal Tab; for ASCII this is octal code 011.
  108. </p>
  109. <a name="index--_005cddd-_0028octal-character-code_0029"></a>
  110. <a name="index-octal-character-code-_0028_005cddd_0029"></a>
  111. </dd>
  112. <dt><kbd>\ <var>digit</var> <var>digit</var> <var>digit</var></kbd></dt>
  113. <dd><p>An octal character code. The numeric code is 3 octal digits.
  114. For compatibility with other Unix systems, 8 and 9 are accepted as digits:
  115. for example, <code>\008</code> has the value 010, and <code>\009</code> the value 011.
  116. </p>
  117. <a name="index--_005cxd_002e_002e_002e-_0028hex-character-code_0029"></a>
  118. <a name="index-hex-character-code-_0028_005cxd_002e_002e_002e_0029"></a>
  119. </dd>
  120. <dt><kbd>\<code>x</code> <var>hex-digits...</var></kbd></dt>
  121. <dd><p>A hex character code. All trailing hex digits are combined. Either upper or
  122. lower case <code>x</code> works.
  123. </p>
  124. <a name="index--_005c_005c-_0028_005c-character_0029"></a>
  125. <a name="index-backslash-_0028_005c_005c_0029"></a>
  126. </dd>
  127. <dt><kbd>\\</kbd></dt>
  128. <dd><p>Represents one &lsquo;<samp>\</samp>&rsquo; character.
  129. </p>
  130. <a name="index--_005c_0022-_0028doublequote-character_0029"></a>
  131. <a name="index-doublequote-_0028_005c_0022_0029"></a>
  132. </dd>
  133. <dt><kbd>\&quot;</kbd></dt>
  134. <dd><p>Represents one &lsquo;<samp>&quot;</samp>&rsquo; character. Needed in strings to represent
  135. this character, because an unescaped &lsquo;<samp>&quot;</samp>&rsquo; would end the string.
  136. </p>
  137. </dd>
  138. <dt><kbd>\ <var>anything-else</var></kbd></dt>
  139. <dd><p>Any other character when escaped by <kbd>\</kbd> gives a warning, but
  140. assembles as if the &lsquo;<samp>\</samp>&rsquo; was not present. The idea is that if
  141. you used an escape sequence you clearly didn&rsquo;t want the literal
  142. interpretation of the following character. However <code>as</code> has no
  143. other interpretation, so <code>as</code> knows it is giving you the wrong
  144. code and warns you of the fact.
  145. </p></dd>
  146. </dl>
  147. <p>Which characters are escapable, and what those escapes represent,
  148. varies widely among assemblers. The current set is what we think
  149. the BSD 4.2 assembler recognizes, and is a subset of what most C
  150. compilers recognize. If you are in doubt, do not use an escape
  151. sequence.
  152. </p>
  153. <hr>
  154. <div class="header">
  155. <p>
  156. Next: <a href="Chars.html#Chars" accesskey="n" rel="next">Chars</a>, Up: <a href="Characters.html#Characters" accesskey="u" rel="up">Characters</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>
  157. </div>
  158. </body>
  159. </html>