* lib/ld-lib.exp (default_ld_link): Use ldflags from board description
[deliverable/binutils-gdb.git] / gas / doc / c-msp430.texi
CommitLineData
13761a11 1@c Copyright 2002-2013 Free Software Foundation, Inc.
2469cfa2
NC
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 MSP430-Dependent
7@chapter MSP 430 Dependent Features
8@end ifset
9@ifclear GENERIC
10@node Machine Dependencies
11@chapter MSP 430 Dependent Features
12@end ifclear
13
14@cindex MSP 430 support
15@cindex 430 support
16@menu
17* MSP430 Options:: Options
18* MSP430 Syntax:: Syntax
19* MSP430 Floating Point:: Floating Point
20* MSP430 Directives:: MSP 430 Machine Directives
21* MSP430 Opcodes:: Opcodes
b18c562e 22* MSP430 Profiling Capability:: Profiling Capability
2469cfa2
NC
23@end menu
24
25@node MSP430 Options
26@section Options
27@cindex MSP 430 options (none)
28@cindex options for MSP430 (none)
77592908
DD
29@table @code
30
638d3803
NC
31@item -mmcu
32selects the mpu arch. If the architecture is 430Xv2 then this also
33enables NOP generation unless the @option{-mN} is also specified.
34
997b26e8 35@item -mcpu
638d3803
NC
36selects the cpu architecture. If the architecture is 430Xv2 then this
37also enables NOP generation unless the @option{-mN} is also
38specified.
39
34bca508 40@item -mP
77592908
DD
41enables polymorph instructions handler.
42
34bca508 43@item -mQ
77592908
DD
44enables relaxation at assembly time. DANGEROUS!
45
13761a11
NC
46@item -ml
47indicates that the input uses the large code model.
48
49@item -mN
50disables the generation of a NOP instruction following any instruction
51that might change the interrupts enabled/disabled state. For the
638d3803
NC
52430Xv2 architecture the instructions: @code{EINT}, @code{DINT},
53@code{BIC #8, SR}, @code{BIS #8, SR} and @code{MOV.W <>, SR} must be
54followed by a NOP instruction in order to ensure the correct
55processing of interrupts. By default generation of the NOP
56instruction happens automatically, but this command line option
57disables this behaviour. It is then up to the programmer to ensure
58that interrupts are enabled and disabled correctly.
13761a11 59
ab905915
NC
60@item -md
61mark the object file as one that requires data to copied from ROM to
62RAM at execution startup. Disabled by default.
63
77592908 64@end table
2469cfa2
NC
65
66@node MSP430 Syntax
67@section Syntax
68@menu
69* MSP430-Macros:: Macros
70* MSP430-Chars:: Special Characters
71* MSP430-Regs:: Register Names
72* MSP430-Ext:: Assembler Extensions
73@end menu
74
75@node MSP430-Macros
76@subsection Macros
77
78@cindex Macros, MSP 430
79@cindex MSP 430 macros
80The macro syntax used on the MSP 430 is like that described in the MSP
81430 Family Assembler Specification. Normal @code{@value{AS}}
82macros should still work.
83
84Additional built-in macros are:
85
86@table @code
87
34bca508 88@item llo(exp)
2469cfa2
NC
89Extracts least significant word from 32-bit expression 'exp'.
90
91@item lhi(exp)
92Extracts most significant word from 32-bit expression 'exp'.
93
94@item hlo(exp)
95Extracts 3rd word from 64-bit expression 'exp'.
96
34bca508 97@item hhi(exp)
2469cfa2
NC
98Extracts 4rd word from 64-bit expression 'exp'.
99
100@end table
101
102They normally being used as an immediate source operand.
103@smallexample
34bca508 104 mov #llo(1), r10 ; == mov #1, r10
2469cfa2
NC
105 mov #lhi(1), r10 ; == mov #0, r10
106@end smallexample
34bca508 107
2469cfa2
NC
108@node MSP430-Chars
109@subsection Special Characters
110
111@cindex line comment character, MSP 430
112@cindex MSP 430 line comment character
7c31ae13
NC
113A semicolon (@samp{;}) appearing anywhere on a line starts a comment
114that extends to the end of that line.
115
116If a @samp{#} appears as the first character of a line then the whole
117line is treated as a comment, but it can also be a logical line number
118directive (@pxref{Comments}) or a preprocessor control command
119(@pxref{Preprocessing}).
120
121@cindex line separator, MSP 430
122@cindex statement separator, MSP 430
123@cindex MSP 430 line separator
124Multiple statements can appear on the same line provided that they are
125separated by the @samp{@{} character.
2469cfa2
NC
126
127@cindex identifiers, MSP 430
128@cindex MSP 430 identifiers
34bca508 129The character @samp{$} in jump instructions indicates current location and
2469cfa2
NC
130implemented only for TI syntax compatibility.
131
132@node MSP430-Regs
133@subsection Register Names
134
135@cindex MSP 430 register names
136@cindex register names, MSP 430
137General-purpose registers are represented by predefined symbols of the
138form @samp{r@var{N}} (for global registers), where @var{N} represents
139a number between @code{0} and @code{15}. The leading
140letters may be in either upper or lower case; for example, @samp{r13}
141and @samp{R7} are both valid register names.
142
143@cindex special purpose registers, MSP 430
144Register names @samp{PC}, @samp{SP} and @samp{SR} cannot be used as register names
145and will be treated as variables. Use @samp{r0}, @samp{r1}, and @samp{r2} instead.
146
147
148@node MSP430-Ext
149@subsection Assembler Extensions
150@cindex MSP430 Assembler Extensions
151
152@table @code
153
154@item @@rN
155As destination operand being treated as @samp{0(rn)}
156
157@item 0(rN)
158As source operand being treated as @samp{@@rn}
159
160@item jCOND +N
161Skips next N bytes followed by jump instruction and equivalent to
162@samp{jCOND $+N+2}
163
164@end table
165
b18c562e
NC
166Also, there are some instructions, which cannot be found in other assemblers.
167These are branch instructions, which has different opcodes upon jump distance.
168They all got PC relative addressing mode.
169
170@table @code
171@item beq label
172A polymorph instruction which is @samp{jeq label} in case if jump distance
173within allowed range for cpu's jump instruction. If not, this unrolls into
174a sequence of
175@smallexample
176 jne $+6
177 br label
178@end smallexample
179
180@item bne label
181A polymorph instruction which is @samp{jne label} or @samp{jeq +4; br label}
182
183@item blt label
184A polymorph instruction which is @samp{jl label} or @samp{jge +4; br label}
185
186@item bltn label
187A polymorph instruction which is @samp{jn label} or @samp{jn +2; jmp +4; br label}
188
189@item bltu label
190A polymorph instruction which is @samp{jlo label} or @samp{jhs +2; br label}
191
192@item bge label
193A polymorph instruction which is @samp{jge label} or @samp{jl +4; br label}
194
195@item bgeu label
196A polymorph instruction which is @samp{jhs label} or @samp{jlo +4; br label}
197
198@item bgt label
199A polymorph instruction which is @samp{jeq +2; jge label} or @samp{jeq +6; jl +4; br label}
200
201@item bgtu label
202A polymorph instruction which is @samp{jeq +2; jhs label} or @samp{jeq +6; jlo +4; br label}
203
204@item bleu label
205A polymorph instruction which is @samp{jeq label; jlo label} or @samp{jeq +2; jhs +4; br label}
206
207@item ble label
208A polymorph instruction which is @samp{jeq label; jl label} or @samp{jeq +2; jge +4; br label}
209
210@item jump label
211A polymorph instruction which is @samp{jmp label} or @samp{br label}
212@end table
213
2469cfa2
NC
214
215@node MSP430 Floating Point
216@section Floating Point
217
218@cindex floating point, MSP 430 (@sc{ieee})
219@cindex MSP 430 floating point (@sc{ieee})
220The MSP 430 family uses @sc{ieee} 32-bit floating-point numbers.
221
222@node MSP430 Directives
223@section MSP 430 Machine Directives
224
225@cindex machine directives, MSP 430
226@cindex MSP 430 machine directives
227@table @code
228@cindex @code{file} directive, MSP 430
229@item .file
230This directive is ignored; it is accepted for compatibility with other
231MSP 430 assemblers.
232
233@quotation
234@emph{Warning:} in other versions of the @sc{gnu} assembler, @code{.file} is
235used for the directive called @code{.app-file} in the MSP 430 support.
236@end quotation
237
238@cindex @code{line} directive, MSP 430
239@item .line
240This directive is ignored; it is accepted for compatibility with other
241MSP 430 assemblers.
242
638d3803 243@cindex @code{arch} directive, MSP 430
2469cfa2 244@item .arch
638d3803
NC
245Sets the target microcontroller in the same way as the @option{-mmcu}
246command line option.
247
248@cindex @code{cpu} directive, MSP 430
249@item .cpu
250Sets the target architecture in the same way as the @option{-mcpu}
251command line option.
2469cfa2 252
b18c562e
NC
253@cindex @code{profiler} directive, MSP 430
254@item .profiler
255This directive instructs assembler to add new profile entry to the object file.
256
2469cfa2
NC
257@end table
258
259@node MSP430 Opcodes
260@section Opcodes
261
262@cindex MSP 430 opcodes
263@cindex opcodes for MSP 430
264@code{@value{AS}} implements all the standard MSP 430 opcodes. No
265additional pseudo-instructions are needed on this family.
266
267For information on the 430 machine instruction set, see @cite{MSP430
77592908 268User's Manual, document slau049d}, Texas Instrument, Inc.
b18c562e
NC
269
270@node MSP430 Profiling Capability
271@section Profiling Capability
272
273@cindex MSP 430 profiling capability
274@cindex profiling capability for MSP 430
275It is a performance hit to use gcc's profiling approach for this tiny target.
276Even more -- jtag hardware facility does not perform any profiling functions.
277However we've got gdb's built-in simulator where we can do anything.
278
279We define new section @samp{.profiler} which holds all profiling information.
280We define new pseudo operation @samp{.profiler} which will instruct assembler to
281add new profile entry to the object file. Profile should take place at the
282present address.
283
284Pseudo operation format:
285
286@samp{.profiler flags,function_to_profile [, cycle_corrector, extra]}
287
288
289where:
290
291@table @code
292
293@table @code
294
295@samp{flags} is a combination of the following characters:
296
34bca508 297@item s
b18c562e 298function entry
34bca508 299@item x
b18c562e 300function exit
34bca508 301@item i
b18c562e 302function is in init section
34bca508 303@item f
b18c562e 304function is in fini section
34bca508 305@item l
b18c562e 306library call
34bca508 307@item c
b18c562e 308libc standard call
34bca508 309@item d
b18c562e 310stack value demand
34bca508 311@item I
b18c562e 312interrupt service routine
34bca508 313@item P
b18c562e 314prologue start
34bca508 315@item p
b18c562e 316prologue end
34bca508 317@item E
b18c562e 318epilogue start
34bca508 319@item e
b18c562e 320epilogue end
34bca508 321@item j
b18c562e 322long jump / sjlj unwind
34bca508 323@item a
b18c562e
NC
324an arbitrary code fragment
325@item t
326extra parameter saved (a constant value like frame size)
327@end table
328
34bca508 329@item function_to_profile
b18c562e 330a function address
34bca508 331@item cycle_corrector
b18c562e 332a value which should be added to the cycle counter, zero if omitted.
34bca508 333@item extra
b18c562e
NC
334any extra parameter, zero if omitted.
335
336@end table
337
338For example:
339@smallexample
340.global fxx
341.type fxx,@@function
342fxx:
343.LFrameOffset_fxx=0x08
344.profiler "scdP", fxx ; function entry.
345 ; we also demand stack value to be saved
346 push r11
347 push r10
348 push r9
349 push r8
350.profiler "cdpt",fxx,0, .LFrameOffset_fxx ; check stack value at this point
351 ; (this is a prologue end)
34bca508 352 ; note, that spare var filled with
b18c562e
NC
353 ; the farme size
354 mov r15,r8
355...
356.profiler cdE,fxx ; check stack
357 pop r8
358 pop r9
359 pop r10
360 pop r11
361.profiler xcde,fxx,3 ; exit adds 3 to the cycle counter
362 ret ; cause 'ret' insn takes 3 cycles
363@end smallexample
This page took 0.541081 seconds and 4 git commands to generate.