hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the GNU Assembler "as".
 
Copyright (C) 1991-2016 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".
 -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Using as: ARC Directives</title>
 
<meta name="description" content="Using as: ARC Directives">
<meta name="keywords" content="Using as: ARC Directives">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="ARC_002dDependent.html#ARC_002dDependent" rel="up" title="ARC-Dependent">
<link href="ARC-Modifiers.html#ARC-Modifiers" rel="next" title="ARC Modifiers">
<link href="ARC_002dRegs.html#ARC_002dRegs" rel="prev" title="ARC-Regs">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="ARC-Directives"></a>
<div class="header">
<p>
Next: <a href="ARC-Modifiers.html#ARC-Modifiers" accesskey="n" rel="next">ARC Modifiers</a>, Previous: <a href="ARC-Syntax.html#ARC-Syntax" accesskey="p" rel="prev">ARC Syntax</a>, Up: <a href="ARC_002dDependent.html#ARC_002dDependent" accesskey="u" rel="up">ARC-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>
</div>
<hr>
<a name="ARC-Machine-Directives"></a>
<h4 class="subsection">9.3.3 ARC Machine Directives</h4>
 
<a name="index-machine-directives_002c-ARC"></a>
<a name="index-ARC-machine-directives"></a>
<p>The ARC version of <code>as</code> supports the following additional
machine directives:
</p>
<dl compact="compact">
<dd>
<a name="index-lcomm-directive-1"></a>
</dd>
<dt><code>.lcomm <var>symbol</var>, <var>length</var>[, <var>alignment</var>]</code></dt>
<dd><p>Reserve <var>length</var> (an absolute expression) bytes for a local common
denoted by <var>symbol</var>.  The section and value of <var>symbol</var> are
those of the new local common.  The addresses are allocated in the bss
section, so that at run-time the bytes start off zeroed.  Since
<var>symbol</var> is not declared global, it is normally not visible to
<code>ld</code>.  The optional third parameter, <var>alignment</var>,
specifies the desired alignment of the symbol in the bss section,
specified as a byte boundary (for example, an alignment of 16 means
that the least significant 4 bits of the address should be zero).  The
alignment must be an absolute expression, and it must be a power of
two.  If no alignment is specified, as will set the alignment to the
largest power of two less than or equal to the size of the symbol, up
to a maximum of 16.
</p>
<a name="index-lcommon-directive_002c-ARC"></a>
</dd>
<dt><code>.lcommon <var>symbol</var>, <var>length</var>[, <var>alignment</var>]</code></dt>
<dd><p>The same as <code>lcomm</code> directive.
</p>
<a name="index-cpu-directive_002c-ARC"></a>
</dd>
<dt><code>.cpu <var>cpu</var></code></dt>
<dd><p>The <code>.cpu</code> directive must be followed by the desired core
version.  Permitted values for CPU are:
</p><dl compact="compact">
<dt><code>ARC600</code></dt>
<dd><p>Assemble for the ARC600 instruction set.
</p>
</dd>
<dt><code>ARC700</code></dt>
<dd><p>Assemble for the ARC700 instruction set.
</p>
</dd>
<dt><code>NPS400</code></dt>
<dd><p>Assemble for the NPS400 instruction set.
</p>
</dd>
<dt><code>EM</code></dt>
<dd><p>Assemble for the ARC EM instruction set.
</p>
</dd>
<dt><code>HS</code></dt>
<dd><p>Assemble for the ARC HS instruction set.
</p>
</dd>
</dl>
 
<p>Note: the <code>.cpu</code> directive overrides the command line option
<code>-mcpu=<var>cpu</var></code>; a warning is emitted when the version is not
consistent between the two.
</p>
</dd>
<dt><code>.extAuxRegister <var>name</var>, <var>addr</var>, <var>mode</var></code></dt>
<dd><a name="index-extAuxRegister-directive_002c-ARC"></a>
<p>Auxiliary registers can be defined in the assembler source code by
using this directive.  The first parameter, <var>name</var>, is the name of the
new auxiliary register.  The second parameter, <var>addr</var>, is
address the of the auxiliary register.  The third parameter,
<var>mode</var>, specifies whether the register is readable and/or writable
and is one of:
</p><dl compact="compact">
<dt><code>r</code></dt>
<dd><p>Read only;
</p>
</dd>
<dt><code>w</code></dt>
<dd><p>Write only;
</p>
</dd>
<dt><code>r|w</code></dt>
<dd><p>Read and write.
</p>
</dd>
</dl>
 
<p>For example:
</p><div class="example">
<pre class="example">    .extAuxRegister mulhi, 0x12, w
</pre></div>
<p>specifies a write only extension auxiliary register, <var>mulhi</var> at
address 0x12.
</p>
</dd>
<dt><code>.extCondCode <var>suffix</var>, <var>val</var></code></dt>
<dd><a name="index-extCondCode-directive_002c-ARC"></a>
<p>ARC supports extensible condition codes.  This directive defines a new
condition code, to be known by the suffix, <var>suffix</var> and will
depend on the value, <var>val</var> in the condition code.
</p>
<p>For example:
</p><div class="example">
<pre class="example">    .extCondCode is_busy,0x14
   add.is_busy  r1,r2,r3
</pre></div>
<p>will only execute the <code>add</code> instruction if the condition code
value is 0x14.
</p>
</dd>
<dt><code>.extCoreRegister <var>name</var>, <var>regnum</var>, <var>mode</var>, <var>shortcut</var></code></dt>
<dd><a name="index-extCoreRegister-directive_002c-ARC"></a>
<p>Specifies an extension core register named <var>name</var> as a synonym for
the register numbered <var>regnum</var>.  The register number must be
between 32 and 59.  The third argument, <var>mode</var>, indicates whether
the register is readable and/or writable and is one of:
</p><dl compact="compact">
<dt><code>r</code></dt>
<dd><p>Read only;
</p>
</dd>
<dt><code>w</code></dt>
<dd><p>Write only;
</p>
</dd>
<dt><code>r|w</code></dt>
<dd><p>Read and write.
</p>
</dd>
</dl>
 
<p>The final parameter, <var>shortcut</var> indicates whether the register has
a short cut in the pipeline.  The valid values are:
</p><dl compact="compact">
<dt><code>can_shortcut</code></dt>
<dd><p>The register has a short cut in the pipeline;
</p>
</dd>
<dt><code>cannot_shortcut</code></dt>
<dd><p>The register does not have a short cut in the pipeline.
</p></dd>
</dl>
 
<p>For example:
</p><div class="example">
<pre class="example">    .extCoreRegister mlo, 57, r , can_shortcut
</pre></div>
<p>defines a read only extension core register, <code>mlo</code>, which is
register 57, and can short cut the pipeline.
</p>
</dd>
<dt><code>.extInstruction <var>name</var>, <var>opcode</var>, <var>subopcode</var>, <var>suffixclass</var>, <var>syntaxclass</var></code></dt>
<dd><a name="index-extInstruction-directive_002c-ARC"></a>
<p>ARC allows the user to specify extension instructions.  These
extension instructions are not macros; the assembler creates encodings
for use of these instructions according to the specification by the
user.
</p>
<p>The first argument, <var>name</var>, gives the name of the instruction.
</p>
<p>The second argument, <var>opcode</var>, is the opcode to be used (bits 31:27
in the encoding).
</p>
<p>The third argument, <var>subopcode</var>, is the sub-opcode to be used, but
the correct value also depends on the fifth argument,
<var>syntaxclass</var>
</p>
<p>The fourth argument, <var>suffixclass</var>, determines the kinds of
suffixes to be allowed.  Valid values are:
</p><dl compact="compact">
<dt><code>SUFFIX_NONE</code></dt>
<dd><p>No suffixes are permitted;
</p>
</dd>
<dt><code>SUFFIX_COND</code></dt>
<dd><p>Conditional suffixes are permitted;
</p>
</dd>
<dt><code>SUFFIX_FLAG</code></dt>
<dd><p>Flag setting suffixes are permitted.
</p>
</dd>
<dt><code>SUFFIX_COND|SUFFIX_FLAG</code></dt>
<dd><p>Both conditional and flag setting suffices are permitted.
</p>
</dd>
</dl>
 
<p>The fifth and final argument, <var>syntaxclass</var>, determines the syntax
class for the instruction.  It can have the following values:
</p><dl compact="compact">
<dt><code>SYNTAX_2OP</code></dt>
<dd><p>Two Operand Instruction;
</p>
</dd>
<dt><code>SYNTAX_3OP</code></dt>
<dd><p>Three Operand Instruction.
</p>
</dd>
<dt><code>SYNTAX_1OP</code></dt>
<dd><p>One Operand Instruction.
</p>
</dd>
<dt><code>SYNTAX_NOP</code></dt>
<dd><p>No Operand Instruction.
</p></dd>
</dl>
 
<p>The syntax class may be followed by &lsquo;<samp>|</samp>&rsquo; and one of the following
modifiers.
</p><dl compact="compact">
<dt><code>OP1_MUST_BE_IMM</code></dt>
<dd><p>Modifies syntax class <code>SYNTAX_3OP</code>, specifying that the first
operand of a three-operand instruction must be an immediate (i.e., the
result is discarded).  This is usually used to set the flags using
specific instructions and not retain results.
</p>
</dd>
<dt><code>OP1_IMM_IMPLIED</code></dt>
<dd><p>Modifies syntax class <code>SYNTAX_20P</code>, specifying that there is an
implied immediate destination operand which does not appear in the
syntax.
</p>
<p>For example, if the source code contains an instruction like:
</p><div class="example">
<pre class="example">inst r1,r2
</pre></div>
<p>the first argument is an implied immediate (that is, the result is
discarded).  This is the same as though the source code were: inst
0,r1,r2.
</p>
</dd>
</dl>
 
<p>For example, defining a 64-bit multiplier with immediate operands:
</p><div class="example">
<pre class="example">    .extInstruction  mp64, 0x07, 0x2d, SUFFIX_COND|SUFFIX_FLAG,
            SYNTAX_3OP|OP1_MUST_BE_IMM
</pre></div>
<p>which specifies an extension instruction named <code>mp64</code> with 3
operands.  It sets the flags and can be used with a condition code,
for which the first operand is an immediate, i.e. equivalent to
discarding the result of the operation.
</p>
<p>A two operands instruction variant would be:
</p><div class="example">
<pre class="example">    .extInstruction mul64, 0x07, 0x2d, SUFFIX_COND,
   SYNTAX_2OP|OP1_IMM_IMPLIED
</pre></div>
<p>which describes a two operand instruction with an implicit first
immediate operand.  The result of this operation would be discarded.
</p>
</dd>
</dl>
 
<hr>
<div class="header">
<p>
Next: <a href="ARC-Modifiers.html#ARC-Modifiers" accesskey="n" rel="next">ARC Modifiers</a>, Previous: <a href="ARC-Syntax.html#ARC-Syntax" accesskey="p" rel="prev">ARC Syntax</a>, Up: <a href="ARC_002dDependent.html#ARC_002dDependent" accesskey="u" rel="up">ARC-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>
</div>
 
 
 
</body>
</html>