1 @c Copyright (C) 1991-2018 Free Software Foundation, Inc.
2 @c This is part of the GAS manual.
3 @c For copying conditions, see the file as.texinfo.
6 @chapter Renesas / SuperH SH Dependent Features
10 * SH Options:: Options
12 * SH Floating Point:: Floating Point
13 * SH Directives:: SH Machine Directives
14 * SH Opcodes:: Opcodes
22 @code{@value{AS}} has following command-line options for the Renesas
23 (formerly Hitachi) / SuperH SH family.
32 @kindex --allow-reg-prefix
35 Generate little endian code.
38 Generate big endian code.
41 Alter jump instructions for long displacements.
44 Align sections to 4 byte boundaries, not 16.
47 Enable sh-dsp insns, and disable sh3e / sh4 insns.
50 Disable optimization with section symbol for compatibility with
53 @item --allow-reg-prefix
54 Allow '$' as a register name prefix.
58 Generate an FDPIC object file.
60 @item --isa=sh4 | sh4a
61 Specify the sh4 or sh4a instruction set.
63 Enable sh-dsp insns, and disable sh3e / sh4 insns.
65 Enable sh2e, sh3e, sh4, and sh4a insn sets.
67 Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
70 Support H'00 style hex constants in addition to 0x00 style.
78 * SH-Chars:: Special Characters
79 * SH-Regs:: Register Names
80 * SH-Addressing:: Addressing Modes
84 @subsection Special Characters
86 @cindex line comment character, SH
87 @cindex SH line comment character
88 @samp{!} is the line comment character.
90 @cindex line separator, SH
91 @cindex statement separator, SH
92 @cindex SH line separator
93 You can use @samp{;} instead of a newline to separate statements.
95 If a @samp{#} appears as the first character of a line then the whole
96 line is treated as a comment, but in this case the line could also be
97 a logical line number directive (@pxref{Comments}) or a preprocessor
98 control command (@pxref{Preprocessing}).
100 @cindex symbol names, @samp{$} in
101 @cindex @code{$} in symbol names
102 Since @samp{$} has no special meaning, you may use it in symbol names.
105 @subsection Register Names
108 @cindex registers, SH
109 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
110 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
111 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
112 and @samp{r15} to refer to the SH registers.
114 The SH also has these control registers:
118 procedure register (holds return address)
125 high and low multiply accumulator registers
134 vector base register (for interrupt vectors)
138 @subsection Addressing Modes
140 @cindex addressing modes, SH
141 @cindex SH addressing modes
142 @code{@value{AS}} understands the following addressing modes for the SH.
143 @code{R@var{n}} in the following refers to any of the numbered
144 registers, but @emph{not} the control registers.
154 Register indirect with pre-decrement
157 Register indirect with post-increment
159 @item @@(@var{disp}, R@var{n})
160 Register indirect with displacement
162 @item @@(R0, R@var{n})
165 @item @@(@var{disp}, GBR)
172 @itemx @@(@var{disp}, PC)
173 PC relative address (for branch or for addressing memory). The
174 @code{@value{AS}} implementation allows you to use the simpler form
175 @var{addr} anywhere a PC relative address is called for; the alternate
176 form is supported for compatibility with other assemblers.
182 @node SH Floating Point
183 @section Floating Point
185 @cindex floating point, SH (@sc{ieee})
186 @cindex SH floating point (@sc{ieee})
187 SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). Other
188 SH groups can use @code{.float} directive to generate @sc{ieee}
189 floating-point numbers.
191 SH2E and SH3E support single-precision floating point calculations as
192 well as entirely PCAPI compatible emulation of double-precision
193 floating point calculations. SH2E and SH3E instructions are a subset of
194 the floating point calculations conforming to the IEEE754 standard.
196 In addition to single-precision and double-precision floating-point
197 operation capability, the on-chip FPU of SH4 has a 128-bit graphic
198 engine that enables 32-bit floating-point data to be processed 128
199 bits at a time. It also supports 4 * 4 array operations and inner
200 product operations. Also, a superscalar architecture is employed that
201 enables simultaneous execution of two instructions (including FPU
202 instructions), providing performance of up to twice that of
203 conventional architectures at the same frequency.
206 @section SH Machine Directives
208 @cindex SH machine directives
209 @cindex machine directives, SH
210 @cindex @code{uaword} directive, SH
211 @cindex @code{ualong} directive, SH
212 @cindex @code{uaquad} directive, SH
218 @code{@value{AS}} will issue a warning when a misaligned @code{.word},
219 @code{.long}, or @code{.quad} directive is used. You may use
220 @code{.uaword}, @code{.ualong}, or @code{.uaquad} to indicate that the
221 value is intentionally misaligned.
227 @cindex SH opcode summary
228 @cindex opcode summary, SH
229 @cindex mnemonics, SH
230 @cindex instruction summary, SH
231 For detailed information on the SH machine instruction set, see
232 @cite{SH-Microcomputer User's Manual} (Renesas) or
233 @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
234 @cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
236 @code{@value{AS}} implements all the standard SH opcodes. No additional
237 pseudo-instructions are needed on this family. Note, however, that
238 because @code{@value{AS}} supports a simpler form of PC-relative
239 addressing, you may simply write (for example)
246 where other assemblers might require an explicit displacement to
247 @code{bar} from the program counter:
250 mov.l @@(@var{disp}, PC)
254 @c this table, due to the multi-col faking and hardcoded order, looks silly
255 @c except in smallbook. See comments below "@set SMALL" near top of this file.
257 Here is a summary of SH opcodes:
262 Rn @r{a numbered register}
263 Rm @r{another numbered register}
264 #imm @r{immediate data}
265 disp @r{displacement}
266 disp8 @r{8-bit displacement}
267 disp12 @r{12-bit displacement}
269 add #imm,Rn lds.l @@Rn+,PR
270 add Rm,Rn mac.w @@Rm+,@@Rn+
271 addc Rm,Rn mov #imm,Rn
273 and #imm,R0 mov.b Rm,@@(R0,Rn)
274 and Rm,Rn mov.b Rm,@@-Rn
275 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
276 bf disp8 mov.b @@(disp,Rm),R0
277 bra disp12 mov.b @@(disp,GBR),R0
278 bsr disp12 mov.b @@(R0,Rm),Rn
279 bt disp8 mov.b @@Rm+,Rn
281 clrt mov.b R0,@@(disp,Rm)
282 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
283 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
284 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
285 cmp/gt Rm,Rn mov.l Rm,@@-Rn
286 cmp/hi Rm,Rn mov.l Rm,@@Rn
287 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
288 cmp/pl Rn mov.l @@(disp,GBR),R0
289 cmp/pz Rn mov.l @@(disp,PC),Rn
290 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
291 div0s Rm,Rn mov.l @@Rm+,Rn
293 div1 Rm,Rn mov.l R0,@@(disp,GBR)
294 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
295 exts.w Rm,Rn mov.w Rm,@@-Rn
296 extu.b Rm,Rn mov.w Rm,@@Rn
297 extu.w Rm,Rn mov.w @@(disp,Rm),R0
298 jmp @@Rn mov.w @@(disp,GBR),R0
299 jsr @@Rn mov.w @@(disp,PC),Rn
300 ldc Rn,GBR mov.w @@(R0,Rm),Rn
301 ldc Rn,SR mov.w @@Rm+,Rn
302 ldc Rn,VBR mov.w @@Rm,Rn
303 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
304 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
305 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
307 lds Rn,MACL muls Rm,Rn
309 lds.l @@Rn+,MACH neg Rm,Rn
310 lds.l @@Rn+,MACL negc Rm,Rn
313 not Rm,Rn stc.l GBR,@@-Rn
314 or #imm,R0 stc.l SR,@@-Rn
315 or Rm,Rn stc.l VBR,@@-Rn
316 or.b #imm,@@(R0,GBR) sts MACH,Rn
319 rotl Rn sts.l MACH,@@-Rn
320 rotr Rn sts.l MACL,@@-Rn
331 shlr16 Rn tst.b #imm,@@(R0,GBR)
334 sleep xor.b #imm,@@(R0,GBR)
335 stc GBR,Rn xtrct Rm,Rn