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