You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
213 lines
14 KiB
HTML
213 lines
14 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>MMIX-Pseudos - 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="MMIX_002dSyntax.html#MMIX_002dSyntax" title="MMIX-Syntax">
|
||
|
<link rel="prev" href="MMIX_002dRegs.html#MMIX_002dRegs" title="MMIX-Regs">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
This file documents the GNU Assembler "as".
|
||
|
|
||
|
Copyright (C) 1991-2015 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="MMIX-Pseudos"></a>
|
||
|
<a name="MMIX_002dPseudos"></a>
|
||
|
<p>
|
||
|
Previous: <a rel="previous" accesskey="p" href="MMIX_002dRegs.html#MMIX_002dRegs">MMIX-Regs</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="MMIX_002dSyntax.html#MMIX_002dSyntax">MMIX-Syntax</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h5 class="subsubsection">9.28.3.4 Assembler Directives</h5>
|
||
|
|
||
|
<p><a name="index-assembler-directives_002c-MMIX-1577"></a><a name="index-pseudo_002dops_002c-MMIX-1578"></a><a name="index-MMIX-assembler-directives-1579"></a><a name="index-MMIX-pseudo_002dops-1580"></a>
|
||
|
<dl>
|
||
|
<dt><code>LOC</code><dd><a name="index-assembler-directive-LOC_002c-MMIX-1581"></a><a name="index-pseudo_002dop-LOC_002c-MMIX-1582"></a><a name="index-MMIX-assembler-directive-LOC-1583"></a><a name="index-MMIX-pseudo_002dop-LOC-1584"></a>
|
||
|
<a name="MMIX_002dloc"></a>The <code>LOC</code> directive sets the current location to the value of the
|
||
|
operand field, which may include changing sections. If the operand is a
|
||
|
constant, the section is set to either <code>.data</code> if the value is
|
||
|
<code>0x2000000000000000</code> or larger, else it is set to <code>.text</code>.
|
||
|
Within a section, the current location may only be changed to
|
||
|
monotonically higher addresses. A LOC expression must be a previously
|
||
|
defined symbol or a “pure” constant.
|
||
|
|
||
|
<p>An example, which sets the label <var>prev</var> to the current location, and
|
||
|
updates the current location to eight bytes forward:
|
||
|
<pre class="smallexample"> prev LOC @+8
|
||
|
</pre>
|
||
|
<p>When a LOC has a constant as its operand, a symbol
|
||
|
<code>__.MMIX.start..text</code> or <code>__.MMIX.start..data</code> is defined
|
||
|
depending on the address as mentioned above. Each such symbol is
|
||
|
interpreted as special by the linker, locating the section at that
|
||
|
address. Note that if multiple files are linked, the first object file
|
||
|
with that section will be mapped to that address (not necessarily the file
|
||
|
with the LOC definition).
|
||
|
|
||
|
<br><dt><code>LOCAL</code><dd><a name="index-assembler-directive-LOCAL_002c-MMIX-1585"></a><a name="index-pseudo_002dop-LOCAL_002c-MMIX-1586"></a><a name="index-MMIX-assembler-directive-LOCAL-1587"></a><a name="index-MMIX-pseudo_002dop-LOCAL-1588"></a>
|
||
|
<a name="MMIX_002dlocal"></a>Example:
|
||
|
<pre class="smallexample"> LOCAL external_symbol
|
||
|
LOCAL 42
|
||
|
.local asymbol
|
||
|
</pre>
|
||
|
<p>This directive-operation generates a link-time assertion that the operand
|
||
|
does not correspond to a global register. The operand is an expression
|
||
|
that at link-time resolves to a register symbol or a number. A number is
|
||
|
treated as the register having that number. There is one restriction on
|
||
|
the use of this directive: the pseudo-directive must be placed in a
|
||
|
section with contents, code or data.
|
||
|
|
||
|
<br><dt><code>IS</code><dd><a name="index-assembler-directive-IS_002c-MMIX-1589"></a><a name="index-pseudo_002dop-IS_002c-MMIX-1590"></a><a name="index-MMIX-assembler-directive-IS-1591"></a><a name="index-MMIX-pseudo_002dop-IS-1592"></a>
|
||
|
<a name="MMIX_002dis"></a>The <code>IS</code> directive:
|
||
|
<pre class="smallexample"> asymbol IS an_expression
|
||
|
</pre>
|
||
|
<p>sets the symbol ‘<samp><span class="samp">asymbol</span></samp>’ to ‘<samp><span class="samp">an_expression</span></samp>’. A symbol may not
|
||
|
be set more than once using this directive. Local labels may be set using
|
||
|
this directive, for example:
|
||
|
<pre class="smallexample"> 5H IS @+4
|
||
|
</pre>
|
||
|
<br><dt><code>GREG</code><dd><a name="index-assembler-directive-GREG_002c-MMIX-1593"></a><a name="index-pseudo_002dop-GREG_002c-MMIX-1594"></a><a name="index-MMIX-assembler-directive-GREG-1595"></a><a name="index-MMIX-pseudo_002dop-GREG-1596"></a>
|
||
|
<a name="MMIX_002dgreg"></a>This directive reserves a global register, gives it an initial value and
|
||
|
optionally gives it a symbolic name. Some examples:
|
||
|
|
||
|
<pre class="smallexample"> areg GREG
|
||
|
breg GREG data_value
|
||
|
GREG data_buffer
|
||
|
.greg creg, another_data_value
|
||
|
</pre>
|
||
|
<p>The symbolic register name can be used in place of a (non-special)
|
||
|
register. If a value isn't provided, it defaults to zero. Unless the
|
||
|
option ‘<samp><span class="samp">--no-merge-gregs</span></samp>’ is specified, non-zero registers allocated
|
||
|
with this directive may be eliminated by <code>as</code>; another
|
||
|
register with the same value used in its place.
|
||
|
Any of the instructions
|
||
|
‘<samp><span class="samp">CSWAP</span></samp>’,
|
||
|
‘<samp><span class="samp">GO</span></samp>’,
|
||
|
‘<samp><span class="samp">LDA</span></samp>’,
|
||
|
‘<samp><span class="samp">LDBU</span></samp>’,
|
||
|
‘<samp><span class="samp">LDB</span></samp>’,
|
||
|
‘<samp><span class="samp">LDHT</span></samp>’,
|
||
|
‘<samp><span class="samp">LDOU</span></samp>’,
|
||
|
‘<samp><span class="samp">LDO</span></samp>’,
|
||
|
‘<samp><span class="samp">LDSF</span></samp>’,
|
||
|
‘<samp><span class="samp">LDTU</span></samp>’,
|
||
|
‘<samp><span class="samp">LDT</span></samp>’,
|
||
|
‘<samp><span class="samp">LDUNC</span></samp>’,
|
||
|
‘<samp><span class="samp">LDVTS</span></samp>’,
|
||
|
‘<samp><span class="samp">LDWU</span></samp>’,
|
||
|
‘<samp><span class="samp">LDW</span></samp>’,
|
||
|
‘<samp><span class="samp">PREGO</span></samp>’,
|
||
|
‘<samp><span class="samp">PRELD</span></samp>’,
|
||
|
‘<samp><span class="samp">PREST</span></samp>’,
|
||
|
‘<samp><span class="samp">PUSHGO</span></samp>’,
|
||
|
‘<samp><span class="samp">STBU</span></samp>’,
|
||
|
‘<samp><span class="samp">STB</span></samp>’,
|
||
|
‘<samp><span class="samp">STCO</span></samp>’,
|
||
|
‘<samp><span class="samp">STHT</span></samp>’,
|
||
|
‘<samp><span class="samp">STOU</span></samp>’,
|
||
|
‘<samp><span class="samp">STSF</span></samp>’,
|
||
|
‘<samp><span class="samp">STTU</span></samp>’,
|
||
|
‘<samp><span class="samp">STT</span></samp>’,
|
||
|
‘<samp><span class="samp">STUNC</span></samp>’,
|
||
|
‘<samp><span class="samp">SYNCD</span></samp>’,
|
||
|
‘<samp><span class="samp">SYNCID</span></samp>’,
|
||
|
can have a value nearby <a name="GREG_002dbase"></a>an initial value in place of its
|
||
|
second and third operands. Here, “nearby” is defined as within the
|
||
|
range 0<small class="dots">...</small>255 from the initial value of such an allocated register.
|
||
|
|
||
|
<pre class="smallexample"> buffer1 BYTE 0,0,0,0,0
|
||
|
buffer2 BYTE 0,0,0,0,0
|
||
|
...
|
||
|
GREG buffer1
|
||
|
LDOU $42,buffer2
|
||
|
</pre>
|
||
|
<p>In the example above, the ‘<samp><span class="samp">Y</span></samp>’ field of the <code>LDOUI</code> instruction
|
||
|
(LDOU with a constant Z) will be replaced with the global register
|
||
|
allocated for ‘<samp><span class="samp">buffer1</span></samp>’, and the ‘<samp><span class="samp">Z</span></samp>’ field will have the value
|
||
|
5, the offset from ‘<samp><span class="samp">buffer1</span></samp>’ to ‘<samp><span class="samp">buffer2</span></samp>’. The result is
|
||
|
equivalent to this code:
|
||
|
<pre class="smallexample"> buffer1 BYTE 0,0,0,0,0
|
||
|
buffer2 BYTE 0,0,0,0,0
|
||
|
...
|
||
|
tmpreg GREG buffer1
|
||
|
LDOU $42,tmpreg,(buffer2-buffer1)
|
||
|
</pre>
|
||
|
<p>Global registers allocated with this directive are allocated in order
|
||
|
higher-to-lower within a file. Other than that, the exact order of
|
||
|
register allocation and elimination is undefined. For example, the order
|
||
|
is undefined when more than one file with such directives are linked
|
||
|
together. With the options ‘<samp><span class="samp">-x</span></samp>’ and ‘<samp><span class="samp">--linker-allocated-gregs</span></samp>’,
|
||
|
‘<samp><span class="samp">GREG</span></samp>’ directives for two-operand cases like the one mentioned above
|
||
|
can be omitted. Sufficient global registers will then be allocated by the
|
||
|
linker.
|
||
|
|
||
|
<br><dt><code>BYTE</code><dd><a name="index-assembler-directive-BYTE_002c-MMIX-1597"></a><a name="index-pseudo_002dop-BYTE_002c-MMIX-1598"></a><a name="index-MMIX-assembler-directive-BYTE-1599"></a><a name="index-MMIX-pseudo_002dop-BYTE-1600"></a>
|
||
|
<a name="MMIX_002dbyte"></a>The ‘<samp><span class="samp">BYTE</span></samp>’ directive takes a series of operands separated by a comma.
|
||
|
If an operand is a string (see <a href="Strings.html#Strings">Strings</a>), each character of that string
|
||
|
is emitted as a byte. Other operands must be constant expressions without
|
||
|
forward references, in the range 0<small class="dots">...</small>255. If you need operands having
|
||
|
expressions with forward references, use ‘<samp><span class="samp">.byte</span></samp>’ (see <a href="Byte.html#Byte">Byte</a>). An
|
||
|
operand can be omitted, defaulting to a zero value.
|
||
|
|
||
|
<br><dt><code>WYDE</code><dt><code>TETRA</code><dt><code>OCTA</code><dd><a name="index-assembler-directive-WYDE_002c-MMIX-1601"></a><a name="index-pseudo_002dop-WYDE_002c-MMIX-1602"></a><a name="index-MMIX-assembler-directive-WYDE-1603"></a><a name="index-MMIX-pseudo_002dop-WYDE-1604"></a><a name="index-assembler-directive-TETRA_002c-MMIX-1605"></a><a name="index-pseudo_002dop-TETRA_002c-MMIX-1606"></a><a name="index-MMIX-assembler-directive-TETRA-1607"></a><a name="index-MMIX-pseudo_002dop-TETRA-1608"></a><a name="index-assembler-directive-OCTA_002c-MMIX-1609"></a><a name="index-pseudo_002dop-OCTA_002c-MMIX-1610"></a><a name="index-MMIX-assembler-directive-OCTA-1611"></a><a name="index-MMIX-pseudo_002dop-OCTA-1612"></a>
|
||
|
<a name="MMIX_002dconstants"></a>The directives ‘<samp><span class="samp">WYDE</span></samp>’, ‘<samp><span class="samp">TETRA</span></samp>’ and ‘<samp><span class="samp">OCTA</span></samp>’ emit constants of
|
||
|
two, four and eight bytes size respectively. Before anything else happens
|
||
|
for the directive, the current location is aligned to the respective
|
||
|
constant-size boundary. If a label is defined at the beginning of the
|
||
|
line, its value will be that after the alignment. A single operand can be
|
||
|
omitted, defaulting to a zero value emitted for the directive. Operands
|
||
|
can be expressed as strings (see <a href="Strings.html#Strings">Strings</a>), in which case each
|
||
|
character in the string is emitted as a separate constant of the size
|
||
|
indicated by the directive.
|
||
|
|
||
|
<br><dt><code>PREFIX</code><dd><a name="index-assembler-directive-PREFIX_002c-MMIX-1613"></a><a name="index-pseudo_002dop-PREFIX_002c-MMIX-1614"></a><a name="index-MMIX-assembler-directive-PREFIX-1615"></a><a name="index-MMIX-pseudo_002dop-PREFIX-1616"></a>
|
||
|
<a name="MMIX_002dprefix"></a>The ‘<samp><span class="samp">PREFIX</span></samp>’ directive sets a symbol name prefix to be prepended to
|
||
|
all symbols (except local symbols, see <a href="MMIX_002dSymbols.html#MMIX_002dSymbols">MMIX-Symbols</a>), that are not
|
||
|
prefixed with ‘<samp><span class="samp">:</span></samp>’, until the next ‘<samp><span class="samp">PREFIX</span></samp>’ directive. Such
|
||
|
prefixes accumulate. For example,
|
||
|
<pre class="smallexample"> PREFIX a
|
||
|
PREFIX b
|
||
|
c IS 0
|
||
|
</pre>
|
||
|
<p>defines a symbol ‘<samp><span class="samp">abc</span></samp>’ with the value 0.
|
||
|
|
||
|
<br><dt><code>BSPEC</code><dt><code>ESPEC</code><dd><a name="index-assembler-directive-BSPEC_002c-MMIX-1617"></a><a name="index-pseudo_002dop-BSPEC_002c-MMIX-1618"></a><a name="index-MMIX-assembler-directive-BSPEC-1619"></a><a name="index-MMIX-pseudo_002dop-BSPEC-1620"></a><a name="index-assembler-directive-ESPEC_002c-MMIX-1621"></a><a name="index-pseudo_002dop-ESPEC_002c-MMIX-1622"></a><a name="index-MMIX-assembler-directive-ESPEC-1623"></a><a name="index-MMIX-pseudo_002dop-ESPEC-1624"></a>
|
||
|
<a name="MMIX_002dspec"></a>A pair of ‘<samp><span class="samp">BSPEC</span></samp>’ and ‘<samp><span class="samp">ESPEC</span></samp>’ directives delimit a section of
|
||
|
special contents (without specified semantics). Example:
|
||
|
<pre class="smallexample"> BSPEC 42
|
||
|
TETRA 1,2,3
|
||
|
ESPEC
|
||
|
</pre>
|
||
|
<p>The single operand to ‘<samp><span class="samp">BSPEC</span></samp>’ must be number in the range
|
||
|
0<small class="dots">...</small>255. The ‘<samp><span class="samp">BSPEC</span></samp>’ number 80 is used by the GNU binutils
|
||
|
implementation.
|
||
|
</dl>
|
||
|
|
||
|
</body></html>
|
||
|
|