?? as.html
字號:
constants are an exception: they do not end statements.A <EM>statement</EM> ends at a newline character (<SAMP>`\n'</SAMP>) or lineseparator character. (The line separator is usually <SAMP>`;'</SAMP>, unlessthis conflicts with the comment character; see section <A HREF="as.html#SEC128">Machine Dependent Features</A>.) Thenewline or separator character is considered part of the precedingstatement. Newlines and separators within character constants are anexception: they do not end statements.</P><P><A NAME="IDX101"></A><A NAME="IDX102"></A>It is an error to end any statement with end-of-file: the lastcharacter of any input file should be a newline.</P><P><A NAME="IDX103"></A><A NAME="IDX104"></A><A NAME="IDX105"></A>You may write a statement on more than one line if you put abackslash (<KBD>\</KBD>) immediately in front of any newlines within thestatement. When <CODE>as</CODE> reads a backslashed newline bothcharacters are ignored. You can even put backslashed newlines inthe middle of symbol names without changing the meaning of yoursource program.</P><P>An empty statement is allowed, and may include whitespace. It is ignored.</P><P><A NAME="IDX106"></A><A NAME="IDX107"></A>A statement begins with zero or more labels, optionally followed by akey symbol which determines what kind of statement it is. The keysymbol determines the syntax of the rest of the statement. If thesymbol begins with a dot <SAMP>`.'</SAMP> then the statement is an assemblerdirective: typically valid for any computer. If the symbol begins witha letter the statement is an assembly language <EM>instruction</EM>: itassembles into a machine language instruction.Different versions of <CODE>as</CODE> for different computersrecognize different instructions. In fact, the same symbol mayrepresent a different instruction in a different computer's assemblylanguage.</P><P><A NAME="IDX108"></A><A NAME="IDX109"></A>A label is a symbol immediately followed by a colon (<CODE>:</CODE>).Whitespace before a label or after a colon is permitted, but you may nothave whitespace between a label's symbol and its colon. See section <A HREF="as.html#SEC44">Labels</A>.</P><P>For HPPA targets, labels need not be immediately followed by a colon, but the definition of a label must begin in column zero. This also implies thatonly one label may be defined on each line.</P><PRE>label: .directive followed by somethinganother_label: # This is an empty statement. instruction operand_1, operand_2, ...</PRE><H2><A NAME="SEC29" HREF="as_toc.html#TOC29">Constants</A></H2><P><A NAME="IDX110"></A>A constant is a number, written so that its value is known byinspection, without knowing any context. Like this:<PRE>.byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value..ascii "Ring the bell\7" # A string constant..octa 0x123456789abcdef0123456789ABCDEF0 # A bignum..float 0f-314159265358979323846264338327\95028841971.693993751E-40 # - pi, a flonum.</PRE><H3><A NAME="SEC30" HREF="as_toc.html#TOC30">Character Constants</A></H3><P><A NAME="IDX111"></A><A NAME="IDX112"></A>There are two kinds of character constants. A <EM>character</EM> standsfor one character in one byte and its value may be used innumeric expressions. String constants (properly called string<EM>literals</EM>) are potentially many bytes and their values may not beused in arithmetic expressions.</P><H4><A NAME="SEC31" HREF="as_toc.html#TOC31">Strings</A></H4><P><A NAME="IDX113"></A><A NAME="IDX114"></A>A <EM>string</EM> is written between double-quotes. It may containdouble-quotes or null characters. The way to get special charactersinto a string is to <EM>escape</EM> these characters: precede them witha backslash <SAMP>`\'</SAMP> character. For example <SAMP>`\\'</SAMP> representsone backslash: the first <CODE>\</CODE> is an escape which tells<CODE>as</CODE> to interpret the second character literally as a backslash(which prevents <CODE>as</CODE> from recognizing the second <CODE>\</CODE> as anescape character). The complete list of escapes follows.</P><P><A NAME="IDX115"></A><A NAME="IDX116"></A><DL COMPACT><DT><KBD>\b</KBD><DD><A NAME="IDX117"></A> <A NAME="IDX118"></A> Mnemonic for backspace; for ASCII this is octal code 010.<A NAME="IDX119"></A><A NAME="IDX120"></A><DT><KBD>\f</KBD><DD>Mnemonic for FormFeed; for ASCII this is octal code 014.<A NAME="IDX121"></A><A NAME="IDX122"></A><DT><KBD>\n</KBD><DD>Mnemonic for newline; for ASCII this is octal code 012.<A NAME="IDX123"></A><A NAME="IDX124"></A><DT><KBD>\r</KBD><DD>Mnemonic for carriage-Return; for ASCII this is octal code 015.<A NAME="IDX125"></A><A NAME="IDX126"></A><DT><KBD>\t</KBD><DD>Mnemonic for horizontal Tab; for ASCII this is octal code 011.<A NAME="IDX127"></A><A NAME="IDX128"></A><DT><KBD>\ <VAR>digit</VAR> <VAR>digit</VAR> <VAR>digit</VAR></KBD><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.<A NAME="IDX129"></A><A NAME="IDX130"></A><DT><KBD>\<CODE>x</CODE> <VAR>hex-digit</VAR> <VAR>hex-digit</VAR></KBD><DD>A hex character code. The numeric code is 2 hexadecimal digits. Eitherupper or lower case <CODE>x</CODE> works.<A NAME="IDX131"></A><A NAME="IDX132"></A><DT><KBD>\\</KBD><DD>Represents one <SAMP>`\'</SAMP> character.<A NAME="IDX133"></A><A NAME="IDX134"></A><DT><KBD>\"</KBD><DD>Represents one <SAMP>`"'</SAMP> character. Needed in strings to representthis character, because an unescaped <SAMP>`"'</SAMP> would end the string.<DT><KBD>\ <VAR>anything-else</VAR></KBD><DD>Any other character when escaped by <KBD>\</KBD> gives a warning, butassembles as if the <SAMP>`\'</SAMP> was not present. The idea is that ifyou used an escape sequence you clearly didn't want the literalinterpretation of the following character. However <CODE>as</CODE> has noother interpretation, so <CODE>as</CODE> knows it is giving you the wrongcode 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 thinkthe BSD 4.2 assembler recognizes, and is a subset of what most Ccompilers recognize. If you are in doubt, do not use an escapesequence.</P><H4><A NAME="SEC32" HREF="as_toc.html#TOC32">Characters</A></H4><P><A NAME="IDX135"></A><A NAME="IDX136"></A><A NAME="IDX137"></A>A single character may be written as a single quote immediatelyfollowed by that character. The same escapes apply to characters asto strings. So if you want to write the character backslash, youmust write <KBD>'\\</KBD> where the first <CODE>\</CODE> escapes the second<CODE>\</CODE>. As you can see, the quote is an acute accent, not agrave accent. A newlineimmediately following an acute accent is taken as a literal characterand does not count as the end of a statement. The value of a characterconstant in a numeric expression is the machine's byte-wide code forthat character. <CODE>as</CODE> assumes your character code is ASCII:<KBD>'A</KBD> means 65, <KBD>'B</KBD> means 66, and so on. </P><H3><A NAME="SEC33" HREF="as_toc.html#TOC33">Number Constants</A></H3><P><A NAME="IDX138"></A><A NAME="IDX139"></A><CODE>as</CODE> distinguishes three kinds of numbers according to how theyare stored in the target machine. <EM>Integers</EM> are numbers thatwould fit into an <CODE>int</CODE> in the C language. <EM>Bignums</EM> areintegers, but they are stored in more than 32 bits. <EM>Flonums</EM>are floating point numbers, described below.</P><H4><A NAME="SEC34" HREF="as_toc.html#TOC34">Integers</A></H4><P><A NAME="IDX140"></A><A NAME="IDX141"></A></P><P><A NAME="IDX142"></A><A NAME="IDX143"></A>A binary integer is <SAMP>`0b'</SAMP> or <SAMP>`0B'</SAMP> followed by zero or more ofthe binary digits <SAMP>`01'</SAMP>.</P><P><A NAME="IDX144"></A><A NAME="IDX145"></A>An octal integer is <SAMP>`0'</SAMP> followed by zero or more of the octaldigits (<SAMP>`01234567'</SAMP>).</P><P><A NAME="IDX146"></A><A NAME="IDX147"></A>A decimal integer starts with a non-zero digit followed by zero ormore digits (<SAMP>`0123456789'</SAMP>).</P><P><A NAME="IDX148"></A><A NAME="IDX149"></A>A hexadecimal integer is <SAMP>`0x'</SAMP> or <SAMP>`0X'</SAMP> followed by one ormore hexadecimal digits chosen from <SAMP>`0123456789abcdefABCDEF'</SAMP>.</P><P>Integers have the usual values. To denote a negative integer, usethe prefix operator <SAMP>`-'</SAMP> discussed under expressions(see section <A HREF="as.html#SEC63">Prefix Operator</A>).</P><H4><A NAME="SEC35" HREF="as_toc.html#TOC35">Bignums</A></H4><P><A NAME="IDX150"></A><A NAME="IDX151"></A>A <EM>bignum</EM> has the same syntax and semantics as an integerexcept that the number (or its negative) takes more than 32 bits torepresent in binary. The distinction is made because in some placesintegers are permitted while bignums are not.</P><H4><A NAME="SEC36" HREF="as_toc.html#TOC36">Flonums</A></H4><P><A NAME="IDX152"></A><A NAME="IDX153"></A><A NAME="IDX154"></A></P><P><A NAME="IDX155"></A>A <EM>flonum</EM> represents a floating point number. The translation isindirect: a decimal floating point number from the text is converted by<CODE>as</CODE> to a generic binary floating point number of more thansufficient precision. This generic floating point number is convertedto a particular computer's floating point format (or formats) by aportion of <CODE>as</CODE> specialized to that computer.</P><P>A flonum is written by writing (in order)<UL><LI>The digit <SAMP>`0'</SAMP>.(<SAMP>`0'</SAMP> is optional on the HPPA.)<LI>A letter, to tell <CODE>as</CODE> the rest of the number is a flonum.<KBD>e</KBD> is recommended. Case is not important.On the H8/300, H8/500,Hitachi SH,and AMD 29K architectures, the letter must beone of the letters <SAMP>`DFPRSX'</SAMP> (in upper or lower case).On the Intel 960 architecture, the letter must beone of the letters <SAMP>`DFT'</SAMP> (in upper or lower case).On the HPPA architecture, the letter must be <SAMP>`E'</SAMP> (upper case only).<LI>An optional sign: either <SAMP>`+'</SAMP> or <SAMP>`-'</SAMP>.<LI>An optional <EM>integer part</EM>: zero or more decimal digits.<LI>An optional <EM>fractional part</EM>: <SAMP>`.'</SAMP> followed by zeroor more decimal digits.<LI>An optional exponent, consisting of:<UL><LI>An <SAMP>`E'</SAMP> or <SAMP>`e'</SAMP>.<LI>Optional sign: either <SAMP>`+'</SAMP> or <SAMP>`-'</SAMP>.<LI>One or more decimal digits.</UL></UL><P>At least one of the integer part or the fractional part must bepresent. The floating point number has the usual base-10 value.</P><P><CODE>as</CODE> does all processing using integers. Flonums are computedindependently of any floating point hardware in the computer running<CODE>as</CODE>.</P><H1><A NAME="SEC37" HREF="as_toc.html#TOC37">Sections and Relocation</A></H1><P><A NAME="IDX156"></A><A NAME="IDX157"></A></P><H2><A NAME="SEC38" HREF="as_toc.html#TOC38">Background</A></H2><P>Roughly, a section is a range of addresses, with no gaps; all data"in" those addresses is treated the same for some particular purpose.For example there may be a "read only" section.</P><P><A NAME="IDX158"></A><A NAME="IDX159"></A>The linker <CODE>ld</CODE> reads many object files (partial programs) andcombines their contents to form a runnable program. When <CODE>as</CODE>emits an object file, the partial program is assumed to start at address 0.<CODE>ld</CODE> assigns the final addresses for the partial program, so thatdifferent partial programs do not overlap. This is actually anoversimplification, but it suffices to explain how <CODE>as</CODE> usessections.</P><P><CODE>ld</CODE> moves blocks of bytes of your program to their run-timeaddresses. These blocks slide to their run-time addresses as rigidunits; their length does not change and neither does the order of byteswithin them. Such a rigid unit is called a <EM>section</EM>. Assigningrun-time addresses to sections is called <EM>relocation</EM>. It includesthe task of adjusting mentions of object-file addresses so they refer tothe proper run-time addresses.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -