1 @c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2003, 2004, 2005
2 @c Free Software Foundation, Inc.
3 @c This is part of the GAS manual.
4 @c For copying conditions, see the file as.texinfo.
7 @chapter Renesas / SuperH SH Dependent Features
11 * SH Options:: Options
13 * SH Floating Point:: Floating Point
14 * SH Directives:: SH Machine Directives
15 * SH Opcodes:: Opcodes
23 @code{@value{AS}} has following command-line options for the Renesas
24 (formerly Hitachi) / SuperH SH family.
33 @kindex --allow-reg-prefix
36 Generate little endian code.
39 Generate big endian code.
42 Alter jump instructions for long displacements.
45 Align sections to 4 byte boundaries, not 16.
48 Enable sh-dsp insns, and disable sh3e / sh4 insns.
51 Disable optimization with section symbol for compatibility with
54 @item --allow-reg-prefix
55 Allow '$' as a register name prefix.
57 @item --isa=sh4 | sh4a
58 Specify the sh4 or sh4a instruction set.
60 Enable sh-dsp insns, and disable sh3e / sh4 insns.
62 Enable sh2e, sh3e, sh4, and sh4a insn sets.
64 Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
72 * SH-Chars:: Special Characters
73 * SH-Regs:: Register Names
74 * SH-Addressing:: Addressing Modes
78 @subsection Special Characters
80 @cindex line comment character, SH
81 @cindex SH line comment character
82 @samp{!} is the line comment character.
84 @cindex line separator, SH
85 @cindex statement separator, SH
86 @cindex SH line separator
87 You can use @samp{;} instead of a newline to separate statements.
89 @cindex symbol names, @samp{$} in
90 @cindex @code{$} in symbol names
91 Since @samp{$} has no special meaning, you may use it in symbol names.
94 @subsection Register Names
98 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
99 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
100 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
101 and @samp{r15} to refer to the SH registers.
103 The SH also has these control registers:
107 procedure register (holds return address)
114 high and low multiply accumulator registers
123 vector base register (for interrupt vectors)
127 @subsection Addressing Modes
129 @cindex addressing modes, SH
130 @cindex SH addressing modes
131 @code{@value{AS}} understands the following addressing modes for the SH.
132 @code{R@var{n}} in the following refers to any of the numbered
133 registers, but @emph{not} the control registers.
143 Register indirect with pre-decrement
146 Register indirect with post-increment
148 @item @@(@var{disp}, R@var{n})
149 Register indirect with displacement
151 @item @@(R0, R@var{n})
154 @item @@(@var{disp}, GBR)
161 @itemx @@(@var{disp}, PC)
162 PC relative address (for branch or for addressing memory). The
163 @code{@value{AS}} implementation allows you to use the simpler form
164 @var{addr} anywhere a PC relative address is called for; the alternate
165 form is supported for compatibility with other assemblers.
171 @node SH Floating Point
172 @section Floating Point
174 @cindex floating point, SH (@sc{ieee})
175 @cindex SH floating point (@sc{ieee})
176 SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). Other
177 SH groups can use @code{.float} directive to generate @sc{ieee}
178 floating-point numbers.
180 SH2E and SH3E support single-precision floating point calculations as
181 well as entirely PCAPI compatible emulation of double-precision
182 floating point calculations. SH2E and SH3E instructions are a subset of
183 the floating point calculations conforming to the IEEE754 standard.
185 In addition to single-precision and double-precision floating-point
186 operation capability, the on-chip FPU of SH4 has a 128-bit graphic
187 engine that enables 32-bit floating-point data to be processed 128
188 bits at a time. It also supports 4 * 4 array operations and inner
189 product operations. Also, a superscalar architecture is employed that
190 enables simultaneous execution of two instructions (including FPU
191 instructions), providing performance of up to twice that of
192 conventional architectures at the same frequency.
195 @section SH Machine Directives
197 @cindex SH machine directives
198 @cindex machine directives, SH
199 @cindex @code{uaword} directive, SH
200 @cindex @code{ualong} directive, SH
205 @code{@value{AS}} will issue a warning when a misaligned @code{.word} or
206 @code{.long} directive is used. You may use @code{.uaword} or
207 @code{.ualong} to indicate that the value is intentionally misaligned.
213 @cindex SH opcode summary
214 @cindex opcode summary, SH
215 @cindex mnemonics, SH
216 @cindex instruction summary, SH
217 For detailed information on the SH machine instruction set, see
218 @cite{SH-Microcomputer User's Manual} (Renesas) or
219 @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
220 @cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
222 @code{@value{AS}} implements all the standard SH opcodes. No additional
223 pseudo-instructions are needed on this family. Note, however, that
224 because @code{@value{AS}} supports a simpler form of PC-relative
225 addressing, you may simply write (for example)
232 where other assemblers might require an explicit displacement to
233 @code{bar} from the program counter:
236 mov.l @@(@var{disp}, PC)
240 @c this table, due to the multi-col faking and hardcoded order, looks silly
241 @c except in smallbook. See comments below "@set SMALL" near top of this file.
243 Here is a summary of SH opcodes:
248 Rn @r{a numbered register}
249 Rm @r{another numbered register}
250 #imm @r{immediate data}
251 disp @r{displacement}
252 disp8 @r{8-bit displacement}
253 disp12 @r{12-bit displacement}
255 add #imm,Rn lds.l @@Rn+,PR
256 add Rm,Rn mac.w @@Rm+,@@Rn+
257 addc Rm,Rn mov #imm,Rn
259 and #imm,R0 mov.b Rm,@@(R0,Rn)
260 and Rm,Rn mov.b Rm,@@-Rn
261 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
262 bf disp8 mov.b @@(disp,Rm),R0
263 bra disp12 mov.b @@(disp,GBR),R0
264 bsr disp12 mov.b @@(R0,Rm),Rn
265 bt disp8 mov.b @@Rm+,Rn
267 clrt mov.b R0,@@(disp,Rm)
268 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
269 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
270 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
271 cmp/gt Rm,Rn mov.l Rm,@@-Rn
272 cmp/hi Rm,Rn mov.l Rm,@@Rn
273 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
274 cmp/pl Rn mov.l @@(disp,GBR),R0
275 cmp/pz Rn mov.l @@(disp,PC),Rn
276 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
277 div0s Rm,Rn mov.l @@Rm+,Rn
279 div1 Rm,Rn mov.l R0,@@(disp,GBR)
280 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
281 exts.w Rm,Rn mov.w Rm,@@-Rn
282 extu.b Rm,Rn mov.w Rm,@@Rn
283 extu.w Rm,Rn mov.w @@(disp,Rm),R0
284 jmp @@Rn mov.w @@(disp,GBR),R0
285 jsr @@Rn mov.w @@(disp,PC),Rn
286 ldc Rn,GBR mov.w @@(R0,Rm),Rn
287 ldc Rn,SR mov.w @@Rm+,Rn
288 ldc Rn,VBR mov.w @@Rm,Rn
289 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
290 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
291 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
293 lds Rn,MACL muls Rm,Rn
295 lds.l @@Rn+,MACH neg Rm,Rn
296 lds.l @@Rn+,MACL negc Rm,Rn
299 not Rm,Rn stc.l GBR,@@-Rn
300 or #imm,R0 stc.l SR,@@-Rn
301 or Rm,Rn stc.l VBR,@@-Rn
302 or.b #imm,@@(R0,GBR) sts MACH,Rn
305 rotl Rn sts.l MACH,@@-Rn
306 rotr Rn sts.l MACL,@@-Rn
317 shlr16 Rn tst.b #imm,@@(R0,GBR)
320 sleep xor.b #imm,@@(R0,GBR)
321 stc GBR,Rn xtrct Rm,Rn