gas/
[deliverable/binutils-gdb.git] / gas / doc / c-sh.texi
CommitLineData
37dedf66 1@c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2003, 2004, 2005
f7e42eb4 2@c 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
57@item --isa=sh4 | sh4a
88da98f3 58Specify the sh4 or sh4a instruction set.
37dedf66 59@item --isa=dsp
88da98f3 60Enable sh-dsp insns, and disable sh3e / sh4 insns.
37dedf66 61@item --isa=fp
88da98f3 62Enable sh2e, sh3e, sh4, and sh4a insn sets.
37dedf66 63@item --isa=all
88da98f3
MS
64Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
65
6fd4f6cc
DD
66@item -h-tick-hex
67Support H'00 style hex constants in addition to 0x00 style.
68
7649aa50
NC
69@end table
70
252b5132
RH
71@node SH Syntax
72@section Syntax
73
74@menu
75* SH-Chars:: Special Characters
76* SH-Regs:: Register Names
77* SH-Addressing:: Addressing Modes
78@end menu
79
80@node SH-Chars
81@subsection Special Characters
82
83@cindex line comment character, SH
84@cindex SH line comment character
85@samp{!} is the line comment character.
86
87@cindex line separator, SH
88@cindex statement separator, SH
89@cindex SH line separator
90You can use @samp{;} instead of a newline to separate statements.
91
92@cindex symbol names, @samp{$} in
93@cindex @code{$} in symbol names
94Since @samp{$} has no special meaning, you may use it in symbol names.
95
96@node SH-Regs
97@subsection Register Names
98
99@cindex SH registers
100@cindex registers, SH
101You 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},
104and @samp{r15} to refer to the SH registers.
105
106The SH also has these control registers:
107
108@table @code
109@item pr
110procedure register (holds return address)
111
112@item pc
113program counter
114
115@item mach
116@itemx macl
117high and low multiply accumulator registers
118
119@item sr
120status register
121
122@item gbr
123global base register
124
125@item vbr
126vector base register (for interrupt vectors)
127@end table
128
129@node SH-Addressing
130@subsection Addressing Modes
131
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
136registers, but @emph{not} the control registers.
137
138@table @code
139@item R@var{n}
140Register direct
141
142@item @@R@var{n}
143Register indirect
144
145@item @@-R@var{n}
146Register indirect with pre-decrement
147
148@item @@R@var{n}+
149Register indirect with post-increment
150
151@item @@(@var{disp}, R@var{n})
152Register indirect with displacement
153
154@item @@(R0, R@var{n})
155Register indexed
156
157@item @@(@var{disp}, GBR)
158@code{GBR} offset
159
160@item @@(R0, GBR)
161GBR indexed
162
163@item @var{addr}
164@itemx @@(@var{disp}, PC)
165PC 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
168form is supported for compatibility with other assemblers.
169
170@item #@var{imm}
171Immediate data
172@end table
173
174@node SH Floating Point
175@section Floating Point
176
177@cindex floating point, SH (@sc{ieee})
178@cindex SH floating point (@sc{ieee})
303e7b79
NC
179SH2E, SH3E and SH4 groups have on-chip floating-point unit (FPU). Other
180SH groups can use @code{.float} directive to generate @sc{ieee}
181floating-point numbers.
182
183SH2E and SH3E support single-precision floating point calculations as
184well as entirely PCAPI compatible emulation of double-precision
185floating point calculations. SH2E and SH3E instructions are a subset of
186the floating point calculations conforming to the IEEE754 standard.
187
188In addition to single-precision and double-precision floating-point
189operation capability, the on-chip FPU of SH4 has a 128-bit graphic
190engine that enables 32-bit floating-point data to be processed 128
191bits at a time. It also supports 4 * 4 array operations and inner
192product operations. Also, a superscalar architecture is employed that
193enables simultaneous execution of two instructions (including FPU
194instructions), providing performance of up to twice that of
195conventional architectures at the same frequency.
252b5132
RH
196
197@node SH Directives
198@section SH Machine Directives
199
200@cindex SH machine directives
201@cindex machine directives, SH
202@cindex @code{uaword} directive, SH
203@cindex @code{ualong} directive, SH
204
205@table @code
206@item uaword
207@itemx ualong
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.
211@end table
212
213@node SH Opcodes
214@section Opcodes
215
216@cindex SH opcode summary
217@cindex opcode summary, SH
218@cindex mnemonics, SH
219@cindex instruction summary, SH
220For detailed information on the SH machine instruction set, see
ef230218
JR
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).
252b5132
RH
224
225@code{@value{AS}} implements all the standard SH opcodes. No additional
226pseudo-instructions are needed on this family. Note, however, that
227because @code{@value{AS}} supports a simpler form of PC-relative
228addressing, you may simply write (for example)
229
230@example
231mov.l bar,r0
232@end example
233
234@noindent
235where other assemblers might require an explicit displacement to
236@code{bar} from the program counter:
237
238@example
239mov.l @@(@var{disp}, PC)
240@end example
241
242@ifset SMALL
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.
245
246Here is a summary of SH opcodes:
247
248@page
249@smallexample
250@i{Legend:}
251Rn @r{a numbered register}
252Rm @r{another numbered register}
253#imm @r{immediate data}
254disp @r{displacement}
255disp8 @r{8-bit displacement}
256disp12 @r{12-bit displacement}
257
258add #imm,Rn lds.l @@Rn+,PR
259add Rm,Rn mac.w @@Rm+,@@Rn+
260addc Rm,Rn mov #imm,Rn
261addv Rm,Rn mov Rm,Rn
262and #imm,R0 mov.b Rm,@@(R0,Rn)
263and Rm,Rn mov.b Rm,@@-Rn
264and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
265bf disp8 mov.b @@(disp,Rm),R0
266bra disp12 mov.b @@(disp,GBR),R0
267bsr disp12 mov.b @@(R0,Rm),Rn
268bt disp8 mov.b @@Rm+,Rn
269clrmac mov.b @@Rm,Rn
270clrt mov.b R0,@@(disp,Rm)
271cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
272cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
273cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
274cmp/gt Rm,Rn mov.l Rm,@@-Rn
275cmp/hi Rm,Rn mov.l Rm,@@Rn
276cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
277cmp/pl Rn mov.l @@(disp,GBR),R0
278cmp/pz Rn mov.l @@(disp,PC),Rn
279cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
280div0s Rm,Rn mov.l @@Rm+,Rn
281div0u mov.l @@Rm,Rn
282div1 Rm,Rn mov.l R0,@@(disp,GBR)
283exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
284exts.w Rm,Rn mov.w Rm,@@-Rn
285extu.b Rm,Rn mov.w Rm,@@Rn
286extu.w Rm,Rn mov.w @@(disp,Rm),R0
287jmp @@Rn mov.w @@(disp,GBR),R0
288jsr @@Rn mov.w @@(disp,PC),Rn
289ldc Rn,GBR mov.w @@(R0,Rm),Rn
290ldc Rn,SR mov.w @@Rm+,Rn
291ldc Rn,VBR mov.w @@Rm,Rn
292ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
293ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
294ldc.l @@Rn+,VBR mova @@(disp,PC),R0
295lds Rn,MACH movt Rn
296lds Rn,MACL muls Rm,Rn
297lds Rn,PR mulu Rm,Rn
298lds.l @@Rn+,MACH neg Rm,Rn
299lds.l @@Rn+,MACL negc Rm,Rn
300@page
301nop stc VBR,Rn
302not Rm,Rn stc.l GBR,@@-Rn
303or #imm,R0 stc.l SR,@@-Rn
304or Rm,Rn stc.l VBR,@@-Rn
305or.b #imm,@@(R0,GBR) sts MACH,Rn
306rotcl Rn sts MACL,Rn
307rotcr Rn sts PR,Rn
308rotl Rn sts.l MACH,@@-Rn
309rotr Rn sts.l MACL,@@-Rn
310rte sts.l PR,@@-Rn
311rts sub Rm,Rn
312sett subc Rm,Rn
313shal Rn subv Rm,Rn
314shar Rn swap.b Rm,Rn
315shll Rn swap.w Rm,Rn
316shll16 Rn tas.b @@Rn
317shll2 Rn trapa #imm
318shll8 Rn tst #imm,R0
319shlr Rn tst Rm,Rn
320shlr16 Rn tst.b #imm,@@(R0,GBR)
321shlr2 Rn xor #imm,R0
322shlr8 Rn xor Rm,Rn
323sleep xor.b #imm,@@(R0,GBR)
324stc GBR,Rn xtrct Rm,Rn
325stc SR,Rn
326@end smallexample
327@end ifset
328
c2dcd04e 329@ifset Renesas-all
252b5132
RH
330@ifclear GENERIC
331@raisesections
332@end ifclear
333@end ifset
334
This page took 0.485103 seconds and 4 git commands to generate.