xref: /openbsd-src/gnu/usr.bin/binutils-2.17/gas/doc/c-m32r.texi (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod@c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2*3d8817e4Smiod@c 2000, 2003, 2004
3*3d8817e4Smiod@c Free Software Foundation, Inc.
4*3d8817e4Smiod@c This is part of the GAS manual.
5*3d8817e4Smiod@c For copying conditions, see the file as.texinfo.
6*3d8817e4Smiod@ifset GENERIC
7*3d8817e4Smiod@page
8*3d8817e4Smiod@node M32R-Dependent
9*3d8817e4Smiod@chapter M32R Dependent Features
10*3d8817e4Smiod@end ifset
11*3d8817e4Smiod@ifclear GENERIC
12*3d8817e4Smiod@node Machine Dependencies
13*3d8817e4Smiod@chapter M32R Dependent Features
14*3d8817e4Smiod@end ifclear
15*3d8817e4Smiod
16*3d8817e4Smiod@cindex M32R support
17*3d8817e4Smiod@menu
18*3d8817e4Smiod* M32R-Opts::                   M32R Options
19*3d8817e4Smiod* M32R-Directives::             M32R Directives
20*3d8817e4Smiod* M32R-Warnings::               M32R Warnings
21*3d8817e4Smiod@end menu
22*3d8817e4Smiod
23*3d8817e4Smiod@node M32R-Opts
24*3d8817e4Smiod@section M32R Options
25*3d8817e4Smiod
26*3d8817e4Smiod@cindex options, M32R
27*3d8817e4Smiod@cindex M32R options
28*3d8817e4Smiod
29*3d8817e4SmiodThe Renease M32R version of @code{@value{AS}} has a few machine
30*3d8817e4Smioddependent options:
31*3d8817e4Smiod
32*3d8817e4Smiod@table @code
33*3d8817e4Smiod
34*3d8817e4Smiod@item -m32rx
35*3d8817e4Smiod@cindex @samp{-m32rx} option, M32RX
36*3d8817e4Smiod@cindex architecture options, M32RX
37*3d8817e4Smiod@cindex M32R architecture options
38*3d8817e4Smiod@code{@value{AS}} can assemble code for several different members of the
39*3d8817e4SmiodRenesas M32R family.  Normally the default is to assemble code for
40*3d8817e4Smiodthe M32R microprocessor.  This option may be used to change the default
41*3d8817e4Smiodto the M32RX microprocessor, which adds some more instructions to the
42*3d8817e4Smiodbasic M32R instruction set, and some additional parameters to some of
43*3d8817e4Smiodthe original instructions.
44*3d8817e4Smiod
45*3d8817e4Smiod@item -m32r2
46*3d8817e4Smiod@cindex @samp{-m32rx} option, M32R2
47*3d8817e4Smiod@cindex architecture options, M32R2
48*3d8817e4Smiod@cindex M32R architecture options
49*3d8817e4SmiodThis option changes the target processor to the the M32R2
50*3d8817e4Smiodmicroprocessor.
51*3d8817e4Smiod
52*3d8817e4Smiod@item -m32r
53*3d8817e4Smiod@cindex @samp{-m32r} option, M32R
54*3d8817e4Smiod@cindex architecture options, M32R
55*3d8817e4Smiod@cindex M32R architecture options
56*3d8817e4SmiodThis option can be used to restore the assembler's default behaviour of
57*3d8817e4Smiodassembling for the M32R microprocessor.  This can be useful if the
58*3d8817e4Smioddefault has been changed by a previous command line option.
59*3d8817e4Smiod
60*3d8817e4Smiod@item -little
61*3d8817e4Smiod@cindex @code{-little} option, M32R
62*3d8817e4SmiodThis option tells the assembler to produce little-endian code and
63*3d8817e4Smioddata.  The default is dependent upon how the toolchain was
64*3d8817e4Smiodconfigured.
65*3d8817e4Smiod
66*3d8817e4Smiod@item -EL
67*3d8817e4Smiod@cindex @code{-EL} option, M32R
68*3d8817e4SmiodThis is a synonum for @emph{-little}.
69*3d8817e4Smiod
70*3d8817e4Smiod@item -big
71*3d8817e4Smiod@cindex @code{-big} option, M32R
72*3d8817e4SmiodThis option tells the assembler to produce big-endian code and
73*3d8817e4Smioddata.
74*3d8817e4Smiod
75*3d8817e4Smiod@item -EB
76*3d8817e4Smiod@cindex @code{-EB} option, M32R
77*3d8817e4SmiodThis is a synonum for @emph{-big}.
78*3d8817e4Smiod
79*3d8817e4Smiod@item -KPIC
80*3d8817e4Smiod@cindex @code{-KPIC} option, M32R
81*3d8817e4Smiod@cindex PIC code generation for M32R
82*3d8817e4SmiodThis option specifies that the output of the assembler should be
83*3d8817e4Smiodmarked as position-independent code (PIC).
84*3d8817e4Smiod
85*3d8817e4Smiod@item -parallel
86*3d8817e4Smiod@cindex @code{-parallel} option, M32RX
87*3d8817e4SmiodThis option tells the assembler to attempts to combine two sequential
88*3d8817e4Smiodinstructions into a single, parallel instruction, where it is legal to
89*3d8817e4Smioddo so.
90*3d8817e4Smiod
91*3d8817e4Smiod@item -no-parallel
92*3d8817e4Smiod@cindex @code{-no-parallel} option, M32RX
93*3d8817e4SmiodThis option disables a previously enabled @emph{-parallel} option.
94*3d8817e4Smiod
95*3d8817e4Smiod@item -no-bitinst
96*3d8817e4Smiod@cindex @samp{-no-bitinst}, M32R2
97*3d8817e4SmiodThis option disables the support for the extended bit-field
98*3d8817e4Smiodinstructions provided by the M32R2.  If this support needs to be
99*3d8817e4Smiodre-enabled the @emph{-bitinst} switch can be used to restore it.
100*3d8817e4Smiod
101*3d8817e4Smiod@item -O
102*3d8817e4Smiod@cindex @code{-O} option, M32RX
103*3d8817e4SmiodThis option tells the assembler to attempt to optimize the
104*3d8817e4Smiodinstructions that it produces.  This includes filling delay slots and
105*3d8817e4Smiodconverting sequential instructions into parallel ones.  This option
106*3d8817e4Smiodimplies @emph{-parallel}.
107*3d8817e4Smiod
108*3d8817e4Smiod@item -warn-explicit-parallel-conflicts
109*3d8817e4Smiod@cindex @samp{-warn-explicit-parallel-conflicts} option, M32RX
110*3d8817e4SmiodInstructs @code{@value{AS}} to produce warning messages when
111*3d8817e4Smiodquestionable parallel instructions are encountered.  This option is
112*3d8817e4Smiodenabled by default, but @code{@value{GCC}} disables it when it invokes
113*3d8817e4Smiod@code{@value{AS}} directly.  Questionable instructions are those whoes
114*3d8817e4Smiodbehaviour would be different if they were executed sequentially.  For
115*3d8817e4Smiodexample the code fragment @samp{mv r1, r2 || mv r3, r1} produces a
116*3d8817e4Smioddifferent result from @samp{mv r1, r2 \n mv r3, r1} since the former
117*3d8817e4Smiodmoves r1 into r3 and then r2 into r1, whereas the later moves r2 into r1
118*3d8817e4Smiodand r3.
119*3d8817e4Smiod
120*3d8817e4Smiod@item -Wp
121*3d8817e4Smiod@cindex @samp{-Wp} option, M32RX
122*3d8817e4SmiodThis is a shorter synonym for the @emph{-warn-explicit-parallel-conflicts}
123*3d8817e4Smiodoption.
124*3d8817e4Smiod
125*3d8817e4Smiod@item -no-warn-explicit-parallel-conflicts
126*3d8817e4Smiod@cindex @samp{-no-warn-explicit-parallel-conflicts} option, M32RX
127*3d8817e4SmiodInstructs @code{@value{AS}} not to produce warning messages when
128*3d8817e4Smiodquestionable parallel instructions are encountered.
129*3d8817e4Smiod
130*3d8817e4Smiod@item -Wnp
131*3d8817e4Smiod@cindex @samp{-Wnp} option, M32RX
132*3d8817e4SmiodThis is a shorter synonym for the @emph{-no-warn-explicit-parallel-conflicts}
133*3d8817e4Smiodoption.
134*3d8817e4Smiod
135*3d8817e4Smiod@item -ignore-parallel-conflicts
136*3d8817e4Smiod@cindex @samp{-ignore-parallel-conflicts} option, M32RX
137*3d8817e4SmiodThis option tells the assembler's to stop checking parallel
138*3d8817e4Smiodinstructions for contraint violations.  This ability is provided for
139*3d8817e4Smiodhardware vendors testing chip designs and should not be used under
140*3d8817e4Smiodnormal circumstances.
141*3d8817e4Smiod
142*3d8817e4Smiod@item -no-ignore-parallel-conflicts
143*3d8817e4Smiod@cindex @samp{-no-ignore-parallel-conflicts} option, M32RX
144*3d8817e4SmiodThis option restores the assembler's default behaviour of checking
145*3d8817e4Smiodparallel instructions to detect constraint violations.
146*3d8817e4Smiod
147*3d8817e4Smiod@item -Ip
148*3d8817e4Smiod@cindex @samp{-Ip} option, M32RX
149*3d8817e4SmiodThis is a shorter synonym for the @emph{-ignore-parallel-conflicts}
150*3d8817e4Smiodoption.
151*3d8817e4Smiod
152*3d8817e4Smiod@item -nIp
153*3d8817e4Smiod@cindex @samp{-nIp} option, M32RX
154*3d8817e4SmiodThis is a shorter synonym for the @emph{-no-ignore-parallel-conflicts}
155*3d8817e4Smiodoption.
156*3d8817e4Smiod
157*3d8817e4Smiod@item -warn-unmatched-high
158*3d8817e4Smiod@cindex @samp{-warn-unmatched-high} option, M32R
159*3d8817e4SmiodThis option tells the assembler to produce a warning message if a
160*3d8817e4Smiod@code{.high} pseudo op is encountered without a mathcing @code{.low}
161*3d8817e4Smiodpseudo op.  The presence of such an unmatches pseudo op usually
162*3d8817e4Smiodindicates a programming error.
163*3d8817e4Smiod
164*3d8817e4Smiod@item -no-warn-unmatched-high
165*3d8817e4Smiod@cindex @samp{-no-warn-unmatched-high} option, M32R
166*3d8817e4SmiodDisables a previously enabled @emph{-warn-unmatched-high} option.
167*3d8817e4Smiod
168*3d8817e4Smiod@item -Wuh
169*3d8817e4Smiod@cindex @samp{-Wuh} option, M32RX
170*3d8817e4SmiodThis is a shorter synonym for the @emph{-warn-unmatched-high} option.
171*3d8817e4Smiod
172*3d8817e4Smiod@item -Wnuh
173*3d8817e4Smiod@cindex @samp{-Wnuh} option, M32RX
174*3d8817e4SmiodThis is a shorter synonym for the @emph{-no-warn-unmatched-high} option.
175*3d8817e4Smiod
176*3d8817e4Smiod@end table
177*3d8817e4Smiod
178*3d8817e4Smiod@node M32R-Directives
179*3d8817e4Smiod@section M32R Directives
180*3d8817e4Smiod@cindex directives, M32R
181*3d8817e4Smiod@cindex M32R directives
182*3d8817e4Smiod
183*3d8817e4SmiodThe Renease M32R version of @code{@value{AS}} has a few architecture
184*3d8817e4Smiodspecific directives:
185*3d8817e4Smiod
186*3d8817e4Smiod@table @code
187*3d8817e4Smiod
188*3d8817e4Smiod@cindex @code{low} directive, M32R
189*3d8817e4Smiod@item low @var{expression}
190*3d8817e4SmiodThe @code{low} directive computes the value of its expression and
191*3d8817e4Smiodplaces the lower 16-bits of the result into the immediate-field of the
192*3d8817e4Smiodinstruction.  For example:
193*3d8817e4Smiod
194*3d8817e4Smiod@smallexample
195*3d8817e4Smiod   or3   r0, r0, #low(0x12345678) ; compute r0 = r0 | 0x5678
196*3d8817e4Smiod   add3, r0, r0, #low(fred)   ; compute r0 = r0 + low 16-bits of address of fred
197*3d8817e4Smiod@end smallexample
198*3d8817e4Smiod
199*3d8817e4Smiod@item high @var{expression}
200*3d8817e4Smiod@cindex @code{high} directive, M32R
201*3d8817e4SmiodThe @code{high} directive computes the value of its expression and
202*3d8817e4Smiodplaces the upper 16-bits of the result into the immediate-field of the
203*3d8817e4Smiodinstruction.  For example:
204*3d8817e4Smiod
205*3d8817e4Smiod@smallexample
206*3d8817e4Smiod   seth  r0, #high(0x12345678) ; compute r0 = 0x12340000
207*3d8817e4Smiod   seth, r0, #high(fred)       ; compute r0 = upper 16-bits of address of fred
208*3d8817e4Smiod@end smallexample
209*3d8817e4Smiod
210*3d8817e4Smiod@item shigh @var{expression}
211*3d8817e4Smiod@cindex @code{shigh} directive, M32R
212*3d8817e4SmiodThe @code{shigh} directive is very similar to the @code{high}
213*3d8817e4Smioddirective.  It also computes the value of its expression and places
214*3d8817e4Smiodthe upper 16-bits of the result into the immediate-field of the
215*3d8817e4Smiodinstruction.  The difference is that @code{shigh} also checks to see
216*3d8817e4Smiodif the lower 16-bits could be interpreted as a signed number, and if
217*3d8817e4Smiodso it assumes that a borrow will occur from the upper-16 bits.  To
218*3d8817e4Smiodcompensate for this the @code{shigh} directive pre-biases the upper
219*3d8817e4Smiod16 bit value by adding one to it.  For example:
220*3d8817e4Smiod
221*3d8817e4SmiodFor example:
222*3d8817e4Smiod
223*3d8817e4Smiod@smallexample
224*3d8817e4Smiod   seth  r0, #shigh(0x12345678) ; compute r0 = 0x12340000
225*3d8817e4Smiod   seth  r0, #shigh(0x00008000) ; compute r0 = 0x00010000
226*3d8817e4Smiod@end smallexample
227*3d8817e4Smiod
228*3d8817e4SmiodIn the second example the lower 16-bits are 0x8000.  If these are
229*3d8817e4Smiodtreated as a signed value and sign extended to 32-bits then the value
230*3d8817e4Smiodbecomes 0xffff8000.  If this value is then added to 0x00010000 then
231*3d8817e4Smiodthe result is 0x00008000.
232*3d8817e4Smiod
233*3d8817e4SmiodThis behaviour is to allow for the different semantics of the
234*3d8817e4Smiod@code{or3} and @code{add3} instructions.  The @code{or3} instruction
235*3d8817e4Smiodtreats its 16-bit immediate argument as unsigned whereas the
236*3d8817e4Smiod@code{add3} treats its 16-bit immediate as a signed value.  So for
237*3d8817e4Smiodexample:
238*3d8817e4Smiod
239*3d8817e4Smiod@smallexample
240*3d8817e4Smiod   seth  r0, #shigh(0x00008000)
241*3d8817e4Smiod   add3  r0, r0, #low(0x00008000)
242*3d8817e4Smiod@end smallexample
243*3d8817e4Smiod
244*3d8817e4SmiodProduces the correct result in r0, whereas:
245*3d8817e4Smiod
246*3d8817e4Smiod@smallexample
247*3d8817e4Smiod   seth  r0, #shigh(0x00008000)
248*3d8817e4Smiod   or3   r0, r0, #low(0x00008000)
249*3d8817e4Smiod@end smallexample
250*3d8817e4Smiod
251*3d8817e4SmiodStores 0xffff8000 into r0.
252*3d8817e4Smiod
253*3d8817e4SmiodNote - the @code{shigh} directive does not know where in the assembly
254*3d8817e4Smiodsource code the lower 16-bits of the value are going set, so it cannot
255*3d8817e4Smiodcheck to make sure that an @code{or3} instruction is being used rather
256*3d8817e4Smiodthan an @code{add3} instruction.  It is up to the programmer to make
257*3d8817e4Smiodsure that correct directives are used.
258*3d8817e4Smiod
259*3d8817e4Smiod@cindex @code{.m32r} directive, M32R
260*3d8817e4Smiod@item .m32r
261*3d8817e4SmiodThe directive performs a similar thing as the @emph{-m32r} command
262*3d8817e4Smiodline option.  It tells the assembler to only accept M32R instructions
263*3d8817e4Smiodfrom now on.  An instructions from later M32R architectures are
264*3d8817e4Smiodrefused.
265*3d8817e4Smiod
266*3d8817e4Smiod@cindex @code{.m32rx} directive, M32RX
267*3d8817e4Smiod@item .m32rx
268*3d8817e4SmiodThe directive performs a similar thing as the @emph{-m32rx} command
269*3d8817e4Smiodline option.  It tells the assembler to start accepting the extra
270*3d8817e4Smiodinstructions in the M32RX ISA as well as the ordinary M32R ISA.
271*3d8817e4Smiod
272*3d8817e4Smiod@cindex @code{.m32r2} directive, M32R2
273*3d8817e4Smiod@item .m32r2
274*3d8817e4SmiodThe directive performs a similar thing as the @emph{-m32r2} command
275*3d8817e4Smiodline option.  It tells the assembler to start accepting the extra
276*3d8817e4Smiodinstructions in the M32R2 ISA as well as the ordinary M32R ISA.
277*3d8817e4Smiod
278*3d8817e4Smiod@cindex @code{.little} directive, M32RX
279*3d8817e4Smiod@item .little
280*3d8817e4SmiodThe directive performs a similar thing as the @emph{-little} command
281*3d8817e4Smiodline option.  It tells the assembler to start producing little-endian
282*3d8817e4Smiodcode and data.  This option should be used with care as producing
283*3d8817e4Smiodmixed-endian binary files is frought with danger.
284*3d8817e4Smiod
285*3d8817e4Smiod@cindex @code{.big} directive, M32RX
286*3d8817e4Smiod@item .big
287*3d8817e4SmiodThe directive performs a similar thing as the @emph{-big} command
288*3d8817e4Smiodline option.  It tells the assembler to start producing big-endian
289*3d8817e4Smiodcode and data.  This option should be used with care as producing
290*3d8817e4Smiodmixed-endian binary files is frought with danger.
291*3d8817e4Smiod
292*3d8817e4Smiod@end table
293*3d8817e4Smiod
294*3d8817e4Smiod@node M32R-Warnings
295*3d8817e4Smiod@section M32R Warnings
296*3d8817e4Smiod
297*3d8817e4Smiod@cindex warnings, M32R
298*3d8817e4Smiod@cindex M32R warnings
299*3d8817e4Smiod
300*3d8817e4SmiodThere are several warning and error messages that can be produced by
301*3d8817e4Smiod@code{@value{AS}} which are specific to the M32R:
302*3d8817e4Smiod
303*3d8817e4Smiod@table @code
304*3d8817e4Smiod
305*3d8817e4Smiod@item output of 1st instruction is the same as an input to 2nd instruction - is this intentional ?
306*3d8817e4SmiodThis message is only produced if warnings for explicit parallel
307*3d8817e4Smiodconflicts have been enabled.  It indicates that the assembler has
308*3d8817e4Smiodencountered a parallel instruction in which the destination register of
309*3d8817e4Smiodthe left hand instruction is used as an input register in the right hand
310*3d8817e4Smiodinstruction.  For example in this code fragment
311*3d8817e4Smiod@samp{mv r1, r2 || neg r3, r1} register r1 is the destination of the
312*3d8817e4Smiodmove instruction and the input to the neg instruction.
313*3d8817e4Smiod
314*3d8817e4Smiod@item output of 2nd instruction is the same as an input to 1st instruction - is this intentional ?
315*3d8817e4SmiodThis message is only produced if warnings for explicit parallel
316*3d8817e4Smiodconflicts have been enabled.  It indicates that the assembler has
317*3d8817e4Smiodencountered a parallel instruction in which the destination register of
318*3d8817e4Smiodthe right hand instruction is used as an input register in the left hand
319*3d8817e4Smiodinstruction.  For example in this code fragment
320*3d8817e4Smiod@samp{mv r1, r2 || neg r2, r3} register r2 is the destination of the
321*3d8817e4Smiodneg instruction and the input to the move instruction.
322*3d8817e4Smiod
323*3d8817e4Smiod@item instruction @samp{...} is for the M32RX only
324*3d8817e4SmiodThis message is produced when the assembler encounters an instruction
325*3d8817e4Smiodwhich is only supported by the M32Rx processor, and the @samp{-m32rx}
326*3d8817e4Smiodcommand line flag has not been specified to allow assembly of such
327*3d8817e4Smiodinstructions.
328*3d8817e4Smiod
329*3d8817e4Smiod@item unknown instruction @samp{...}
330*3d8817e4SmiodThis message is produced when the assembler encounters an instruction
331*3d8817e4Smiodwhich it does not recognise.
332*3d8817e4Smiod
333*3d8817e4Smiod@item only the NOP instruction can be issued in parallel on the m32r
334*3d8817e4SmiodThis message is produced when the assembler encounters a parallel
335*3d8817e4Smiodinstruction which does not involve a NOP instruction and the
336*3d8817e4Smiod@samp{-m32rx} command line flag has not been specified.  Only the M32Rx
337*3d8817e4Smiodprocessor is able to execute two instructions in parallel.
338*3d8817e4Smiod
339*3d8817e4Smiod@item instruction @samp{...} cannot be executed in parallel.
340*3d8817e4SmiodThis message is produced when the assembler encounters a parallel
341*3d8817e4Smiodinstruction which is made up of one or two instructions which cannot be
342*3d8817e4Smiodexecuted in parallel.
343*3d8817e4Smiod
344*3d8817e4Smiod@item Instructions share the same execution pipeline
345*3d8817e4SmiodThis message is produced when the assembler encounters a parallel
346*3d8817e4Smiodinstruction whoes components both use the same execution pipeline.
347*3d8817e4Smiod
348*3d8817e4Smiod@item Instructions write to the same destination register.
349*3d8817e4SmiodThis message is produced when the assembler encounters a parallel
350*3d8817e4Smiodinstruction where both components attempt to modify the same register.
351*3d8817e4SmiodFor example these code fragments will produce this message:
352*3d8817e4Smiod@samp{mv r1, r2 || neg r1, r3}
353*3d8817e4Smiod@samp{jl r0 || mv r14, r1}
354*3d8817e4Smiod@samp{st r2, @@-r1 || mv r1, r3}
355*3d8817e4Smiod@samp{mv r1, r2 || ld r0, @@r1+}
356*3d8817e4Smiod@samp{cmp r1, r2 || addx r3, r4} (Both write to the condition bit)
357*3d8817e4Smiod
358*3d8817e4Smiod@end table
359