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