2005-08-12 Dmitry Diky <diwil@spec.ru>
[deliverable/binutils-gdb.git] / gas / doc / c-msp430.texi
CommitLineData
b18c562e 1@c Copyright 2002, 2004 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)
29@code{@value{AS}} has only -m flag which selects the mpu arch. Currently has
30no effect.
31
32@node MSP430 Syntax
33@section Syntax
34@menu
35* MSP430-Macros:: Macros
36* MSP430-Chars:: Special Characters
37* MSP430-Regs:: Register Names
38* MSP430-Ext:: Assembler Extensions
39@end menu
40
41@node MSP430-Macros
42@subsection Macros
43
44@cindex Macros, MSP 430
45@cindex MSP 430 macros
46The macro syntax used on the MSP 430 is like that described in the MSP
47430 Family Assembler Specification. Normal @code{@value{AS}}
48macros should still work.
49
50Additional built-in macros are:
51
52@table @code
53
54@item llo(exp)
55Extracts least significant word from 32-bit expression 'exp'.
56
57@item lhi(exp)
58Extracts most significant word from 32-bit expression 'exp'.
59
60@item hlo(exp)
61Extracts 3rd word from 64-bit expression 'exp'.
62
63@item hhi(exp)
64Extracts 4rd word from 64-bit expression 'exp'.
65
66@end table
67
68They normally being used as an immediate source operand.
69@smallexample
70 mov #llo(1), r10 ; == mov #1, r10
71 mov #lhi(1), r10 ; == mov #0, r10
72@end smallexample
73
74@node MSP430-Chars
75@subsection Special Characters
76
77@cindex line comment character, MSP 430
78@cindex MSP 430 line comment character
79@samp{;} is the line comment character.
80
81@cindex identifiers, MSP 430
82@cindex MSP 430 identifiers
83The character @samp{$} in jump instructions indicates current location and
84implemented only for TI syntax compatibility.
85
86@node MSP430-Regs
87@subsection Register Names
88
89@cindex MSP 430 register names
90@cindex register names, MSP 430
91General-purpose registers are represented by predefined symbols of the
92form @samp{r@var{N}} (for global registers), where @var{N} represents
93a number between @code{0} and @code{15}. The leading
94letters may be in either upper or lower case; for example, @samp{r13}
95and @samp{R7} are both valid register names.
96
97@cindex special purpose registers, MSP 430
98Register names @samp{PC}, @samp{SP} and @samp{SR} cannot be used as register names
99and will be treated as variables. Use @samp{r0}, @samp{r1}, and @samp{r2} instead.
100
101
102@node MSP430-Ext
103@subsection Assembler Extensions
104@cindex MSP430 Assembler Extensions
105
106@table @code
107
108@item @@rN
109As destination operand being treated as @samp{0(rn)}
110
111@item 0(rN)
112As source operand being treated as @samp{@@rn}
113
114@item jCOND +N
115Skips next N bytes followed by jump instruction and equivalent to
116@samp{jCOND $+N+2}
117
118@end table
119
b18c562e
NC
120Also, there are some instructions, which cannot be found in other assemblers.
121These are branch instructions, which has different opcodes upon jump distance.
122They all got PC relative addressing mode.
123
124@table @code
125@item beq label
126A polymorph instruction which is @samp{jeq label} in case if jump distance
127within allowed range for cpu's jump instruction. If not, this unrolls into
128a sequence of
129@smallexample
130 jne $+6
131 br label
132@end smallexample
133
134@item bne label
135A polymorph instruction which is @samp{jne label} or @samp{jeq +4; br label}
136
137@item blt label
138A polymorph instruction which is @samp{jl label} or @samp{jge +4; br label}
139
140@item bltn label
141A polymorph instruction which is @samp{jn label} or @samp{jn +2; jmp +4; br label}
142
143@item bltu label
144A polymorph instruction which is @samp{jlo label} or @samp{jhs +2; br label}
145
146@item bge label
147A polymorph instruction which is @samp{jge label} or @samp{jl +4; br label}
148
149@item bgeu label
150A polymorph instruction which is @samp{jhs label} or @samp{jlo +4; br label}
151
152@item bgt label
153A polymorph instruction which is @samp{jeq +2; jge label} or @samp{jeq +6; jl +4; br label}
154
155@item bgtu label
156A polymorph instruction which is @samp{jeq +2; jhs label} or @samp{jeq +6; jlo +4; br label}
157
158@item bleu label
159A polymorph instruction which is @samp{jeq label; jlo label} or @samp{jeq +2; jhs +4; br label}
160
161@item ble label
162A polymorph instruction which is @samp{jeq label; jl label} or @samp{jeq +2; jge +4; br label}
163
164@item jump label
165A polymorph instruction which is @samp{jmp label} or @samp{br label}
166@end table
167
2469cfa2
NC
168
169@node MSP430 Floating Point
170@section Floating Point
171
172@cindex floating point, MSP 430 (@sc{ieee})
173@cindex MSP 430 floating point (@sc{ieee})
174The MSP 430 family uses @sc{ieee} 32-bit floating-point numbers.
175
176@node MSP430 Directives
177@section MSP 430 Machine Directives
178
179@cindex machine directives, MSP 430
180@cindex MSP 430 machine directives
181@table @code
182@cindex @code{file} directive, MSP 430
183@item .file
184This directive is ignored; it is accepted for compatibility with other
185MSP 430 assemblers.
186
187@quotation
188@emph{Warning:} in other versions of the @sc{gnu} assembler, @code{.file} is
189used for the directive called @code{.app-file} in the MSP 430 support.
190@end quotation
191
192@cindex @code{line} directive, MSP 430
193@item .line
194This directive is ignored; it is accepted for compatibility with other
195MSP 430 assemblers.
196
197@cindex @code{sect} directive, MSP 430
198@item .arch
199Currently this directive is ignored; it is accepted for compatibility with other
200MSP 430 assemblers.
201
b18c562e
NC
202@cindex @code{profiler} directive, MSP 430
203@item .profiler
204This directive instructs assembler to add new profile entry to the object file.
205
2469cfa2
NC
206@end table
207
208@node MSP430 Opcodes
209@section Opcodes
210
211@cindex MSP 430 opcodes
212@cindex opcodes for MSP 430
213@code{@value{AS}} implements all the standard MSP 430 opcodes. No
214additional pseudo-instructions are needed on this family.
215
216For information on the 430 machine instruction set, see @cite{MSP430
217User's Manual, document slau049b}, Texas Instrument, Inc.
b18c562e
NC
218
219@node MSP430 Profiling Capability
220@section Profiling Capability
221
222@cindex MSP 430 profiling capability
223@cindex profiling capability for MSP 430
224It is a performance hit to use gcc's profiling approach for this tiny target.
225Even more -- jtag hardware facility does not perform any profiling functions.
226However we've got gdb's built-in simulator where we can do anything.
227
228We define new section @samp{.profiler} which holds all profiling information.
229We define new pseudo operation @samp{.profiler} which will instruct assembler to
230add new profile entry to the object file. Profile should take place at the
231present address.
232
233Pseudo operation format:
234
235@samp{.profiler flags,function_to_profile [, cycle_corrector, extra]}
236
237
238where:
239
240@table @code
241
242@table @code
243
244@samp{flags} is a combination of the following characters:
245
246@item s
247function entry
248@item x
249function exit
250@item i
251function is in init section
252@item f
253function is in fini section
254@item l
255library call
256@item c
257libc standard call
258@item d
259stack value demand
260@item I
261interrupt service routine
262@item P
263prologue start
264@item p
265prologue end
266@item E
267epilogue start
268@item e
269epilogue end
270@item j
271long jump / sjlj unwind
272@item a
273an arbitrary code fragment
274@item t
275extra parameter saved (a constant value like frame size)
276@end table
277
278@item function_to_profile
279a function address
280@item cycle_corrector
281a value which should be added to the cycle counter, zero if omitted.
282@item extra
283any extra parameter, zero if omitted.
284
285@end table
286
287For example:
288@smallexample
289.global fxx
290.type fxx,@@function
291fxx:
292.LFrameOffset_fxx=0x08
293.profiler "scdP", fxx ; function entry.
294 ; we also demand stack value to be saved
295 push r11
296 push r10
297 push r9
298 push r8
299.profiler "cdpt",fxx,0, .LFrameOffset_fxx ; check stack value at this point
300 ; (this is a prologue end)
301 ; note, that spare var filled with
302 ; the farme size
303 mov r15,r8
304...
305.profiler cdE,fxx ; check stack
306 pop r8
307 pop r9
308 pop r10
309 pop r11
310.profiler xcde,fxx,3 ; exit adds 3 to the cycle counter
311 ret ; cause 'ret' insn takes 3 cycles
312@end smallexample
This page took 0.152024 seconds and 4 git commands to generate.