1 @c Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 @c This is part of the GAS manual.
3 @c For copying conditions, see the file as.texinfo.
7 @chapter MSP 430 Dependent Features
10 @node Machine Dependencies
11 @chapter MSP 430 Dependent Features
14 @cindex MSP 430 support
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
22 * MSP430 Profiling Capability:: Profiling Capability
27 @cindex MSP 430 options (none)
28 @cindex options for MSP430 (none)
32 selects the mcu architecture. If the architecture is 430Xv2 then this
33 also enables NOP generation unless the @option{-mN} is also specified.
36 selects the cpu architecture. If the architecture is 430Xv2 then this
37 also enables NOP generation unless the @option{-mN} is also specified.
39 @item -msilicon-errata=@var{name}[,@var{name}@dots{}]
40 Implements a fixup for named silicon errata. Multiple silicon errata
41 can be specified by multiple uses of the @option{-msilicon-errata}
42 option and/or by including the errata names, separated by commas, on
43 an individual @option{-msilicon-errata} option. Errata names
44 currently recognised by the assembler are:
48 @code{PUSH #4} and @option{PUSH #8} need longer encodings on the
49 MSP430. This option is enabled by default, and cannot be disabled.
51 Do not set the @code{SP} to an odd value.
53 Do not update the @code{SR} and the @code{PC} in the same instruction.
55 Do not use the @code{PC} in a @code{CMP} or @code{BIT} instruction.
57 Do not use an arithmetic instruction to modify the @code{SR}.
59 Insert @code{NOP} after @code{CPUOFF}.
62 @item -msilicon-errata-warn=@var{name}[,@var{name}@dots{}]
63 Like the @option{-msilicon-errata} option except that instead of
64 fixing the specified errata, a warning message is issued instead.
65 This option can be used alongside @option{-msilicon-errata} to
66 generate messages whenever a problem is fixed, or on its own in order
67 to inspect code for potential problems.
70 enables polymorph instructions handler.
73 enables relaxation at assembly time. DANGEROUS!
76 indicates that the input uses the large code model.
79 enables the generation of a NOP instruction following any instruction
80 that might change the interrupts enabled/disabled state. The
81 pipelined nature of the MSP430 core means that any instruction that
82 changes the interrupt state (@code{EINT}, @code{DINT}, @code{BIC #8,
83 SR}, @code{BIS #8, SR} or @code{MOV.W <>, SR}) must be
84 followed by a NOP instruction in order to ensure the correct
85 processing of interrupts. By default it is up to the programmer to
86 supply these NOP instructions, but this command-line option enables
87 the automatic insertion by the assembler, if they are missing.
90 disables the generation of a NOP instruction following any instruction
91 that might change the interrupts enabled/disabled state. This is the
95 tells the assembler to generate a warning message if a NOP does not
96 immediately follow an instruction that enables or disables
97 interrupts. This is the default.
99 Note that this option can be stacked with the @option{-mn} option so
100 that the assembler will both warn about missing NOP instructions and
101 then insert them automatically.
104 disables warnings about missing NOP instructions.
107 mark the object file as one that requires data to copied from ROM to
108 RAM at execution startup. Disabled by default.
110 @item -mdata-region=@var{region}
111 Select the region data will be placed in.
112 Region placement is performed by the compiler and linker. The only effect this
113 option will have on the assembler is that if @var{upper} or @var{either} is
114 selected, then the symbols to initialise high data and bss will be defined.
115 Valid @var{region} values are:
128 * MSP430-Macros:: Macros
129 * MSP430-Chars:: Special Characters
130 * MSP430-Regs:: Register Names
131 * MSP430-Ext:: Assembler Extensions
137 @cindex Macros, MSP 430
138 @cindex MSP 430 macros
139 The macro syntax used on the MSP 430 is like that described in the MSP
140 430 Family Assembler Specification. Normal @code{@value{AS}}
141 macros should still work.
143 Additional built-in macros are:
148 Extracts least significant word from 32-bit expression 'exp'.
151 Extracts most significant word from 32-bit expression 'exp'.
154 Extracts 3rd word from 64-bit expression 'exp'.
157 Extracts 4rd word from 64-bit expression 'exp'.
161 They normally being used as an immediate source operand.
163 mov #llo(1), r10 ; == mov #1, r10
164 mov #lhi(1), r10 ; == mov #0, r10
168 @subsection Special Characters
170 @cindex line comment character, MSP 430
171 @cindex MSP 430 line comment character
172 A semicolon (@samp{;}) appearing anywhere on a line starts a comment
173 that extends to the end of that line.
175 If a @samp{#} appears as the first character of a line then the whole
176 line is treated as a comment, but it can also be a logical line number
177 directive (@pxref{Comments}) or a preprocessor control command
178 (@pxref{Preprocessing}).
180 @cindex line separator, MSP 430
181 @cindex statement separator, MSP 430
182 @cindex MSP 430 line separator
183 Multiple statements can appear on the same line provided that they are
184 separated by the @samp{@{} character.
186 @cindex identifiers, MSP 430
187 @cindex MSP 430 identifiers
188 The character @samp{$} in jump instructions indicates current location and
189 implemented only for TI syntax compatibility.
192 @subsection Register Names
194 @cindex MSP 430 register names
195 @cindex register names, MSP 430
196 General-purpose registers are represented by predefined symbols of the
197 form @samp{r@var{N}} (for global registers), where @var{N} represents
198 a number between @code{0} and @code{15}. The leading
199 letters may be in either upper or lower case; for example, @samp{r13}
200 and @samp{R7} are both valid register names.
202 @cindex special purpose registers, MSP 430
203 Register names @samp{PC}, @samp{SP} and @samp{SR} cannot be used as register names
204 and will be treated as variables. Use @samp{r0}, @samp{r1}, and @samp{r2} instead.
208 @subsection Assembler Extensions
209 @cindex MSP430 Assembler Extensions
214 As destination operand being treated as @samp{0(rn)}
217 As source operand being treated as @samp{@@rn}
220 Skips next N bytes followed by jump instruction and equivalent to
225 Also, there are some instructions, which cannot be found in other assemblers.
226 These are branch instructions, which has different opcodes upon jump distance.
227 They all got PC relative addressing mode.
231 A polymorph instruction which is @samp{jeq label} in case if jump distance
232 within allowed range for cpu's jump instruction. If not, this unrolls into
240 A polymorph instruction which is @samp{jne label} or @samp{jeq +4; br label}
243 A polymorph instruction which is @samp{jl label} or @samp{jge +4; br label}
246 A polymorph instruction which is @samp{jn label} or @samp{jn +2; jmp +4; br label}
249 A polymorph instruction which is @samp{jlo label} or @samp{jhs +2; br label}
252 A polymorph instruction which is @samp{jge label} or @samp{jl +4; br label}
255 A polymorph instruction which is @samp{jhs label} or @samp{jlo +4; br label}
258 A polymorph instruction which is @samp{jeq +2; jge label} or @samp{jeq +6; jl +4; br label}
261 A polymorph instruction which is @samp{jeq +2; jhs label} or @samp{jeq +6; jlo +4; br label}
264 A polymorph instruction which is @samp{jeq label; jlo label} or @samp{jeq +2; jhs +4; br label}
267 A polymorph instruction which is @samp{jeq label; jl label} or @samp{jeq +2; jge +4; br label}
270 A polymorph instruction which is @samp{jmp label} or @samp{br label}
274 @node MSP430 Floating Point
275 @section Floating Point
277 @cindex floating point, MSP 430 (@sc{ieee})
278 @cindex MSP 430 floating point (@sc{ieee})
279 The MSP 430 family uses @sc{ieee} 32-bit floating-point numbers.
281 @node MSP430 Directives
282 @section MSP 430 Machine Directives
284 @cindex machine directives, MSP 430
285 @cindex MSP 430 machine directives
287 @cindex @code{file} directive, MSP 430
289 This directive is ignored; it is accepted for compatibility with other
293 @emph{Warning:} in other versions of the @sc{gnu} assembler, @code{.file} is
294 used for the directive called @code{.app-file} in the MSP 430 support.
297 @cindex @code{line} directive, MSP 430
299 This directive is ignored; it is accepted for compatibility with other
302 @cindex @code{arch} directive, MSP 430
304 Sets the target microcontroller in the same way as the @option{-mmcu}
307 @cindex @code{cpu} directive, MSP 430
309 Sets the target architecture in the same way as the @option{-mcpu}
312 @cindex @code{profiler} directive, MSP 430
314 This directive instructs assembler to add new profile entry to the object file.
316 @cindex @code{refsym} directive, MSP 430
318 This directive instructs assembler to add an undefined reference to
319 the symbol following the directive. The maximum symbol name length is
320 1023 characters. No relocation is created for this symbol; it will
321 exist purely for pulling in object files from archives. Note that
322 this reloc is not sufficient to prevent garbage collection; use a
323 KEEP() directive in the linker file to preserve such objects.
330 @cindex MSP 430 opcodes
331 @cindex opcodes for MSP 430
332 @code{@value{AS}} implements all the standard MSP 430 opcodes. No
333 additional pseudo-instructions are needed on this family.
335 For information on the 430 machine instruction set, see @cite{MSP430
336 User's Manual, document slau049d}, Texas Instrument, Inc.
338 @node MSP430 Profiling Capability
339 @section Profiling Capability
341 @cindex MSP 430 profiling capability
342 @cindex profiling capability for MSP 430
343 It is a performance hit to use gcc's profiling approach for this tiny target.
344 Even more -- jtag hardware facility does not perform any profiling functions.
345 However we've got gdb's built-in simulator where we can do anything.
347 We define new section @samp{.profiler} which holds all profiling information.
348 We define new pseudo operation @samp{.profiler} which will instruct assembler to
349 add new profile entry to the object file. Profile should take place at the
352 Pseudo operation format:
354 @samp{.profiler flags,function_to_profile [, cycle_corrector, extra]}
363 @samp{flags} is a combination of the following characters:
370 function is in init section
372 function is in fini section
380 interrupt service routine
390 long jump / sjlj unwind
392 an arbitrary code fragment
394 extra parameter saved (a constant value like frame size)
397 @item function_to_profile
399 @item cycle_corrector
400 a value which should be added to the cycle counter, zero if omitted.
402 any extra parameter, zero if omitted.
411 .LFrameOffset_fxx=0x08
412 .profiler "scdP", fxx ; function entry.
413 ; we also demand stack value to be saved
418 .profiler "cdpt",fxx,0, .LFrameOffset_fxx ; check stack value at this point
419 ; (this is a prologue end)
420 ; note, that spare var filled with
424 .profiler cdE,fxx ; check stack
429 .profiler xcde,fxx,3 ; exit adds 3 to the cycle counter
430 ret ; cause 'ret' insn takes 3 cycles