1 @c Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
2 @c Free Software Foundation, Inc.
3 @c This is part of the GAS manual.
4 @c For copying conditions, see the file as.texinfo.
9 @chapter ARM Dependent Features
13 @node Machine Dependencies
14 @chapter ARM Dependent Features
20 * ARM Options:: Options
22 * ARM Floating Point:: Floating Point
23 * ARM Directives:: ARM Machine Directives
24 * ARM Opcodes:: Opcodes
25 * ARM Mapping Symbols:: Mapping Symbols
30 @cindex ARM options (none)
31 @cindex options for ARM (none)
35 @cindex @code{-mcpu=} command line option, ARM
36 @item -mcpu=@var{processor}[+@var{extension}@dots{}]
37 This option specifies the target processor. The assembler will issue an
38 error message if an attempt is made to assemble an instruction which
39 will not execute on the target processor. The following processor names are
103 @code{ep9312} (ARM920 with Cirrus Maverick coprocessor),
104 @code{i80200} (Intel XScale processor)
105 @code{iwmmxt} (Intel(r) XScale processor with Wireless MMX(tm) technology coprocessor)
108 The special name @code{all} may be used to allow the
109 assembler to accept instructions valid for any ARM processor.
111 In addition to the basic instruction set, the assembler can be told to
112 accept various extension mnemonics that extend the processor using the
113 co-processor instruction space. For example, @code{-mcpu=arm920+maverick}
114 is equivalent to specifying @code{-mcpu=ep9312}. The following extensions
115 are currently supported:
121 @cindex @code{-march=} command line option, ARM
122 @item -march=@var{architecture}[+@var{extension}@dots{}]
123 This option specifies the target architecture. The assembler will issue
124 an error message if an attempt is made to assemble an instruction which
125 will not execute on the target architecture. The following architecture
126 names are recognized:
150 If both @code{-mcpu} and
151 @code{-march} are specified, the assembler will use
152 the setting for @code{-mcpu}.
154 The architecture option can be extended with the same instruction set
155 extension options as the @code{-mcpu} option.
157 @cindex @code{-mfpu=} command line option, ARM
158 @item -mfpu=@var{floating-point-format}
160 This option specifies the floating point format to assemble for. The
161 assembler will issue an error message if an attempt is made to assemble
162 an instruction which will not execute on the target floating point unit.
163 The following format options are recognized:
185 In addition to determining which instructions are assembled, this option
186 also affects the way in which the @code{.double} assembler directive behaves
187 when assembling little-endian code.
189 The default is dependent on the processor selected. For Architecture 5 or
190 later, the default is to assembler for VFP instructions; for earlier
191 architectures the default is to assemble for FPA instructions.
193 @cindex @code{-mthumb} command line option, ARM
195 This option specifies that the assembler should start assembling Thumb
196 instructions; that is, it should behave as though the file starts with a
197 @code{.code 16} directive.
199 @cindex @code{-mthumb-interwork} command line option, ARM
200 @item -mthumb-interwork
201 This option specifies that the output generated by the assembler should
202 be marked as supporting interworking.
204 @cindex @code{-mapcs} command line option, ARM
205 @item -mapcs @code{[26|32]}
206 This option specifies that the output generated by the assembler should
207 be marked as supporting the indicated version of the Arm Procedure.
210 @cindex @code{-matpcs} command line option, ARM
212 This option specifies that the output generated by the assembler should
213 be marked as supporting the Arm/Thumb Procedure Calling Standard. If
214 enabled this option will cause the assembler to create an empty
215 debugging section in the object file called .arm.atpcs. Debuggers can
216 use this to determine the ABI being used by.
218 @cindex @code{-mapcs-float} command line option, ARM
220 This indicates the floating point variant of the APCS should be
221 used. In this variant floating point arguments are passed in FP
222 registers rather than integer registers.
224 @cindex @code{-mapcs-reentrant} command line option, ARM
225 @item -mapcs-reentrant
226 This indicates that the reentrant variant of the APCS should be used.
227 This variant supports position independent code.
229 @cindex @code{-mfloat-abi=} command line option, ARM
230 @item -mfloat-abi=@var{abi}
231 This option specifies that the output generated by the assembler should be
232 marked as using specified floating point ABI.
233 The following values are recognized:
239 @cindex @code{-eabi=} command line option, ARM
240 @item -meabi=@var{ver}
241 This option specifies which EABI version the produced object files should
243 The following values are recognised:
248 @cindex @code{-EB} command line option, ARM
250 This option specifies that the output generated by the assembler should
251 be marked as being encoded for a big-endian processor.
253 @cindex @code{-EL} command line option, ARM
255 This option specifies that the output generated by the assembler should
256 be marked as being encoded for a little-endian processor.
258 @cindex @code{-k} command line option, ARM
259 @cindex PIC code generation for ARM
261 This option specifies that the output of the assembler should be marked
262 as position-independent code (PIC).
270 * ARM-Chars:: Special Characters
271 * ARM-Regs:: Register Names
275 @subsection Special Characters
277 @cindex line comment character, ARM
278 @cindex ARM line comment character
279 The presence of a @samp{@@} on a line indicates the start of a comment
280 that extends to the end of the current line. If a @samp{#} appears as
281 the first character of a line, the whole line is treated as a comment.
283 @cindex line separator, ARM
284 @cindex statement separator, ARM
285 @cindex ARM line separator
286 The @samp{;} character can be used instead of a newline to separate
289 @cindex immediate character, ARM
290 @cindex ARM immediate character
291 Either @samp{#} or @samp{$} can be used to indicate immediate operands.
293 @cindex identifiers, ARM
294 @cindex ARM identifiers
295 *TODO* Explain about /data modifier on symbols.
298 @subsection Register Names
300 @cindex ARM register names
301 @cindex register names, ARM
302 *TODO* Explain about ARM register naming, and the predefined names.
304 @node ARM Floating Point
305 @section Floating Point
307 @cindex floating point, ARM (@sc{ieee})
308 @cindex ARM floating point (@sc{ieee})
309 The ARM family uses @sc{ieee} floating-point numbers.
314 @section ARM Machine Directives
316 @cindex machine directives, ARM
317 @cindex ARM machine directives
320 @cindex @code{align} directive, ARM
321 @item .align @var{expression} [, @var{expression}]
322 This is the generic @var{.align} directive. For the ARM however if the
323 first argument is zero (ie no alignment is needed) the assembler will
324 behave as if the argument had been 2 (ie pad to the next four byte
325 boundary). This is for compatibility with ARM's own assembler.
327 @cindex @code{req} directive, ARM
328 @item @var{name} .req @var{register name}
329 This creates an alias for @var{register name} called @var{name}. For
336 @cindex @code{unreq} directive, ARM
337 @item .unreq @var{alias-name}
338 This undefines a register alias which was previously defined using the
339 @code{req} directive. For example:
346 An error occurs if the name is undefined. Note - this pseudo op can
347 be used to delete builtin in register name aliases (eg 'r0'). This
348 should only be done if it is really necessary.
350 @cindex @code{code} directive, ARM
351 @item .code @code{[16|32]}
352 This directive selects the instruction set being generated. The value 16
353 selects Thumb, with the value 32 selecting ARM.
355 @cindex @code{thumb} directive, ARM
357 This performs the same action as @var{.code 16}.
359 @cindex @code{arm} directive, ARM
361 This performs the same action as @var{.code 32}.
363 @cindex @code{force_thumb} directive, ARM
365 This directive forces the selection of Thumb instructions, even if the
366 target processor does not support those instructions
368 @cindex @code{thumb_func} directive, ARM
370 This directive specifies that the following symbol is the name of a
371 Thumb encoded function. This information is necessary in order to allow
372 the assembler and linker to generate correct code for interworking
373 between Arm and Thumb instructions and should be used even if
374 interworking is not going to be performed. The presence of this
375 directive also implies @code{.thumb}
377 @cindex @code{thumb_set} directive, ARM
379 This performs the equivalent of a @code{.set} directive in that it
380 creates a symbol which is an alias for another symbol (possibly not yet
381 defined). This directive also has the added property in that it marks
382 the aliased symbol as being a thumb function entry point, in the same
383 way that the @code{.thumb_func} directive does.
385 @cindex @code{.ltorg} directive, ARM
387 This directive causes the current contents of the literal pool to be
388 dumped into the current section (which is assumed to be the .text
389 section) at the current location (aligned to a word boundary).
390 @code{GAS} maintains a separate literal pool for each section and each
391 sub-section. The @code{.ltorg} directive will only affect the literal
392 pool of the current section and sub-section. At the end of assembly
393 all remaining, un-empty literal pools will automatically be dumped.
395 Note - older versions of @code{GAS} would dump the current literal
396 pool any time a section change occurred. This is no longer done, since
397 it prevents accurate control of the placement of literal pools.
399 @cindex @code{.pool} directive, ARM
401 This is a synonym for .ltorg.
403 @cindex @code{.fnstart} directive, ARM
404 @item .unwind_fnstart
405 Marks the start of a function with an unwind table entry.
407 @cindex @code{.fnend} directive, ARM
409 Marks the end of a function with an unwind table entry. The unwind index
410 table entry is created when this directive is processed.
412 If no personality routine has been specified then standard personality
413 routine 0 or 1 will be used, depending on the number of unwind opcodes
416 @cindex @code{.cantunwind} directive, ARM
418 Prevents unwinding through the current function. No personality routine
419 or exception table data is required or permitted.
421 @cindex @code{.personality} directive, ARM
422 @item .personality @var{name}
423 Sets the personality routine for the current function to @var{name}.
425 @cindex @code{.personalityindex} directive, ARM
426 @item .personalityindex @var{index}
427 Sets the personality routine for the current function to the EABI standard
428 routine number @var{index}
430 @cindex @code{.handlerdata} directive, ARM
432 Marks the end of the current function, and the start of the exception table
433 entry for that function. Anything between this directive and the
434 @code{.fnend} directive will be added to the exception table entry.
436 Must be preceded by a @code{.personality} or @code{.personalityindex}
439 @cindex @code{.save} directive, ARM
440 @item .save @var{reglist}
441 Generate unwinder annotations to restore the registers in @var{reglist}.
442 The format of @var{reglist} is the same as the corresponding store-multiple
446 @exdent @emph{core registers}
447 .save @{r4, r5, r6, lr@}
448 stmfd sp!, @{r4, r5, r6, lr@}
449 @exdent @emph{FPA registers}
452 @exdent @emph{VFP registers}
453 .save @{d8, d9, d10@}
454 fstmdf sp!, @{d8, d9, d10@}
455 @exdent @emph{iWMMXt registers}
457 wstrd wr11, [sp, #-8]!
458 wstrd wr10, [sp, #-8]!
461 wstrd wr11, [sp, #-8]!
463 wstrd wr10, [sp, #-8]!
466 @cindex @code{.pad} directive, ARM
467 @item .pad #@var{count}
468 Generate unwinder annotations for a stack adjustment of @var{count} bytes.
469 A positive value indicates the function prologue allocated stack space by
470 decrementing the stack pointer.
472 @cindex @code{.movsp} directive, ARM
473 @item .movsp @var{reg}
474 Tell the unwinder that @var{reg} contains the current stack pointer.
476 @cindex @code{.setfp} directive, ARM
477 @item .setfp @var{fpreg}, @var{spreg} [, #@var{offset}]
478 Make all unwinder annotations relaive to a frame pointer. Without this
479 the unwinder will use offsets from the stack pointer.
481 The syntax of this directive is the same as the @code{sub} or @code{mov}
482 instruction used to set the frame pointer. @var{spreg} must be either
483 @code{sp} or mentioned in a previous @code{.movsp} directive.
493 @cindex @code{.unwind_raw} directive, ARM
494 @item .raw @var{offset}, @var{byte1}, @dots{}
495 Insert one of more arbitary unwind opcode bytes, which are known to adjust
496 the stack pointer by @var{offset} bytes.
498 For example @code{.unwind_raw 4, 0xb1, 0x01} is equivalent to
507 @cindex opcodes for ARM
508 @code{@value{AS}} implements all the standard ARM opcodes. It also
509 implements several pseudo opcodes, including several synthetic load
514 @cindex @code{NOP} pseudo op, ARM
520 This pseudo op will always evaluate to a legal ARM instruction that does
521 nothing. Currently it will evaluate to MOV r0, r0.
523 @cindex @code{LDR reg,=<label>} pseudo op, ARM
526 ldr <register> , = <expression>
529 If expression evaluates to a numeric constant then a MOV or MVN
530 instruction will be used in place of the LDR instruction, if the
531 constant can be generated by either of these instructions. Otherwise
532 the constant will be placed into the nearest literal pool (if it not
533 already there) and a PC relative LDR instruction will be generated.
535 @cindex @code{ADR reg,<label>} pseudo op, ARM
538 adr <register> <label>
541 This instruction will load the address of @var{label} into the indicated
542 register. The instruction will evaluate to a PC relative ADD or SUB
543 instruction depending upon where the label is located. If the label is
544 out of range, or if it is not defined in the same file (and section) as
545 the ADR instruction, then an error will be generated. This instruction
546 will not make use of the literal pool.
548 @cindex @code{ADRL reg,<label>} pseudo op, ARM
551 adrl <register> <label>
554 This instruction will load the address of @var{label} into the indicated
555 register. The instruction will evaluate to one or two PC relative ADD
556 or SUB instructions depending upon where the label is located. If a
557 second instruction is not needed a NOP instruction will be generated in
558 its place, so that this instruction is always 8 bytes long.
560 If the label is out of range, or if it is not defined in the same file
561 (and section) as the ADRL instruction, then an error will be generated.
562 This instruction will not make use of the literal pool.
566 For information on the ARM or Thumb instruction sets, see @cite{ARM
567 Software Development Toolkit Reference Manual}, Advanced RISC Machines
570 @node ARM Mapping Symbols
571 @section Mapping Symbols
573 The ARM ELF specification requires that special symbols be inserted
574 into object files to mark certain features:
580 At the start of a region of code containing ARM instructions.
584 At the start of a region of code containing THUMB instructions.
588 At the start of a region of data.
592 The assembler will automatically insert these symbols for you - there
593 is no need to code them yourself. Support for tagging symbols ($b,
594 $f, $p and $m) which is also mentioned in the current ARM ELF
595 specification is not implemented. This is because they have been
596 dropped from the new EABI and so tools cannot rely upon their