1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU Assembler "as".
4
5Copyright (C) 1991-2021 Free Software Foundation, Inc.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3
9or any later version published by the Free Software Foundation;
10with no Invariant Sections, with no Front-Cover Texts, and with no
11Back-Cover Texts.  A copy of the license is included in the
12section entitled "GNU Free Documentation License".
13 -->
14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
15<head>
16<title>Using as: V850 Opcodes</title>
17
18<meta name="description" content="Using as: V850 Opcodes">
19<meta name="keywords" content="Using as: V850 Opcodes">
20<meta name="resource-type" content="document">
21<meta name="distribution" content="global">
22<meta name="Generator" content="makeinfo">
23<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
24<link href="index.html#Top" rel="start" title="Top">
25<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
26<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
27<link href="V850_002dDependent.html#V850_002dDependent" rel="up" title="V850-Dependent">
28<link href="Vax_002dDependent.html#Vax_002dDependent" rel="next" title="Vax-Dependent">
29<link href="V850-Directives.html#V850-Directives" rel="previous" title="V850 Directives">
30<style type="text/css">
31<!--
32a.summary-letter {text-decoration: none}
33blockquote.smallquotation {font-size: smaller}
34div.display {margin-left: 3.2em}
35div.example {margin-left: 3.2em}
36div.indentedblock {margin-left: 3.2em}
37div.lisp {margin-left: 3.2em}
38div.smalldisplay {margin-left: 3.2em}
39div.smallexample {margin-left: 3.2em}
40div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
41div.smalllisp {margin-left: 3.2em}
42kbd {font-style:oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47pre.smalldisplay {font-family: inherit; font-size: smaller}
48pre.smallexample {font-size: smaller}
49pre.smallformat {font-family: inherit; font-size: smaller}
50pre.smalllisp {font-size: smaller}
51span.nocodebreak {white-space:nowrap}
52span.nolinebreak {white-space:nowrap}
53span.roman {font-family:serif; font-weight:normal}
54span.sansserif {font-family:sans-serif; font-weight:normal}
55ul.no-bullet {list-style: none}
56-->
57</style>
58
59
60</head>
61
62<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
63<a name="V850-Opcodes"></a>
64<div class="header">
65<p>
66Previous: <a href="V850-Directives.html#V850-Directives" accesskey="p" rel="previous">V850 Directives</a>, Up: <a href="V850_002dDependent.html#V850_002dDependent" accesskey="u" rel="up">V850-Dependent</a> &nbsp; [<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>
67</div>
68<hr>
69<a name="Opcodes-19"></a>
70<h4 class="subsection">9.49.5 Opcodes</h4>
71
72<a name="index-V850-opcodes"></a>
73<a name="index-opcodes-for-V850"></a>
74<p><code>as</code> implements all the standard V850 opcodes.
75</p>
76<p><code>as</code> also implements the following pseudo ops:
77</p>
78<dl compact="compact">
79<dd>
80<a name="index-hi0-pseudo_002dop_002c-V850"></a>
81</dd>
82<dt><code>hi0()</code></dt>
83<dd><p>Computes the higher 16 bits of the given expression and stores it into
84the immediate operand field of the given instruction.  For example:
85</p>
86<p>&lsquo;<samp>mulhi hi0(here - there), r5, r6</samp>&rsquo;
87</p>
88<p>computes the difference between the address of labels &rsquo;here&rsquo; and
89&rsquo;there&rsquo;, takes the upper 16 bits of this difference, shifts it down 16
90bits and then multiplies it by the lower 16 bits in register 5, putting
91the result into register 6.
92</p>
93<a name="index-lo-pseudo_002dop_002c-V850"></a>
94</dd>
95<dt><code>lo()</code></dt>
96<dd><p>Computes the lower 16 bits of the given expression and stores it into
97the immediate operand field of the given instruction.  For example:
98</p>
99<p>&lsquo;<samp>addi lo(here - there), r5, r6</samp>&rsquo;
100</p>
101<p>computes the difference between the address of labels &rsquo;here&rsquo; and
102&rsquo;there&rsquo;, takes the lower 16 bits of this difference and adds it to
103register 5, putting the result into register 6.
104</p>
105<a name="index-hi-pseudo_002dop_002c-V850"></a>
106</dd>
107<dt><code>hi()</code></dt>
108<dd><p>Computes the higher 16 bits of the given expression and then adds the
109value of the most significant bit of the lower 16 bits of the expression
110and stores the result into the immediate operand field of the given
111instruction.  For example the following code can be used to compute the
112address of the label &rsquo;here&rsquo; and store it into register 6:
113</p>
114<p>&lsquo;<samp>movhi hi(here), r0, r6</samp>&rsquo;
115    &lsquo;<samp>movea lo(here), r6, r6</samp>&rsquo;
116</p>
117<p>The reason for this special behaviour is that movea performs a sign
118extension on its immediate operand.  So for example if the address of
119&rsquo;here&rsquo; was 0xFFFFFFFF then without the special behaviour of the hi()
120pseudo-op the movhi instruction would put 0xFFFF0000 into r6, then the
121movea instruction would takes its immediate operand, 0xFFFF, sign extend
122it to 32 bits, 0xFFFFFFFF, and then add it into r6 giving 0xFFFEFFFF
123which is wrong (the fifth nibble is E).  With the hi() pseudo op adding
124in the top bit of the lo() pseudo op, the movhi instruction actually
125stores 0 into r6 (0xFFFF + 1 = 0x0000), so that the movea instruction
126stores 0xFFFFFFFF into r6 - the right value.
127</p>
128<a name="index-hilo-pseudo_002dop_002c-V850"></a>
129</dd>
130<dt><code>hilo()</code></dt>
131<dd><p>Computes the 32 bit value of the given expression and stores it into
132the immediate operand field of the given instruction (which must be a
133mov instruction).  For example:
134</p>
135<p>&lsquo;<samp>mov hilo(here), r6</samp>&rsquo;
136</p>
137<p>computes the absolute address of label &rsquo;here&rsquo; and puts the result into
138register 6.
139</p>
140<a name="index-sdaoff-pseudo_002dop_002c-V850"></a>
141</dd>
142<dt><code>sdaoff()</code></dt>
143<dd><p>Computes the offset of the named variable from the start of the Small
144Data Area (whose address is held in register 4, the GP register) and
145stores the result as a 16 bit signed value in the immediate operand
146field of the given instruction.  For example:
147</p>
148<p>&lsquo;<samp>ld.w sdaoff(_a_variable)[gp],r6</samp>&rsquo;
149</p>
150<p>loads the contents of the location pointed to by the label &rsquo;_a_variable&rsquo;
151into register 6, provided that the label is located somewhere within +/-
15232K of the address held in the GP register.  [Note the linker assumes
153that the GP register contains a fixed address set to the address of the
154label called &rsquo;__gp&rsquo;.  This can either be set up automatically by the
155linker, or specifically set by using the &lsquo;<samp>--defsym __gp=&lt;value&gt;</samp>&rsquo;
156command-line option].
157</p>
158<a name="index-tdaoff-pseudo_002dop_002c-V850"></a>
159</dd>
160<dt><code>tdaoff()</code></dt>
161<dd><p>Computes the offset of the named variable from the start of the Tiny
162Data Area (whose address is held in register 30, the EP register) and
163stores the result as a 4,5, 7 or 8 bit unsigned value in the immediate
164operand field of the given instruction.  For example:
165</p>
166<p>&lsquo;<samp>sld.w tdaoff(_a_variable)[ep],r6</samp>&rsquo;
167</p>
168<p>loads the contents of the location pointed to by the label &rsquo;_a_variable&rsquo;
169into register 6, provided that the label is located somewhere within +256
170bytes of the address held in the EP register.  [Note the linker assumes
171that the EP register contains a fixed address set to the address of the
172label called &rsquo;__ep&rsquo;.  This can either be set up automatically by the
173linker, or specifically set by using the &lsquo;<samp>--defsym __ep=&lt;value&gt;</samp>&rsquo;
174command-line option].
175</p>
176<a name="index-zdaoff-pseudo_002dop_002c-V850"></a>
177</dd>
178<dt><code>zdaoff()</code></dt>
179<dd><p>Computes the offset of the named variable from address 0 and stores the
180result as a 16 bit signed value in the immediate operand field of the
181given instruction.  For example:
182</p>
183<p>&lsquo;<samp>movea zdaoff(_a_variable),zero,r6</samp>&rsquo;
184</p>
185<p>puts the address of the label &rsquo;_a_variable&rsquo; into register 6, assuming
186that the label is somewhere within the first 32K of memory.  (Strictly
187speaking it also possible to access the last 32K of memory as well, as
188the offsets are signed).
189</p>
190<a name="index-ctoff-pseudo_002dop_002c-V850"></a>
191</dd>
192<dt><code>ctoff()</code></dt>
193<dd><p>Computes the offset of the named variable from the start of the Call
194Table Area (whose address is held in system register 20, the CTBP
195register) and stores the result a 6 or 16 bit unsigned value in the
196immediate field of then given instruction or piece of data.  For
197example:
198</p>
199<p>&lsquo;<samp>callt ctoff(table_func1)</samp>&rsquo;
200</p>
201<p>will put the call the function whose address is held in the call table
202at the location labeled &rsquo;table_func1&rsquo;.
203</p>
204<a name="index-longcall-pseudo_002dop_002c-V850"></a>
205</dd>
206<dt><code>.longcall <code>name</code></code></dt>
207<dd><p>Indicates that the following sequence of instructions is a long call
208to function <code>name</code>.  The linker will attempt to shorten this call
209sequence if <code>name</code> is within a 22bit offset of the call.  Only
210valid if the <code>-mrelax</code> command-line switch has been enabled.
211</p>
212<a name="index-longjump-pseudo_002dop_002c-V850"></a>
213</dd>
214<dt><code>.longjump <code>name</code></code></dt>
215<dd><p>Indicates that the following sequence of instructions is a long jump
216to label <code>name</code>.  The linker will attempt to shorten this code
217sequence if <code>name</code> is within a 22bit offset of the jump.  Only
218valid if the <code>-mrelax</code> command-line switch has been enabled.
219</p>
220</dd>
221</dl>
222
223
224<p>For information on the V850 instruction set, see <cite>V850
225Family 32-/16-Bit single-Chip Microcontroller Architecture Manual</cite> from NEC.
226Ltd.
227</p>
228<hr>
229<div class="header">
230<p>
231Previous: <a href="V850-Directives.html#V850-Directives" accesskey="p" rel="previous">V850 Directives</a>, Up: <a href="V850_002dDependent.html#V850_002dDependent" accesskey="u" rel="up">V850-Dependent</a> &nbsp; [<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>
232</div>
233
234
235
236</body>
237</html>
238