146 lines
7.1 KiB
HTML
146 lines
7.1 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This file documents the GNU Assembler "as".
|
|
|
|
Copyright (C) 1991-2016 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".
|
|
-->
|
|
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Using as: MIPS Macros</title>
|
|
|
|
<meta name="description" content="Using as: MIPS Macros">
|
|
<meta name="keywords" content="Using as: MIPS Macros">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="MIPS_002dDependent.html#MIPS_002dDependent" rel="up" title="MIPS-Dependent">
|
|
<link href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" rel="next" title="MIPS Symbol Sizes">
|
|
<link href="MIPS-Options.html#MIPS-Options" rel="prev" title="MIPS Options">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.indentedblock {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style:oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nocodebreak {white-space:nowrap}
|
|
span.nolinebreak {white-space:nowrap}
|
|
span.roman {font-family:serif; font-weight:normal}
|
|
span.sansserif {font-family:sans-serif; font-weight:normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
|
|
<a name="MIPS-Macros"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="n" rel="next">MIPS Symbol Sizes</a>, Previous: <a href="MIPS-Options.html#MIPS-Options" accesskey="p" rel="prev">MIPS Options</a>, Up: <a href="MIPS_002dDependent.html#MIPS_002dDependent" accesskey="u" rel="up">MIPS-Dependent</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>
|
|
</div>
|
|
<hr>
|
|
<a name="High_002dlevel-assembly-macros"></a>
|
|
<h4 class="subsection">9.27.2 High-level assembly macros</h4>
|
|
|
|
<p>MIPS assemblers have traditionally provided a wider range of
|
|
instructions than the MIPS architecture itself. These extra
|
|
instructions are usually referred to as “macro” instructions
|
|
<a name="DOCF2" href="#FOOT2"><sup>2</sup></a>.
|
|
</p>
|
|
<p>Some MIPS macro instructions extend an underlying architectural instruction
|
|
while others are entirely new. An example of the former type is <code>and</code>,
|
|
which allows the third operand to be either a register or an arbitrary
|
|
immediate value. Examples of the latter type include <code>bgt</code>, which
|
|
branches to the third operand when the first operand is greater than
|
|
the second operand, and <code>ulh</code>, which implements an unaligned
|
|
2-byte load.
|
|
</p>
|
|
<p>One of the most common extensions provided by macros is to expand
|
|
memory offsets to the full address range (32 or 64 bits) and to allow
|
|
symbolic offsets such as ‘<samp>my_data + 4</samp>’ to be used in place of
|
|
integer constants. For example, the architectural instruction
|
|
<code>lbu</code> allows only a signed 16-bit offset, whereas the macro
|
|
<code>lbu</code> allows code such as ‘<samp>lbu $4,array+32769($5)</samp>’.
|
|
The implementation of these symbolic offsets depends on several factors,
|
|
such as whether the assembler is generating SVR4-style PIC (selected by
|
|
<samp>-KPIC</samp>, see <a href="MIPS-Options.html#MIPS-Options">Assembler options</a>), the size of symbols
|
|
(see <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes">Directives to override the size of symbols</a>),
|
|
and the small data limit (see <a href="MIPS-Small-Data.html#MIPS-Small-Data">Controlling the use
|
|
of small data accesses</a>).
|
|
</p>
|
|
<a name="index-_002eset-macro"></a>
|
|
<a name="index-_002eset-nomacro"></a>
|
|
<p>Sometimes it is undesirable to have one assembly instruction expand
|
|
to several machine instructions. The directive <code>.set nomacro</code>
|
|
tells the assembler to warn when this happens. <code>.set macro</code>
|
|
restores the default behavior.
|
|
</p>
|
|
<a name="index-at-register_002c-MIPS"></a>
|
|
<a name="index-_002eset-at_003dreg"></a>
|
|
<p>Some macro instructions need a temporary register to store intermediate
|
|
results. This register is usually <code>$1</code>, also known as <code>$at</code>,
|
|
but it can be changed to any core register <var>reg</var> using
|
|
<code>.set at=<var>reg</var></code>. Note that <code>$at</code> always refers
|
|
to <code>$1</code> regardless of which register is being used as the
|
|
temporary register.
|
|
</p>
|
|
<a name="index-_002eset-at"></a>
|
|
<a name="index-_002eset-noat"></a>
|
|
<p>Implicit uses of the temporary register in macros could interfere with
|
|
explicit uses in the assembly code. The assembler therefore warns
|
|
whenever it sees an explicit use of the temporary register. The directive
|
|
<code>.set noat</code> silences this warning while <code>.set at</code> restores
|
|
the default behavior. It is safe to use <code>.set noat</code> while
|
|
<code>.set nomacro</code> is in effect since single-instruction macros
|
|
never need a temporary register.
|
|
</p>
|
|
<p>Note that while the <small>GNU</small> assembler provides these macros for compatibility,
|
|
it does not make any attempt to optimize them with the surrounding code.
|
|
</p>
|
|
<div class="footnote">
|
|
<hr>
|
|
<h4 class="footnotes-heading">Footnotes</h4>
|
|
|
|
<h3><a name="FOOT2" href="#DOCF2">(2)</a></h3>
|
|
<p>The term “macro” is somewhat overloaded here, since
|
|
these macros have no relation to those defined by <code>.macro</code>,
|
|
see <a href="Macro.html#Macro"><code>.macro</code></a>.</p>
|
|
</div>
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="n" rel="next">MIPS Symbol Sizes</a>, Previous: <a href="MIPS-Options.html#MIPS-Options" accesskey="p" rel="prev">MIPS Options</a>, Up: <a href="MIPS_002dDependent.html#MIPS_002dDependent" accesskey="u" rel="up">MIPS-Dependent</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>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|