1 @c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 2001
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.
34 Generate little endian code.
37 Generate big endian code.
40 Alter jump instructions for long displacements.
43 Align sections to 4 byte boundaries, not 16.
46 Enable sh-dsp insns, and disable sh3e / sh4 insns.
49 Specify the sh4 or sh4a instruction set.
51 Enable sh-dsp insns, and disable sh3e / sh4 insns.
53 Enable sh2e, sh3e, sh4, and sh4a insn sets.
55 Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
63 * SH-Chars:: Special Characters
64 * SH-Regs:: Register Names
65 * SH-Addressing:: Addressing Modes
69 @subsection Special Characters
71 @cindex line comment character, SH
72 @cindex SH line comment character
73 @samp{!} is the line comment character.
75 @cindex line separator, SH
76 @cindex statement separator, SH
77 @cindex SH line separator
78 You can use @samp{;} instead of a newline to separate statements.
80 @cindex symbol names, @samp{$} in
81 @cindex @code{$} in symbol names
82 Since @samp{$} has no special meaning, you may use it in symbol names.
85 @subsection Register Names
89 You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2},
90 @samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8},
91 @samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14},
92 and @samp{r15} to refer to the SH registers.
94 The SH also has these control registers:
98 procedure register (holds return address)
105 high and low multiply accumulator registers
114 vector base register (for interrupt vectors)
118 @subsection Addressing Modes
120 @cindex addressing modes, SH
121 @cindex SH addressing modes
122 @code{@value{AS}} understands the following addressing modes for the SH.
123 @code{R@var{n}} in the following refers to any of the numbered
124 registers, but @emph{not} the control registers.
134 Register indirect with pre-decrement
137 Register indirect with post-increment
139 @item @@(@var{disp}, R@var{n})
140 Register indirect with displacement
142 @item @@(R0, R@var{n})
145 @item @@(@var{disp}, GBR)
152 @itemx @@(@var{disp}, PC)
153 PC relative address (for branch or for addressing memory). The
154 @code{@value{AS}} implementation allows you to use the simpler form
155 @var{addr} anywhere a PC relative address is called for; the alternate
156 form is supported for compatibility with other assemblers.
162 @node SH Floating Point
163 @section Floating Point
165 @cindex floating point, SH (@sc{ieee})
166 @cindex SH floating point (@sc{ieee})
167 The SH family has no hardware floating point, but the @code{.float}
168 directive generates @sc{ieee} floating-point numbers for compatibility
169 with other development tools.
172 @section SH Machine Directives
174 @cindex SH machine directives
175 @cindex machine directives, SH
176 @cindex @code{uaword} directive, SH
177 @cindex @code{ualong} directive, SH
182 @code{@value{AS}} will issue a warning when a misaligned @code{.word} or
183 @code{.long} directive is used. You may use @code{.uaword} or
184 @code{.ualong} to indicate that the value is intentionally misaligned.
190 @cindex SH opcode summary
191 @cindex opcode summary, SH
192 @cindex mnemonics, SH
193 @cindex instruction summary, SH
194 For detailed information on the SH machine instruction set, see
195 @cite{SH-Microcomputer User's Manual} (Renesas) or
196 @cite{SH-4 32-bit CPU Core Architecture} (SuperH) and
197 @cite{SuperH (SH) 64-Bit RISC Series} (SuperH).
199 @code{@value{AS}} implements all the standard SH opcodes. No additional
200 pseudo-instructions are needed on this family. Note, however, that
201 because @code{@value{AS}} supports a simpler form of PC-relative
202 addressing, you may simply write (for example)
209 where other assemblers might require an explicit displacement to
210 @code{bar} from the program counter:
213 mov.l @@(@var{disp}, PC)
217 @c this table, due to the multi-col faking and hardcoded order, looks silly
218 @c except in smallbook. See comments below "@set SMALL" near top of this file.
220 Here is a summary of SH opcodes:
225 Rn @r{a numbered register}
226 Rm @r{another numbered register}
227 #imm @r{immediate data}
228 disp @r{displacement}
229 disp8 @r{8-bit displacement}
230 disp12 @r{12-bit displacement}
232 add #imm,Rn lds.l @@Rn+,PR
233 add Rm,Rn mac.w @@Rm+,@@Rn+
234 addc Rm,Rn mov #imm,Rn
236 and #imm,R0 mov.b Rm,@@(R0,Rn)
237 and Rm,Rn mov.b Rm,@@-Rn
238 and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn
239 bf disp8 mov.b @@(disp,Rm),R0
240 bra disp12 mov.b @@(disp,GBR),R0
241 bsr disp12 mov.b @@(R0,Rm),Rn
242 bt disp8 mov.b @@Rm+,Rn
244 clrt mov.b R0,@@(disp,Rm)
245 cmp/eq #imm,R0 mov.b R0,@@(disp,GBR)
246 cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn)
247 cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn)
248 cmp/gt Rm,Rn mov.l Rm,@@-Rn
249 cmp/hi Rm,Rn mov.l Rm,@@Rn
250 cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm
251 cmp/pl Rn mov.l @@(disp,GBR),R0
252 cmp/pz Rn mov.l @@(disp,PC),Rn
253 cmp/str Rm,Rn mov.l @@(R0,Rm),Rn
254 div0s Rm,Rn mov.l @@Rm+,Rn
256 div1 Rm,Rn mov.l R0,@@(disp,GBR)
257 exts.b Rm,Rn mov.w Rm,@@(R0,Rn)
258 exts.w Rm,Rn mov.w Rm,@@-Rn
259 extu.b Rm,Rn mov.w Rm,@@Rn
260 extu.w Rm,Rn mov.w @@(disp,Rm),R0
261 jmp @@Rn mov.w @@(disp,GBR),R0
262 jsr @@Rn mov.w @@(disp,PC),Rn
263 ldc Rn,GBR mov.w @@(R0,Rm),Rn
264 ldc Rn,SR mov.w @@Rm+,Rn
265 ldc Rn,VBR mov.w @@Rm,Rn
266 ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm)
267 ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR)
268 ldc.l @@Rn+,VBR mova @@(disp,PC),R0
270 lds Rn,MACL muls Rm,Rn
272 lds.l @@Rn+,MACH neg Rm,Rn
273 lds.l @@Rn+,MACL negc Rm,Rn
276 not Rm,Rn stc.l GBR,@@-Rn
277 or #imm,R0 stc.l SR,@@-Rn
278 or Rm,Rn stc.l VBR,@@-Rn
279 or.b #imm,@@(R0,GBR) sts MACH,Rn
282 rotl Rn sts.l MACH,@@-Rn
283 rotr Rn sts.l MACL,@@-Rn
294 shlr16 Rn tst.b #imm,@@(R0,GBR)
297 sleep xor.b #imm,@@(R0,GBR)
298 stc GBR,Rn xtrct Rm,Rn