| <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, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
| 2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010, 2011 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: <a rel="next" accesskey="n" href="M32C_002dChars.html#M32C_002dChars">M32C-Chars</a>, | |
| Up: <a rel="up" accesskey="u" href="M32C_002dSyntax.html#M32C_002dSyntax">M32C-Syntax</a> | |
| <hr> | |
| </div> | |
| <h5 class="subsubsection">9.21.2.1 Symbolic Operand Modifiers</h5> | |
| <p><a name="index-M32C-modifiers-1180"></a><a name="index-modifiers_002c-M32C-1181"></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-1182"></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 | |
| ‘<samp><span class="samp">sym[a0]</span></samp>’ it assumes ‘<samp><span class="samp">sym</span></samp>’ may require the widest | |
| displacement field (16 bits for ‘<samp><span class="samp">-m16c</span></samp>’, 24 bits for | |
| ‘<samp><span class="samp">-m32c</span></samp>’). 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 ‘<samp><span class="samp">smovf</span></samp>’ instruction, which expects a 20 bit address in | |
| ‘<samp><span class="samp">r1h</span></samp>’ and ‘<samp><span class="samp">a0</span></samp>’. 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 ‘<samp><span class="samp">a1a0</span></samp>’ for the ‘<samp><span class="samp">lde</span></samp>’ 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> | |