<html lang="en"> <head> <title>M32R-Directives - Using as</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using as"> <meta name="generator" content="makeinfo 4.7"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="M32R_002dDependent.html#M32R_002dDependent" title="M32R-Dependent"> <link rel="prev" href="M32R_002dOpts.html#M32R_002dOpts" title="M32R-Opts"> <link rel="next" href="M32R_002dWarnings.html#M32R_002dWarnings" title="M32R-Warnings"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- This file documents the GNU Assembler "as". Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006, 2007 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.1 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''. man end--> <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; } --></style> </head> <body> <div class="node"> <p> <a name="M32R_002dDirectives"></a>Next: <a rel="next" accesskey="n" href="M32R_002dWarnings.html#M32R_002dWarnings">M32R-Warnings</a>, Previous: <a rel="previous" accesskey="p" href="M32R_002dOpts.html#M32R_002dOpts">M32R-Opts</a>, Up: <a rel="up" accesskey="u" href="M32R_002dDependent.html#M32R_002dDependent">M32R-Dependent</a> <hr><br> </div> <h4 class="subsection">9.19.2 M32R Directives</h4> <p><a name="index-directives_002c-M32R-1072"></a><a name="index-M32R-directives-1073"></a> The Renease M32R version of <code>as</code> has a few architecture specific directives: <a name="index-_0040code_007blow_007d-directive_002c-M32R-1074"></a> <dl><dt><code>low </code><var>expression</var><dd>The <code>low</code> directive computes the value of its expression and places the lower 16-bits of the result into the immediate-field of the instruction. For example: <pre class="smallexample"> or3 r0, r0, #low(0x12345678) ; compute r0 = r0 | 0x5678 add3, r0, r0, #low(fred) ; compute r0 = r0 + low 16-bits of address of fred </pre> <br><dt><code>high </code><var>expression</var><dd><a name="index-_0040code_007bhigh_007d-directive_002c-M32R-1075"></a>The <code>high</code> directive computes the value of its expression and places the upper 16-bits of the result into the immediate-field of the instruction. For example: <pre class="smallexample"> seth r0, #high(0x12345678) ; compute r0 = 0x12340000 seth, r0, #high(fred) ; compute r0 = upper 16-bits of address of fred </pre> <br><dt><code>shigh </code><var>expression</var><dd><a name="index-_0040code_007bshigh_007d-directive_002c-M32R-1076"></a>The <code>shigh</code> directive is very similar to the <code>high</code> directive. It also computes the value of its expression and places the upper 16-bits of the result into the immediate-field of the instruction. The difference is that <code>shigh</code> also checks to see if the lower 16-bits could be interpreted as a signed number, and if so it assumes that a borrow will occur from the upper-16 bits. To compensate for this the <code>shigh</code> directive pre-biases the upper 16 bit value by adding one to it. For example: <p>For example: <pre class="smallexample"> seth r0, #shigh(0x12345678) ; compute r0 = 0x12340000 seth r0, #shigh(0x00008000) ; compute r0 = 0x00010000 </pre> <p>In the second example the lower 16-bits are 0x8000. If these are treated as a signed value and sign extended to 32-bits then the value becomes 0xffff8000. If this value is then added to 0x00010000 then the result is 0x00008000. <p>This behaviour is to allow for the different semantics of the <code>or3</code> and <code>add3</code> instructions. The <code>or3</code> instruction treats its 16-bit immediate argument as unsigned whereas the <code>add3</code> treats its 16-bit immediate as a signed value. So for example: <pre class="smallexample"> seth r0, #shigh(0x00008000) add3 r0, r0, #low(0x00008000) </pre> <p>Produces the correct result in r0, whereas: <pre class="smallexample"> seth r0, #shigh(0x00008000) or3 r0, r0, #low(0x00008000) </pre> <p>Stores 0xffff8000 into r0. <p>Note - the <code>shigh</code> directive does not know where in the assembly source code the lower 16-bits of the value are going set, so it cannot check to make sure that an <code>or3</code> instruction is being used rather than an <code>add3</code> instruction. It is up to the programmer to make sure that correct directives are used. <p><a name="index-_0040code_007b_002em32r_007d-directive_002c-M32R-1077"></a><br><dt><code>.m32r</code><dd>The directive performs a similar thing as the <em>-m32r</em> command line option. It tells the assembler to only accept M32R instructions from now on. An instructions from later M32R architectures are refused. <p><a name="index-_0040code_007b_002em32rx_007d-directive_002c-M32RX-1078"></a><br><dt><code>.m32rx</code><dd>The directive performs a similar thing as the <em>-m32rx</em> command line option. It tells the assembler to start accepting the extra instructions in the M32RX ISA as well as the ordinary M32R ISA. <p><a name="index-_0040code_007b_002em32r2_007d-directive_002c-M32R2-1079"></a><br><dt><code>.m32r2</code><dd>The directive performs a similar thing as the <em>-m32r2</em> command line option. It tells the assembler to start accepting the extra instructions in the M32R2 ISA as well as the ordinary M32R ISA. <p><a name="index-_0040code_007b_002elittle_007d-directive_002c-M32RX-1080"></a><br><dt><code>.little</code><dd>The directive performs a similar thing as the <em>-little</em> command line option. It tells the assembler to start producing little-endian code and data. This option should be used with care as producing mixed-endian binary files is fraught with danger. <p><a name="index-_0040code_007b_002ebig_007d-directive_002c-M32RX-1081"></a><br><dt><code>.big</code><dd>The directive performs a similar thing as the <em>-big</em> command line option. It tells the assembler to start producing big-endian code and data. This option should be used with care as producing mixed-endian binary files is fraught with danger. </dl> </body></html>