Add support for .extCondCode, .extCoreRegister and .extAuxRegister.
[deliverable/binutils-gdb.git] / gas / doc / c-arc.texi
CommitLineData
6f2750fe 1@c Copyright (C) 2000-2016 Free Software Foundation, Inc.
2d73a4ca
NC
2@c This is part of the GAS manual.
3@c For copying conditions, see the file as.texinfo.
4
5@ifset GENERIC
6@page
7@node ARC-Dependent
8@chapter ARC Dependent Features
9@end ifset
10
11@ifclear GENERIC
12@node Machine Dependencies
13@chapter ARC Dependent Features
14@end ifclear
15
bcee8eb8 16@set ARC_CORE_DEFAULT 6
2d73a4ca
NC
17
18@cindex ARC support
19@menu
20* ARC Options:: Options
21* ARC Syntax:: Syntax
2d73a4ca 22* ARC Directives:: ARC Machine Directives
886a2506
NC
23* ARC Modifiers:: ARC Assembler Modifiers
24* ARC Symbols:: ARC Pre-defined Symbols
2d73a4ca
NC
25* ARC Opcodes:: Opcodes
26@end menu
27
2d73a4ca
NC
28@node ARC Options
29@section Options
886a2506
NC
30@cindex ARC options
31@cindex options for ARC
32
33The following options control the type of CPU for which code is
34assembled, and generic constraints on the code generated:
2d73a4ca
NC
35
36@table @code
37
886a2506
NC
38@item -mcpu=@var{cpu}
39@cindex @code{-mcpu=@var{cpu}} command line option, ARC
40Set architecture type and register usage for @var{cpu}. There are
41also shortcut alias options available for backward compatibility and
42convenience. Supported values for @var{cpu} are
2d73a4ca
NC
43
44@table @code
886a2506
NC
45@cindex @code{mA6} command line option, ARC
46@cindex @code{marc600} command line option, ARC
47@item arc600
48Assemble for ARC 600. Aliases: @code{-mA6}, @code{-mARC600}.
2d73a4ca 49
886a2506
NC
50@item arc601
51@cindex @code{mARC601} command line option, ARC
52Assemble for ARC 601. Alias: @code{-mARC601}.
2d73a4ca 53
886a2506
NC
54@item arc700
55@cindex @code{mA7} command line option, ARC
56@cindex @code{mARC700} command line option, ARC
57Assemble for ARC 700. Aliases: @code{-mA7}, @code{-mARC700}.
2d73a4ca 58
886a2506
NC
59@item arcem
60@cindex @code{mEM} command line option, ARC
61Assemble for ARC EM. Aliases: @code{-mEM}
2d73a4ca 62
886a2506
NC
63@item archs
64@cindex @code{mHS} command line option, ARC
65Assemble for ARC HS. Aliases: @code{-mHS}, @code{-mav2hs}.
2d73a4ca
NC
66
67@end table
68
886a2506 69Note: the @code{.cpu} directive can to be used to select a core
2d73a4ca
NC
70variant from within assembly code.
71
72@cindex @code{-EB} command line option, ARC
73@item -EB
74This option specifies that the output generated by the assembler should
75be marked as being encoded for a big-endian processor.
76
77@cindex @code{-EL} command line option, ARC
78@item -EL
79This option specifies that the output generated by the assembler should
80be marked as being encoded for a little-endian processor - this is the
81default.
82
886a2506
NC
83@cindex @code{-mcode-density} command line option, ARC
84@item -mcode-density
85This option turns on Code Density instructions. Only valid for ARC EM
86processors.
87
4670103e
CZ
88@cindex @code{-mrelax} command line option, ARC
89@item -mrelax
90Enable support for assembly-time relaxation. The assembler will
91replace a longer version of an instruction with a shorter one,
92whenever it is possible.
93
2d73a4ca
NC
94@end table
95
2d73a4ca
NC
96@node ARC Syntax
97@section Syntax
98@menu
99* ARC-Chars:: Special Characters
100* ARC-Regs:: Register Names
101@end menu
102
103@node ARC-Chars
104@subsection Special Characters
105
886a2506
NC
106@table @code
107@item %
108@cindex register name prefix character, ARC
109@cindex ARC register name prefix character
110A register name can optionally be prefixed by a @samp{%} character. So
111register @code{%r0} is equivalent to @code{r0} in the assembly code.
112
113@item #
7c31ae13
NC
114@cindex line comment character, ARC
115@cindex ARC line comment character
886a2506
NC
116The presence of a @samp{#} character within a line (but not at the
117start of a line) indicates the start of a comment that extends to the
118end of the current line.
119
120@emph{Note:} if a line starts with a @samp{#} character then it can
121also be a logical line number directive (@pxref{Comments}) or a
122preprocessor control command (@pxref{Preprocessing}).
123
124@item @@
125@cindex symbol prefix character, ARC
126@cindex ARC symbol prefix character
127Prefixing an operand with an @samp{@@} specifies that the operand is a
128symbol and not a register. This is how the assembler disambiguates
129the use of an ARC register name as a symbol. So the instruction
130@example
131mov r0, @@r0
132@end example
133moves the address of symbol @code{r0} into register @code{r0}.
134
135@item `
7c31ae13
NC
136@cindex line separator, ARC
137@cindex statement separator, ARC
138@cindex ARC line separator
886a2506
NC
139The @samp{`} (backtick) character is used to separate statements on a
140single line.
141
142@cindex line
143@item -
144@cindex C preprocessor macro separator, ARC
145@cindex ARC C preprocessor macro separator
146Used as a separator to obtain a sequence of commands from a C
147preprocessor macro.
148
149@end table
2d73a4ca
NC
150
151@node ARC-Regs
152@subsection Register Names
153
154@cindex ARC register names
155@cindex register names, ARC
886a2506
NC
156The ARC assembler uses the following register names for its core
157registers:
158
159@table @code
160@item r0-r31
161@cindex core general registers, ARC
162@cindex ARC core general registers
163The core general registers. Registers @code{r26} through @code{r31}
164have special functions, and are usually referred to by those synonyms.
165
166@item gp
167@cindex global pointer, ARC
168@cindex ARC global pointer
169The global pointer and a synonym for @code{r26}.
170
171@item fp
172@cindex frame pointer, ARC
173@cindex ARC frame pointer
174The frame pointer and a synonym for @code{r27}.
175
176@item sp
177@cindex stack pointer, ARC
178@cindex ARC stack pointer
179The stack pointer and a synonym for @code{r28}.
180
181@item ilink1
182@cindex level 1 interrupt link register, ARC
183@cindex ARC level 1 interrupt link register
184For ARC 600 and ARC 700, the level 1 interrupt link register and a
185synonym for @code{r29}. Not supported for ARCv2.
186
187@item ilink
188@cindex interrupt link register, ARC
189@cindex ARC interrupt link register
190For ARCv2, the interrupt link register and a synonym for @code{r29}.
191Not supported for ARC 600 and ARC 700.
192
193@item ilink2
194@cindex level 2 interrupt link register, ARC
195@cindex ARC level 2 interrupt link register
196For ARC 600 and ARC 700, the level 2 interrupt link register and a
197synonym for @code{r30}. Not supported for ARC v2.
198
199@item blink
200@cindex link register, ARC
201@cindex ARC link register
202The link register and a synonym for @code{r31}.
203
204@item r32-r59
205@cindex extension core registers, ARC
206@cindex ARC extension core registers
207The extension core registers.
208
209@item lp_count
210@cindex loop counter, ARC
211@cindex ARC loop counter
212The loop count register.
213
214@item pcl
215@cindex word aligned program counter, ARC
216@cindex ARC word aligned program counter
217The word aligned program counter.
218
219@end table
2d73a4ca 220
886a2506
NC
221In addition the ARC processor has a large number of @emph{auxiliary
222registers}. The precise set depends on the extensions being
223supported, but the following baseline set are always defined:
2d73a4ca 224
886a2506
NC
225@table @code
226@item identity
227@cindex Processor Identification register, ARC
228@cindex ARC Processor Identification register
229Processor Identification register. Auxiliary register address 0x4.
230
231@item pc
232@cindex Program Counter, ARC
233@cindex ARC Program Counter
234Program Counter. Auxiliary register address 0x6.
235
236@item status32
237@cindex Status register, ARC
238@cindex ARC Status register
239Status register. Auxiliary register address 0x0a.
240
241@item bta
242@cindex Branch Target Address, ARC
243@cindex ARC Branch Target Address
244Branch Target Address. Auxiliary register address 0x412.
245
246@item ecr
247@cindex Exception Cause Register, ARC
248@cindex ARC Exception Cause Register
249Exception Cause Register. Auxiliary register address 0x403.
250
251@item int_vector_base
252@cindex Interrupt Vector Base address, ARC
253@cindex ARC Interrupt Vector Base address
254Interrupt Vector Base address. Auxiliary register address 0x25.
255
256@item status32_p0
257@cindex Stored STATUS32 register on entry to level P0 interrupts, ARC
258@cindex ARC Stored STATUS32 register on entry to level P0 interrupts
259Stored STATUS32 register on entry to level P0 interrupts. Auxiliary
260register address 0xb.
261
262@item aux_user_sp
263@cindex Saved User Stack Pointer, ARC
264@cindex ARC Saved User Stack Pointer
265Saved User Stack Pointer. Auxiliary register address 0xd.
266
267@item eret
268@cindex Exception Return Address, ARC
269@cindex ARC Exception Return Address
270Exception Return Address. Auxiliary register address 0x400.
271
272@item erbta
273@cindex BTA saved on exception entry, ARC
274@cindex ARC BTA saved on exception entry
275BTA saved on exception entry. Auxiliary register address 0x401.
276
277@item erstatus
278@cindex STATUS32 saved on exception, ARC
279@cindex ARC STATUS32 saved on exception
280STATUS32 saved on exception. Auxiliary register address 0x402.
281
282@item bcr_ver
283@cindex Build Configuration Registers Version, ARC
284@cindex ARC Build Configuration Registers Version
285Build Configuration Registers Version. Auxiliary register address 0x60.
286
287@item bta_link_build
288@cindex Build configuration for: BTA Registers, ARC
289@cindex ARC Build configuration for: BTA Registers
290Build configuration for: BTA Registers. Auxiliary register address 0x63.
291
292@item vecbase_ac_build
293@cindex Build configuration for: Interrupts, ARC
294@cindex ARC Build configuration for: Interrupts
295Build configuration for: Interrupts. Auxiliary register address 0x68.
296
297@item rf_build
298@cindex Build configuration for: Core Registers, ARC
299@cindex ARC Build configuration for: Core Registers
300Build configuration for: Core Registers. Auxiliary register address 0x6e.
301
302@item dccm_build
303@cindex DCCM RAM Configuration Register, ARC
304@cindex ARC DCCM RAM Configuration Register
305DCCM RAM Configuration Register. Auxiliary register address 0xc1.
2d73a4ca 306
886a2506 307@end table
2d73a4ca 308
886a2506
NC
309Additional auxiliary register names are defined according to the
310processor architecture version and extensions selected by the options.
2d73a4ca
NC
311
312@node ARC Directives
313@section ARC Machine Directives
314
315@cindex machine directives, ARC
316@cindex ARC machine directives
317The ARC version of @code{@value{AS}} supports the following additional
318machine directives:
319
320@table @code
321
886a2506 322@cindex @code{lcomm} directive
b99747ae 323@item .lcomm @var{symbol}, @var{length}[, @var{alignment}]
886a2506
NC
324Reserve @var{length} (an absolute expression) bytes for a local common
325denoted by @var{symbol}. The section and value of @var{symbol} are
326those of the new local common. The addresses are allocated in the bss
327section, so that at run-time the bytes start off zeroed. Since
328@var{symbol} is not declared global, it is normally not visible to
329@code{@value{LD}}. The optional third parameter, @var{alignment},
330specifies the desired alignment of the symbol in the bss section,
331specified as a byte boundary (for example, an alignment of 16 means
332that the least significant 4 bits of the address should be zero). The
333alignment must be an absolute expression, and it must be a power of
334two. If no alignment is specified, as will set the alignment to the
335largest power of two less than or equal to the size of the symbol, up
336to a maximum of 16.
337
f36e33da 338@cindex @code{lcommon} directive, ARC
b99747ae 339@item .lcommon @var{symbol}, @var{length}[, @var{alignment}]
886a2506
NC
340The same as @code{lcomm} directive.
341
f36e33da 342@cindex @code{cpu} directive, ARC
b99747ae 343@item .cpu @var{cpu}
886a2506
NC
344The @code{.cpu} directive must be followed by the desired core
345version. Permitted values for CPU are:
802a113d 346@table @code
886a2506
NC
347@item ARC600
348Assemble for the ARC600 instruction set.
2d73a4ca 349
886a2506
NC
350@item ARC700
351Assemble for the ARC700 instruction set.
802a113d 352
886a2506
NC
353@item EM
354Assemble for the ARC EM instruction set.
2d73a4ca 355
886a2506
NC
356@item HS
357Assemble for the ARC HS instruction set.
34bca508 358
802a113d
NC
359@end table
360
886a2506
NC
361Note: the @code{.cpu} directive overrides the command line option
362@code{-mcpu=@var{cpu}}; a warning is emitted when the version is not
363consistent between the two.
b99747ae 364
f36e33da
CZ
365@item .extAuxRegister @var{name}, @var{addr}, @var{mode}
366@cindex @code{extAuxRegister} directive, ARC
367Auxiliary registers can be defined in the assembler source code by
368using this directive. The first parameter, @var{name}, is the name of the
369new auxiliary register. The second parameter, @var{addr}, is
370address the of the auxiliary register. The third parameter,
371@var{mode}, specifies whether the register is readable and/or writable
372and is one of:
373@table @code
374@item r
375Read only;
376
377@item w
378Write only;
379
380@item r|w
381Read and write.
382
383@end table
384
385For example:
386@example
387 .extAuxRegister mulhi, 0x12, w
388@end example
389specifies a write only extension auxiliary register, @var{mulhi} at
390address 0x12.
391
392@item .extCondCode @var{suffix}, @var{val}
393@cindex @code{extCondCode} directive, ARC
394ARC supports extensible condition codes. This directive defines a new
395condition code, to be known by the suffix, @var{suffix} and will
396depend on the value, @var{val} in the condition code.
397
398For example:
399@example
400 .extCondCode is_busy,0x14
401 add.is_busy r1,r2,r3
402@end example
403will only execute the @code{add} instruction if the condition code
404value is 0x14.
405
406@item .extCoreRegister @var{name}, @var{regnum}, @var{mode}, @var{shortcut}
407@cindex @code{extCoreRegister} directive, ARC
408Specifies an extension core register named @var{name} as a synonym for
409the register numbered @var{regnum}. The register number must be
410between 32 and 59. The third argument, @var{mode}, indicates whether
411the register is readable and/or writable and is one of:
412@table @code
413@item r
414Read only;
415
416@item w
417Write only;
418
419@item r|w
420Read and write.
421
422@end table
423
424The final parameter, @var{shortcut} indicates whether the register has
425a short cut in the pipeline. The valid values are:
426@table @code
427@item can_shortcut
428The register has a short cut in the pipeline;
429
430@item cannot_shortcut
431The register does not have a short cut in the pipeline.
432@end table
433
434For example:
435@example
436 .extCoreRegister mlo, 57, r , can_shortcut
437@end example
438defines a read only extension core register, @code{mlo}, which is
439register 57, and can short cut the pipeline.
440
b99747ae 441@item .extInstruction @var{name}, @var{opcode}, @var{subopcode}, @var{suffixclass}, @var{syntaxclass}
f36e33da 442@cindex @code{extInstruction} directive, ARC
b99747ae
CZ
443ARC allows the user to specify extension instructions. These
444extension instructions are not macros; the assembler creates encodings
445for use of these instructions according to the specification by the
446user.
447
448The first argument, @var{name}, gives the name of the instruction.
449
450The second argument, @var{opcode}, is the opcode to be used (bits 31:27
451in the encoding).
452
453The third argument, @var{subopcode}, is the sub-opcode to be used, but
454the correct value also depends on the fifth argument,
455@var{syntaxclass}
456
457The fourth argument, @var{suffixclass}, determines the kinds of
458suffixes to be allowed. Valid values are:
459@table @code
460@item SUFFIX_NONE
461No suffixes are permitted;
462
463@item SUFFIX_COND
464Conditional suffixes are permitted;
465
466@item SUFFIX_FLAG
467Flag setting suffixes are permitted.
468
469@item SUFFIX_COND|SUFFIX_FLAG
470Both conditional and flag setting suffices are permitted.
471
472@end table
473
474The fifth and final argument, @var{syntaxclass}, determines the syntax
475class for the instruction. It can have the following values:
476@table @code
477@item SYNTAX_2OP
478Two Operand Instruction;
479
480@item SYNTAX_3OP
481Three Operand Instruction.
482@end table
483
484The syntax class may be followed by @samp{|} and one of the following
485modifiers.
486@table @code
487
488@item OP1_MUST_BE_IMM
489Modifies syntax class @code{SYNTAX_3OP}, specifying that the first
490operand of a three-operand instruction must be an immediate (i.e., the
491result is discarded). This is usually used to set the flags using
492specific instructions and not retain results.
493
494@item OP1_IMM_IMPLIED
495Modifies syntax class @code{SYNTAX_20P}, specifying that there is an
496implied immediate destination operand which does not appear in the
497syntax.
498
499For example, if the source code contains an instruction like:
500@example
501inst r1,r2
502@end example
503the first argument is an implied immediate (that is, the result is
504discarded). This is the same as though the source code were: inst
5050,r1,r2.
506
507@end table
508
509For example, defining a 64-bit multiplier with immediate operands:
510@example
511 .extInstruction mp64, 0x07, 0x2d, SUFFIX_COND|SUFFIX_FLAG,
512 SYNTAX_3OP|OP1_MUST_BE_IMM
513@end example
514which specifies an extension instruction named @code{mp64} with 3
515operands. It sets the flags and can be used with a condition code,
516for which the first operand is an immediate, i.e. equivalent to
517discarding the result of the operation.
518
519A two operands instruction variant would be:
520@example
521 .extInstruction mul64, 0x07, 0x2d, SUFFIX_COND,
522 SYNTAX_2OP|OP1_IMM_IMPLIED
523@end example
524which describes a two operand instruction with an implicit first
525immediate operand. The result of this operation would be discarded.
526
802a113d
NC
527@end table
528
886a2506
NC
529@node ARC Modifiers
530@section ARC Assembler Modifiers
802a113d 531
886a2506
NC
532The following additional assembler modifiers have been added for
533position-independent code. These modifiers are available only with
534the ARC 700 and above processors and generate relocation entries,
535which are interpreted by the linker as follows:
802a113d
NC
536
537@table @code
886a2506
NC
538@item @@pcl(@var{symbol})
539@cindex @@pcl(@var{symbol}), ARC modifier
540Relative distance of @var{symbol}'s from the current program counter
541location.
542
543@item @@gotpc(@var{symbol})
544@cindex @@gotpc(@var{symbol}), ARC modifier
545Relative distance of @var{symbol}'s Global Offset Table entry from the
546current program counter location.
547
548@item @@gotoff(@var{symbol})
549@cindex @@gotoff(@var{symbol}), ARC modifier
550Distance of @var{symbol} from the base of the Global Offset Table.
551
552@item @@plt(@var{symbol})
553@cindex @@plt(@var{symbol}), ARC modifier
554Distance of @var{symbol}'s Procedure Linkage Table entry from the
555current program counter. This is valid only with branch and link
556instructions and PC-relative calls.
557
558@item @@sda(@var{symbol})
559@cindex @@sda(@var{symbol}), ARC modifier
560Relative distance of @var{symbol} from the base of the Small Data
561Pointer.
802a113d 562
886a2506 563@end table
2d73a4ca 564
886a2506
NC
565@node ARC Symbols
566@section ARC Pre-defined Symbols
2d73a4ca 567
886a2506
NC
568The following assembler symbols will prove useful when developing
569position-independent code. These symbols are available only with the
570ARC 700 and above processors.
2d73a4ca 571
886a2506
NC
572@table @code
573@item __GLOBAL_OFFSET_TABLE__
574@cindex __GLOBAL_OFFSET_TABLE__, ARC pre-defined symbol
575Symbol referring to the base of the Global Offset Table.
2d73a4ca 576
886a2506
NC
577@item __DYNAMIC__
578@cindex __DYNAMIC__, ARC pre-defined symbol
579An alias for the Global Offset Table
580@code{Base__GLOBAL_OFFSET_TABLE__}. It can be used only with
581@code{@@gotpc} modifiers.
2d73a4ca
NC
582
583@end table
584
2d73a4ca
NC
585@node ARC Opcodes
586@section Opcodes
587
588@cindex ARC opcodes
589@cindex opcodes for ARC
590
591For information on the ARC instruction set, see @cite{ARC Programmers
886a2506 592Reference Manual}, available where you download the processor IP library.
This page took 0.62263 seconds and 4 git commands to generate.