2005-10-08 Paul Brook <paul@codesourcery.com>
[deliverable/binutils-gdb.git] / gas / doc / c-arm.texi
CommitLineData
2da5c037 1@c Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
f7e42eb4 2@c Free Software Foundation, Inc.
252b5132
RH
3@c This is part of the GAS manual.
4@c For copying conditions, see the file as.texinfo.
5
6@ifset GENERIC
7@page
8@node ARM-Dependent
9@chapter ARM Dependent Features
10@end ifset
11
12@ifclear GENERIC
13@node Machine Dependencies
14@chapter ARM Dependent Features
15@end ifclear
16
17@cindex ARM support
18@cindex Thumb support
19@menu
20* ARM Options:: Options
21* ARM Syntax:: Syntax
22* ARM Floating Point:: Floating Point
23* ARM Directives:: ARM Machine Directives
24* ARM Opcodes:: Opcodes
6057a28f 25* ARM Mapping Symbols:: Mapping Symbols
252b5132
RH
26@end menu
27
28@node ARM Options
29@section Options
30@cindex ARM options (none)
31@cindex options for ARM (none)
adcf07e6 32
252b5132 33@table @code
adcf07e6 34
03b1477f 35@cindex @code{-mcpu=} command line option, ARM
92081f48 36@item -mcpu=@var{processor}[+@var{extension}@dots{}]
252b5132
RH
37This option specifies the target processor. The assembler will issue an
38error message if an attempt is made to assemble an instruction which
03b1477f
RE
39will not execute on the target processor. The following processor names are
40recognized:
41@code{arm1},
42@code{arm2},
43@code{arm250},
44@code{arm3},
45@code{arm6},
46@code{arm60},
47@code{arm600},
48@code{arm610},
49@code{arm620},
50@code{arm7},
51@code{arm7m},
52@code{arm7d},
53@code{arm7dm},
54@code{arm7di},
55@code{arm7dmi},
56@code{arm70},
57@code{arm700},
58@code{arm700i},
59@code{arm710},
60@code{arm710t},
61@code{arm720},
62@code{arm720t},
63@code{arm740t},
64@code{arm710c},
65@code{arm7100},
66@code{arm7500},
67@code{arm7500fe},
68@code{arm7t},
69@code{arm7tdmi},
1ff4677c 70@code{arm7tdmi-s},
03b1477f
RE
71@code{arm8},
72@code{arm810},
73@code{strongarm},
74@code{strongarm1},
75@code{strongarm110},
76@code{strongarm1100},
77@code{strongarm1110},
78@code{arm9},
79@code{arm920},
80@code{arm920t},
81@code{arm922t},
82@code{arm940t},
83@code{arm9tdmi},
84@code{arm9e},
7de9afa2 85@code{arm926e},
1ff4677c 86@code{arm926ej-s},
03b1477f
RE
87@code{arm946e-r0},
88@code{arm946e},
db8ac8f9 89@code{arm946e-s},
03b1477f
RE
90@code{arm966e-r0},
91@code{arm966e},
db8ac8f9
PB
92@code{arm966e-s},
93@code{arm968e-s},
03b1477f 94@code{arm10t},
db8ac8f9 95@code{arm10tdmi},
03b1477f
RE
96@code{arm10e},
97@code{arm1020},
98@code{arm1020t},
7de9afa2 99@code{arm1020e},
db8ac8f9 100@code{arm1022e},
1ff4677c
RE
101@code{arm1026ej-s},
102@code{arm1136j-s},
103@code{arm1136jf-s},
db8ac8f9
PB
104@code{arm1156t2-s},
105@code{arm1156t2f-s},
0dd132b6
NC
106@code{arm1176jz-s},
107@code{arm1176jzf-s},
108@code{mpcore},
109@code{mpcorenovfp},
03b1477f
RE
110@code{ep9312} (ARM920 with Cirrus Maverick coprocessor),
111@code{i80200} (Intel XScale processor)
e16bb312 112@code{iwmmxt} (Intel(r) XScale processor with Wireless MMX(tm) technology coprocessor)
03b1477f
RE
113and
114@code{xscale}.
115The special name @code{all} may be used to allow the
116assembler to accept instructions valid for any ARM processor.
117
118In addition to the basic instruction set, the assembler can be told to
119accept various extension mnemonics that extend the processor using the
120co-processor instruction space. For example, @code{-mcpu=arm920+maverick}
121is equivalent to specifying @code{-mcpu=ep9312}. The following extensions
122are currently supported:
123@code{+maverick}
e16bb312 124@code{+iwmmxt}
03b1477f
RE
125and
126@code{+xscale}.
127
128@cindex @code{-march=} command line option, ARM
92081f48 129@item -march=@var{architecture}[+@var{extension}@dots{}]
252b5132
RH
130This option specifies the target architecture. The assembler will issue
131an error message if an attempt is made to assemble an instruction which
03b1477f
RE
132will not execute on the target architecture. The following architecture
133names are recognized:
134@code{armv1},
135@code{armv2},
136@code{armv2a},
137@code{armv2s},
138@code{armv3},
139@code{armv3m},
140@code{armv4},
141@code{armv4xm},
142@code{armv4t},
143@code{armv4txm},
144@code{armv5},
145@code{armv5t},
146@code{armv5txm},
147@code{armv5te},
09d92015 148@code{armv5texp},
c5f98204 149@code{armv6},
1ddd7f43 150@code{armv6j},
0dd132b6
NC
151@code{armv6k},
152@code{armv6z},
153@code{armv6zk},
e16bb312 154@code{iwmmxt}
03b1477f
RE
155and
156@code{xscale}.
157If both @code{-mcpu} and
158@code{-march} are specified, the assembler will use
159the setting for @code{-mcpu}.
160
161The architecture option can be extended with the same instruction set
162extension options as the @code{-mcpu} option.
163
164@cindex @code{-mfpu=} command line option, ARM
165@item -mfpu=@var{floating-point-format}
166
167This option specifies the floating point format to assemble for. The
168assembler will issue an error message if an attempt is made to assemble
169an instruction which will not execute on the target floating point unit.
170The following format options are recognized:
171@code{softfpa},
172@code{fpe},
bc89618b
RE
173@code{fpe2},
174@code{fpe3},
03b1477f
RE
175@code{fpa},
176@code{fpa10},
177@code{fpa11},
178@code{arm7500fe},
179@code{softvfp},
180@code{softvfp+vfp},
181@code{vfp},
182@code{vfp10},
183@code{vfp10-r0},
184@code{vfp9},
185@code{vfpxd},
09d92015
MM
186@code{arm1020t},
187@code{arm1020e},
1ff4677c 188@code{arm1136jf-s}
03b1477f 189and
33a392fb 190@code{maverick}.
03b1477f
RE
191
192In addition to determining which instructions are assembled, this option
193also affects the way in which the @code{.double} assembler directive behaves
194when assembling little-endian code.
195
196The default is dependent on the processor selected. For Architecture 5 or
197later, the default is to assembler for VFP instructions; for earlier
198architectures the default is to assemble for FPA instructions.
adcf07e6 199
252b5132
RH
200@cindex @code{-mthumb} command line option, ARM
201@item -mthumb
03b1477f
RE
202This option specifies that the assembler should start assembling Thumb
203instructions; that is, it should behave as though the file starts with a
204@code{.code 16} directive.
adcf07e6 205
252b5132
RH
206@cindex @code{-mthumb-interwork} command line option, ARM
207@item -mthumb-interwork
208This option specifies that the output generated by the assembler should
209be marked as supporting interworking.
adcf07e6 210
252b5132 211@cindex @code{-mapcs} command line option, ARM
0ac658b8 212@item -mapcs @code{[26|32]}
252b5132
RH
213This option specifies that the output generated by the assembler should
214be marked as supporting the indicated version of the Arm Procedure.
215Calling Standard.
adcf07e6 216
077b8428
NC
217@cindex @code{-matpcs} command line option, ARM
218@item -matpcs
219This option specifies that the output generated by the assembler should
220be marked as supporting the Arm/Thumb Procedure Calling Standard. If
221enabled this option will cause the assembler to create an empty
222debugging section in the object file called .arm.atpcs. Debuggers can
223use this to determine the ABI being used by.
224
adcf07e6 225@cindex @code{-mapcs-float} command line option, ARM
252b5132 226@item -mapcs-float
1be59579 227This indicates the floating point variant of the APCS should be
252b5132 228used. In this variant floating point arguments are passed in FP
550262c4 229registers rather than integer registers.
adcf07e6
NC
230
231@cindex @code{-mapcs-reentrant} command line option, ARM
252b5132
RH
232@item -mapcs-reentrant
233This indicates that the reentrant variant of the APCS should be used.
234This variant supports position independent code.
adcf07e6 235
33a392fb
PB
236@cindex @code{-mfloat-abi=} command line option, ARM
237@item -mfloat-abi=@var{abi}
238This option specifies that the output generated by the assembler should be
239marked as using specified floating point ABI.
240The following values are recognized:
241@code{soft},
242@code{softfp}
243and
244@code{hard}.
245
d507cf36
PB
246@cindex @code{-eabi=} command line option, ARM
247@item -meabi=@var{ver}
248This option specifies which EABI version the produced object files should
249conform to.
250The following values are recognised:
251@code{gnu}
252and
8cb51566 253@code{4}.
d507cf36 254
252b5132
RH
255@cindex @code{-EB} command line option, ARM
256@item -EB
257This option specifies that the output generated by the assembler should
258be marked as being encoded for a big-endian processor.
adcf07e6 259
252b5132
RH
260@cindex @code{-EL} command line option, ARM
261@item -EL
262This option specifies that the output generated by the assembler should
263be marked as being encoded for a little-endian processor.
adcf07e6 264
252b5132
RH
265@cindex @code{-k} command line option, ARM
266@cindex PIC code generation for ARM
267@item -k
a349d9dd
PB
268This option specifies that the output of the assembler should be marked
269as position-independent code (PIC).
adcf07e6 270
252b5132
RH
271@end table
272
273
274@node ARM Syntax
275@section Syntax
276@menu
277* ARM-Chars:: Special Characters
278* ARM-Regs:: Register Names
279@end menu
280
281@node ARM-Chars
282@subsection Special Characters
283
284@cindex line comment character, ARM
285@cindex ARM line comment character
550262c4
NC
286The presence of a @samp{@@} on a line indicates the start of a comment
287that extends to the end of the current line. If a @samp{#} appears as
288the first character of a line, the whole line is treated as a comment.
289
290@cindex line separator, ARM
291@cindex statement separator, ARM
292@cindex ARM line separator
a349d9dd
PB
293The @samp{;} character can be used instead of a newline to separate
294statements.
550262c4
NC
295
296@cindex immediate character, ARM
297@cindex ARM immediate character
298Either @samp{#} or @samp{$} can be used to indicate immediate operands.
252b5132
RH
299
300@cindex identifiers, ARM
301@cindex ARM identifiers
302*TODO* Explain about /data modifier on symbols.
303
304@node ARM-Regs
305@subsection Register Names
306
307@cindex ARM register names
308@cindex register names, ARM
309*TODO* Explain about ARM register naming, and the predefined names.
310
311@node ARM Floating Point
312@section Floating Point
313
314@cindex floating point, ARM (@sc{ieee})
315@cindex ARM floating point (@sc{ieee})
316The ARM family uses @sc{ieee} floating-point numbers.
317
318
319
320@node ARM Directives
321@section ARM Machine Directives
322
323@cindex machine directives, ARM
324@cindex ARM machine directives
325@table @code
326
adcf07e6
NC
327@cindex @code{align} directive, ARM
328@item .align @var{expression} [, @var{expression}]
329This is the generic @var{.align} directive. For the ARM however if the
330first argument is zero (ie no alignment is needed) the assembler will
331behave as if the argument had been 2 (ie pad to the next four byte
062b7c0c 332boundary). This is for compatibility with ARM's own assembler.
adcf07e6 333
252b5132
RH
334@cindex @code{req} directive, ARM
335@item @var{name} .req @var{register name}
336This creates an alias for @var{register name} called @var{name}. For
337example:
338
339@smallexample
340 foo .req r0
341@end smallexample
342
0bbf2aa4
NC
343@cindex @code{unreq} directive, ARM
344@item .unreq @var{alias-name}
345This undefines a register alias which was previously defined using the
346@code{req} directive. For example:
347
348@smallexample
349 foo .req r0
350 .unreq foo
351@end smallexample
352
353An error occurs if the name is undefined. Note - this pseudo op can
354be used to delete builtin in register name aliases (eg 'r0'). This
355should only be done if it is really necessary.
356
252b5132 357@cindex @code{code} directive, ARM
0ac658b8 358@item .code @code{[16|32]}
252b5132
RH
359This directive selects the instruction set being generated. The value 16
360selects Thumb, with the value 32 selecting ARM.
361
362@cindex @code{thumb} directive, ARM
363@item .thumb
364This performs the same action as @var{.code 16}.
365
366@cindex @code{arm} directive, ARM
367@item .arm
368This performs the same action as @var{.code 32}.
369
370@cindex @code{force_thumb} directive, ARM
371@item .force_thumb
372This directive forces the selection of Thumb instructions, even if the
373target processor does not support those instructions
374
375@cindex @code{thumb_func} directive, ARM
376@item .thumb_func
377This directive specifies that the following symbol is the name of a
378Thumb encoded function. This information is necessary in order to allow
379the assembler and linker to generate correct code for interworking
380between Arm and Thumb instructions and should be used even if
1994a7c7
NC
381interworking is not going to be performed. The presence of this
382directive also implies @code{.thumb}
252b5132 383
5395a469
NC
384@cindex @code{thumb_set} directive, ARM
385@item .thumb_set
386This performs the equivalent of a @code{.set} directive in that it
387creates a symbol which is an alias for another symbol (possibly not yet
388defined). This directive also has the added property in that it marks
389the aliased symbol as being a thumb function entry point, in the same
390way that the @code{.thumb_func} directive does.
391
252b5132
RH
392@cindex @code{.ltorg} directive, ARM
393@item .ltorg
394This directive causes the current contents of the literal pool to be
395dumped into the current section (which is assumed to be the .text
396section) at the current location (aligned to a word boundary).
3d0c9500
NC
397@code{GAS} maintains a separate literal pool for each section and each
398sub-section. The @code{.ltorg} directive will only affect the literal
399pool of the current section and sub-section. At the end of assembly
400all remaining, un-empty literal pools will automatically be dumped.
401
402Note - older versions of @code{GAS} would dump the current literal
403pool any time a section change occurred. This is no longer done, since
404it prevents accurate control of the placement of literal pools.
252b5132
RH
405
406@cindex @code{.pool} directive, ARM
407@item .pool
408This is a synonym for .ltorg.
409
7ed4c4c5
NC
410@cindex @code{.fnstart} directive, ARM
411@item .unwind_fnstart
412Marks the start of a function with an unwind table entry.
413
414@cindex @code{.fnend} directive, ARM
415@item .unwind_fnend
416Marks the end of a function with an unwind table entry. The unwind index
417table entry is created when this directive is processed.
418
419If no personality routine has been specified then standard personality
420routine 0 or 1 will be used, depending on the number of unwind opcodes
421required.
422
423@cindex @code{.cantunwind} directive, ARM
424@item .cantunwind
425Prevents unwinding through the current function. No personality routine
426or exception table data is required or permitted.
427
428@cindex @code{.personality} directive, ARM
429@item .personality @var{name}
430Sets the personality routine for the current function to @var{name}.
431
432@cindex @code{.personalityindex} directive, ARM
433@item .personalityindex @var{index}
434Sets the personality routine for the current function to the EABI standard
435routine number @var{index}
436
437@cindex @code{.handlerdata} directive, ARM
438@item .handlerdata
439Marks the end of the current function, and the start of the exception table
440entry for that function. Anything between this directive and the
441@code{.fnend} directive will be added to the exception table entry.
442
443Must be preceded by a @code{.personality} or @code{.personalityindex}
444directive.
445
446@cindex @code{.save} directive, ARM
447@item .save @var{reglist}
448Generate unwinder annotations to restore the registers in @var{reglist}.
449The format of @var{reglist} is the same as the corresponding store-multiple
450instruction.
451
452@smallexample
453@exdent @emph{core registers}
454 .save @{r4, r5, r6, lr@}
455 stmfd sp!, @{r4, r5, r6, lr@}
456@exdent @emph{FPA registers}
457 .save f4, 2
458 sfmfd f4, 2, [sp]!
459@exdent @emph{VFP registers}
460 .save @{d8, d9, d10@}
461 fstmdf sp!, @{d8, d9, d10@}
462@exdent @emph{iWMMXt registers}
463 .save @{wr10, wr11@}
464 wstrd wr11, [sp, #-8]!
465 wstrd wr10, [sp, #-8]!
466or
467 .save wr11
468 wstrd wr11, [sp, #-8]!
469 .save wr10
470 wstrd wr10, [sp, #-8]!
471@end smallexample
472
473@cindex @code{.pad} directive, ARM
474@item .pad #@var{count}
475Generate unwinder annotations for a stack adjustment of @var{count} bytes.
476A positive value indicates the function prologue allocated stack space by
477decrementing the stack pointer.
478
479@cindex @code{.movsp} directive, ARM
480@item .movsp @var{reg}
481Tell the unwinder that @var{reg} contains the current stack pointer.
482
483@cindex @code{.setfp} directive, ARM
484@item .setfp @var{fpreg}, @var{spreg} [, #@var{offset}]
485Make all unwinder annotations relaive to a frame pointer. Without this
486the unwinder will use offsets from the stack pointer.
487
488The syntax of this directive is the same as the @code{sub} or @code{mov}
489instruction used to set the frame pointer. @var{spreg} must be either
490@code{sp} or mentioned in a previous @code{.movsp} directive.
491
492@smallexample
493.movsp ip
494mov ip, sp
495@dots{}
496.setfp fp, ip, #4
497sub fp, ip, #4
498@end smallexample
499
500@cindex @code{.unwind_raw} directive, ARM
501@item .raw @var{offset}, @var{byte1}, @dots{}
502Insert one of more arbitary unwind opcode bytes, which are known to adjust
503the stack pointer by @var{offset} bytes.
504
505For example @code{.unwind_raw 4, 0xb1, 0x01} is equivalent to
506@code{.save @{r0@}}
507
ee065d83
PB
508@cindex @code{.cpu} directive, ARM
509@item .cpu @var{name}
510Select the target processor. Valid values for @var{name} are the same as
511for the @option{-mcpu} commandline option.
512
513@cindex @code{.arch} directive, ARM
514@item .arch @var{name}
515Select the target architecture. Valid values for @var{name} are the same as
516for the @option{-march} commandline option.
517
518@cindex @code{.fpu} directive, ARM
519@item .fpu @var{name}
520Select the floating point unit to assemble for. Valid values for @var{name}
521are the same as for the @option{-mfpu} commandline option.
522
523@cindex @code{.eabi_attribute} directive, ARM
524@item .eabi_attribute @var{tag}, @var{value}
525Set the EABI object attribute number @var{tag} to @var{value}. The value
526is either a @code{number}, @code{"string"}, or @code{number, "string"}
527depending on the tag.
528
252b5132
RH
529@end table
530
531@node ARM Opcodes
532@section Opcodes
533
534@cindex ARM opcodes
535@cindex opcodes for ARM
49a5575c
NC
536@code{@value{AS}} implements all the standard ARM opcodes. It also
537implements several pseudo opcodes, including several synthetic load
538instructions.
252b5132 539
49a5575c
NC
540@table @code
541
542@cindex @code{NOP} pseudo op, ARM
543@item NOP
544@smallexample
545 nop
546@end smallexample
252b5132 547
49a5575c
NC
548This pseudo op will always evaluate to a legal ARM instruction that does
549nothing. Currently it will evaluate to MOV r0, r0.
252b5132 550
49a5575c
NC
551@cindex @code{LDR reg,=<label>} pseudo op, ARM
552@item LDR
252b5132
RH
553@smallexample
554 ldr <register> , = <expression>
555@end smallexample
556
557If expression evaluates to a numeric constant then a MOV or MVN
558instruction will be used in place of the LDR instruction, if the
559constant can be generated by either of these instructions. Otherwise
560the constant will be placed into the nearest literal pool (if it not
561already there) and a PC relative LDR instruction will be generated.
562
49a5575c
NC
563@cindex @code{ADR reg,<label>} pseudo op, ARM
564@item ADR
565@smallexample
566 adr <register> <label>
567@end smallexample
568
569This instruction will load the address of @var{label} into the indicated
570register. The instruction will evaluate to a PC relative ADD or SUB
571instruction depending upon where the label is located. If the label is
572out of range, or if it is not defined in the same file (and section) as
573the ADR instruction, then an error will be generated. This instruction
574will not make use of the literal pool.
575
576@cindex @code{ADRL reg,<label>} pseudo op, ARM
577@item ADRL
578@smallexample
579 adrl <register> <label>
580@end smallexample
581
582This instruction will load the address of @var{label} into the indicated
a349d9dd 583register. The instruction will evaluate to one or two PC relative ADD
49a5575c
NC
584or SUB instructions depending upon where the label is located. If a
585second instruction is not needed a NOP instruction will be generated in
586its place, so that this instruction is always 8 bytes long.
587
588If the label is out of range, or if it is not defined in the same file
589(and section) as the ADRL instruction, then an error will be generated.
590This instruction will not make use of the literal pool.
591
592@end table
593
252b5132
RH
594For information on the ARM or Thumb instruction sets, see @cite{ARM
595Software Development Toolkit Reference Manual}, Advanced RISC Machines
596Ltd.
597
6057a28f
NC
598@node ARM Mapping Symbols
599@section Mapping Symbols
600
601The ARM ELF specification requires that special symbols be inserted
602into object files to mark certain features:
603
604@table @code
605
606@cindex @code{$a}
607@item $a
608At the start of a region of code containing ARM instructions.
609
610@cindex @code{$t}
611@item $t
612At the start of a region of code containing THUMB instructions.
613
614@cindex @code{$d}
615@item $d
616At the start of a region of data.
617
618@end table
619
620The assembler will automatically insert these symbols for you - there
621is no need to code them yourself. Support for tagging symbols ($b,
622$f, $p and $m) which is also mentioned in the current ARM ELF
623specification is not implemented. This is because they have been
624dropped from the new EABI and so tools cannot rely upon their
625presence.
626
This page took 0.282253 seconds and 4 git commands to generate.