bfd/
[deliverable/binutils-gdb.git] / gas / doc / c-arm.texi
CommitLineData
aa820537
AM
1@c Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2@c 2006, 2007, 2008, 2009 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
7da4f750 26* ARM Unwinding Tutorial:: Unwinding
252b5132
RH
27@end menu
28
29@node ARM Options
30@section Options
31@cindex ARM options (none)
32@cindex options for ARM (none)
adcf07e6 33
252b5132 34@table @code
adcf07e6 35
03b1477f 36@cindex @code{-mcpu=} command line option, ARM
92081f48 37@item -mcpu=@var{processor}[+@var{extension}@dots{}]
252b5132
RH
38This option specifies the target processor. The assembler will issue an
39error message if an attempt is made to assemble an instruction which
03b1477f
RE
40will not execute on the target processor. The following processor names are
41recognized:
42@code{arm1},
43@code{arm2},
44@code{arm250},
45@code{arm3},
46@code{arm6},
47@code{arm60},
48@code{arm600},
49@code{arm610},
50@code{arm620},
51@code{arm7},
52@code{arm7m},
53@code{arm7d},
54@code{arm7dm},
55@code{arm7di},
56@code{arm7dmi},
57@code{arm70},
58@code{arm700},
59@code{arm700i},
60@code{arm710},
61@code{arm710t},
62@code{arm720},
63@code{arm720t},
64@code{arm740t},
65@code{arm710c},
66@code{arm7100},
67@code{arm7500},
68@code{arm7500fe},
69@code{arm7t},
70@code{arm7tdmi},
1ff4677c 71@code{arm7tdmi-s},
03b1477f
RE
72@code{arm8},
73@code{arm810},
74@code{strongarm},
75@code{strongarm1},
76@code{strongarm110},
77@code{strongarm1100},
78@code{strongarm1110},
79@code{arm9},
80@code{arm920},
81@code{arm920t},
82@code{arm922t},
83@code{arm940t},
84@code{arm9tdmi},
7fac0536
NC
85@code{fa526} (Faraday FA526 processor),
86@code{fa626} (Faraday FA626 processor),
03b1477f 87@code{arm9e},
7de9afa2 88@code{arm926e},
1ff4677c 89@code{arm926ej-s},
03b1477f
RE
90@code{arm946e-r0},
91@code{arm946e},
db8ac8f9 92@code{arm946e-s},
03b1477f
RE
93@code{arm966e-r0},
94@code{arm966e},
db8ac8f9
PB
95@code{arm966e-s},
96@code{arm968e-s},
03b1477f 97@code{arm10t},
db8ac8f9 98@code{arm10tdmi},
03b1477f
RE
99@code{arm10e},
100@code{arm1020},
101@code{arm1020t},
7de9afa2 102@code{arm1020e},
db8ac8f9 103@code{arm1022e},
1ff4677c 104@code{arm1026ej-s},
7fac0536
NC
105@code{fa626te} (Faraday FA626TE processor),
106@code{fa726te} (Faraday FA726TE processor),
1ff4677c
RE
107@code{arm1136j-s},
108@code{arm1136jf-s},
db8ac8f9
PB
109@code{arm1156t2-s},
110@code{arm1156t2f-s},
0dd132b6
NC
111@code{arm1176jz-s},
112@code{arm1176jzf-s},
113@code{mpcore},
114@code{mpcorenovfp},
b38f9f31 115@code{cortex-a5},
62b3e311 116@code{cortex-a8},
15290f0a 117@code{cortex-a9},
dbb1f804 118@code{cortex-a15},
62b3e311 119@code{cortex-r4},
307c948d 120@code{cortex-r4f},
7ef07ba0 121@code{cortex-m4},
62b3e311 122@code{cortex-m3},
5b19eaba
NC
123@code{cortex-m1},
124@code{cortex-m0},
03b1477f
RE
125@code{ep9312} (ARM920 with Cirrus Maverick coprocessor),
126@code{i80200} (Intel XScale processor)
e16bb312 127@code{iwmmxt} (Intel(r) XScale processor with Wireless MMX(tm) technology coprocessor)
03b1477f
RE
128and
129@code{xscale}.
130The special name @code{all} may be used to allow the
131assembler to accept instructions valid for any ARM processor.
132
133In addition to the basic instruction set, the assembler can be told to
134accept various extension mnemonics that extend the processor using the
135co-processor instruction space. For example, @code{-mcpu=arm920+maverick}
69133863
MGD
136is equivalent to specifying @code{-mcpu=ep9312}.
137
138Multiple extensions may be specified, separated by a @code{+}. The
139extensions should be specified in ascending alphabetical order.
140
60e5ef9f
MGD
141Some extensions may be restricted to particular architectures; this is
142documented in the list of extensions below.
143
69133863
MGD
144Extension mnemonics may also be removed from those the assembler accepts.
145This is done be prepending @code{no} to the option that adds the extension.
146Extensions that are removed should be listed after all extensions which have
147been added, again in ascending alphabetical order. For example,
148@code{-mcpu=ep9312+nomaverick} is equivalent to specifying @code{-mcpu=arm920}.
149
150
eea54501
MGD
151The following extensions are currently supported:
152@code{idiv}, (Integer Divide Extensions for v7-A architecture),
69133863
MGD
153@code{iwmmxt},
154@code{iwmmxt2},
155@code{maverick},
60e5ef9f 156@code{mp} (Multiprocessing Extensions for v7-A and v7-R architectures),
b2a5fbdc 157@code{os} (Operating System for v6M architecture),
f4c65163 158@code{sec} (Security Extensions for v6K and v7-A architectures),
90ec0d68
MGD
159@code{virt} (Virtualization Extensions for v7-A architecture, implies
160@code{idiv}),
03b1477f 161and
69133863 162@code{xscale}.
03b1477f
RE
163
164@cindex @code{-march=} command line option, ARM
92081f48 165@item -march=@var{architecture}[+@var{extension}@dots{}]
252b5132
RH
166This option specifies the target architecture. The assembler will issue
167an error message if an attempt is made to assemble an instruction which
03b1477f
RE
168will not execute on the target architecture. The following architecture
169names are recognized:
170@code{armv1},
171@code{armv2},
172@code{armv2a},
173@code{armv2s},
174@code{armv3},
175@code{armv3m},
176@code{armv4},
177@code{armv4xm},
178@code{armv4t},
179@code{armv4txm},
180@code{armv5},
181@code{armv5t},
182@code{armv5txm},
183@code{armv5te},
09d92015 184@code{armv5texp},
c5f98204 185@code{armv6},
1ddd7f43 186@code{armv6j},
0dd132b6
NC
187@code{armv6k},
188@code{armv6z},
189@code{armv6zk},
b2a5fbdc
MGD
190@code{armv6-m},
191@code{armv6s-m},
62b3e311 192@code{armv7},
c450d570
PB
193@code{armv7-a},
194@code{armv7-r},
195@code{armv7-m},
9e3c6df6 196@code{armv7e-m},
e16bb312 197@code{iwmmxt}
03b1477f
RE
198and
199@code{xscale}.
200If both @code{-mcpu} and
201@code{-march} are specified, the assembler will use
202the setting for @code{-mcpu}.
203
204The architecture option can be extended with the same instruction set
205extension options as the @code{-mcpu} option.
206
207@cindex @code{-mfpu=} command line option, ARM
208@item -mfpu=@var{floating-point-format}
209
210This option specifies the floating point format to assemble for. The
211assembler will issue an error message if an attempt is made to assemble
212an instruction which will not execute on the target floating point unit.
213The following format options are recognized:
214@code{softfpa},
215@code{fpe},
bc89618b
RE
216@code{fpe2},
217@code{fpe3},
03b1477f
RE
218@code{fpa},
219@code{fpa10},
220@code{fpa11},
221@code{arm7500fe},
222@code{softvfp},
223@code{softvfp+vfp},
224@code{vfp},
225@code{vfp10},
226@code{vfp10-r0},
227@code{vfp9},
228@code{vfpxd},
62f3b8c8
PB
229@code{vfpv2},
230@code{vfpv3},
231@code{vfpv3-fp16},
232@code{vfpv3-d16},
233@code{vfpv3-d16-fp16},
234@code{vfpv3xd},
235@code{vfpv3xd-d16},
236@code{vfpv4},
237@code{vfpv4-d16},
f0cd0667 238@code{fpv4-sp-d16},
09d92015
MM
239@code{arm1020t},
240@code{arm1020e},
b1cc4aeb 241@code{arm1136jf-s},
62f3b8c8
PB
242@code{maverick},
243@code{neon},
03b1477f 244and
62f3b8c8 245@code{neon-vfpv4}.
03b1477f
RE
246
247In addition to determining which instructions are assembled, this option
248also affects the way in which the @code{.double} assembler directive behaves
249when assembling little-endian code.
250
251The default is dependent on the processor selected. For Architecture 5 or
252later, the default is to assembler for VFP instructions; for earlier
253architectures the default is to assemble for FPA instructions.
adcf07e6 254
252b5132
RH
255@cindex @code{-mthumb} command line option, ARM
256@item -mthumb
03b1477f
RE
257This option specifies that the assembler should start assembling Thumb
258instructions; that is, it should behave as though the file starts with a
259@code{.code 16} directive.
adcf07e6 260
252b5132
RH
261@cindex @code{-mthumb-interwork} command line option, ARM
262@item -mthumb-interwork
263This option specifies that the output generated by the assembler should
264be marked as supporting interworking.
adcf07e6 265
52970753
NC
266@cindex @code{-mimplicit-it} command line option, ARM
267@item -mimplicit-it=never
268@itemx -mimplicit-it=always
269@itemx -mimplicit-it=arm
270@itemx -mimplicit-it=thumb
271The @code{-mimplicit-it} option controls the behavior of the assembler when
272conditional instructions are not enclosed in IT blocks.
273There are four possible behaviors.
274If @code{never} is specified, such constructs cause a warning in ARM
275code and an error in Thumb-2 code.
276If @code{always} is specified, such constructs are accepted in both
277ARM and Thumb-2 code, where the IT instruction is added implicitly.
278If @code{arm} is specified, such constructs are accepted in ARM code
279and cause an error in Thumb-2 code.
280If @code{thumb} is specified, such constructs cause a warning in ARM
281code and are accepted in Thumb-2 code. If you omit this option, the
282behavior is equivalent to @code{-mimplicit-it=arm}.
e07e6e58 283
5a5829dd
NS
284@cindex @code{-mapcs-26} command line option, ARM
285@cindex @code{-mapcs-32} command line option, ARM
286@item -mapcs-26
287@itemx -mapcs-32
288These options specify that the output generated by the assembler should
252b5132
RH
289be marked as supporting the indicated version of the Arm Procedure.
290Calling Standard.
adcf07e6 291
077b8428
NC
292@cindex @code{-matpcs} command line option, ARM
293@item -matpcs
294This option specifies that the output generated by the assembler should
295be marked as supporting the Arm/Thumb Procedure Calling Standard. If
296enabled this option will cause the assembler to create an empty
297debugging section in the object file called .arm.atpcs. Debuggers can
298use this to determine the ABI being used by.
299
adcf07e6 300@cindex @code{-mapcs-float} command line option, ARM
252b5132 301@item -mapcs-float
1be59579 302This indicates the floating point variant of the APCS should be
252b5132 303used. In this variant floating point arguments are passed in FP
550262c4 304registers rather than integer registers.
adcf07e6
NC
305
306@cindex @code{-mapcs-reentrant} command line option, ARM
252b5132
RH
307@item -mapcs-reentrant
308This indicates that the reentrant variant of the APCS should be used.
309This variant supports position independent code.
adcf07e6 310
33a392fb
PB
311@cindex @code{-mfloat-abi=} command line option, ARM
312@item -mfloat-abi=@var{abi}
313This option specifies that the output generated by the assembler should be
314marked as using specified floating point ABI.
315The following values are recognized:
316@code{soft},
317@code{softfp}
318and
319@code{hard}.
320
d507cf36
PB
321@cindex @code{-eabi=} command line option, ARM
322@item -meabi=@var{ver}
323This option specifies which EABI version the produced object files should
324conform to.
b45619c0 325The following values are recognized:
3a4a14e9
PB
326@code{gnu},
327@code{4}
d507cf36 328and
3a4a14e9 329@code{5}.
d507cf36 330
252b5132
RH
331@cindex @code{-EB} command line option, ARM
332@item -EB
333This option specifies that the output generated by the assembler should
334be marked as being encoded for a big-endian processor.
adcf07e6 335
252b5132
RH
336@cindex @code{-EL} command line option, ARM
337@item -EL
338This option specifies that the output generated by the assembler should
339be marked as being encoded for a little-endian processor.
adcf07e6 340
252b5132
RH
341@cindex @code{-k} command line option, ARM
342@cindex PIC code generation for ARM
343@item -k
a349d9dd
PB
344This option specifies that the output of the assembler should be marked
345as position-independent code (PIC).
adcf07e6 346
845b51d6
PB
347@cindex @code{--fix-v4bx} command line option, ARM
348@item --fix-v4bx
349Allow @code{BX} instructions in ARMv4 code. This is intended for use with
350the linker option of the same name.
351
278df34e
NS
352@cindex @code{-mwarn-deprecated} command line option, ARM
353@item -mwarn-deprecated
354@itemx -mno-warn-deprecated
355Enable or disable warnings about using deprecated options or
356features. The default is to warn.
357
252b5132
RH
358@end table
359
360
361@node ARM Syntax
362@section Syntax
363@menu
cab7e4d9 364* ARM-Instruction-Set:: Instruction Set
252b5132
RH
365* ARM-Chars:: Special Characters
366* ARM-Regs:: Register Names
b6895b4f 367* ARM-Relocations:: Relocations
99f1a7a7 368* ARM-Neon-Alignment:: NEON Alignment Specifiers
252b5132
RH
369@end menu
370
cab7e4d9
NC
371@node ARM-Instruction-Set
372@subsection Instruction Set Syntax
373Two slightly different syntaxes are support for ARM and THUMB
374instructions. The default, @code{divided}, uses the old style where
375ARM and THUMB instructions had their own, separate syntaxes. The new,
376@code{unified} syntax, which can be selected via the @code{.syntax}
377directive, and has the following main features:
378
379@table @bullet
380@item
381Immediate operands do not require a @code{#} prefix.
382
383@item
384The @code{IT} instruction may appear, and if it does it is validated
385against subsequent conditional affixes. In ARM mode it does not
386generate machine code, in THUMB mode it does.
387
388@item
389For ARM instructions the conditional affixes always appear at the end
390of the instruction. For THUMB instructions conditional affixes can be
391used, but only inside the scope of an @code{IT} instruction.
392
393@item
394All of the instructions new to the V6T2 architecture (and later) are
395available. (Only a few such instructions can be written in the
396@code{divided} syntax).
397
398@item
399The @code{.N} and @code{.W} suffixes are recognized and honored.
400
401@item
402All instructions set the flags if and only if they have an @code{s}
403affix.
404@end table
405
252b5132
RH
406@node ARM-Chars
407@subsection Special Characters
408
409@cindex line comment character, ARM
410@cindex ARM line comment character
550262c4
NC
411The presence of a @samp{@@} on a line indicates the start of a comment
412that extends to the end of the current line. If a @samp{#} appears as
413the first character of a line, the whole line is treated as a comment.
414
415@cindex line separator, ARM
416@cindex statement separator, ARM
417@cindex ARM line separator
a349d9dd
PB
418The @samp{;} character can be used instead of a newline to separate
419statements.
550262c4
NC
420
421@cindex immediate character, ARM
422@cindex ARM immediate character
423Either @samp{#} or @samp{$} can be used to indicate immediate operands.
252b5132
RH
424
425@cindex identifiers, ARM
426@cindex ARM identifiers
427*TODO* Explain about /data modifier on symbols.
428
429@node ARM-Regs
430@subsection Register Names
431
432@cindex ARM register names
433@cindex register names, ARM
434*TODO* Explain about ARM register naming, and the predefined names.
435
99f1a7a7
DG
436@node ARM-Neon-Alignment
437@subsection NEON Alignment Specifiers
438
439@cindex alignment for NEON instructions
440Some NEON load/store instructions allow an optional address
441alignment qualifier.
442The ARM documentation specifies that this is indicated by
443@samp{@@ @var{align}}. However GAS already interprets
444the @samp{@@} character as a "line comment" start,
445so @samp{: @var{align}} is used instead. For example:
446
447@smallexample
448 vld1.8 @{q0@}, [r0, :128]
449@end smallexample
450
252b5132
RH
451@node ARM Floating Point
452@section Floating Point
453
454@cindex floating point, ARM (@sc{ieee})
455@cindex ARM floating point (@sc{ieee})
456The ARM family uses @sc{ieee} floating-point numbers.
457
b6895b4f
PB
458@node ARM-Relocations
459@subsection ARM relocation generation
460
461@cindex data relocations, ARM
462@cindex ARM data relocations
463Specific data relocations can be generated by putting the relocation name
464in parentheses after the symbol name. For example:
465
466@smallexample
467 .word foo(TARGET1)
468@end smallexample
469
470This will generate an @samp{R_ARM_TARGET1} relocation against the symbol
471@var{foo}.
472The following relocations are supported:
473@code{GOT},
474@code{GOTOFF},
475@code{TARGET1},
476@code{TARGET2},
477@code{SBREL},
478@code{TLSGD},
479@code{TLSLDM},
480@code{TLSLDO},
0855e32b
NS
481@code{TLSDESC},
482@code{TLSCALL},
b43420e6
NC
483@code{GOTTPOFF},
484@code{GOT_PREL}
b6895b4f
PB
485and
486@code{TPOFF}.
487
488For compatibility with older toolchains the assembler also accepts
489@code{(PLT)} after branch targets. This will generate the deprecated
490@samp{R_ARM_PLT32} relocation.
491
492@cindex MOVW and MOVT relocations, ARM
493Relocations for @samp{MOVW} and @samp{MOVT} instructions can be generated
494by prefixing the value with @samp{#:lower16:} and @samp{#:upper16}
b45619c0 495respectively. For example to load the 32-bit address of foo into r0:
252b5132 496
b6895b4f
PB
497@smallexample
498 MOVW r0, #:lower16:foo
499 MOVT r0, #:upper16:foo
500@end smallexample
252b5132
RH
501
502@node ARM Directives
503@section ARM Machine Directives
504
505@cindex machine directives, ARM
506@cindex ARM machine directives
507@table @code
508
4a6bc624
NS
509@c AAAAAAAAAAAAAAAAAAAAAAAAA
510
511@cindex @code{.2byte} directive, ARM
512@cindex @code{.4byte} directive, ARM
513@cindex @code{.8byte} directive, ARM
514@item .2byte @var{expression} [, @var{expression}]*
515@itemx .4byte @var{expression} [, @var{expression}]*
516@itemx .8byte @var{expression} [, @var{expression}]*
517These directives write 2, 4 or 8 byte values to the output section.
518
519@cindex @code{.align} directive, ARM
adcf07e6
NC
520@item .align @var{expression} [, @var{expression}]
521This is the generic @var{.align} directive. For the ARM however if the
522first argument is zero (ie no alignment is needed) the assembler will
523behave as if the argument had been 2 (ie pad to the next four byte
062b7c0c 524boundary). This is for compatibility with ARM's own assembler.
adcf07e6 525
4a6bc624
NS
526@cindex @code{.arch} directive, ARM
527@item .arch @var{name}
528Select the target architecture. Valid values for @var{name} are the same as
529for the @option{-march} commandline option.
252b5132 530
69133863
MGD
531Specifying @code{.arch} clears any previously selected architecture
532extensions.
533
534@cindex @code{.arch_extension} directive, ARM
535@item .arch_extension @var{name}
536Add or remove an architecture extension to the target architecture. Valid
537values for @var{name} are the same as those accepted as architectural
538extensions by the @option{-mcpu} commandline option.
539
540@code{.arch_extension} may be used multiple times to add or remove extensions
541incrementally to the architecture being compiled for.
542
4a6bc624
NS
543@cindex @code{.arm} directive, ARM
544@item .arm
545This performs the same action as @var{.code 32}.
252b5132 546
4a6bc624
NS
547@anchor{arm_pad}
548@cindex @code{.pad} directive, ARM
549@item .pad #@var{count}
550Generate unwinder annotations for a stack adjustment of @var{count} bytes.
551A positive value indicates the function prologue allocated stack space by
552decrementing the stack pointer.
0bbf2aa4 553
4a6bc624 554@c BBBBBBBBBBBBBBBBBBBBBBBBBB
0bbf2aa4 555
4a6bc624
NS
556@cindex @code{.bss} directive, ARM
557@item .bss
558This directive switches to the @code{.bss} section.
0bbf2aa4 559
4a6bc624
NS
560@c CCCCCCCCCCCCCCCCCCCCCCCCCC
561
562@cindex @code{.cantunwind} directive, ARM
563@item .cantunwind
564Prevents unwinding through the current function. No personality routine
565or exception table data is required or permitted.
566
567@cindex @code{.code} directive, ARM
568@item .code @code{[16|32]}
569This directive selects the instruction set being generated. The value 16
570selects Thumb, with the value 32 selecting ARM.
571
572@cindex @code{.cpu} directive, ARM
573@item .cpu @var{name}
574Select the target processor. Valid values for @var{name} are the same as
575for the @option{-mcpu} commandline option.
576
69133863
MGD
577Specifying @code{.cpu} clears any previously selected architecture
578extensions.
579
4a6bc624
NS
580@c DDDDDDDDDDDDDDDDDDDDDDDDDD
581
582@cindex @code{.dn} and @code{.qn} directives, ARM
f467aa98 583@item @var{name} .dn @var{register name} [@var{.type}] [[@var{index}]]
1f9bb1ca 584@itemx @var{name} .qn @var{register name} [@var{.type}] [[@var{index}]]
23753660
JB
585
586The @code{dn} and @code{qn} directives are used to create typed
587and/or indexed register aliases for use in Advanced SIMD Extension
588(Neon) instructions. The former should be used to create aliases
589of double-precision registers, and the latter to create aliases of
590quad-precision registers.
591
592If these directives are used to create typed aliases, those aliases can
593be used in Neon instructions instead of writing types after the mnemonic
594or after each operand. For example:
595
596@smallexample
597 x .dn d2.f32
598 y .dn d3.f32
599 z .dn d4.f32[1]
600 vmul x,y,z
601@end smallexample
602
603This is equivalent to writing the following:
604
605@smallexample
606 vmul.f32 d2,d3,d4[1]
607@end smallexample
608
609Aliases created using @code{dn} or @code{qn} can be destroyed using
610@code{unreq}.
611
4a6bc624 612@c EEEEEEEEEEEEEEEEEEEEEEEEEE
252b5132 613
4a6bc624
NS
614@cindex @code{.eabi_attribute} directive, ARM
615@item .eabi_attribute @var{tag}, @var{value}
616Set the EABI object attribute @var{tag} to @var{value}.
252b5132 617
4a6bc624
NS
618The @var{tag} is either an attribute number, or one of the following:
619@code{Tag_CPU_raw_name}, @code{Tag_CPU_name}, @code{Tag_CPU_arch},
620@code{Tag_CPU_arch_profile}, @code{Tag_ARM_ISA_use},
75375b3e 621@code{Tag_THUMB_ISA_use}, @code{Tag_FP_arch}, @code{Tag_WMMX_arch},
4a6bc624
NS
622@code{Tag_Advanced_SIMD_arch}, @code{Tag_PCS_config},
623@code{Tag_ABI_PCS_R9_use}, @code{Tag_ABI_PCS_RW_data},
624@code{Tag_ABI_PCS_RO_data}, @code{Tag_ABI_PCS_GOT_use},
625@code{Tag_ABI_PCS_wchar_t}, @code{Tag_ABI_FP_rounding},
626@code{Tag_ABI_FP_denormal}, @code{Tag_ABI_FP_exceptions},
627@code{Tag_ABI_FP_user_exceptions}, @code{Tag_ABI_FP_number_model},
75375b3e 628@code{Tag_ABI_align_needed}, @code{Tag_ABI_align_preserved},
4a6bc624
NS
629@code{Tag_ABI_enum_size}, @code{Tag_ABI_HardFP_use},
630@code{Tag_ABI_VFP_args}, @code{Tag_ABI_WMMX_args},
631@code{Tag_ABI_optimization_goals}, @code{Tag_ABI_FP_optimization_goals},
632@code{Tag_compatibility}, @code{Tag_CPU_unaligned_access},
75375b3e 633@code{Tag_FP_HP_extension}, @code{Tag_ABI_FP_16bit_format},
cd21e546 634@code{Tag_MPextension_use}, @code{Tag_DIV_use},
4a6bc624
NS
635@code{Tag_nodefaults}, @code{Tag_also_compatible_with},
636@code{Tag_conformance}, @code{Tag_T2EE_use},
cd21e546 637@code{Tag_Virtualization_use}
4a6bc624
NS
638
639The @var{value} is either a @code{number}, @code{"string"}, or
640@code{number, "string"} depending on the tag.
641
75375b3e
MGD
642Note - the following legacy values are also accepted by @var{tag}:
643@code{Tag_VFP_arch}, @code{Tag_ABI_align8_needed},
644@code{Tag_ABI_align8_preserved}, @code{Tag_VFP_HP_extension},
645
4a6bc624
NS
646@cindex @code{.even} directive, ARM
647@item .even
648This directive aligns to an even-numbered address.
649
650@cindex @code{.extend} directive, ARM
651@cindex @code{.ldouble} directive, ARM
652@item .extend @var{expression} [, @var{expression}]*
653@itemx .ldouble @var{expression} [, @var{expression}]*
654These directives write 12byte long double floating-point values to the
655output section. These are not compatible with current ARM processors
656or ABIs.
657
658@c FFFFFFFFFFFFFFFFFFFFFFFFFF
659
660@anchor{arm_fnend}
661@cindex @code{.fnend} directive, ARM
662@item .fnend
663Marks the end of a function with an unwind table entry. The unwind index
664table entry is created when this directive is processed.
252b5132 665
4a6bc624
NS
666If no personality routine has been specified then standard personality
667routine 0 or 1 will be used, depending on the number of unwind opcodes
668required.
669
670@anchor{arm_fnstart}
671@cindex @code{.fnstart} directive, ARM
672@item .fnstart
673Marks the start of a function with an unwind table entry.
674
675@cindex @code{.force_thumb} directive, ARM
252b5132
RH
676@item .force_thumb
677This directive forces the selection of Thumb instructions, even if the
678target processor does not support those instructions
679
4a6bc624
NS
680@cindex @code{.fpu} directive, ARM
681@item .fpu @var{name}
682Select the floating-point unit to assemble for. Valid values for @var{name}
683are the same as for the @option{-mfpu} commandline option.
252b5132 684
4a6bc624
NS
685@c GGGGGGGGGGGGGGGGGGGGGGGGGG
686@c HHHHHHHHHHHHHHHHHHHHHHHHHH
e1da3f5b 687
4a6bc624
NS
688@cindex @code{.handlerdata} directive, ARM
689@item .handlerdata
690Marks the end of the current function, and the start of the exception table
691entry for that function. Anything between this directive and the
692@code{.fnend} directive will be added to the exception table entry.
693
694Must be preceded by a @code{.personality} or @code{.personalityindex}
695directive.
696
697@c IIIIIIIIIIIIIIIIIIIIIIIIII
c921be7d
NC
698
699@cindex @code{.inst} directive, ARM
700@item .inst @var{opcode} [ , @dots{} ]
1f9bb1ca
AS
701@itemx .inst.n @var{opcode} [ , @dots{} ]
702@itemx .inst.w @var{opcode} [ , @dots{} ]
c921be7d
NC
703Generates the instruction corresponding to the numerical value @var{opcode}.
704@code{.inst.n} and @code{.inst.w} allow the Thumb instruction size to be
705specified explicitly, overriding the normal encoding rules.
706
4a6bc624
NS
707@c JJJJJJJJJJJJJJJJJJJJJJJJJJ
708@c KKKKKKKKKKKKKKKKKKKKKKKKKK
709@c LLLLLLLLLLLLLLLLLLLLLLLLLL
710
711@item .ldouble @var{expression} [, @var{expression}]*
712See @code{.extend}.
5395a469 713
252b5132
RH
714@cindex @code{.ltorg} directive, ARM
715@item .ltorg
716This directive causes the current contents of the literal pool to be
717dumped into the current section (which is assumed to be the .text
718section) at the current location (aligned to a word boundary).
3d0c9500
NC
719@code{GAS} maintains a separate literal pool for each section and each
720sub-section. The @code{.ltorg} directive will only affect the literal
721pool of the current section and sub-section. At the end of assembly
722all remaining, un-empty literal pools will automatically be dumped.
723
724Note - older versions of @code{GAS} would dump the current literal
725pool any time a section change occurred. This is no longer done, since
726it prevents accurate control of the placement of literal pools.
252b5132 727
4a6bc624 728@c MMMMMMMMMMMMMMMMMMMMMMMMMM
252b5132 729
4a6bc624
NS
730@cindex @code{.movsp} directive, ARM
731@item .movsp @var{reg} [, #@var{offset}]
732Tell the unwinder that @var{reg} contains an offset from the current
733stack pointer. If @var{offset} is not specified then it is assumed to be
734zero.
7ed4c4c5 735
4a6bc624
NS
736@c NNNNNNNNNNNNNNNNNNNNNNNNNN
737@c OOOOOOOOOOOOOOOOOOOOOOOOOO
7ed4c4c5 738
4a6bc624
NS
739@cindex @code{.object_arch} directive, ARM
740@item .object_arch @var{name}
741Override the architecture recorded in the EABI object attribute section.
742Valid values for @var{name} are the same as for the @code{.arch} directive.
743Typically this is useful when code uses runtime detection of CPU features.
7ed4c4c5 744
4a6bc624
NS
745@c PPPPPPPPPPPPPPPPPPPPPPPPPP
746
747@cindex @code{.packed} directive, ARM
748@item .packed @var{expression} [, @var{expression}]*
749This directive writes 12-byte packed floating-point values to the
750output section. These are not compatible with current ARM processors
751or ABIs.
752
753@cindex @code{.pad} directive, ARM
754@item .pad #@var{count}
755Generate unwinder annotations for a stack adjustment of @var{count} bytes.
756A positive value indicates the function prologue allocated stack space by
757decrementing the stack pointer.
7ed4c4c5
NC
758
759@cindex @code{.personality} directive, ARM
760@item .personality @var{name}
761Sets the personality routine for the current function to @var{name}.
762
763@cindex @code{.personalityindex} directive, ARM
764@item .personalityindex @var{index}
765Sets the personality routine for the current function to the EABI standard
766routine number @var{index}
767
4a6bc624
NS
768@cindex @code{.pool} directive, ARM
769@item .pool
770This is a synonym for .ltorg.
7ed4c4c5 771
4a6bc624
NS
772@c QQQQQQQQQQQQQQQQQQQQQQQQQQ
773@c RRRRRRRRRRRRRRRRRRRRRRRRRR
774
775@cindex @code{.req} directive, ARM
776@item @var{name} .req @var{register name}
777This creates an alias for @var{register name} called @var{name}. For
778example:
779
780@smallexample
781 foo .req r0
782@end smallexample
783
784@c SSSSSSSSSSSSSSSSSSSSSSSSSS
7ed4c4c5 785
7da4f750 786@anchor{arm_save}
7ed4c4c5
NC
787@cindex @code{.save} directive, ARM
788@item .save @var{reglist}
789Generate unwinder annotations to restore the registers in @var{reglist}.
790The format of @var{reglist} is the same as the corresponding store-multiple
791instruction.
792
793@smallexample
794@exdent @emph{core registers}
795 .save @{r4, r5, r6, lr@}
796 stmfd sp!, @{r4, r5, r6, lr@}
797@exdent @emph{FPA registers}
798 .save f4, 2
799 sfmfd f4, 2, [sp]!
800@exdent @emph{VFP registers}
801 .save @{d8, d9, d10@}
fa073d69 802 fstmdx sp!, @{d8, d9, d10@}
7ed4c4c5
NC
803@exdent @emph{iWMMXt registers}
804 .save @{wr10, wr11@}
805 wstrd wr11, [sp, #-8]!
806 wstrd wr10, [sp, #-8]!
807or
808 .save wr11
809 wstrd wr11, [sp, #-8]!
810 .save wr10
811 wstrd wr10, [sp, #-8]!
812@end smallexample
813
7da4f750 814@anchor{arm_setfp}
7ed4c4c5
NC
815@cindex @code{.setfp} directive, ARM
816@item .setfp @var{fpreg}, @var{spreg} [, #@var{offset}]
4a6bc624 817Make all unwinder annotations relative to a frame pointer. Without this
7ed4c4c5
NC
818the unwinder will use offsets from the stack pointer.
819
a5b82cbe 820The syntax of this directive is the same as the @code{add} or @code{mov}
7ed4c4c5
NC
821instruction used to set the frame pointer. @var{spreg} must be either
822@code{sp} or mentioned in a previous @code{.movsp} directive.
823
824@smallexample
825.movsp ip
826mov ip, sp
827@dots{}
828.setfp fp, ip, #4
a5b82cbe 829add fp, ip, #4
7ed4c4c5
NC
830@end smallexample
831
4a6bc624
NS
832@cindex @code{.secrel32} directive, ARM
833@item .secrel32 @var{expression} [, @var{expression}]*
834This directive emits relocations that evaluate to the section-relative
835offset of each expression's symbol. This directive is only supported
836for PE targets.
837
cab7e4d9
NC
838@cindex @code{.syntax} directive, ARM
839@item .syntax [@code{unified} | @code{divided}]
840This directive sets the Instruction Set Syntax as described in the
841@ref{ARM-Instruction-Set} section.
842
4a6bc624
NS
843@c TTTTTTTTTTTTTTTTTTTTTTTTTT
844
845@cindex @code{.thumb} directive, ARM
846@item .thumb
847This performs the same action as @var{.code 16}.
848
849@cindex @code{.thumb_func} directive, ARM
850@item .thumb_func
851This directive specifies that the following symbol is the name of a
852Thumb encoded function. This information is necessary in order to allow
853the assembler and linker to generate correct code for interworking
854between Arm and Thumb instructions and should be used even if
855interworking is not going to be performed. The presence of this
856directive also implies @code{.thumb}
857
858This directive is not neccessary when generating EABI objects. On these
859targets the encoding is implicit when generating Thumb code.
860
861@cindex @code{.thumb_set} directive, ARM
862@item .thumb_set
863This performs the equivalent of a @code{.set} directive in that it
864creates a symbol which is an alias for another symbol (possibly not yet
865defined). This directive also has the added property in that it marks
866the aliased symbol as being a thumb function entry point, in the same
867way that the @code{.thumb_func} directive does.
868
0855e32b
NS
869@cindex @code{.tlsdescseq} directive, ARM
870@item .tlsdescseq @var{tls-variable}
871This directive is used to annotate parts of an inlined TLS descriptor
872trampoline. Normally the trampoline is provided by the linker, and
873this directive is not needed.
874
4a6bc624
NS
875@c UUUUUUUUUUUUUUUUUUUUUUUUUU
876
877@cindex @code{.unreq} directive, ARM
878@item .unreq @var{alias-name}
879This undefines a register alias which was previously defined using the
880@code{req}, @code{dn} or @code{qn} directives. For example:
881
882@smallexample
883 foo .req r0
884 .unreq foo
885@end smallexample
886
887An error occurs if the name is undefined. Note - this pseudo op can
888be used to delete builtin in register name aliases (eg 'r0'). This
889should only be done if it is really necessary.
890
7ed4c4c5 891@cindex @code{.unwind_raw} directive, ARM
4a6bc624 892@item .unwind_raw @var{offset}, @var{byte1}, @dots{}
7ed4c4c5
NC
893Insert one of more arbitary unwind opcode bytes, which are known to adjust
894the stack pointer by @var{offset} bytes.
895
896For example @code{.unwind_raw 4, 0xb1, 0x01} is equivalent to
897@code{.save @{r0@}}
898
4a6bc624 899@c VVVVVVVVVVVVVVVVVVVVVVVVVV
ee065d83 900
4a6bc624
NS
901@cindex @code{.vsave} directive, ARM
902@item .vsave @var{vfp-reglist}
903Generate unwinder annotations to restore the VFP registers in @var{vfp-reglist}
904using FLDMD. Also works for VFPv3 registers
905that are to be restored using VLDM.
906The format of @var{vfp-reglist} is the same as the corresponding store-multiple
907instruction.
ee065d83 908
4a6bc624
NS
909@smallexample
910@exdent @emph{VFP registers}
911 .vsave @{d8, d9, d10@}
912 fstmdd sp!, @{d8, d9, d10@}
913@exdent @emph{VFPv3 registers}
914 .vsave @{d15, d16, d17@}
915 vstm sp!, @{d15, d16, d17@}
916@end smallexample
e04befd0 917
4a6bc624
NS
918Since FLDMX and FSTMX are now deprecated, this directive should be
919used in favour of @code{.save} for saving VFP registers for ARMv6 and above.
e04befd0 920
4a6bc624
NS
921@c WWWWWWWWWWWWWWWWWWWWWWWWWW
922@c XXXXXXXXXXXXXXXXXXXXXXXXXX
923@c YYYYYYYYYYYYYYYYYYYYYYYYYY
924@c ZZZZZZZZZZZZZZZZZZZZZZZZZZ
ee065d83 925
252b5132
RH
926@end table
927
928@node ARM Opcodes
929@section Opcodes
930
931@cindex ARM opcodes
932@cindex opcodes for ARM
49a5575c
NC
933@code{@value{AS}} implements all the standard ARM opcodes. It also
934implements several pseudo opcodes, including several synthetic load
935instructions.
252b5132 936
49a5575c
NC
937@table @code
938
939@cindex @code{NOP} pseudo op, ARM
940@item NOP
941@smallexample
942 nop
943@end smallexample
252b5132 944
49a5575c
NC
945This pseudo op will always evaluate to a legal ARM instruction that does
946nothing. Currently it will evaluate to MOV r0, r0.
252b5132 947
49a5575c
NC
948@cindex @code{LDR reg,=<label>} pseudo op, ARM
949@item LDR
252b5132
RH
950@smallexample
951 ldr <register> , = <expression>
952@end smallexample
953
954If expression evaluates to a numeric constant then a MOV or MVN
955instruction will be used in place of the LDR instruction, if the
956constant can be generated by either of these instructions. Otherwise
957the constant will be placed into the nearest literal pool (if it not
958already there) and a PC relative LDR instruction will be generated.
959
49a5575c
NC
960@cindex @code{ADR reg,<label>} pseudo op, ARM
961@item ADR
962@smallexample
963 adr <register> <label>
964@end smallexample
965
966This instruction will load the address of @var{label} into the indicated
967register. The instruction will evaluate to a PC relative ADD or SUB
968instruction depending upon where the label is located. If the label is
969out of range, or if it is not defined in the same file (and section) as
970the ADR instruction, then an error will be generated. This instruction
971will not make use of the literal pool.
972
973@cindex @code{ADRL reg,<label>} pseudo op, ARM
974@item ADRL
975@smallexample
976 adrl <register> <label>
977@end smallexample
978
979This instruction will load the address of @var{label} into the indicated
a349d9dd 980register. The instruction will evaluate to one or two PC relative ADD
49a5575c
NC
981or SUB instructions depending upon where the label is located. If a
982second instruction is not needed a NOP instruction will be generated in
983its place, so that this instruction is always 8 bytes long.
984
985If the label is out of range, or if it is not defined in the same file
986(and section) as the ADRL instruction, then an error will be generated.
987This instruction will not make use of the literal pool.
988
989@end table
990
252b5132
RH
991For information on the ARM or Thumb instruction sets, see @cite{ARM
992Software Development Toolkit Reference Manual}, Advanced RISC Machines
993Ltd.
994
6057a28f
NC
995@node ARM Mapping Symbols
996@section Mapping Symbols
997
998The ARM ELF specification requires that special symbols be inserted
999into object files to mark certain features:
1000
1001@table @code
1002
1003@cindex @code{$a}
1004@item $a
1005At the start of a region of code containing ARM instructions.
1006
1007@cindex @code{$t}
1008@item $t
1009At the start of a region of code containing THUMB instructions.
1010
1011@cindex @code{$d}
1012@item $d
1013At the start of a region of data.
1014
1015@end table
1016
1017The assembler will automatically insert these symbols for you - there
1018is no need to code them yourself. Support for tagging symbols ($b,
1019$f, $p and $m) which is also mentioned in the current ARM ELF
1020specification is not implemented. This is because they have been
1021dropped from the new EABI and so tools cannot rely upon their
1022presence.
1023
7da4f750
MM
1024@node ARM Unwinding Tutorial
1025@section Unwinding
1026
1027The ABI for the ARM Architecture specifies a standard format for
1028exception unwind information. This information is used when an
1029exception is thrown to determine where control should be transferred.
1030In particular, the unwind information is used to determine which
1031function called the function that threw the exception, and which
1032function called that one, and so forth. This information is also used
1033to restore the values of callee-saved registers in the function
1034catching the exception.
1035
1036If you are writing functions in assembly code, and those functions
1037call other functions that throw exceptions, you must use assembly
1038pseudo ops to ensure that appropriate exception unwind information is
1039generated. Otherwise, if one of the functions called by your assembly
1040code throws an exception, the run-time library will be unable to
1041unwind the stack through your assembly code and your program will not
1042behave correctly.
1043
1044To illustrate the use of these pseudo ops, we will examine the code
1045that G++ generates for the following C++ input:
1046
1047@verbatim
1048void callee (int *);
1049
1050int
1051caller ()
1052{
1053 int i;
1054 callee (&i);
1055 return i;
1056}
1057@end verbatim
1058
1059This example does not show how to throw or catch an exception from
1060assembly code. That is a much more complex operation and should
1061always be done in a high-level language, such as C++, that directly
1062supports exceptions.
1063
1064The code generated by one particular version of G++ when compiling the
1065example above is:
1066
1067@verbatim
1068_Z6callerv:
1069 .fnstart
1070.LFB2:
1071 @ Function supports interworking.
1072 @ args = 0, pretend = 0, frame = 8
1073 @ frame_needed = 1, uses_anonymous_args = 0
1074 stmfd sp!, {fp, lr}
1075 .save {fp, lr}
1076.LCFI0:
1077 .setfp fp, sp, #4
1078 add fp, sp, #4
1079.LCFI1:
1080 .pad #8
1081 sub sp, sp, #8
1082.LCFI2:
1083 sub r3, fp, #8
1084 mov r0, r3
1085 bl _Z6calleePi
1086 ldr r3, [fp, #-8]
1087 mov r0, r3
1088 sub sp, fp, #4
1089 ldmfd sp!, {fp, lr}
1090 bx lr
1091.LFE2:
1092 .fnend
1093@end verbatim
1094
1095Of course, the sequence of instructions varies based on the options
1096you pass to GCC and on the version of GCC in use. The exact
1097instructions are not important since we are focusing on the pseudo ops
1098that are used to generate unwind information.
1099
1100An important assumption made by the unwinder is that the stack frame
1101does not change during the body of the function. In particular, since
1102we assume that the assembly code does not itself throw an exception,
1103the only point where an exception can be thrown is from a call, such
1104as the @code{bl} instruction above. At each call site, the same saved
1105registers (including @code{lr}, which indicates the return address)
1106must be located in the same locations relative to the frame pointer.
1107
1108The @code{.fnstart} (@pxref{arm_fnstart,,.fnstart pseudo op}) pseudo
1109op appears immediately before the first instruction of the function
1110while the @code{.fnend} (@pxref{arm_fnend,,.fnend pseudo op}) pseudo
1111op appears immediately after the last instruction of the function.
1112These pseudo ops specify the range of the function.
1113
1114Only the order of the other pseudos ops (e.g., @code{.setfp} or
1115@code{.pad}) matters; their exact locations are irrelevant. In the
1116example above, the compiler emits the pseudo ops with particular
1117instructions. That makes it easier to understand the code, but it is
1118not required for correctness. It would work just as well to emit all
1119of the pseudo ops other than @code{.fnend} in the same order, but
1120immediately after @code{.fnstart}.
1121
1122The @code{.save} (@pxref{arm_save,,.save pseudo op}) pseudo op
1123indicates registers that have been saved to the stack so that they can
1124be restored before the function returns. The argument to the
1125@code{.save} pseudo op is a list of registers to save. If a register
1126is ``callee-saved'' (as specified by the ABI) and is modified by the
1127function you are writing, then your code must save the value before it
1128is modified and restore the original value before the function
1129returns. If an exception is thrown, the run-time library restores the
1130values of these registers from their locations on the stack before
1131returning control to the exception handler. (Of course, if an
1132exception is not thrown, the function that contains the @code{.save}
1133pseudo op restores these registers in the function epilogue, as is
1134done with the @code{ldmfd} instruction above.)
1135
1136You do not have to save callee-saved registers at the very beginning
1137of the function and you do not need to use the @code{.save} pseudo op
1138immediately following the point at which the registers are saved.
1139However, if you modify a callee-saved register, you must save it on
1140the stack before modifying it and before calling any functions which
1141might throw an exception. And, you must use the @code{.save} pseudo
1142op to indicate that you have done so.
1143
1144The @code{.pad} (@pxref{arm_pad,,.pad}) pseudo op indicates a
1145modification of the stack pointer that does not save any registers.
1146The argument is the number of bytes (in decimal) that are subtracted
1147from the stack pointer. (On ARM CPUs, the stack grows downwards, so
1148subtracting from the stack pointer increases the size of the stack.)
1149
1150The @code{.setfp} (@pxref{arm_setfp,,.setfp pseudo op}) pseudo op
1151indicates the register that contains the frame pointer. The first
1152argument is the register that is set, which is typically @code{fp}.
1153The second argument indicates the register from which the frame
1154pointer takes its value. The third argument, if present, is the value
1155(in decimal) added to the register specified by the second argument to
1156compute the value of the frame pointer. You should not modify the
1157frame pointer in the body of the function.
1158
1159If you do not use a frame pointer, then you should not use the
1160@code{.setfp} pseudo op. If you do not use a frame pointer, then you
1161should avoid modifying the stack pointer outside of the function
1162prologue. Otherwise, the run-time library will be unable to find
1163saved registers when it is unwinding the stack.
1164
1165The pseudo ops described above are sufficient for writing assembly
1166code that calls functions which may throw exceptions. If you need to
1167know more about the object-file format used to represent unwind
1168information, you may consult the @cite{Exception Handling ABI for the
1169ARM Architecture} available from @uref{http://infocenter.arm.com}.
This page took 0.514756 seconds and 4 git commands to generate.