blob: 29083e07351b007f5c575b7334f4279d642f926e [file] [log] [blame]
<html lang="en">
<head>
<title>MMIX-mmixal - 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_002dDependent.html#MMIX_002dDependent" title="MMIX-Dependent">
<link rel="prev" href="MMIX_002dSyntax.html#MMIX_002dSyntax" title="MMIX-Syntax">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 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>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="MMIX-mmixal"></a>
<a name="MMIX_002dmmixal"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="MMIX_002dSyntax.html#MMIX_002dSyntax">MMIX-Syntax</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="MMIX_002dDependent.html#MMIX_002dDependent">MMIX-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.25.4 Differences to <code>mmixal</code></h4>
<p><a name="index-mmixal-differences-1378"></a><a name="index-differences_002c-mmixal-1379"></a>
The binutils <code>as</code> and <code>ld</code> combination has a few
differences in function compared to <code>mmixal</code> (see <a href="mmixsite.html#mmixsite">mmixsite</a>).
<p>The replacement of a symbol with a GREG-allocated register
(see <a href="GREG_002dbase.html#GREG_002dbase">GREG-base</a>) is not handled the exactly same way in
<code>as</code> as in <code>mmixal</code>. This is apparent in the
<code>mmixal</code> example file <code>inout.mms</code>, where different registers
with different offsets, eventually yielding the same address, are used in
the first instruction. This type of difference should however not affect
the function of any program unless it has specific assumptions about the
allocated register number.
<p>Line numbers (in the &lsquo;<samp><span class="samp">mmo</span></samp>&rsquo; object format) are currently not
supported.
<p>Expression operator precedence is not that of mmixal: operator precedence
is that of the C programming language. It's recommended to use
parentheses to explicitly specify wanted operator precedence whenever more
than one type of operators are used.
<p>The serialize unary operator <code>&amp;</code>, the fractional division operator
&lsquo;<samp><span class="samp">//</span></samp>&rsquo;, the logical not operator <code>!</code> and the modulus operator
&lsquo;<samp><span class="samp">%</span></samp>&rsquo; are not available.
<p>Symbols are not global by default, unless the option
&lsquo;<samp><span class="samp">--globalize-symbols</span></samp>&rsquo; is passed. Use the &lsquo;<samp><span class="samp">.global</span></samp>&rsquo; directive to
globalize symbols (see <a href="Global.html#Global">Global</a>).
<p>Operand syntax is a bit stricter with <code>as</code> than
<code>mmixal</code>. For example, you can't say <code>addu 1,2,3</code>, instead you
must write <code>addu $1,$2,3</code>.
<p>You can't LOC to a lower address than those already visited
(i.e., &ldquo;backwards&rdquo;).
<p>A LOC directive must come before any emitted code.
<p>Predefined symbols are visible as file-local symbols after use. (In the
ELF file, that is&mdash;the linked mmo file has no notion of a file-local
symbol.)
<p>Some mapping of constant expressions to sections in LOC expressions is
attempted, but that functionality is easily confused and should be avoided
unless compatibility with <code>mmixal</code> is required. A LOC expression to
&lsquo;<samp><span class="samp">0x2000000000000000</span></samp>&rsquo; or higher, maps to the &lsquo;<samp><span class="samp">.data</span></samp>&rsquo; section and
lower addresses map to the &lsquo;<samp><span class="samp">.text</span></samp>&rsquo; section (see <a href="MMIX_002dloc.html#MMIX_002dloc">MMIX-loc</a>).
<p>The code and data areas are each contiguous. Sparse programs with
far-away LOC directives will take up the same amount of space as a
contiguous program with zeros filled in the gaps between the LOC
directives. If you need sparse programs, you might try and get the wanted
effect with a linker script and splitting up the code parts into sections
(see <a href="Section.html#Section">Section</a>). Assembly code for this, to be compatible with
<code>mmixal</code>, would look something like:
<pre class="smallexample"> .if 0
LOC away_expression
.else
.section away,"ax"
.fi
</pre>
<p><code>as</code> will not execute the LOC directive and <code>mmixal</code>
ignores the lines with <code>.</code>. This construct can be used generally to
help compatibility.
<p>Symbols can't be defined twice&ndash;not even to the same value.
<p>Instruction mnemonics are recognized case-insensitive, though the
&lsquo;<samp><span class="samp">IS</span></samp>&rsquo; and &lsquo;<samp><span class="samp">GREG</span></samp>&rsquo; pseudo-operations must be specified in
upper-case characters.
<p>There's no unicode support.
<p>The following is a list of programs in &lsquo;<samp><span class="samp">mmix.tar.gz</span></samp>&rsquo;, available at
<a href="http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html">http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html</a>, last
checked with the version dated 2001-08-25 (md5sum
c393470cfc86fac040487d22d2bf0172) that assemble with <code>mmixal</code> but do
not assemble with <code>as</code>:
<dl>
<dt><code>silly.mms</code><dd>LOC to a previous address.
<br><dt><code>sim.mms</code><dd>Redefines symbol &lsquo;<samp><span class="samp">Done</span></samp>&rsquo;.
<br><dt><code>test.mms</code><dd>Uses the serial operator &lsquo;<samp><span class="samp">&amp;</span></samp>&rsquo;.
</dl>
<!-- Copyright 2002, 2004, 2005 Free Software Foundation, Inc. -->
<!-- This is part of the GAS manual. -->
<!-- For copying conditions, see the file as.texinfo. -->
</body></html>