c-d10v.texi 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. @c Copyright (C) 1996-2022 Free Software Foundation, Inc.
  2. @c This is part of the GAS manual.
  3. @c For copying conditions, see the file as.texinfo.
  4. @ifset GENERIC
  5. @page
  6. @node D10V-Dependent
  7. @chapter D10V Dependent Features
  8. @end ifset
  9. @ifclear GENERIC
  10. @node Machine Dependencies
  11. @chapter D10V Dependent Features
  12. @end ifclear
  13. @cindex D10V support
  14. @menu
  15. * D10V-Opts:: D10V Options
  16. * D10V-Syntax:: Syntax
  17. * D10V-Float:: Floating Point
  18. * D10V-Opcodes:: Opcodes
  19. @end menu
  20. @node D10V-Opts
  21. @section D10V Options
  22. @cindex options, D10V
  23. @cindex D10V options
  24. The Mitsubishi D10V version of @code{@value{AS}} has a few machine
  25. dependent options.
  26. @table @samp
  27. @item -O
  28. The D10V can often execute two sub-instructions in parallel. When this option
  29. is used, @code{@value{AS}} will attempt to optimize its output by detecting when
  30. instructions can be executed in parallel.
  31. @item --nowarnswap
  32. To optimize execution performance, @code{@value{AS}} will sometimes swap the
  33. order of instructions. Normally this generates a warning. When this option
  34. is used, no warning will be generated when instructions are swapped.
  35. @item --gstabs-packing
  36. @itemx --no-gstabs-packing
  37. @code{@value{AS}} packs adjacent short instructions into a single packed
  38. instruction. @samp{--no-gstabs-packing} turns instruction packing off if
  39. @samp{--gstabs} is specified as well; @samp{--gstabs-packing} (the
  40. default) turns instruction packing on even when @samp{--gstabs} is
  41. specified.
  42. @end table
  43. @node D10V-Syntax
  44. @section Syntax
  45. @cindex D10V syntax
  46. @cindex syntax, D10V
  47. The D10V syntax is based on the syntax in Mitsubishi's D10V architecture manual.
  48. The differences are detailed below.
  49. @menu
  50. * D10V-Size:: Size Modifiers
  51. * D10V-Subs:: Sub-Instructions
  52. * D10V-Chars:: Special Characters
  53. * D10V-Regs:: Register Names
  54. * D10V-Addressing:: Addressing Modes
  55. * D10V-Word:: @@WORD Modifier
  56. @end menu
  57. @node D10V-Size
  58. @subsection Size Modifiers
  59. @cindex D10V size modifiers
  60. @cindex size modifiers, D10V
  61. The D10V version of @code{@value{AS}} uses the instruction names in the D10V
  62. Architecture Manual. However, the names in the manual are sometimes ambiguous.
  63. There are instruction names that can assemble to a short or long form opcode.
  64. How does the assembler pick the correct form? @code{@value{AS}} will always pick the
  65. smallest form if it can. When dealing with a symbol that is not defined yet when a
  66. line is being assembled, it will always use the long form. If you need to force the
  67. assembler to use either the short or long form of the instruction, you can append
  68. either @samp{.s} (short) or @samp{.l} (long) to it. For example, if you are writing
  69. an assembly program and you want to do a branch to a symbol that is defined later
  70. in your program, you can write @samp{bra.s foo}.
  71. Objdump and GDB will always append @samp{.s} or @samp{.l} to instructions which
  72. have both short and long forms.
  73. @node D10V-Subs
  74. @subsection Sub-Instructions
  75. @cindex D10V sub-instructions
  76. @cindex sub-instructions, D10V
  77. The D10V assembler takes as input a series of instructions, either one-per-line,
  78. or in the special two-per-line format described in the next section. Some of these
  79. instructions will be short-form or sub-instructions. These sub-instructions can be packed
  80. into a single instruction. The assembler will do this automatically. It will also detect
  81. when it should not pack instructions. For example, when a label is defined, the next
  82. instruction will never be packaged with the previous one. Whenever a branch and link
  83. instruction is called, it will not be packaged with the next instruction so the return
  84. address will be valid. Nops are automatically inserted when necessary.
  85. If you do not want the assembler automatically making these decisions, you can control
  86. the packaging and execution type (parallel or sequential) with the special execution
  87. symbols described in the next section.
  88. @node D10V-Chars
  89. @subsection Special Characters
  90. @cindex line comment character, D10V
  91. @cindex D10V line comment character
  92. A semicolon (@samp{;}) can be used anywhere on a line to start a
  93. comment that extends to the end of the line.
  94. If a @samp{#} appears as the first character of a line, the whole line
  95. is treated as a comment, but in this case the line could also be a
  96. logical line number directive (@pxref{Comments}) or a preprocessor
  97. control command (@pxref{Preprocessing}).
  98. @cindex sub-instruction ordering, D10V
  99. @cindex D10V sub-instruction ordering
  100. Sub-instructions may be executed in order, in reverse-order, or in parallel.
  101. Instructions listed in the standard one-per-line format will be executed sequentially.
  102. To specify the executing order, use the following symbols:
  103. @table @samp
  104. @item ->
  105. Sequential with instruction on the left first.
  106. @item <-
  107. Sequential with instruction on the right first.
  108. @item ||
  109. Parallel
  110. @end table
  111. The D10V syntax allows either one instruction per line, one instruction per line with
  112. the execution symbol, or two instructions per line. For example
  113. @table @code
  114. @item abs a1 -> abs r0
  115. Execute these sequentially. The instruction on the right is in the right
  116. container and is executed second.
  117. @item abs r0 <- abs a1
  118. Execute these reverse-sequentially. The instruction on the right is in the right
  119. container, and is executed first.
  120. @item ld2w r2,@@r8+ || mac a0,r0,r7
  121. Execute these in parallel.
  122. @item ld2w r2,@@r8+ ||
  123. @itemx mac a0,r0,r7
  124. Two-line format. Execute these in parallel.
  125. @item ld2w r2,@@r8+
  126. @itemx mac a0,r0,r7
  127. Two-line format. Execute these sequentially. Assembler will
  128. put them in the proper containers.
  129. @item ld2w r2,@@r8+ ->
  130. @itemx mac a0,r0,r7
  131. Two-line format. Execute these sequentially. Same as above but
  132. second instruction will always go into right container.
  133. @end table
  134. @cindex symbol names, @samp{$} in
  135. @cindex @code{$} in symbol names
  136. Since @samp{$} has no special meaning, you may use it in symbol names.
  137. @node D10V-Regs
  138. @subsection Register Names
  139. @cindex D10V registers
  140. @cindex registers, D10V
  141. You can use the predefined symbols @samp{r0} through @samp{r15} to refer to the D10V
  142. registers. You can also use @samp{sp} as an alias for @samp{r15}. The accumulators
  143. are @samp{a0} and @samp{a1}. There are special register-pair names that may
  144. optionally be used in opcodes that require even-numbered registers. Register names are
  145. not case sensitive.
  146. Register Pairs
  147. @table @code
  148. @item r0-r1
  149. @item r2-r3
  150. @item r4-r5
  151. @item r6-r7
  152. @item r8-r9
  153. @item r10-r11
  154. @item r12-r13
  155. @item r14-r15
  156. @end table
  157. The D10V also has predefined symbols for these control registers and status bits:
  158. @table @code
  159. @item psw
  160. Processor Status Word
  161. @item bpsw
  162. Backup Processor Status Word
  163. @item pc
  164. Program Counter
  165. @item bpc
  166. Backup Program Counter
  167. @item rpt_c
  168. Repeat Count
  169. @item rpt_s
  170. Repeat Start address
  171. @item rpt_e
  172. Repeat End address
  173. @item mod_s
  174. Modulo Start address
  175. @item mod_e
  176. Modulo End address
  177. @item iba
  178. Instruction Break Address
  179. @item f0
  180. Flag 0
  181. @item f1
  182. Flag 1
  183. @item c
  184. Carry flag
  185. @end table
  186. @node D10V-Addressing
  187. @subsection Addressing Modes
  188. @cindex addressing modes, D10V
  189. @cindex D10V addressing modes
  190. @code{@value{AS}} understands the following addressing modes for the D10V.
  191. @code{R@var{n}} in the following refers to any of the numbered
  192. registers, but @emph{not} the control registers.
  193. @table @code
  194. @item R@var{n}
  195. Register direct
  196. @item @@R@var{n}
  197. Register indirect
  198. @item @@R@var{n}+
  199. Register indirect with post-increment
  200. @item @@R@var{n}-
  201. Register indirect with post-decrement
  202. @item @@-SP
  203. Register indirect with pre-decrement
  204. @item @@(@var{disp}, R@var{n})
  205. Register indirect with displacement
  206. @item @var{addr}
  207. PC relative address (for branch or rep).
  208. @item #@var{imm}
  209. Immediate data (the @samp{#} is optional and ignored)
  210. @end table
  211. @node D10V-Word
  212. @subsection @@WORD Modifier
  213. @cindex D10V @@word modifier
  214. @cindex @@word modifier, D10V
  215. Any symbol followed by @code{@@word} will be replaced by the symbol's value
  216. shifted right by 2. This is used in situations such as loading a register
  217. with the address of a function (or any other code fragment). For example, if
  218. you want to load a register with the location of the function @code{main} then
  219. jump to that function, you could do it as follows:
  220. @smallexample
  221. @group
  222. ldi r2, main@@word
  223. jmp r2
  224. @end group
  225. @end smallexample
  226. @node D10V-Float
  227. @section Floating Point
  228. @cindex floating point, D10V
  229. @cindex D10V floating point
  230. The D10V has no hardware floating point, but the @code{.float} and @code{.double}
  231. directives generates @sc{ieee} floating-point numbers for compatibility
  232. with other development tools.
  233. @node D10V-Opcodes
  234. @section Opcodes
  235. @cindex D10V opcode summary
  236. @cindex opcode summary, D10V
  237. @cindex mnemonics, D10V
  238. @cindex instruction summary, D10V
  239. For detailed information on the D10V machine instruction set, see
  240. @cite{D10V Architecture: A VLIW Microprocessor for Multimedia Applications}
  241. (Mitsubishi Electric Corp.).
  242. @code{@value{AS}} implements all the standard D10V opcodes. The only changes are those
  243. described in the section on size modifiers