xref: /dflybsd-src/contrib/binutils-2.27/gas/doc/c-msp430.texi (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj@c Copyright (C) 2002-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 MSP430-Dependent
7*a9fa9459Szrj@chapter MSP 430 Dependent Features
8*a9fa9459Szrj@end ifset
9*a9fa9459Szrj@ifclear GENERIC
10*a9fa9459Szrj@node Machine Dependencies
11*a9fa9459Szrj@chapter MSP 430 Dependent Features
12*a9fa9459Szrj@end ifclear
13*a9fa9459Szrj
14*a9fa9459Szrj@cindex MSP 430 support
15*a9fa9459Szrj@cindex 430 support
16*a9fa9459Szrj@menu
17*a9fa9459Szrj* MSP430 Options::              Options
18*a9fa9459Szrj* MSP430 Syntax::               Syntax
19*a9fa9459Szrj* MSP430 Floating Point::       Floating Point
20*a9fa9459Szrj* MSP430 Directives::           MSP 430 Machine Directives
21*a9fa9459Szrj* MSP430 Opcodes::              Opcodes
22*a9fa9459Szrj* MSP430 Profiling Capability::	Profiling Capability
23*a9fa9459Szrj@end menu
24*a9fa9459Szrj
25*a9fa9459Szrj@node MSP430 Options
26*a9fa9459Szrj@section Options
27*a9fa9459Szrj@cindex MSP 430 options (none)
28*a9fa9459Szrj@cindex options for MSP430 (none)
29*a9fa9459Szrj@table @code
30*a9fa9459Szrj
31*a9fa9459Szrj@item -mmcu
32*a9fa9459Szrjselects the mcu architecture.  If the architecture is 430Xv2 then this
33*a9fa9459Szrjalso enables NOP generation unless the @option{-mN} is also specified.
34*a9fa9459Szrj
35*a9fa9459Szrj@item -mcpu
36*a9fa9459Szrjselects the cpu architecture.  If the architecture is 430Xv2 then this
37*a9fa9459Szrjalso enables NOP generation unless the @option{-mN} is also specified.
38*a9fa9459Szrj
39*a9fa9459Szrj@item -msilicon-errata=@var{name}[,@var{name}@dots{}]
40*a9fa9459SzrjImplements a fixup for named silicon errata.  Multiple silicon errata
41*a9fa9459Szrjcan be specified by multiple uses of the @option{-msilicon-errata}
42*a9fa9459Szrjoption and/or by including the errata names, separated by commas, on
43*a9fa9459Szrjan individual @option{-msilicon-errata} option.  Errata names
44*a9fa9459Szrjcurrently recognised by the assembler are:
45*a9fa9459Szrj
46*a9fa9459Szrj@table @code
47*a9fa9459Szrj@item cpu4
48*a9fa9459Szrj@code{PUSH #4} and @option{PUSH #8} need longer encodings on the
49*a9fa9459SzrjMSP430.  This option is enabled by default, and cannot be disabled.
50*a9fa9459Szrj@item cpu8
51*a9fa9459SzrjDo not set the @code{SP} to an odd value.
52*a9fa9459Szrj@item cpu11
53*a9fa9459SzrjDo not update the @code{SR} and the @code{PC} in the same instruction.
54*a9fa9459Szrj@item cpu12
55*a9fa9459SzrjDo not use the @code{PC} in a @code{CMP} or @code{BIT} instruction.
56*a9fa9459Szrj@item cpu13
57*a9fa9459SzrjDo not use an arithmetic instruction to modify the @code{SR}.
58*a9fa9459Szrj@item cpu19
59*a9fa9459SzrjInsert @code{NOP} after @code{CPUOFF}.
60*a9fa9459Szrj@end table
61*a9fa9459Szrj
62*a9fa9459Szrj@item -msilicon-errata-warn=@var{name}[,@var{name}@dots{}]
63*a9fa9459SzrjLike the @option{-msilicon-errata} option except that instead of
64*a9fa9459Szrjfixing the specified errata, a warning message is issued instead.
65*a9fa9459SzrjThis option can be used alongside @option{-msilicon-errata} to
66*a9fa9459Szrjgenerate messages whenever a problem is fixed, or on its own in order
67*a9fa9459Szrjto inspect code for potential problems.
68*a9fa9459Szrj
69*a9fa9459Szrj@item -mP
70*a9fa9459Szrjenables polymorph instructions handler.
71*a9fa9459Szrj
72*a9fa9459Szrj@item -mQ
73*a9fa9459Szrjenables relaxation at assembly time. DANGEROUS!
74*a9fa9459Szrj
75*a9fa9459Szrj@item -ml
76*a9fa9459Szrjindicates that the input uses the large code model.
77*a9fa9459Szrj
78*a9fa9459Szrj@item -mn
79*a9fa9459Szrjenables the generation of a NOP instruction following any instruction
80*a9fa9459Szrjthat might change the interrupts enabled/disabled state.  The
81*a9fa9459Szrjpipelined nature of the MSP430 core means that any instruction that
82*a9fa9459Szrjchanges the interrupt state (@code{EINT}, @code{DINT}, @code{BIC #8,
83*a9fa9459SzrjSR}, @code{BIS #8, SR} or @code{MOV.W <>, SR}) must be
84*a9fa9459Szrjfollowed by a NOP instruction in order to ensure the correct
85*a9fa9459Szrjprocessing of interrupts.  By default it is up to the programmer to
86*a9fa9459Szrjsupply these NOP instructions, but this command line option enables
87*a9fa9459Szrjthe automatic insertion by the assembler, if they are missing.
88*a9fa9459Szrj
89*a9fa9459Szrj@item -mN
90*a9fa9459Szrjdisables the generation of a NOP instruction following any instruction
91*a9fa9459Szrjthat might change the interrupts enabled/disabled state.  This is the
92*a9fa9459Szrjdefault behaviour.
93*a9fa9459Szrj
94*a9fa9459Szrj@item -my
95*a9fa9459Szrjtells the assembler to generate a warning message if a NOP does not
96*a9fa9459Szrjimmediately forllow an instruction that enables or disables
97*a9fa9459Szrjinterrupts.  This is the default.
98*a9fa9459Szrj
99*a9fa9459SzrjNote that this option can be stacked with the @option{-mn} option so
100*a9fa9459Szrjthat the assembler will both warn about missing NOP instructions and
101*a9fa9459Szrjthen insert them automatically.
102*a9fa9459Szrj
103*a9fa9459Szrj@item -mY
104*a9fa9459Szrjdisables warnings about missing NOP instructions.
105*a9fa9459Szrj
106*a9fa9459Szrj@item -md
107*a9fa9459Szrjmark the object file as one that requires data to copied from ROM to
108*a9fa9459SzrjRAM at execution startup.  Disabled by default.
109*a9fa9459Szrj
110*a9fa9459Szrj@end table
111*a9fa9459Szrj
112*a9fa9459Szrj@node MSP430 Syntax
113*a9fa9459Szrj@section Syntax
114*a9fa9459Szrj@menu
115*a9fa9459Szrj* MSP430-Macros::		Macros
116*a9fa9459Szrj* MSP430-Chars::                Special Characters
117*a9fa9459Szrj* MSP430-Regs::                 Register Names
118*a9fa9459Szrj* MSP430-Ext::			Assembler Extensions
119*a9fa9459Szrj@end menu
120*a9fa9459Szrj
121*a9fa9459Szrj@node MSP430-Macros
122*a9fa9459Szrj@subsection Macros
123*a9fa9459Szrj
124*a9fa9459Szrj@cindex Macros, MSP 430
125*a9fa9459Szrj@cindex MSP 430 macros
126*a9fa9459SzrjThe macro syntax used on the MSP 430 is like that described in the MSP
127*a9fa9459Szrj430 Family Assembler Specification.  Normal @code{@value{AS}}
128*a9fa9459Szrjmacros should still work.
129*a9fa9459Szrj
130*a9fa9459SzrjAdditional built-in macros are:
131*a9fa9459Szrj
132*a9fa9459Szrj@table @code
133*a9fa9459Szrj
134*a9fa9459Szrj@item llo(exp)
135*a9fa9459SzrjExtracts least significant word from 32-bit expression 'exp'.
136*a9fa9459Szrj
137*a9fa9459Szrj@item lhi(exp)
138*a9fa9459SzrjExtracts most significant word from 32-bit expression 'exp'.
139*a9fa9459Szrj
140*a9fa9459Szrj@item hlo(exp)
141*a9fa9459SzrjExtracts 3rd word from 64-bit expression 'exp'.
142*a9fa9459Szrj
143*a9fa9459Szrj@item 	hhi(exp)
144*a9fa9459SzrjExtracts 4rd word from 64-bit expression 'exp'.
145*a9fa9459Szrj
146*a9fa9459Szrj@end table
147*a9fa9459Szrj
148*a9fa9459SzrjThey normally being used as an immediate source operand.
149*a9fa9459Szrj@smallexample
150*a9fa9459Szrj    mov	#llo(1), r10	;	== mov	#1, r10
151*a9fa9459Szrj    mov	#lhi(1), r10	;	== mov	#0, r10
152*a9fa9459Szrj@end smallexample
153*a9fa9459Szrj
154*a9fa9459Szrj@node MSP430-Chars
155*a9fa9459Szrj@subsection Special Characters
156*a9fa9459Szrj
157*a9fa9459Szrj@cindex line comment character, MSP 430
158*a9fa9459Szrj@cindex MSP 430 line comment character
159*a9fa9459SzrjA semicolon (@samp{;}) appearing anywhere on a line starts a comment
160*a9fa9459Szrjthat extends to the end of that line.
161*a9fa9459Szrj
162*a9fa9459SzrjIf a @samp{#} appears as the first character of a line then the whole
163*a9fa9459Szrjline is treated as a comment, but it can also be a logical line number
164*a9fa9459Szrjdirective (@pxref{Comments}) or a preprocessor control command
165*a9fa9459Szrj(@pxref{Preprocessing}).
166*a9fa9459Szrj
167*a9fa9459Szrj@cindex line separator, MSP 430
168*a9fa9459Szrj@cindex statement separator, MSP 430
169*a9fa9459Szrj@cindex MSP 430 line separator
170*a9fa9459SzrjMultiple statements can appear on the same line provided that they are
171*a9fa9459Szrjseparated by the @samp{@{} character.
172*a9fa9459Szrj
173*a9fa9459Szrj@cindex identifiers, MSP 430
174*a9fa9459Szrj@cindex MSP 430 identifiers
175*a9fa9459SzrjThe character @samp{$} in jump instructions indicates current location and
176*a9fa9459Szrjimplemented only for TI syntax compatibility.
177*a9fa9459Szrj
178*a9fa9459Szrj@node MSP430-Regs
179*a9fa9459Szrj@subsection Register Names
180*a9fa9459Szrj
181*a9fa9459Szrj@cindex MSP 430 register names
182*a9fa9459Szrj@cindex register names, MSP 430
183*a9fa9459SzrjGeneral-purpose registers are represented by predefined symbols of the
184*a9fa9459Szrjform @samp{r@var{N}} (for global registers), where @var{N} represents
185*a9fa9459Szrja number between @code{0} and @code{15}.  The leading
186*a9fa9459Szrjletters may be in either upper or lower case; for example, @samp{r13}
187*a9fa9459Szrjand @samp{R7} are both valid register names.
188*a9fa9459Szrj
189*a9fa9459Szrj@cindex special purpose registers, MSP 430
190*a9fa9459SzrjRegister names @samp{PC}, @samp{SP} and @samp{SR} cannot be used as register names
191*a9fa9459Szrjand will be treated as variables. Use @samp{r0}, @samp{r1}, and @samp{r2} instead.
192*a9fa9459Szrj
193*a9fa9459Szrj
194*a9fa9459Szrj@node MSP430-Ext
195*a9fa9459Szrj@subsection Assembler Extensions
196*a9fa9459Szrj@cindex MSP430 Assembler Extensions
197*a9fa9459Szrj
198*a9fa9459Szrj@table @code
199*a9fa9459Szrj
200*a9fa9459Szrj@item @@rN
201*a9fa9459SzrjAs destination operand being treated as @samp{0(rn)}
202*a9fa9459Szrj
203*a9fa9459Szrj@item 0(rN)
204*a9fa9459SzrjAs source operand being treated as @samp{@@rn}
205*a9fa9459Szrj
206*a9fa9459Szrj@item jCOND +N
207*a9fa9459SzrjSkips next N bytes followed by jump instruction and equivalent to
208*a9fa9459Szrj@samp{jCOND $+N+2}
209*a9fa9459Szrj
210*a9fa9459Szrj@end table
211*a9fa9459Szrj
212*a9fa9459SzrjAlso, there are some instructions, which cannot be found in other assemblers.
213*a9fa9459SzrjThese are branch instructions, which has different opcodes upon jump distance.
214*a9fa9459SzrjThey all got PC relative addressing mode.
215*a9fa9459Szrj
216*a9fa9459Szrj@table @code
217*a9fa9459Szrj@item	beq label
218*a9fa9459SzrjA polymorph instruction which is @samp{jeq label} in case if jump distance
219*a9fa9459Szrjwithin allowed range for cpu's jump instruction. If not, this unrolls into
220*a9fa9459Szrja sequence of
221*a9fa9459Szrj@smallexample
222*a9fa9459Szrj  jne $+6
223*a9fa9459Szrj  br  label
224*a9fa9459Szrj@end smallexample
225*a9fa9459Szrj
226*a9fa9459Szrj@item bne label
227*a9fa9459SzrjA polymorph instruction which is @samp{jne label} or @samp{jeq +4; br label}
228*a9fa9459Szrj
229*a9fa9459Szrj@item blt label
230*a9fa9459SzrjA polymorph instruction which is @samp{jl label} or @samp{jge +4; br label}
231*a9fa9459Szrj
232*a9fa9459Szrj@item bltn label
233*a9fa9459SzrjA polymorph instruction which is @samp{jn label} or @samp{jn +2; jmp +4; br label}
234*a9fa9459Szrj
235*a9fa9459Szrj@item bltu label
236*a9fa9459SzrjA polymorph instruction which is @samp{jlo label} or @samp{jhs +2; br label}
237*a9fa9459Szrj
238*a9fa9459Szrj@item bge label
239*a9fa9459SzrjA polymorph instruction which is @samp{jge label} or @samp{jl +4; br label}
240*a9fa9459Szrj
241*a9fa9459Szrj@item bgeu label
242*a9fa9459SzrjA polymorph instruction which is @samp{jhs label} or @samp{jlo +4; br label}
243*a9fa9459Szrj
244*a9fa9459Szrj@item bgt label
245*a9fa9459SzrjA polymorph instruction which is @samp{jeq +2; jge label} or @samp{jeq +6; jl  +4; br label}
246*a9fa9459Szrj
247*a9fa9459Szrj@item bgtu label
248*a9fa9459SzrjA polymorph instruction which is @samp{jeq +2; jhs label} or @samp{jeq +6; jlo +4; br label}
249*a9fa9459Szrj
250*a9fa9459Szrj@item bleu label
251*a9fa9459SzrjA polymorph instruction which is @samp{jeq label; jlo label} or @samp{jeq +2; jhs +4; br label}
252*a9fa9459Szrj
253*a9fa9459Szrj@item ble label
254*a9fa9459SzrjA polymorph instruction which is @samp{jeq label; jl  label} or @samp{jeq +2; jge +4; br label}
255*a9fa9459Szrj
256*a9fa9459Szrj@item jump label
257*a9fa9459SzrjA polymorph instruction which is @samp{jmp label} or @samp{br label}
258*a9fa9459Szrj@end table
259*a9fa9459Szrj
260*a9fa9459Szrj
261*a9fa9459Szrj@node MSP430 Floating Point
262*a9fa9459Szrj@section Floating Point
263*a9fa9459Szrj
264*a9fa9459Szrj@cindex floating point, MSP 430 (@sc{ieee})
265*a9fa9459Szrj@cindex MSP 430 floating point (@sc{ieee})
266*a9fa9459SzrjThe MSP 430 family uses @sc{ieee} 32-bit floating-point numbers.
267*a9fa9459Szrj
268*a9fa9459Szrj@node MSP430 Directives
269*a9fa9459Szrj@section MSP 430 Machine Directives
270*a9fa9459Szrj
271*a9fa9459Szrj@cindex machine directives, MSP 430
272*a9fa9459Szrj@cindex MSP 430 machine directives
273*a9fa9459Szrj@table @code
274*a9fa9459Szrj@cindex @code{file} directive, MSP 430
275*a9fa9459Szrj@item .file
276*a9fa9459SzrjThis directive is ignored; it is accepted for compatibility with other
277*a9fa9459SzrjMSP 430 assemblers.
278*a9fa9459Szrj
279*a9fa9459Szrj@quotation
280*a9fa9459Szrj@emph{Warning:} in other versions of the @sc{gnu} assembler, @code{.file} is
281*a9fa9459Szrjused for the directive called @code{.app-file} in the MSP 430 support.
282*a9fa9459Szrj@end quotation
283*a9fa9459Szrj
284*a9fa9459Szrj@cindex @code{line} directive, MSP 430
285*a9fa9459Szrj@item .line
286*a9fa9459SzrjThis directive is ignored; it is accepted for compatibility with other
287*a9fa9459SzrjMSP 430 assemblers.
288*a9fa9459Szrj
289*a9fa9459Szrj@cindex @code{arch} directive, MSP 430
290*a9fa9459Szrj@item .arch
291*a9fa9459SzrjSets the target microcontroller in the same way as the @option{-mmcu}
292*a9fa9459Szrjcommand line option.
293*a9fa9459Szrj
294*a9fa9459Szrj@cindex @code{cpu} directive, MSP 430
295*a9fa9459Szrj@item .cpu
296*a9fa9459SzrjSets the target architecture in the same way as the @option{-mcpu}
297*a9fa9459Szrjcommand line option.
298*a9fa9459Szrj
299*a9fa9459Szrj@cindex @code{profiler} directive, MSP 430
300*a9fa9459Szrj@item .profiler
301*a9fa9459SzrjThis directive instructs assembler to add new profile entry to the object file.
302*a9fa9459Szrj
303*a9fa9459Szrj@cindex @code{refsym} directive, MSP 430
304*a9fa9459Szrj@item .refsym
305*a9fa9459SzrjThis directive instructs assembler to add an undefined reference to
306*a9fa9459Szrjthe symbol following the directive.  The maximum symbol name length is
307*a9fa9459Szrj1023 characters.  No relocation is created for this symbol; it will
308*a9fa9459Szrjexist purely for pulling in object files from archives.  Note that
309*a9fa9459Szrjthis reloc is not sufficient to prevent garbage collection; use a
310*a9fa9459SzrjKEEP() directive in the linker file to preserve such objects.
311*a9fa9459Szrj
312*a9fa9459Szrj@end table
313*a9fa9459Szrj
314*a9fa9459Szrj@node MSP430 Opcodes
315*a9fa9459Szrj@section Opcodes
316*a9fa9459Szrj
317*a9fa9459Szrj@cindex MSP 430 opcodes
318*a9fa9459Szrj@cindex opcodes for MSP 430
319*a9fa9459Szrj@code{@value{AS}} implements all the standard MSP 430 opcodes.  No
320*a9fa9459Szrjadditional pseudo-instructions are needed on this family.
321*a9fa9459Szrj
322*a9fa9459SzrjFor information on the 430 machine instruction set, see @cite{MSP430
323*a9fa9459SzrjUser's Manual, document slau049d}, Texas Instrument, Inc.
324*a9fa9459Szrj
325*a9fa9459Szrj@node MSP430 Profiling Capability
326*a9fa9459Szrj@section Profiling Capability
327*a9fa9459Szrj
328*a9fa9459Szrj@cindex MSP 430 profiling capability
329*a9fa9459Szrj@cindex profiling capability for MSP 430
330*a9fa9459SzrjIt is a performance hit to use gcc's profiling approach for this tiny target.
331*a9fa9459SzrjEven more -- jtag hardware facility does not perform any profiling functions.
332*a9fa9459SzrjHowever we've got gdb's built-in simulator where we can do anything.
333*a9fa9459Szrj
334*a9fa9459SzrjWe define new section @samp{.profiler} which holds all profiling information.
335*a9fa9459SzrjWe define new pseudo operation @samp{.profiler} which will instruct assembler to
336*a9fa9459Szrjadd new profile entry to the object file. Profile should take place at the
337*a9fa9459Szrjpresent address.
338*a9fa9459Szrj
339*a9fa9459SzrjPseudo operation format:
340*a9fa9459Szrj
341*a9fa9459Szrj@samp{.profiler flags,function_to_profile [, cycle_corrector, extra]}
342*a9fa9459Szrj
343*a9fa9459Szrj
344*a9fa9459Szrjwhere:
345*a9fa9459Szrj
346*a9fa9459Szrj@table @code
347*a9fa9459Szrj
348*a9fa9459Szrj@table @code
349*a9fa9459Szrj
350*a9fa9459Szrj@samp{flags} is a combination of the following characters:
351*a9fa9459Szrj
352*a9fa9459Szrj@item  s
353*a9fa9459Szrjfunction entry
354*a9fa9459Szrj@item  x
355*a9fa9459Szrjfunction exit
356*a9fa9459Szrj@item  i
357*a9fa9459Szrjfunction is in init section
358*a9fa9459Szrj@item  f
359*a9fa9459Szrjfunction is in fini section
360*a9fa9459Szrj@item  l
361*a9fa9459Szrjlibrary call
362*a9fa9459Szrj@item  c
363*a9fa9459Szrjlibc standard call
364*a9fa9459Szrj@item  d
365*a9fa9459Szrjstack value demand
366*a9fa9459Szrj@item  I
367*a9fa9459Szrjinterrupt service routine
368*a9fa9459Szrj@item  P
369*a9fa9459Szrjprologue start
370*a9fa9459Szrj@item  p
371*a9fa9459Szrjprologue end
372*a9fa9459Szrj@item  E
373*a9fa9459Szrjepilogue start
374*a9fa9459Szrj@item  e
375*a9fa9459Szrjepilogue end
376*a9fa9459Szrj@item  j
377*a9fa9459Szrjlong jump / sjlj unwind
378*a9fa9459Szrj@item  a
379*a9fa9459Szrjan arbitrary code fragment
380*a9fa9459Szrj@item t
381*a9fa9459Szrjextra parameter saved (a constant value like frame size)
382*a9fa9459Szrj@end table
383*a9fa9459Szrj
384*a9fa9459Szrj@item function_to_profile
385*a9fa9459Szrja function address
386*a9fa9459Szrj@item cycle_corrector
387*a9fa9459Szrja value which should be added to the cycle counter, zero if omitted.
388*a9fa9459Szrj@item extra
389*a9fa9459Szrjany extra parameter, zero if omitted.
390*a9fa9459Szrj
391*a9fa9459Szrj@end table
392*a9fa9459Szrj
393*a9fa9459SzrjFor example:
394*a9fa9459Szrj@smallexample
395*a9fa9459Szrj.global fxx
396*a9fa9459Szrj.type fxx,@@function
397*a9fa9459Szrjfxx:
398*a9fa9459Szrj.LFrameOffset_fxx=0x08
399*a9fa9459Szrj.profiler "scdP", fxx     ; function entry.
400*a9fa9459Szrj			  ; we also demand stack value to be saved
401*a9fa9459Szrj  push r11
402*a9fa9459Szrj  push r10
403*a9fa9459Szrj  push r9
404*a9fa9459Szrj  push r8
405*a9fa9459Szrj.profiler "cdpt",fxx,0, .LFrameOffset_fxx  ; check stack value at this point
406*a9fa9459Szrj					  ; (this is a prologue end)
407*a9fa9459Szrj					  ; note, that spare var filled with
408*a9fa9459Szrj					  ; the farme size
409*a9fa9459Szrj  mov r15,r8
410*a9fa9459Szrj...
411*a9fa9459Szrj.profiler cdE,fxx         ; check stack
412*a9fa9459Szrj  pop r8
413*a9fa9459Szrj  pop r9
414*a9fa9459Szrj  pop r10
415*a9fa9459Szrj  pop r11
416*a9fa9459Szrj.profiler xcde,fxx,3      ; exit adds 3 to the cycle counter
417*a9fa9459Szrj  ret                     ; cause 'ret' insn takes 3 cycles
418*a9fa9459Szrj@end smallexample
419