1<html lang="en"> 2<head> 3<title>Strings - Using as</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using as"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Characters.html#Characters" title="Characters"> 9<link rel="next" href="Chars.html#Chars" title="Chars"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12This file documents the GNU Assembler "as". 13 14Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 152000, 2001, 2002, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, 16Inc. 17 18Permission is granted to copy, distribute and/or modify this document 19under the terms of the GNU Free Documentation License, Version 1.3 20or any later version published by the Free Software Foundation; 21with no Invariant Sections, with no Front-Cover Texts, and with no 22Back-Cover Texts. A copy of the license is included in the 23section entitled ``GNU Free Documentation License''. 24 25--> 26<meta http-equiv="Content-Style-Type" content="text/css"> 27<style type="text/css"><!-- 28 pre.display { font-family:inherit } 29 pre.format { font-family:inherit } 30 pre.smalldisplay { font-family:inherit; font-size:smaller } 31 pre.smallformat { font-family:inherit; font-size:smaller } 32 pre.smallexample { font-size:smaller } 33 pre.smalllisp { font-size:smaller } 34 span.sc { font-variant:small-caps } 35 span.roman { font-family:serif; font-weight:normal; } 36 span.sansserif { font-family:sans-serif; font-weight:normal; } 37--></style> 38<link rel="stylesheet" type="text/css" href="../cs.css"> 39</head> 40<body> 41<div class="node"> 42<a name="Strings"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="Chars.html#Chars">Chars</a>, 45Up: <a rel="up" accesskey="u" href="Characters.html#Characters">Characters</a> 46<hr> 47</div> 48 49<h5 class="subsubsection">3.6.1.1 Strings</h5> 50 51<p><a name="index-string-constants-142"></a><a name="index-constants_002c-string-143"></a>A <dfn>string</dfn> is written between double-quotes. It may contain 52double-quotes or null characters. The way to get special characters 53into a string is to <dfn>escape</dfn> these characters: precede them with 54a backslash ‘<samp><span class="samp">\</span></samp>’ character. For example ‘<samp><span class="samp">\\</span></samp>’ represents 55one backslash: the first <code>\</code> is an escape which tells 56<samp><span class="command">as</span></samp> to interpret the second character literally as a backslash 57(which prevents <samp><span class="command">as</span></samp> from recognizing the second <code>\</code> as an 58escape character). The complete list of escapes follows. 59 60 <p><a name="index-escape-codes_002c-character-144"></a><a name="index-character-escape-codes-145"></a> 61 <dl> 62<!-- @item \a --> 63<!-- Mnemonic for ACKnowledge; for ASCII this is octal code 007. --> 64<a name="index-g_t_0040code_007b_005cb_007d-_0028backspace-character_0029-146"></a><a name="index-backspace-_0028_0040code_007b_005cb_007d_0029-147"></a><dt><kbd>\b</kbd><dd>Mnemonic for backspace; for ASCII this is octal code 010. 65 66 <!-- @item \e --> 67 <!-- Mnemonic for EOText; for ASCII this is octal code 004. --> 68 <p><a name="index-g_t_0040code_007b_005cf_007d-_0028formfeed-character_0029-148"></a><a name="index-formfeed-_0028_0040code_007b_005cf_007d_0029-149"></a><br><dt><kbd>\f</kbd><dd>Mnemonic for FormFeed; for ASCII this is octal code 014. 69 70 <p><a name="index-g_t_0040code_007b_005cn_007d-_0028newline-character_0029-150"></a><a name="index-newline-_0028_0040code_007b_005cn_007d_0029-151"></a><br><dt><kbd>\n</kbd><dd>Mnemonic for newline; for ASCII this is octal code 012. 71 72 <!-- @item \p --> 73 <!-- Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}. --> 74 <p><a name="index-g_t_0040code_007b_005cr_007d-_0028carriage-return-character_0029-152"></a><a name="index-carriage-return-_0028_0040code_007b_005cr_007d_0029-153"></a><br><dt><kbd>\r</kbd><dd>Mnemonic for carriage-Return; for ASCII this is octal code 015. 75 76 <!-- @item \s --> 77 <!-- Mnemonic for space; for ASCII this is octal code 040. Included for compliance with --> 78 <!-- other assemblers. --> 79 <p><a name="index-g_t_0040code_007b_005ct_007d-_0028tab_0029-154"></a><a name="index-tab-_0028_0040code_007b_005ct_007d_0029-155"></a><br><dt><kbd>\t</kbd><dd>Mnemonic for horizontal Tab; for ASCII this is octal code 011. 80 81 <!-- @item \v --> 82 <!-- Mnemonic for Vertical tab; for ASCII this is octal code 013. --> 83 <!-- @item \x @var{digit} @var{digit} @var{digit} --> 84 <!-- A hexadecimal character code. The numeric code is 3 hexadecimal digits. --> 85 <p><a name="index-g_t_0040code_007b_005c_0040var_007bddd_007d_007d-_0028octal-character-code_0029-156"></a><a name="index-octal-character-code-_0028_0040code_007b_005c_0040var_007bddd_007d_007d_0029-157"></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. 86For compatibility with other Unix systems, 8 and 9 are accepted as digits: 87for example, <code>\008</code> has the value 010, and <code>\009</code> the value 011. 88 89 <p><a name="index-g_t_0040code_007b_005c_0040var_007bxd_002e_002e_002e_007d_007d-_0028hex-character-code_0029-158"></a><a name="index-hex-character-code-_0028_0040code_007b_005c_0040var_007bxd_002e_002e_002e_007d_007d_0029-159"></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 90lower case <code>x</code> works. 91 92 <p><a name="index-g_t_0040code_007b_005c_005c_007d-_0028_0040samp_007b_005c_007d-character_0029-160"></a><a name="index-backslash-_0028_0040code_007b_005c_005c_007d_0029-161"></a><br><dt><kbd>\\</kbd><dd>Represents one ‘<samp><span class="samp">\</span></samp>’ character. 93 94 <!-- @item \' --> 95 <!-- Represents one @samp{'} (accent acute) character. --> 96 <!-- This is needed in single character literals --> 97 <!-- (@xref{Characters,,Character Constants}.) to represent --> 98 <!-- a @samp{'}. --> 99 <p><a name="index-g_t_0040code_007b_005c_0022_007d-_0028doublequote-character_0029-162"></a><a name="index-doublequote-_0028_0040code_007b_005c_0022_007d_0029-163"></a><br><dt><kbd>\"</kbd><dd>Represents one ‘<samp><span class="samp">"</span></samp>’ character. Needed in strings to represent 100this character, because an unescaped ‘<samp><span class="samp">"</span></samp>’ would end the string. 101 102 <br><dt><kbd>\ </kbd><var>anything-else</var><dd>Any other character when escaped by <kbd>\</kbd> gives a warning, but 103assembles as if the ‘<samp><span class="samp">\</span></samp>’ was not present. The idea is that if 104you used an escape sequence you clearly didn't want the literal 105interpretation of the following character. However <samp><span class="command">as</span></samp> has no 106other interpretation, so <samp><span class="command">as</span></samp> knows it is giving you the wrong 107code and warns you of the fact. 108</dl> 109 110 <p>Which characters are escapable, and what those escapes represent, 111varies widely among assemblers. The current set is what we think 112the BSD 4.2 assembler recognizes, and is a subset of what most C 113compilers recognize. If you are in doubt, do not use an escape 114sequence. 115 116 </body></html> 117 118