@c Copyright 2002, 2004 Free Software Foundation, Inc.@c This is part of the GAS manual.@c For copying conditions, see the file as.texinfo.@c CRIS description contributed by Axis Communications.@ifset GENERIC@page@node CRIS-Dependent@chapter CRIS Dependent Features@end ifset@ifclear GENERIC@node Machine Dependencies@chapter CRIS Dependent Features@end ifclear@cindex CRIS support@menu* CRIS-Opts:: Command-line Options* CRIS-Expand:: Instruction expansion* CRIS-Symbols:: Symbols* CRIS-Syntax:: Syntax@end menu@node CRIS-Opts@section Command-line Options@cindex options, CRIS@cindex CRIS optionsThe CRIS version of @code{@value{AS}} has thesemachine-dependent command-line options.@cindex @option{--emulation=criself} command line option, CRIS@cindex @option{--emulation=crisaout} command line option, CRIS@cindex CRIS @option{--emulation=criself} command line option@cindex CRIS @option{--emulation=crisaout} command line optionThe format of the generated object files can be either ELF ora.out, specified by the command-line options@option{--emulation=crisaout} and @option{--emulation=criself}.The default is ELF (criself), unless @code{@value{AS}} has beenconfigured specifically for a.out by using the configurationname @code{cris-axis-aout}.@cindex @option{--underscore} command line option, CRIS@cindex @option{--no-underscore} command line option, CRIS@cindex CRIS @option{--underscore} command line option@cindex CRIS @option{--no-underscore} command line optionThere are two different link-incompatible ELF object filevariants for CRIS, for use in environments where symbols areexpected to be prefixed by a leading @samp{_} character and forenvironments without such a symbol prefix. The variant used forGNU/Linux port has no symbol prefix. Which variant to produceis specified by either of the options @option{--underscore} and@option{--no-underscore}. The default is @option{--underscore}.Since symbols in CRIS a.out objects are expected to have a@samp{_} prefix, specifying @option{--no-underscore} whengenerating a.out objects is an error. Besides the object formatdifference, the effect of this option is to parse register namesdifferently (@pxref{crisnous}). The @option{--no-underscore}option makes a @samp{$} register prefix mandatory.@cindex @option{--pic} command line option, CRIS@cindex CRIS @option{--pic} command line option@cindex Position-independent code, CRIS@cindex CRIS position-independent codeThe option @option{--pic} must be passed to @code{@value{AS}} inorder to recognize the symbol syntax used for ELF (SVR4 PIC)position-independent-code (@pxref{crispic}). This will alsoaffect expansion of instructions. The expansion with@option{--pic} will use PC-relative rather than (slightlyfaster) absolute addresses in those expansions.@cindex @option{--march=@var{architecture}} command line option, CRIS@cindex CRIS @option{--march=@var{architecture}} command line option@cindex Architecture variant option, CRIS@cindex CRIS architecture variant optionThe option @option{--march=@var{architecture}}@anchor{march-option}specifies the recognized instruction setand recognized register names. It also controls thearchitecture type of the object file. Valid values for@var{architecture} are:@table @code@item v0_v10All instructions and register names for any architecture variantin the set v0@dots{}v10 are recognized. This is thedefault if the target is configured as cris-*.@item v10Only instructions and register names for CRIS v10 (as found inETRAX 100 LX) are recognized. This is the default if the targetis configured as crisv10-*.@item v32Only instructions and register names for CRIS v32 (code nameGuinness) are recognized. This is the default if the target isconfigured as crisv32-*. This value implies@option{--no-mul-bug-abort}. (A subsequent@option{--mul-bug-abort} will turn it back on.)@item common_v10_v32Only instructions with register names and addressing modes withopcodes common to the v10 and v32 are recognized.@end table@cindex @option{-N} command line option, CRIS@cindex CRIS @option{-N} command line optionWhen @option{-N} is specified, @code{@value{AS}} will emit awarning when a 16-bit branch instruction is expanded into a32-bit multiple-instruction construct (@pxref{CRIS-Expand}).@cindex @option{--no-mul-bug-abort} command line option, CRIS@cindex @option{--mul-bug-abort} command line option, CRIS@cindex CRIS @option{--no-mul-bug-abort} command line option@cindex CRIS @option{--mul-bug-abort} command line optionSome versions of the CRIS v10, for example in the Etrax 100 LX,contain a bug that causes destabilizing memory accesses when amultiply instruction is executed with certain values in thefirst operand just before a cache-miss. When the@option{--mul-bug-abort} command line option is active (thedefault value), @code{@value{AS}} will refuse to assemble a filecontaining a multiply instruction at a dangerous offset, onethat could be the last on a cache-line, or is in a section withinsufficient alignment. This placement checking does not catchany case where the multiply instruction is dangerously placedbecause it is located in a delay-slot. The@option{--mul-bug-abort} command line option turns off thechecking.@node CRIS-Expand@section Instruction expansion@cindex instruction expansion, CRIS@cindex CRIS instruction expansion@code{@value{AS}} will silently choose an instruction that fitsthe operand size for @samp{[register+constant]} operands. Forexample, the offset @code{127} in @code{move.d [r3+127],r4} fitsin an instruction using a signed-byte offset. Similarly,@code{move.d [r2+32767],r1} will generate an instruction using a16-bit offset. For symbolic expressions and constants that donot fit in 16 bits including the sign bit, a 32-bit offset isgenerated.For branches, @code{@value{AS}} will expand from a 16-bit branchinstruction into a sequence of instructions that can reach afull 32-bit address. Since this does not correspond to a singleinstruction, such expansions can optionally be warned about.@xref{CRIS-Opts}.If the operand is found to fit the range, a @code{lapc} mnemonicwill translate to a @code{lapcq} instruction. Use @code{lapc.d}to force the 32-bit @code{lapc} instruction.Similarly, the @code{addo} mnemonic will translate to theshortest fitting instruction of @code{addoq}, @code{addo.w} and@code{addo.d}, when used with a operand that is a constant knownat assembly time.@node CRIS-Symbols@section Symbols@cindex Symbols, built-in, CRIS@cindex Symbols, CRIS, built-in@cindex CRIS built-in symbols@cindex Built-in symbols, CRISSome symbols are defined by the assembler. They're intended tobe used in conditional assembly, for example:@smallexample.if ..asm.arch.cris.v32@var{code for CRIS v32}.elseif ..asm.arch.cris.common_v10_v32@var{code common to CRIS v32 and CRIS v10}.elseif ..asm.arch.cris.v10 | ..asm.arch.cris.any_v0_v10@var{code for v10}.else.error "Code needs to be added here.".endif@end smallexampleThese symbols are defined in the assembler, reflectingcommand-line options, either when specified or the default.They are always defined, to 0 or 1.@table @code@item ..asm.arch.cris.any_v0_v10This symbol is non-zero when @option{--march=v0_v10} is specifiedor the default.@item ..asm.arch.cris.common_v10_v32Set according to the option @option{--march=common_v10_v32}.@item ..asm.arch.cris.v10Reflects the option @option{--march=v10}.@item ..asm.arch.cris.v32Corresponds to @option{--march=v10}.@end tableSpeaking of symbols, when a symbol is used in code, it can havea suffix modifying its value for use in position-independentcode. @xref{CRIS-Pic}.@node CRIS-Syntax@section SyntaxThere are different aspects of the CRIS assembly syntax.@menu* CRIS-Chars:: Special Characters* CRIS-Pic:: Position-Independent Code Symbols* CRIS-Regs:: Register Names* CRIS-Pseudos:: Assembler Directives@end menu@node CRIS-Chars@subsection Special Characters@cindex line comment characters, CRIS@cindex CRIS line comment charactersThe character @samp{#} is a line comment character. It starts acomment if and only if it is placed at the beginning of a line.A @samp{;} character starts a comment anywhere on the line,causing all characters up to the end of the line to be ignored.A @samp{@@} character is handled as a line separator equivalentto a logical new-line character (except in a comment), soseparate instructions can be specified on a single line.@node CRIS-Pic@subsection Symbols in position-independent code@cindex Symbols in position-independent code, CRIS@cindex CRIS symbols in position-independent code@cindex Position-independent code, symbols in, CRISWhen generating @anchor{crispic}position-independent code (SVR4PIC) for use in cris-axis-linux-gnu or crisv32-axis-linux-gnushared libraries, symbolsuffixes are used to specify what kind of run-time symbol lookupwill be used, expressed in the object as different@emph{relocation types}. Usually, all absolute symbol valuesmust be located in a table, the @emph{global offset table},leaving the code position-independent; independent of values ofglobal symbols and independent of the address of the code. Thesuffix modifies the value of the symbol, into for example anindex into the global offset table where the real symbol valueis entered, or a PC-relative value, or a value relative to thestart of the global offset table. All symbol suffixes startwith the character @samp{:} (omitted in the list below). Everysymbol use in code or a read-only section must therefore have aPIC suffix to enable a useful shared library to be created.Usually, these constructs must not be used with an additiveconstant offset as is usually allowed, i.e.@: no 4 as in@code{symbol + 4} is allowed. This restriction is checked atlink-time, not at assembly-time.@table @code@item GOTAttaching this suffix to a symbol in an instruction causes thesymbol to be entered into the global offset table. The value isa 32-bit index for that symbol into the global offset table.The name of the corresponding relocation is@samp{R_CRIS_32_GOT}. Example: @code{move.d[$r0+extsym:GOT],$r9}@item GOT16Same as for @samp{GOT}, but the value is a 16-bit index into theglobal offset table. The corresponding relocation is@samp{R_CRIS_16_GOT}. Example: @code{move.d[$r0+asymbol:GOT16],$r10}@item PLTThis suffix is used for function symbols. It causes a@emph{procedure linkage table}, an array of code stubs, to becreated at the time the shared object is created or linkedagainst, together with a global offset table entry. The valueis a pc-relative offset to the corresponding stub code in theprocedure linkage table. This arrangement causes the run-timesymbol resolver to be called to look up and set the value of thesymbol the first time the function is called (at latest;depending environment variables). It is only safe to leave thesymbol unresolved this way if all references are function calls.The name of the relocation is @samp{R_CRIS_32_PLT_PCREL}.Example: @code{add.d fnname:PLT,$pc}@item PLTGLike PLT, but the value is relative to the beginning of theglobal offset table. The relocation is@samp{R_CRIS_32_PLT_GOTREL}. Example: @code{move.dfnname:PLTG,$r3}@item GOTPLTSimilar to @samp{PLT}, but the value of the symbol is a 32-bitindex into the global offset table. This is somewhat of a mixbetween the effect of the @samp{GOT} and the @samp{PLT} suffix;the difference to @samp{GOT} is that there will be a procedurelinkage table entry created, and that the symbol is assumed tobe a function entry and will be resolved by the run-timeresolver as with @samp{PLT}. The relocation is@samp{R_CRIS_32_GOTPLT}. Example: @code{jsr[$r0+fnname:GOTPLT]}@item GOTPLT16A variant of @samp{GOTPLT} giving a 16-bit value. Itsrelocation name is @samp{R_CRIS_16_GOTPLT}. Example: @code{jsr[$r0+fnname:GOTPLT16]}@item GOTOFFThis suffix must only be attached to a local symbol, but may beused in an expression adding an offset. The value is theaddress of the symbol relative to the start of the global offsettable. The relocation name is @samp{R_CRIS_32_GOTREL}.Example: @code{move.d [$r0+localsym:GOTOFF],r3}@end table@node CRIS-Regs@subsection Register names@cindex register names, CRIS@cindex CRIS register namesA @samp{$} character may always prefix a general or specialregister name in an instruction operand but is mandatory whenthe option @option{--no-underscore} is specified or when the@code{.syntax register_prefix} directive is in effect(@pxref{crisnous}). Register names are case-insensitive.@node CRIS-Pseudos@subsection Assembler Directives@cindex assembler directives, CRIS@cindex pseudo-ops, CRIS@cindex CRIS assembler directives@cindex CRIS pseudo-opsThere are a few CRIS-specific pseudo-directives in addition tothe generic ones. @xref{Pseudo Ops}. Constants emitted bypseudo-directives are in little-endian order for CRIS. There isno support for floating-point-specific directives for CRIS.@table @code@item .dword EXPRESSIONS@cindex assembler directive .dword, CRIS@cindex pseudo-op .dword, CRIS@cindex CRIS assembler directive .dword@cindex CRIS pseudo-op .dwordThe @code{.dword} directive is a synonym for @code{.int},expecting zero or more EXPRESSIONS, separated by commas. Foreach expression, a 32-bit little-endian constant is emitted.@item .syntax ARGUMENT@cindex assembler directive .syntax, CRIS@cindex pseudo-op .syntax, CRIS@cindex CRIS assembler directive .syntax@cindex CRIS pseudo-op .syntaxThe @code{.syntax} directive takes as @var{ARGUMENT} one of thefollowing case-sensitive choices.@table @code@item no_register_prefixThe @code{.syntax no_register_prefix} @anchor{crisnous}directivemakes a @samp{$} character prefix on all registers optional. Itoverrides a previous setting, including the corresponding effectof the option @option{--no-underscore}. If this directive isused when ordinary symbols do not have a @samp{_} characterprefix, care must be taken to avoid ambiguities whether anoperand is a register or a symbol; using symbols with names thesame as general or special registers then invoke undefinedbehavior.@item register_prefixThis directive makes a @samp{$} character prefix on allregisters mandatory. It overrides a previous setting, includingthe corresponding effect of the option @option{--underscore}.@item leading_underscoreThis is an assertion directive, emitting an error if the@option{--no-underscore} option is in effect.@item no_leading_underscoreThis is the opposite of the @code{.syntax leading_underscore}directive and emits an error if the option @option{--underscore}is in effect.@end table@item .arch ARGUMENT@cindex assembler directive .arch, CRIS@cindex pseudo-op .arch, CRIS@cindex CRIS assembler directive .arch@cindex CRIS pseudo-op .archThis is an assertion directive, giving an error if the specified@var{ARGUMENT} is not the same as the specified or default valuefor the @option{--march=@var{architecture}} option(@pxref{march-option}).@c If you compare with md_pseudo_table, you see that we don't@c document ".file" and ".loc" here. This is because we're just@c wrapping the corresponding ELF function and emitting an error for@c a.out.@end table