]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/doc/c-cris.texi
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / doc / c-cris.texi
CommitLineData
250d07de 1@c Copyright (C) 2002-2021 Free Software Foundation, Inc.
328eb32e
HPN
2@c This is part of the GAS manual.
3@c For copying conditions, see the file as.texinfo.
4@c CRIS description contributed by Axis Communications.
5@ifset GENERIC
6@page
7@node CRIS-Dependent
8@chapter CRIS Dependent Features
9@end ifset
10@ifclear GENERIC
11@node Machine Dependencies
12@chapter CRIS Dependent Features
13@end ifclear
14
15@cindex CRIS support
16@menu
17* CRIS-Opts:: Command-line Options
18* CRIS-Expand:: Instruction expansion
ae57792d 19* CRIS-Symbols:: Symbols
328eb32e
HPN
20* CRIS-Syntax:: Syntax
21@end menu
22
23@node CRIS-Opts
24@section Command-line Options
25
26@cindex options, CRIS
27@cindex CRIS options
28The CRIS version of @code{@value{AS}} has these
29machine-dependent command-line options.
30
a05a5b64
TP
31@cindex @option{--emulation=criself} command-line option, CRIS
32@cindex @option{--emulation=crisaout} command-line option, CRIS
33@cindex CRIS @option{--emulation=criself} command-line option
34@cindex CRIS @option{--emulation=crisaout} command-line option
328eb32e
HPN
35
36The format of the generated object files can be either ELF or
37a.out, specified by the command-line options
38@option{--emulation=crisaout} and @option{--emulation=criself}.
39The default is ELF (criself), unless @code{@value{AS}} has been
40configured specifically for a.out by using the configuration
41name @code{cris-axis-aout}.
42
a05a5b64
TP
43@cindex @option{--underscore} command-line option, CRIS
44@cindex @option{--no-underscore} command-line option, CRIS
45@cindex CRIS @option{--underscore} command-line option
46@cindex CRIS @option{--no-underscore} command-line option
328eb32e
HPN
47There are two different link-incompatible ELF object file
48variants for CRIS, for use in environments where symbols are
49expected to be prefixed by a leading @samp{_} character and for
50environments without such a symbol prefix. The variant used for
51GNU/Linux port has no symbol prefix. Which variant to produce
52is specified by either of the options @option{--underscore} and
53@option{--no-underscore}. The default is @option{--underscore}.
54Since symbols in CRIS a.out objects are expected to have a
55@samp{_} prefix, specifying @option{--no-underscore} when
56generating a.out objects is an error. Besides the object format
57difference, the effect of this option is to parse register names
58differently (@pxref{crisnous}). The @option{--no-underscore}
59option makes a @samp{$} register prefix mandatory.
60
a05a5b64
TP
61@cindex @option{--pic} command-line option, CRIS
62@cindex CRIS @option{--pic} command-line option
328eb32e
HPN
63@cindex Position-independent code, CRIS
64@cindex CRIS position-independent code
65The option @option{--pic} must be passed to @code{@value{AS}} in
66order to recognize the symbol syntax used for ELF (SVR4 PIC)
67position-independent-code (@pxref{crispic}). This will also
68affect expansion of instructions. The expansion with
69@option{--pic} will use PC-relative rather than (slightly
0d7e0060
HPN
70faster) absolute addresses in those expansions. This option is only
71valid when generating ELF format object files.
328eb32e 72
a05a5b64
TP
73@cindex @option{--march=@var{architecture}} command-line option, CRIS
74@cindex CRIS @option{--march=@var{architecture}} command-line option
ae57792d
HPN
75@cindex Architecture variant option, CRIS
76@cindex CRIS architecture variant option
77The option @option{--march=@var{architecture}}
78@anchor{march-option}specifies the recognized instruction set
79and recognized register names. It also controls the
80architecture type of the object file. Valid values for
81@var{architecture} are:
82@table @code
83
84@item v0_v10
85All instructions and register names for any architecture variant
86in the set v0@dots{}v10 are recognized. This is the
87default if the target is configured as cris-*.
88
89@item v10
90Only instructions and register names for CRIS v10 (as found in
91ETRAX 100 LX) are recognized. This is the default if the target
92is configured as crisv10-*.
93
94@item v32
95Only instructions and register names for CRIS v32 (code name
96Guinness) are recognized. This is the default if the target is
97configured as crisv32-*. This value implies
98@option{--no-mul-bug-abort}. (A subsequent
99@option{--mul-bug-abort} will turn it back on.)
100
101@item common_v10_v32
102Only instructions with register names and addressing modes with
103opcodes common to the v10 and v32 are recognized.
104@end table
105
a05a5b64
TP
106@cindex @option{-N} command-line option, CRIS
107@cindex CRIS @option{-N} command-line option
328eb32e
HPN
108When @option{-N} is specified, @code{@value{AS}} will emit a
109warning when a 16-bit branch instruction is expanded into a
11032-bit multiple-instruction construct (@pxref{CRIS-Expand}).
111
a05a5b64
TP
112@cindex @option{--no-mul-bug-abort} command-line option, CRIS
113@cindex @option{--mul-bug-abort} command-line option, CRIS
114@cindex CRIS @option{--no-mul-bug-abort} command-line option
115@cindex CRIS @option{--mul-bug-abort} command-line option
1048a9ba
HPN
116
117Some versions of the CRIS v10, for example in the Etrax 100 LX,
118contain a bug that causes destabilizing memory accesses when a
119multiply instruction is executed with certain values in the
120first operand just before a cache-miss. When the
a05a5b64 121@option{--mul-bug-abort} command-line option is active (the
1048a9ba
HPN
122default value), @code{@value{AS}} will refuse to assemble a file
123containing a multiply instruction at a dangerous offset, one
124that could be the last on a cache-line, or is in a section with
125insufficient alignment. This placement checking does not catch
126any case where the multiply instruction is dangerously placed
127because it is located in a delay-slot. The
a05a5b64 128@option{--mul-bug-abort} command-line option turns off the
1048a9ba
HPN
129checking.
130
328eb32e
HPN
131@node CRIS-Expand
132@section Instruction expansion
133
134@cindex instruction expansion, CRIS
135@cindex CRIS instruction expansion
136@code{@value{AS}} will silently choose an instruction that fits
137the operand size for @samp{[register+constant]} operands. For
138example, the offset @code{127} in @code{move.d [r3+127],r4} fits
139in an instruction using a signed-byte offset. Similarly,
140@code{move.d [r2+32767],r1} will generate an instruction using a
14116-bit offset. For symbolic expressions and constants that do
142not fit in 16 bits including the sign bit, a 32-bit offset is
143generated.
144
145For branches, @code{@value{AS}} will expand from a 16-bit branch
146instruction into a sequence of instructions that can reach a
147full 32-bit address. Since this does not correspond to a single
148instruction, such expansions can optionally be warned about.
149@xref{CRIS-Opts}.
150
ae57792d
HPN
151If the operand is found to fit the range, a @code{lapc} mnemonic
152will translate to a @code{lapcq} instruction. Use @code{lapc.d}
153to force the 32-bit @code{lapc} instruction.
154
155Similarly, the @code{addo} mnemonic will translate to the
156shortest fitting instruction of @code{addoq}, @code{addo.w} and
157@code{addo.d}, when used with a operand that is a constant known
158at assembly time.
159
160@node CRIS-Symbols
161@section Symbols
162@cindex Symbols, built-in, CRIS
163@cindex Symbols, CRIS, built-in
164@cindex CRIS built-in symbols
165@cindex Built-in symbols, CRIS
166
167Some symbols are defined by the assembler. They're intended to
168be used in conditional assembly, for example:
169@smallexample
170 .if ..asm.arch.cris.v32
171 @var{code for CRIS v32}
172 .elseif ..asm.arch.cris.common_v10_v32
173 @var{code common to CRIS v32 and CRIS v10}
174 .elseif ..asm.arch.cris.v10 | ..asm.arch.cris.any_v0_v10
175 @var{code for v10}
176 .else
177 .error "Code needs to be added here."
178 .endif
179@end smallexample
180
181These symbols are defined in the assembler, reflecting
182command-line options, either when specified or the default.
183They are always defined, to 0 or 1.
184@table @code
185
186@item ..asm.arch.cris.any_v0_v10
187This symbol is non-zero when @option{--march=v0_v10} is specified
188or the default.
189
190@item ..asm.arch.cris.common_v10_v32
191Set according to the option @option{--march=common_v10_v32}.
192
193@item ..asm.arch.cris.v10
194Reflects the option @option{--march=v10}.
195
196@item ..asm.arch.cris.v32
197Corresponds to @option{--march=v10}.
198@end table
199
200Speaking of symbols, when a symbol is used in code, it can have
201a suffix modifying its value for use in position-independent
202code. @xref{CRIS-Pic}.
203
328eb32e
HPN
204@node CRIS-Syntax
205@section Syntax
206
207There are different aspects of the CRIS assembly syntax.
208
209@menu
210* CRIS-Chars:: Special Characters
211* CRIS-Pic:: Position-Independent Code Symbols
212* CRIS-Regs:: Register Names
213* CRIS-Pseudos:: Assembler Directives
214@end menu
215
216@node CRIS-Chars
217@subsection Special Characters
218@cindex line comment characters, CRIS
219@cindex CRIS line comment characters
220
221The character @samp{#} is a line comment character. It starts a
222comment if and only if it is placed at the beginning of a line.
223
224A @samp{;} character starts a comment anywhere on the line,
225causing all characters up to the end of the line to be ignored.
226
227A @samp{@@} character is handled as a line separator equivalent
228to a logical new-line character (except in a comment), so
229separate instructions can be specified on a single line.
230
231@node CRIS-Pic
232@subsection Symbols in position-independent code
233@cindex Symbols in position-independent code, CRIS
234@cindex CRIS symbols in position-independent code
235@cindex Position-independent code, symbols in, CRIS
236
237When generating @anchor{crispic}position-independent code (SVR4
ae57792d
HPN
238PIC) for use in cris-axis-linux-gnu or crisv32-axis-linux-gnu
239shared libraries, symbol
328eb32e
HPN
240suffixes are used to specify what kind of run-time symbol lookup
241will be used, expressed in the object as different
242@emph{relocation types}. Usually, all absolute symbol values
243must be located in a table, the @emph{global offset table},
244leaving the code position-independent; independent of values of
245global symbols and independent of the address of the code. The
246suffix modifies the value of the symbol, into for example an
247index into the global offset table where the real symbol value
248is entered, or a PC-relative value, or a value relative to the
249start of the global offset table. All symbol suffixes start
250with the character @samp{:} (omitted in the list below). Every
251symbol use in code or a read-only section must therefore have a
252PIC suffix to enable a useful shared library to be created.
253Usually, these constructs must not be used with an additive
254constant offset as is usually allowed, i.e.@: no 4 as in
255@code{symbol + 4} is allowed. This restriction is checked at
256link-time, not at assembly-time.
257
258@table @code
259@item GOT
260
261Attaching this suffix to a symbol in an instruction causes the
262symbol to be entered into the global offset table. The value is
263a 32-bit index for that symbol into the global offset table.
264The name of the corresponding relocation is
265@samp{R_CRIS_32_GOT}. Example: @code{move.d
266[$r0+extsym:GOT],$r9}
267
268@item GOT16
269
270Same as for @samp{GOT}, but the value is a 16-bit index into the
271global offset table. The corresponding relocation is
272@samp{R_CRIS_16_GOT}. Example: @code{move.d
273[$r0+asymbol:GOT16],$r10}
274
275@item PLT
276
277This suffix is used for function symbols. It causes a
278@emph{procedure linkage table}, an array of code stubs, to be
279created at the time the shared object is created or linked
280against, together with a global offset table entry. The value
281is a pc-relative offset to the corresponding stub code in the
282procedure linkage table. This arrangement causes the run-time
283symbol resolver to be called to look up and set the value of the
284symbol the first time the function is called (at latest;
285depending environment variables). It is only safe to leave the
286symbol unresolved this way if all references are function calls.
287The name of the relocation is @samp{R_CRIS_32_PLT_PCREL}.
288Example: @code{add.d fnname:PLT,$pc}
289
290@item PLTG
291
292Like PLT, but the value is relative to the beginning of the
293global offset table. The relocation is
294@samp{R_CRIS_32_PLT_GOTREL}. Example: @code{move.d
295fnname:PLTG,$r3}
296
297@item GOTPLT
298
299Similar to @samp{PLT}, but the value of the symbol is a 32-bit
300index into the global offset table. This is somewhat of a mix
301between the effect of the @samp{GOT} and the @samp{PLT} suffix;
302the difference to @samp{GOT} is that there will be a procedure
303linkage table entry created, and that the symbol is assumed to
304be a function entry and will be resolved by the run-time
305resolver as with @samp{PLT}. The relocation is
306@samp{R_CRIS_32_GOTPLT}. Example: @code{jsr
307[$r0+fnname:GOTPLT]}
308
309@item GOTPLT16
310
311A variant of @samp{GOTPLT} giving a 16-bit value. Its
312relocation name is @samp{R_CRIS_16_GOTPLT}. Example: @code{jsr
313[$r0+fnname:GOTPLT16]}
314
315@item GOTOFF
316
317This suffix must only be attached to a local symbol, but may be
318used in an expression adding an offset. The value is the
319address of the symbol relative to the start of the global offset
320table. The relocation name is @samp{R_CRIS_32_GOTREL}.
321Example: @code{move.d [$r0+localsym:GOTOFF],r3}
322@end table
323
324@node CRIS-Regs
325@subsection Register names
326@cindex register names, CRIS
327@cindex CRIS register names
328
329A @samp{$} character may always prefix a general or special
330register name in an instruction operand but is mandatory when
331the option @option{--no-underscore} is specified or when the
332@code{.syntax register_prefix} directive is in effect
333(@pxref{crisnous}). Register names are case-insensitive.
334
335@node CRIS-Pseudos
336@subsection Assembler Directives
337@cindex assembler directives, CRIS
338@cindex pseudo-ops, CRIS
339@cindex CRIS assembler directives
340@cindex CRIS pseudo-ops
341
342There are a few CRIS-specific pseudo-directives in addition to
343the generic ones. @xref{Pseudo Ops}. Constants emitted by
344pseudo-directives are in little-endian order for CRIS. There is
345no support for floating-point-specific directives for CRIS.
346
347@table @code
348@item .dword EXPRESSIONS
349@cindex assembler directive .dword, CRIS
350@cindex pseudo-op .dword, CRIS
351@cindex CRIS assembler directive .dword
352@cindex CRIS pseudo-op .dword
353
354The @code{.dword} directive is a synonym for @code{.int},
355expecting zero or more EXPRESSIONS, separated by commas. For
356each expression, a 32-bit little-endian constant is emitted.
357
358@item .syntax ARGUMENT
359@cindex assembler directive .syntax, CRIS
360@cindex pseudo-op .syntax, CRIS
361@cindex CRIS assembler directive .syntax
362@cindex CRIS pseudo-op .syntax
ae57792d 363The @code{.syntax} directive takes as @var{ARGUMENT} one of the
328eb32e
HPN
364following case-sensitive choices.
365
366@table @code
367@item no_register_prefix
368
369The @code{.syntax no_register_prefix} @anchor{crisnous}directive
370makes a @samp{$} character prefix on all registers optional. It
371overrides a previous setting, including the corresponding effect
372of the option @option{--no-underscore}. If this directive is
373used when ordinary symbols do not have a @samp{_} character
374prefix, care must be taken to avoid ambiguities whether an
375operand is a register or a symbol; using symbols with names the
376same as general or special registers then invoke undefined
377behavior.
378
379@item register_prefix
380
381This directive makes a @samp{$} character prefix on all
382registers mandatory. It overrides a previous setting, including
383the corresponding effect of the option @option{--underscore}.
384
385@item leading_underscore
386
387This is an assertion directive, emitting an error if the
388@option{--no-underscore} option is in effect.
389
390@item no_leading_underscore
391
392This is the opposite of the @code{.syntax leading_underscore}
393directive and emits an error if the option @option{--underscore}
394is in effect.
395@end table
396
ae57792d
HPN
397@item .arch ARGUMENT
398@cindex assembler directive .arch, CRIS
399@cindex pseudo-op .arch, CRIS
400@cindex CRIS assembler directive .arch
401@cindex CRIS pseudo-op .arch
402This is an assertion directive, giving an error if the specified
403@var{ARGUMENT} is not the same as the specified or default value
404for the @option{--march=@var{architecture}} option
405(@pxref{march-option}).
406
328eb32e
HPN
407@c If you compare with md_pseudo_table, you see that we don't
408@c document ".file" and ".loc" here. This is because we're just
409@c wrapping the corresponding ELF function and emitting an error for
410@c a.out.
411@end table