]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/doc/c-sh.texi
*** empty log message ***
[thirdparty/binutils-gdb.git] / gas / doc / c-sh.texi
CommitLineData
8e45593f
NC
1@c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2003, 2004,
2@c 2005, 2008, 2010 Free Software Foundation, Inc.
252b5132
RH
3@c This is part of the GAS manual.
4@c For copying conditions, see the file as.texinfo.
5@page
6@node SH-Dependent
ef230218 7@chapter Renesas / SuperH SH Dependent Features
252b5132
RH
8
9@cindex SH support
10@menu
11* SH Options:: Options
12* SH Syntax:: Syntax
13* SH Floating Point:: Floating Point
14* SH Directives:: SH Machine Directives
15* SH Opcodes:: Opcodes
16@end menu
17
18@node SH Options
19@section Options
20
7649aa50
NC
21@cindex SH options
22@cindex options, SH
c2dcd04e 23@code{@value{AS}} has following command-line options for the Renesas
ef230218 24(formerly Hitachi) / SuperH SH family.
252b5132 25
7649aa50 26@table @code
37dedf66
NC
27@kindex --little
28@kindex --big
29@kindex --relax
30@kindex --small
31@kindex --dsp
32@kindex --renesas
33@kindex --allow-reg-prefix
34
35@item --little
7649aa50
NC
36Generate little endian code.
37
37dedf66 38@item --big
7649aa50
NC
39Generate big endian code.
40
37dedf66 41@item --relax
7649aa50
NC
42Alter jump instructions for long displacements.
43
37dedf66 44@item --small
7649aa50
NC
45Align sections to 4 byte boundaries, not 16.
46
37dedf66 47@item --dsp
7649aa50
NC
48Enable sh-dsp insns, and disable sh3e / sh4 insns.
49
37dedf66 50@item --renesas
f55629b8
KK
51Disable optimization with section symbol for compatibility with
52Renesas assembler.
53
37dedf66
NC
54@item --allow-reg-prefix
55Allow '$' as a register name prefix.
56
8e45593f
NC
57@kindex --fdpic
58@item --fdpic
59Generate an FDPIC object file.
60
37dedf66 61@item --isa=sh4 | sh4a
88da98f3 62Specify the sh4 or sh4a instruction set.
37dedf66 63@item --isa=dsp
88da98f3 64Enable sh-dsp insns, and disable sh3e / sh4 insns.
37dedf66 65@item --isa=fp
88da98f3 66Enable sh2e, sh3e, sh4, and sh4a insn sets.
37dedf66 67@item --isa=all
88da98f3
MS
68Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
69
6fd4f6cc
DD
70@item -h-tick-hex
71Support H'00 style hex constants in addition to 0x00 style.
72
7649aa50
NC
73@end table
74
252b5132
RH
75@node SH Syntax
76@section Syntax
77
78@menu
79* SH-Chars:: Special Characters
80* SH-Regs:: Register Names
81* SH-Addressing:: Addressing Modes
82@end menu
83
84@node SH-Chars
85@subsection Special Characters
86
87@cindex line comment character, SH
88@cindex SH line comment character
89@samp{!} is the line comment character.
90
91@cindex line separator, SH
92@cindex statement separator, SH
93@cindex SH line separator
94You can use @samp{;} instead of a newline to separate statements.
95
96@cindex symbol names, @samp{$} in
97@cindex @code{$} in symbol names
98Since @samp{$} has no special meaning, you may use it in symbol names.
99
100@node SH-Regs
101@subsection Register Names
102
103@cindex SH registers
104@cindex registers, SH
105You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
106@samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
107@samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
108and @samp{r15} to refer to the SH registers.
109
110The SH also has these control registers:
111
112@table @code
113@item pr
114procedure register (holds return address)
115
116@item pc
117program counter
118
119@item mach
120@itemx macl
121high and low multiply accumulator registers
122
123@item sr
124status register
125
126@item gbr
127global base register
128
129@item vbr
130vector base register (for interrupt vectors)
131@end table
132
133@node SH-Addressing
134@subsection Addressing Modes
135
136@cindex addressing modes, SH
137@cindex SH addressing modes
138@code{@value{AS}} understands the following addressing modes for the SH.
139@code{R@var{n}} in the following refers to any of the numbered
140registers, but @emph{not} the control registers.
141
142@table @code
143@item R@var{n}
144Register direct
145
146@item @@R@var{n}
147Register indirect
148
149@item @@-R@var{n}
150Register indirect with pre-decrement
151
152@item @@R@var{n}+
153Register indirect with post-increment
154
155@item @@(@var{disp}, R@var{n})
156Register indirect with displacement
157
158@item @@(R0, R@var{n})
159Register indexed
160
161@item @@(@var{disp}, GBR)
162@code{GBR} offset
163
164@item @@(R0, GBR)
165GBR indexed
166
167@item @var{addr}
168@itemx @@(@var{disp}, PC)
169PC relative address (for branch or for addressing memory). The
170@code{@value{AS}} implementation allows you to use the simpler form
171@var{addr} anywhere a PC relative address is called for; the alternate
172form is supported for compatibility with other assemblers.
173
174@item #@var{imm}
175Immediate data
176@end table
177
178@node SH Floating Point
179@section Floating Point
180
181@cindex floating point, SH (@sc{ieee})
182@cindex SH floating point (@sc{ieee})
303e7b79
NC
183SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). Other
184SH groups can use @code{.float} directive to generate @sc{ieee}
185floating-point numbers.
186
187SH2E and SH3E support single-precision floating point calculations as
188well as entirely PCAPI compatible emulation of double-precision
189floating point calculations. SH2E and SH3E instructions are a subset of
190the floating point calculations conforming to the IEEE754 standard.
191
192In addition to single-precision and double-precision floating-point
193operation capability, the on-chip FPU of SH4 has a 128-bit graphic
194engine that enables 32-bit floating-point data to be processed 128
195bits at a time. It also supports 4 * 4 array operations and inner
196product operations. Also, a superscalar architecture is employed that
197enables simultaneous execution of two instructions (including FPU
198instructions), providing performance of up to twice that of
199conventional architectures at the same frequency.
252b5132
RH
200
201@node SH Directives
202@section SH Machine Directives
203
204@cindex SH machine directives
205@cindex machine directives, SH
206@cindex @code{uaword} directive, SH
207@cindex @code{ualong} directive, SH
208
209@table @code
210@item uaword
211@itemx ualong
212@code{@value{AS}} will issue a warning when a misaligned @code{.word} or
213@code{.long} directive is used. You may use @code{.uaword} or
214@code{.ualong} to indicate that the value is intentionally misaligned.
215@end table
216
217@node SH Opcodes
218@section Opcodes
219
220@cindex SH opcode summary
221@cindex opcode summary, SH
222@cindex mnemonics, SH
223@cindex instruction summary, SH
224For detailed information on the SH machine instruction set, see
ef230218
JR
225@cite{SH-Microcomputer User's Manual} (Renesas) or
226@cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
227@cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
252b5132
RH
228
229@code{@value{AS}} implements all the standard SH opcodes. No additional
230pseudo-instructions are needed on this family. Note, however, that
231because @code{@value{AS}} supports a simpler form of PC-relative
232addressing, you may simply write (for example)
233
234@example
235mov.l bar,r0
236@end example
237
238@noindent
239where other assemblers might require an explicit displacement to
240@code{bar} from the program counter:
241
242@example
243mov.l @@(@var{disp}, PC)
244@end example
245
246@ifset SMALL
247@c this table, due to the multi-col faking and hardcoded order, looks silly
248@c except in smallbook. See comments below "@set SMALL" near top of this file.
249
250Here is a summary of SH opcodes:
251
252@page
253@smallexample
254@i{Legend:}
255Rn @r{a numbered register}
256Rm @r{another numbered register}
257#imm @r{immediate data}
258disp @r{displacement}
259disp8 @r{8-bit displacement}
260disp12 @r{12-bit displacement}
261
262add #imm,Rn lds.l @@Rn+,PR
263add Rm,Rn mac.w @@Rm+,@@Rn+
264addc Rm,Rn mov #imm,Rn
265addv Rm,Rn mov Rm,Rn
266and #imm,R0 mov.b Rm,@@(R0,Rn)
267and Rm,Rn mov.b Rm,@@-Rn
268and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
269bf disp8 mov.b @@(disp,Rm),R0
270bra disp12 mov.b @@(disp,GBR),R0
271bsr disp12 mov.b @@(R0,Rm),Rn
272bt disp8 mov.b @@Rm+,Rn
273clrmac mov.b @@Rm,Rn
274clrt mov.b R0,@@(disp,Rm)
275cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
276cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
277cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
278cmp/gt Rm,Rn mov.l Rm,@@-Rn
279cmp/hi Rm,Rn mov.l Rm,@@Rn
280cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
281cmp/pl Rn mov.l @@(disp,GBR),R0
282cmp/pz Rn mov.l @@(disp,PC),Rn
283cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
284div0s Rm,Rn mov.l @@Rm+,Rn
285div0u mov.l @@Rm,Rn
286div1 Rm,Rn mov.l R0,@@(disp,GBR)
287exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
288exts.w Rm,Rn mov.w Rm,@@-Rn
289extu.b Rm,Rn mov.w Rm,@@Rn
290extu.w Rm,Rn mov.w @@(disp,Rm),R0
291jmp @@Rn mov.w @@(disp,GBR),R0
292jsr @@Rn mov.w @@(disp,PC),Rn
293ldc Rn,GBR mov.w @@(R0,Rm),Rn
294ldc Rn,SR mov.w @@Rm+,Rn
295ldc Rn,VBR mov.w @@Rm,Rn
296ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
297ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
298ldc.l @@Rn+,VBR mova @@(disp,PC),R0
299lds Rn,MACH movt Rn
300lds Rn,MACL muls Rm,Rn
301lds Rn,PR mulu Rm,Rn
302lds.l @@Rn+,MACH neg Rm,Rn
303lds.l @@Rn+,MACL negc Rm,Rn
304@page
305nop stc VBR,Rn
306not Rm,Rn stc.l GBR,@@-Rn
307or #imm,R0 stc.l SR,@@-Rn
308or Rm,Rn stc.l VBR,@@-Rn
309or.b #imm,@@(R0,GBR) sts MACH,Rn
310rotcl Rn sts MACL,Rn
311rotcr Rn sts PR,Rn
312rotl Rn sts.l MACH,@@-Rn
313rotr Rn sts.l MACL,@@-Rn
314rte sts.l PR,@@-Rn
315rts sub Rm,Rn
316sett subc Rm,Rn
317shal Rn subv Rm,Rn
318shar Rn swap.b Rm,Rn
319shll Rn swap.w Rm,Rn
320shll16 Rn tas.b @@Rn
321shll2 Rn trapa #imm
322shll8 Rn tst #imm,R0
323shlr Rn tst Rm,Rn
324shlr16 Rn tst.b #imm,@@(R0,GBR)
325shlr2 Rn xor #imm,R0
326shlr8 Rn xor Rm,Rn
327sleep xor.b #imm,@@(R0,GBR)
328stc GBR,Rn xtrct Rm,Rn
329stc SR,Rn
330@end smallexample
331@end ifset
332
c2dcd04e 333@ifset Renesas-all
252b5132
RH
334@ifclear GENERIC
335@raisesections
336@end ifclear
337@end ifset
338