@c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2003, 2004, 2005@c Free Software Foundation, Inc.@c This is part of the GAS manual.@c For copying conditions, see the file as.texinfo.@page@node SH-Dependent@chapter Renesas / SuperH SH Dependent Features@cindex SH support@menu* SH Options:: Options* SH Syntax:: Syntax* SH Floating Point:: Floating Point* SH Directives:: SH Machine Directives* SH Opcodes:: Opcodes@end menu@node SH Options@section Options@cindex SH options@cindex options, SH@code{@value{AS}} has following command-line options for the Renesas(formerly Hitachi) / SuperH SH family.@table @code@kindex --little@kindex --big@kindex --relax@kindex --small@kindex --dsp@kindex --renesas@kindex --allow-reg-prefix@item --littleGenerate little endian code.@item --bigGenerate big endian code.@item --relaxAlter jump instructions for long displacements.@item --smallAlign sections to 4 byte boundaries, not 16.@item --dspEnable sh-dsp insns, and disable sh3e / sh4 insns.@item --renesasDisable optimization with section symbol for compatibility withRenesas assembler.@item --allow-reg-prefixAllow '$' as a register name prefix.@item --isa=sh4 | sh4aSpecify the sh4 or sh4a instruction set.@item --isa=dspEnable sh-dsp insns, and disable sh3e / sh4 insns.@item --isa=fpEnable sh2e, sh3e, sh4, and sh4a insn sets.@item --isa=allEnable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.@item -h-tick-hexSupport H'00 style hex constants in addition to 0x00 style.@end table@node SH Syntax@section Syntax@menu* SH-Chars:: Special Characters* SH-Regs:: Register Names* SH-Addressing:: Addressing Modes@end menu@node SH-Chars@subsection Special Characters@cindex line comment character, SH@cindex SH line comment character@samp{!} is the line comment character.@cindex line separator, SH@cindex statement separator, SH@cindex SH line separatorYou can use @samp{;} instead of a newline to separate statements.@cindex symbol names, @samp{$} in@cindex @code{$} in symbol namesSince @samp{$} has no special meaning, you may use it in symbol names.@node SH-Regs@subsection Register Names@cindex SH registers@cindex registers, SHYou can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},@samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},@samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},and @samp{r15} to refer to the SH registers.The SH also has these control registers:@table @code@item prprocedure register (holds return address)@item pcprogram counter@item mach@itemx maclhigh and low multiply accumulator registers@item srstatus register@item gbrglobal base register@item vbrvector base register (for interrupt vectors)@end table@node SH-Addressing@subsection Addressing Modes@cindex addressing modes, SH@cindex SH addressing modes@code{@value{AS}} understands the following addressing modes for the SH.@code{R@var{n}} in the following refers to any of the numberedregisters, but @emph{not} the control registers.@table @code@item R@var{n}Register direct@item @@R@var{n}Register indirect@item @@-R@var{n}Register indirect with pre-decrement@item @@R@var{n}+Register indirect with post-increment@item @@(@var{disp}, R@var{n})Register indirect with displacement@item @@(R0, R@var{n})Register indexed@item @@(@var{disp}, GBR)@code{GBR} offset@item @@(R0, GBR)GBR indexed@item @var{addr}@itemx @@(@var{disp}, PC)PC relative address (for branch or for addressing memory). The@code{@value{AS}} implementation allows you to use the simpler form@var{addr} anywhere a PC relative address is called for; the alternateform is supported for compatibility with other assemblers.@item #@var{imm}Immediate data@end table@node SH Floating Point@section Floating Point@cindex floating point, SH (@sc{ieee})@cindex SH floating point (@sc{ieee})SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). OtherSH groups can use @code{.float} directive to generate @sc{ieee}floating-point numbers.SH2E and SH3E support single-precision floating point calculations aswell as entirely PCAPI compatible emulation of double-precisionfloating point calculations. SH2E and SH3E instructions are a subset ofthe floating point calculations conforming to the IEEE754 standard.In addition to single-precision and double-precision floating-pointoperation capability, the on-chip FPU of SH4 has a 128-bit graphicengine that enables 32-bit floating-point data to be processed 128bits at a time. It also supports 4 * 4 array operations and innerproduct operations. Also, a superscalar architecture is employed thatenables simultaneous execution of two instructions (including FPUinstructions), providing performance of up to twice that ofconventional architectures at the same frequency.@node SH Directives@section SH Machine Directives@cindex SH machine directives@cindex machine directives, SH@cindex @code{uaword} directive, SH@cindex @code{ualong} directive, SH@table @code@item uaword@itemx ualong@code{@value{AS}} will issue a warning when a misaligned @code{.word} or@code{.long} directive is used. You may use @code{.uaword} or@code{.ualong} to indicate that the value is intentionally misaligned.@end table@node SH Opcodes@section Opcodes@cindex SH opcode summary@cindex opcode summary, SH@cindex mnemonics, SH@cindex instruction summary, SHFor detailed information on the SH machine instruction set, see@cite{SH-Microcomputer User's Manual} (Renesas) or@cite{SH-4 32-bit CPU Core Architecture} (SuperH) and@cite{SuperH (SH) 64-Bit RISC Series} (SuperH).@code{@value{AS}} implements all the standard SH opcodes. No additionalpseudo-instructions are needed on this family. Note, however, thatbecause @code{@value{AS}} supports a simpler form of PC-relativeaddressing, you may simply write (for example)@examplemov.l bar,r0@end example@noindentwhere other assemblers might require an explicit displacement to@code{bar} from the program counter:@examplemov.l @@(@var{disp}, PC)@end example@ifset SMALL@c this table, due to the multi-col faking and hardcoded order, looks silly@c except in smallbook. See comments below "@set SMALL" near top of this file.Here is a summary of SH opcodes:@page@smallexample@i{Legend:}Rn @r{a numbered register}Rm @r{another numbered register}#imm @r{immediate data}disp @r{displacement}disp8 @r{8-bit displacement}disp12 @r{12-bit displacement}add #imm,Rn lds.l @@Rn+,PRadd Rm,Rn mac.w @@Rm+,@@Rn+addc Rm,Rn mov #imm,Rnaddv Rm,Rn mov Rm,Rnand #imm,R0 mov.b Rm,@@(R0,Rn)and Rm,Rn mov.b Rm,@@-Rnand.b #imm,@@(R0,GBR) mov.b Rm,@@Rnbf disp8 mov.b @@(disp,Rm),R0bra disp12 mov.b @@(disp,GBR),R0bsr disp12 mov.b @@(R0,Rm),Rnbt disp8 mov.b @@Rm+,Rnclrmac mov.b @@Rm,Rnclrt mov.b R0,@@(disp,Rm)cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)cmp/gt Rm,Rn mov.l Rm,@@-Rncmp/hi Rm,Rn mov.l Rm,@@Rncmp/hs Rm,Rn mov.l @@(disp,Rn),Rmcmp/pl Rn mov.l @@(disp,GBR),R0cmp/pz Rn mov.l @@(disp,PC),Rncmp/str Rm,Rn mov.l @@(R0,Rm),Rndiv0s Rm,Rn mov.l @@Rm+,Rndiv0u mov.l @@Rm,Rndiv1 Rm,Rn mov.l R0,@@(disp,GBR)exts.b Rm,Rn mov.w Rm,@@(R0,Rn)exts.w Rm,Rn mov.w Rm,@@-Rnextu.b Rm,Rn mov.w Rm,@@Rnextu.w Rm,Rn mov.w @@(disp,Rm),R0jmp @@Rn mov.w @@(disp,GBR),R0jsr @@Rn mov.w @@(disp,PC),Rnldc Rn,GBR mov.w @@(R0,Rm),Rnldc Rn,SR mov.w @@Rm+,Rnldc Rn,VBR mov.w @@Rm,Rnldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)ldc.l @@Rn+,VBR mova @@(disp,PC),R0lds Rn,MACH movt Rnlds Rn,MACL muls Rm,Rnlds Rn,PR mulu Rm,Rnlds.l @@Rn+,MACH neg Rm,Rnlds.l @@Rn+,MACL negc Rm,Rn@pagenop stc VBR,Rnnot Rm,Rn stc.l GBR,@@-Rnor #imm,R0 stc.l SR,@@-Rnor Rm,Rn stc.l VBR,@@-Rnor.b #imm,@@(R0,GBR) sts MACH,Rnrotcl Rn sts MACL,Rnrotcr Rn sts PR,Rnrotl Rn sts.l MACH,@@-Rnrotr Rn sts.l MACL,@@-Rnrte sts.l PR,@@-Rnrts sub Rm,Rnsett subc Rm,Rnshal Rn subv Rm,Rnshar Rn swap.b Rm,Rnshll Rn swap.w Rm,Rnshll16 Rn tas.b @@Rnshll2 Rn trapa #immshll8 Rn tst #imm,R0shlr Rn tst Rm,Rnshlr16 Rn tst.b #imm,@@(R0,GBR)shlr2 Rn xor #imm,R0shlr8 Rn xor Rm,Rnsleep xor.b #imm,@@(R0,GBR)stc GBR,Rn xtrct Rm,Rnstc SR,Rn@end smallexample@end ifset@ifset Renesas-all@ifclear GENERIC@raisesections@end ifclear@end ifset