c-sh.texi 10 KB

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