c-arm.texi 52 KB

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