toolchain/share/doc/as.html/M32C_002dModifiers.html

100 lines
4.3 KiB
HTML
Raw Permalink Normal View History

2024-01-10 05:24:32 +00:00
<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_002dSyntax.html#M32C_002dSyntax" title="M32C-Syntax">
<link rel="next" href="M32C_002dChars.html#M32C_002dChars" title="M32C-Chars">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991-2019 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="M32C-Modifiers"></a>
<a name="M32C_002dModifiers"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="M32C_002dChars.html#M32C_002dChars">M32C-Chars</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="M32C_002dSyntax.html#M32C_002dSyntax">M32C-Syntax</a>
<hr>
</div>
<h5 class="subsubsection">9.20.2.1 Symbolic Operand Modifiers</h5>
<p><a name="index-M32C-modifiers-1343"></a><a name="index-modifiers_002c-M32C-1344"></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-1345"></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>
</body></html>