blob: 445d9ab6ad962df062c26a934d8bff0c804b33ed [file] [log] [blame]
<html lang="en">
<head>
<title>M32C-Modifiers - 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="M32C_002dDependent.html#M32C_002dDependent" title="M32C-Dependent">
<link rel="prev" href="M32C_002dOpts.html#M32C_002dOpts" title="M32C-Opts">
<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="M32C-Modifiers"></a>
<a name="M32C_002dModifiers"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="M32C_002dOpts.html#M32C_002dOpts">M32C-Opts</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="M32C_002dDependent.html#M32C_002dDependent">M32C-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.19.2 Symbolic Operand Modifiers</h4>
<p><a name="index-M32C-modifiers-1090"></a><a name="index-syntax_002c-M32C-1091"></a>
The assembler supports several modifiers when using symbol addresses
in M32C instruction operands. The general syntax is the following:
<pre class="smallexample"> %modifier(symbol)
</pre>
<a name="index-symbol-modifiers-1092"></a>
<dl>
<dt><code>%dsp8</code><dt><code>%dsp16</code><dd>
These modifiers override the assembler's assumptions about how big a
symbol's address is. Normally, when it sees an operand like
&lsquo;<samp><span class="samp">sym[a0]</span></samp>&rsquo; it assumes &lsquo;<samp><span class="samp">sym</span></samp>&rsquo; may require the widest
displacement field (16 bits for &lsquo;<samp><span class="samp">-m16c</span></samp>&rsquo;, 24 bits for
&lsquo;<samp><span class="samp">-m32c</span></samp>&rsquo;). These modifiers tell it to assume the address will fit
in an 8 or 16 bit (respectively) unsigned displacement. Note that, of
course, if it doesn't actually fit you will get linker errors. Example:
<pre class="smallexample"> mov.w %dsp8(sym)[a0],r1
mov.b #0,%dsp8(sym)[a0]
</pre>
<br><dt><code>%hi8</code><dd>
This modifier allows you to load bits 16 through 23 of a 24 bit
address into an 8 bit register. This is useful with, for example, the
M16C &lsquo;<samp><span class="samp">smovf</span></samp>&rsquo; instruction, which expects a 20 bit address in
&lsquo;<samp><span class="samp">r1h</span></samp>&rsquo; and &lsquo;<samp><span class="samp">a0</span></samp>&rsquo;. Example:
<pre class="smallexample"> mov.b #%hi8(sym),r1h
mov.w #%lo16(sym),a0
smovf.b
</pre>
<br><dt><code>%lo16</code><dd>
Likewise, this modifier allows you to load bits 0 through 15 of a 24
bit address into a 16 bit register.
<br><dt><code>%hi16</code><dd>
This modifier allows you to load bits 16 through 31 of a 32 bit
address into a 16 bit register. While the M32C family only has 24
bits of address space, it does support addresses in pairs of 16 bit
registers (like &lsquo;<samp><span class="samp">a1a0</span></samp>&rsquo; for the &lsquo;<samp><span class="samp">lde</span></samp>&rsquo; instruction). This
modifier is for loading the upper half in such cases. Example:
<pre class="smallexample"> mov.w #%hi16(sym),a1
mov.w #%lo16(sym),a0
...
lde.w [a1a0],r1
</pre>
</dl>
<!-- Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -->
<!-- 2000, 2003, 2004, 2006 -->
<!-- Free Software Foundation, Inc. -->
<!-- This is part of the GAS manual. -->
<!-- For copying conditions, see the file as.texinfo. -->
</body></html>