blob: 70a243566a0ac035788f8aead17be49431c91149 [file] [log] [blame]
<html lang="en">
<head>
<title>MIPS symbol sizes - 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="MIPS_002dDependent.html#MIPS_002dDependent" title="MIPS-Dependent">
<link rel="prev" href="MIPS-ISA.html#MIPS-ISA" title="MIPS ISA">
<link rel="next" href="MIPS-autoextend.html#MIPS-autoextend" title="MIPS autoextend">
<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="MIPS-symbol-sizes"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="MIPS-autoextend.html#MIPS-autoextend">MIPS autoextend</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="MIPS-ISA.html#MIPS-ISA">MIPS ISA</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="MIPS_002dDependent.html#MIPS_002dDependent">MIPS-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.24.4 Directives to override the size of symbols</h4>
<p><a name="index-g_t_0040code_007b_002eset-sym32_007d-1271"></a><a name="index-g_t_0040code_007b_002eset-nosym32_007d-1272"></a>The n64 ABI allows symbols to have any 64-bit value. Although this
provides a great deal of flexibility, it means that some macros have
much longer expansions than their 32-bit counterparts. For example,
the non-PIC expansion of &lsquo;<samp><span class="samp">dla $4,sym</span></samp>&rsquo; is usually:
<pre class="smallexample"> lui $4,%highest(sym)
lui $1,%hi(sym)
daddiu $4,$4,%higher(sym)
daddiu $1,$1,%lo(sym)
dsll32 $4,$4,0
daddu $4,$4,$1
</pre>
<p>whereas the 32-bit expansion is simply:
<pre class="smallexample"> lui $4,%hi(sym)
daddiu $4,$4,%lo(sym)
</pre>
<p>n64 code is sometimes constructed in such a way that all symbolic
constants are known to have 32-bit values, and in such cases, it's
preferable to use the 32-bit expansion instead of the 64-bit
expansion.
<p>You can use the <code>.set sym32</code> directive to tell the assembler
that, from this point on, all expressions of the form
&lsquo;<samp><var>symbol</var></samp>&rsquo; or &lsquo;<samp><var>symbol</var><span class="samp"> + </span><var>offset</var></samp>&rsquo;
have 32-bit values. For example:
<pre class="smallexample"> .set sym32
dla $4,sym
lw $4,sym+16
sw $4,sym+0x8000($4)
</pre>
<p>will cause the assembler to treat &lsquo;<samp><span class="samp">sym</span></samp>&rsquo;, <code>sym+16</code> and
<code>sym+0x8000</code> as 32-bit values. The handling of non-symbolic
addresses is not affected.
<p>The directive <code>.set nosym32</code> ends a <code>.set sym32</code> block and
reverts to the normal behavior. It is also possible to change the
symbol size using the command-line options <samp><span class="option">-msym32</span></samp> and
<samp><span class="option">-mno-sym32</span></samp>.
<p>These options and directives are always accepted, but at present,
they have no effect for anything other than n64.
</body></html>