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