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