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.
67 Support H'00 style hex constants in addition to 0x00 style.
75 * SH-Chars:: Special Characters
76 * SH-Regs:: Register Names
77 * SH-Addressing:: Addressing Modes
81 @subsection Special Characters
83 @cindex line comment character, SH
84 @cindex SH line comment character
85 @samp{!} is the line comment character.
87 @cindex line separator, SH
88 @cindex statement separator, SH
89 @cindex SH line separator
90 You can use @samp{;} instead of a newline to separate statements.
92 @cindex symbol names, @samp{$} in
93 @cindex @code{$} in symbol names
94 Since @samp{$} has no special meaning, you may use it in symbol names.
97 @subsection Register Names
100 @cindex registers, SH
101 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
102 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
103 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
104 and @samp{r15} to refer to the SH registers.
106 The SH also has these control registers:
110 procedure register (holds return address)
117 high and low multiply accumulator registers
126 vector base register (for interrupt vectors)
130 @subsection Addressing Modes
132 @cindex addressing modes, SH
133 @cindex SH addressing modes
134 @code{@value{AS}} understands the following addressing modes for the SH.
135 @code{R@var{n}} in the following refers to any of the numbered
136 registers, but @emph{not} the control registers.
146 Register indirect with pre-decrement
149 Register indirect with post-increment
151 @item @@(@var{disp}, R@var{n})
152 Register indirect with displacement
154 @item @@(R0, R@var{n})
157 @item @@(@var{disp}, GBR)
164 @itemx @@(@var{disp}, PC)
165 PC relative address (for branch or for addressing memory). The
166 @code{@value{AS}} implementation allows you to use the simpler form
167 @var{addr} anywhere a PC relative address is called for; the alternate
168 form is supported for compatibility with other assemblers.
174 @node SH Floating Point
175 @section Floating Point
177 @cindex floating point, SH (@sc{ieee})
178 @cindex SH floating point (@sc{ieee})
179 SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). Other
180 SH groups can use @code{.float} directive to generate @sc{ieee}
181 floating-point numbers.
183 SH2E and SH3E support single-precision floating point calculations as
184 well as entirely PCAPI compatible emulation of double-precision
185 floating point calculations. SH2E and SH3E instructions are a subset of
186 the floating point calculations conforming to the IEEE754 standard.
188 In addition to single-precision and double-precision floating-point
189 operation capability, the on-chip FPU of SH4 has a 128-bit graphic
190 engine that enables 32-bit floating-point data to be processed 128
191 bits at a time. It also supports 4 * 4 array operations and inner
192 product operations. Also, a superscalar architecture is employed that
193 enables simultaneous execution of two instructions (including FPU
194 instructions), providing performance of up to twice that of
195 conventional architectures at the same frequency.
198 @section SH Machine Directives
200 @cindex SH machine directives
201 @cindex machine directives, SH
202 @cindex @code{uaword} directive, SH
203 @cindex @code{ualong} directive, SH
208 @code{@value{AS}} will issue a warning when a misaligned @code{.word} or
209 @code{.long} directive is used. You may use @code{.uaword} or
210 @code{.ualong} to indicate that the value is intentionally misaligned.
216 @cindex SH opcode summary
217 @cindex opcode summary, SH
218 @cindex mnemonics, SH
219 @cindex instruction summary, SH
220 For detailed information on the SH machine instruction set, see
221 @cite{SH-Microcomputer User's Manual} (Renesas) or
222 @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
223 @cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
225 @code{@value{AS}} implements all the standard SH opcodes. No additional
226 pseudo-instructions are needed on this family. Note, however, that
227 because @code{@value{AS}} supports a simpler form of PC-relative
228 addressing, you may simply write (for example)
235 where other assemblers might require an explicit displacement to
236 @code{bar} from the program counter:
239 mov.l @@(@var{disp}, PC)
243 @c this table, due to the multi-col faking and hardcoded order, looks silly
244 @c except in smallbook. See comments below "@set SMALL" near top of this file.
246 Here is a summary of SH opcodes:
251 Rn @r{a numbered register}
252 Rm @r{another numbered register}
253 #imm @r{immediate data}
254 disp @r{displacement}
255 disp8 @r{8-bit displacement}
256 disp12 @r{12-bit displacement}
258 add #imm,Rn lds.l @@Rn+,PR
259 add Rm,Rn mac.w @@Rm+,@@Rn+
260 addc Rm,Rn mov #imm,Rn
262 and #imm,R0 mov.b Rm,@@(R0,Rn)
263 and Rm,Rn mov.b Rm,@@-Rn
264 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
265 bf disp8 mov.b @@(disp,Rm),R0
266 bra disp12 mov.b @@(disp,GBR),R0
267 bsr disp12 mov.b @@(R0,Rm),Rn
268 bt disp8 mov.b @@Rm+,Rn
270 clrt mov.b R0,@@(disp,Rm)
271 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
272 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
273 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
274 cmp/gt Rm,Rn mov.l Rm,@@-Rn
275 cmp/hi Rm,Rn mov.l Rm,@@Rn
276 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
277 cmp/pl Rn mov.l @@(disp,GBR),R0
278 cmp/pz Rn mov.l @@(disp,PC),Rn
279 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
280 div0s Rm,Rn mov.l @@Rm+,Rn
282 div1 Rm,Rn mov.l R0,@@(disp,GBR)
283 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
284 exts.w Rm,Rn mov.w Rm,@@-Rn
285 extu.b Rm,Rn mov.w Rm,@@Rn
286 extu.w Rm,Rn mov.w @@(disp,Rm),R0
287 jmp @@Rn mov.w @@(disp,GBR),R0
288 jsr @@Rn mov.w @@(disp,PC),Rn
289 ldc Rn,GBR mov.w @@(R0,Rm),Rn
290 ldc Rn,SR mov.w @@Rm+,Rn
291 ldc Rn,VBR mov.w @@Rm,Rn
292 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
293 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
294 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
296 lds Rn,MACL muls Rm,Rn
298 lds.l @@Rn+,MACH neg Rm,Rn
299 lds.l @@Rn+,MACL negc Rm,Rn
302 not Rm,Rn stc.l GBR,@@-Rn
303 or #imm,R0 stc.l SR,@@-Rn
304 or Rm,Rn stc.l VBR,@@-Rn
305 or.b #imm,@@(R0,GBR) sts MACH,Rn
308 rotl Rn sts.l MACH,@@-Rn
309 rotr Rn sts.l MACL,@@-Rn
320 shlr16 Rn tst.b #imm,@@(R0,GBR)
323 sleep xor.b #imm,@@(R0,GBR)
324 stc GBR,Rn xtrct Rm,Rn