AVR-Options.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>Using the GNU Compiler Collection (GCC): AVR Options</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): AVR Options">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): AVR Options">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Submodel-Options.html#Submodel-Options" rel="up" title="Submodel Options">
  30. <link href="Blackfin-Options.html#Blackfin-Options" rel="next" title="Blackfin Options">
  31. <link href="ARM-Options.html#ARM-Options" rel="prev" title="ARM Options">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="AVR-Options"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Blackfin-Options.html#Blackfin-Options" accesskey="n" rel="next">Blackfin Options</a>, Previous: <a href="ARM-Options.html#ARM-Options" accesskey="p" rel="prev">ARM Options</a>, Up: <a href="Submodel-Options.html#Submodel-Options" accesskey="u" rel="up">Submodel Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="AVR-Options-1"></a>
  69. <h4 class="subsection">3.18.5 AVR Options</h4>
  70. <a name="index-AVR-Options"></a>
  71. <p>These options are defined for AVR implementations:
  72. </p>
  73. <dl compact="compact">
  74. <dt><code>-mmcu=<var>mcu</var></code></dt>
  75. <dd><a name="index-mmcu"></a>
  76. <p>Specify Atmel AVR instruction set architectures (ISA) or MCU type.
  77. </p>
  78. <p>The default for this option is&nbsp;&lsquo;<samp>avr2</samp>&rsquo;.
  79. </p>
  80. <p>GCC supports the following AVR devices and ISAs:
  81. </p>
  82. <dl compact="compact">
  83. <dt><code>avr2</code></dt>
  84. <dd><p>&ldquo;Classic&rdquo; devices with up to 8&nbsp;KiB of program memory.
  85. <br><var>mcu</var>&nbsp;= <code>attiny22</code>, <code>attiny26</code>, <code>at90c8534</code>, <code>at90s2313</code>, <code>at90s2323</code>, <code>at90s2333</code>, <code>at90s2343</code>, <code>at90s4414</code>, <code>at90s4433</code>, <code>at90s4434</code>, <code>at90s8515</code>, <code>at90s8535</code>.
  86. </p>
  87. </dd>
  88. <dt><code>avr25</code></dt>
  89. <dd><p>&ldquo;Classic&rdquo; devices with up to 8&nbsp;KiB of program memory and with the <code>MOVW</code> instruction.
  90. <br><var>mcu</var>&nbsp;= <code>ata5272</code>, <code>ata6616c</code>, <code>attiny13</code>, <code>attiny13a</code>, <code>attiny2313</code>, <code>attiny2313a</code>, <code>attiny24</code>, <code>attiny24a</code>, <code>attiny25</code>, <code>attiny261</code>, <code>attiny261a</code>, <code>attiny43u</code>, <code>attiny4313</code>, <code>attiny44</code>, <code>attiny44a</code>, <code>attiny441</code>, <code>attiny45</code>, <code>attiny461</code>, <code>attiny461a</code>, <code>attiny48</code>, <code>attiny828</code>, <code>attiny84</code>, <code>attiny84a</code>, <code>attiny841</code>, <code>attiny85</code>, <code>attiny861</code>, <code>attiny861a</code>, <code>attiny87</code>, <code>attiny88</code>, <code>at86rf401</code>.
  91. </p>
  92. </dd>
  93. <dt><code>avr3</code></dt>
  94. <dd><p>&ldquo;Classic&rdquo; devices with 16&nbsp;KiB up to 64&nbsp;KiB of program memory.
  95. <br><var>mcu</var>&nbsp;= <code>at43usb355</code>, <code>at76c711</code>.
  96. </p>
  97. </dd>
  98. <dt><code>avr31</code></dt>
  99. <dd><p>&ldquo;Classic&rdquo; devices with 128&nbsp;KiB of program memory.
  100. <br><var>mcu</var>&nbsp;= <code>atmega103</code>, <code>at43usb320</code>.
  101. </p>
  102. </dd>
  103. <dt><code>avr35</code></dt>
  104. <dd><p>&ldquo;Classic&rdquo; devices with 16&nbsp;KiB up to 64&nbsp;KiB of program memory and with the <code>MOVW</code> instruction.
  105. <br><var>mcu</var>&nbsp;= <code>ata5505</code>, <code>ata6617c</code>, <code>ata664251</code>, <code>atmega16u2</code>, <code>atmega32u2</code>, <code>atmega8u2</code>, <code>attiny1634</code>, <code>attiny167</code>, <code>at90usb162</code>, <code>at90usb82</code>.
  106. </p>
  107. </dd>
  108. <dt><code>avr4</code></dt>
  109. <dd><p>&ldquo;Enhanced&rdquo; devices with up to 8&nbsp;KiB of program memory.
  110. <br><var>mcu</var>&nbsp;= <code>ata6285</code>, <code>ata6286</code>, <code>ata6289</code>, <code>ata6612c</code>, <code>atmega48</code>, <code>atmega48a</code>, <code>atmega48p</code>, <code>atmega48pa</code>, <code>atmega48pb</code>, <code>atmega8</code>, <code>atmega8a</code>, <code>atmega8hva</code>, <code>atmega8515</code>, <code>atmega8535</code>, <code>atmega88</code>, <code>atmega88a</code>, <code>atmega88p</code>, <code>atmega88pa</code>, <code>atmega88pb</code>, <code>at90pwm1</code>, <code>at90pwm2</code>, <code>at90pwm2b</code>, <code>at90pwm3</code>, <code>at90pwm3b</code>, <code>at90pwm81</code>.
  111. </p>
  112. </dd>
  113. <dt><code>avr5</code></dt>
  114. <dd><p>&ldquo;Enhanced&rdquo; devices with 16&nbsp;KiB up to 64&nbsp;KiB of program memory.
  115. <br><var>mcu</var>&nbsp;= <code>ata5702m322</code>, <code>ata5782</code>, <code>ata5790</code>, <code>ata5790n</code>, <code>ata5791</code>, <code>ata5795</code>, <code>ata5831</code>, <code>ata6613c</code>, <code>ata6614q</code>, <code>ata8210</code>, <code>ata8510</code>, <code>atmega16</code>, <code>atmega16a</code>, <code>atmega16hva</code>, <code>atmega16hva2</code>, <code>atmega16hvb</code>, <code>atmega16hvbrevb</code>, <code>atmega16m1</code>, <code>atmega16u4</code>, <code>atmega161</code>, <code>atmega162</code>, <code>atmega163</code>, <code>atmega164a</code>, <code>atmega164p</code>, <code>atmega164pa</code>, <code>atmega165</code>, <code>atmega165a</code>, <code>atmega165p</code>, <code>atmega165pa</code>, <code>atmega168</code>, <code>atmega168a</code>, <code>atmega168p</code>, <code>atmega168pa</code>, <code>atmega168pb</code>, <code>atmega169</code>, <code>atmega169a</code>, <code>atmega169p</code>, <code>atmega169pa</code>, <code>atmega32</code>, <code>atmega32a</code>, <code>atmega32c1</code>, <code>atmega32hvb</code>, <code>atmega32hvbrevb</code>, <code>atmega32m1</code>, <code>atmega32u4</code>, <code>atmega32u6</code>, <code>atmega323</code>, <code>atmega324a</code>, <code>atmega324p</code>, <code>atmega324pa</code>, <code>atmega325</code>, <code>atmega325a</code>, <code>atmega325p</code>, <code>atmega325pa</code>, <code>atmega3250</code>, <code>atmega3250a</code>, <code>atmega3250p</code>, <code>atmega3250pa</code>, <code>atmega328</code>, <code>atmega328p</code>, <code>atmega328pb</code>, <code>atmega329</code>, <code>atmega329a</code>, <code>atmega329p</code>, <code>atmega329pa</code>, <code>atmega3290</code>, <code>atmega3290a</code>, <code>atmega3290p</code>, <code>atmega3290pa</code>, <code>atmega406</code>, <code>atmega64</code>, <code>atmega64a</code>, <code>atmega64c1</code>, <code>atmega64hve</code>, <code>atmega64hve2</code>, <code>atmega64m1</code>, <code>atmega64rfr2</code>, <code>atmega640</code>, <code>atmega644</code>, <code>atmega644a</code>, <code>atmega644p</code>, <code>atmega644pa</code>, <code>atmega644rfr2</code>, <code>atmega645</code>, <code>atmega645a</code>, <code>atmega645p</code>, <code>atmega6450</code>, <code>atmega6450a</code>, <code>atmega6450p</code>, <code>atmega649</code>, <code>atmega649a</code>, <code>atmega649p</code>, <code>atmega6490</code>, <code>atmega6490a</code>, <code>atmega6490p</code>, <code>at90can32</code>, <code>at90can64</code>, <code>at90pwm161</code>, <code>at90pwm216</code>, <code>at90pwm316</code>, <code>at90scr100</code>, <code>at90usb646</code>, <code>at90usb647</code>, <code>at94k</code>, <code>m3000</code>.
  116. </p>
  117. </dd>
  118. <dt><code>avr51</code></dt>
  119. <dd><p>&ldquo;Enhanced&rdquo; devices with 128&nbsp;KiB of program memory.
  120. <br><var>mcu</var>&nbsp;= <code>atmega128</code>, <code>atmega128a</code>, <code>atmega128rfa1</code>, <code>atmega128rfr2</code>, <code>atmega1280</code>, <code>atmega1281</code>, <code>atmega1284</code>, <code>atmega1284p</code>, <code>atmega1284rfr2</code>, <code>at90can128</code>, <code>at90usb1286</code>, <code>at90usb1287</code>.
  121. </p>
  122. </dd>
  123. <dt><code>avr6</code></dt>
  124. <dd><p>&ldquo;Enhanced&rdquo; devices with 3-byte PC, i.e. with more than 128&nbsp;KiB of program memory.
  125. <br><var>mcu</var>&nbsp;= <code>atmega256rfr2</code>, <code>atmega2560</code>, <code>atmega2561</code>, <code>atmega2564rfr2</code>.
  126. </p>
  127. </dd>
  128. <dt><code>avrxmega2</code></dt>
  129. <dd><p>&ldquo;XMEGA&rdquo; devices with more than 8&nbsp;KiB and up to 64&nbsp;KiB of program memory.
  130. <br><var>mcu</var>&nbsp;= <code>atxmega16a4</code>, <code>atxmega16a4u</code>, <code>atxmega16c4</code>, <code>atxmega16d4</code>, <code>atxmega16e5</code>, <code>atxmega32a4</code>, <code>atxmega32a4u</code>, <code>atxmega32c3</code>, <code>atxmega32c4</code>, <code>atxmega32d3</code>, <code>atxmega32d4</code>, <code>atxmega32e5</code>, <code>atxmega8e5</code>.
  131. </p>
  132. </dd>
  133. <dt><code>avrxmega4</code></dt>
  134. <dd><p>&ldquo;XMEGA&rdquo; devices with more than 64&nbsp;KiB and up to 128&nbsp;KiB of program memory.
  135. <br><var>mcu</var>&nbsp;= <code>atxmega64a3</code>, <code>atxmega64a3u</code>, <code>atxmega64a4u</code>, <code>atxmega64b1</code>, <code>atxmega64b3</code>, <code>atxmega64c3</code>, <code>atxmega64d3</code>, <code>atxmega64d4</code>.
  136. </p>
  137. </dd>
  138. <dt><code>avrxmega5</code></dt>
  139. <dd><p>&ldquo;XMEGA&rdquo; devices with more than 64&nbsp;KiB and up to 128&nbsp;KiB of program memory and more than 64&nbsp;KiB of RAM.
  140. <br><var>mcu</var>&nbsp;= <code>atxmega64a1</code>, <code>atxmega64a1u</code>.
  141. </p>
  142. </dd>
  143. <dt><code>avrxmega6</code></dt>
  144. <dd><p>&ldquo;XMEGA&rdquo; devices with more than 128&nbsp;KiB of program memory.
  145. <br><var>mcu</var>&nbsp;= <code>atxmega128a3</code>, <code>atxmega128a3u</code>, <code>atxmega128b1</code>, <code>atxmega128b3</code>, <code>atxmega128c3</code>, <code>atxmega128d3</code>, <code>atxmega128d4</code>, <code>atxmega192a3</code>, <code>atxmega192a3u</code>, <code>atxmega192c3</code>, <code>atxmega192d3</code>, <code>atxmega256a3</code>, <code>atxmega256a3b</code>, <code>atxmega256a3bu</code>, <code>atxmega256a3u</code>, <code>atxmega256c3</code>, <code>atxmega256d3</code>, <code>atxmega384c3</code>, <code>atxmega384d3</code>.
  146. </p>
  147. </dd>
  148. <dt><code>avrxmega7</code></dt>
  149. <dd><p>&ldquo;XMEGA&rdquo; devices with more than 128&nbsp;KiB of program memory and more than 64&nbsp;KiB of RAM.
  150. <br><var>mcu</var>&nbsp;= <code>atxmega128a1</code>, <code>atxmega128a1u</code>, <code>atxmega128a4u</code>.
  151. </p>
  152. </dd>
  153. <dt><code>avrtiny</code></dt>
  154. <dd><p>&ldquo;TINY&rdquo; Tiny core devices with 512&nbsp;B up to 4&nbsp;KiB of program memory.
  155. <br><var>mcu</var>&nbsp;= <code>attiny10</code>, <code>attiny20</code>, <code>attiny4</code>, <code>attiny40</code>, <code>attiny5</code>, <code>attiny9</code>.
  156. </p>
  157. </dd>
  158. <dt><code>avr1</code></dt>
  159. <dd><p>This ISA is implemented by the minimal AVR core and supported for assembler only.
  160. <br><var>mcu</var>&nbsp;= <code>attiny11</code>, <code>attiny12</code>, <code>attiny15</code>, <code>attiny28</code>, <code>at90s1200</code>.
  161. </p>
  162. </dd>
  163. </dl>
  164. </dd>
  165. <dt><code>-mabsdata</code></dt>
  166. <dd><a name="index-mabsdata"></a>
  167. <p>Assume that all data in static storage can be accessed by LDS / STS
  168. instructions. This option has only an effect on reduced Tiny devices like
  169. ATtiny40. See also the <code>absdata</code>
  170. <a href="AVR-Variable-Attributes.html#AVR-Variable-Attributes">variable attribute</a>.
  171. </p>
  172. </dd>
  173. <dt><code>-maccumulate-args</code></dt>
  174. <dd><a name="index-maccumulate_002dargs"></a>
  175. <p>Accumulate outgoing function arguments and acquire/release the needed
  176. stack space for outgoing function arguments once in function
  177. prologue/epilogue. Without this option, outgoing arguments are pushed
  178. before calling a function and popped afterwards.
  179. </p>
  180. <p>Popping the arguments after the function call can be expensive on
  181. AVR so that accumulating the stack space might lead to smaller
  182. executables because arguments need not be removed from the
  183. stack after such a function call.
  184. </p>
  185. <p>This option can lead to reduced code size for functions that perform
  186. several calls to functions that get their arguments on the stack like
  187. calls to printf-like functions.
  188. </p>
  189. </dd>
  190. <dt><code>-mbranch-cost=<var>cost</var></code></dt>
  191. <dd><a name="index-mbranch_002dcost-1"></a>
  192. <p>Set the branch costs for conditional branch instructions to
  193. <var>cost</var>. Reasonable values for <var>cost</var> are small, non-negative
  194. integers. The default branch cost is 0.
  195. </p>
  196. </dd>
  197. <dt><code>-mcall-prologues</code></dt>
  198. <dd><a name="index-mcall_002dprologues"></a>
  199. <p>Functions prologues/epilogues are expanded as calls to appropriate
  200. subroutines. Code size is smaller.
  201. </p>
  202. </dd>
  203. <dt><code>-mint8</code></dt>
  204. <dd><a name="index-mint8"></a>
  205. <p>Assume <code>int</code> to be 8-bit integer. This affects the sizes of all types: a
  206. <code>char</code> is 1 byte, an <code>int</code> is 1 byte, a <code>long</code> is 2 bytes,
  207. and <code>long long</code> is 4 bytes. Please note that this option does not
  208. conform to the C standards, but it results in smaller code
  209. size.
  210. </p>
  211. </dd>
  212. <dt><code>-mn-flash=<var>num</var></code></dt>
  213. <dd><a name="index-mn_002dflash"></a>
  214. <p>Assume that the flash memory has a size of
  215. <var>num</var> times 64&nbsp;KiB.
  216. </p>
  217. </dd>
  218. <dt><code>-mno-interrupts</code></dt>
  219. <dd><a name="index-mno_002dinterrupts"></a>
  220. <p>Generated code is not compatible with hardware interrupts.
  221. Code size is smaller.
  222. </p>
  223. </dd>
  224. <dt><code>-mrelax</code></dt>
  225. <dd><a name="index-mrelax"></a>
  226. <p>Try to replace <code>CALL</code> resp. <code>JMP</code> instruction by the shorter
  227. <code>RCALL</code> resp. <code>RJMP</code> instruction if applicable.
  228. Setting <samp>-mrelax</samp> just adds the <samp>--mlink-relax</samp> option to
  229. the assembler&rsquo;s command line and the <samp>--relax</samp> option to the
  230. linker&rsquo;s command line.
  231. </p>
  232. <p>Jump relaxing is performed by the linker because jump offsets are not
  233. known before code is located. Therefore, the assembler code generated by the
  234. compiler is the same, but the instructions in the executable may
  235. differ from instructions in the assembler code.
  236. </p>
  237. <p>Relaxing must be turned on if linker stubs are needed, see the
  238. section on <code>EIND</code> and linker stubs below.
  239. </p>
  240. </dd>
  241. <dt><code>-mrmw</code></dt>
  242. <dd><a name="index-mrmw"></a>
  243. <p>Assume that the device supports the Read-Modify-Write
  244. instructions <code>XCH</code>, <code>LAC</code>, <code>LAS</code> and <code>LAT</code>.
  245. </p>
  246. </dd>
  247. <dt><code>-msp8</code></dt>
  248. <dd><a name="index-msp8"></a>
  249. <p>Treat the stack pointer register as an 8-bit register,
  250. i.e. assume the high byte of the stack pointer is zero.
  251. In general, you don&rsquo;t need to set this option by hand.
  252. </p>
  253. <p>This option is used internally by the compiler to select and
  254. build multilibs for architectures <code>avr2</code> and <code>avr25</code>.
  255. These architectures mix devices with and without <code>SPH</code>.
  256. For any setting other than <samp>-mmcu=avr2</samp> or <samp>-mmcu=avr25</samp>
  257. the compiler driver adds or removes this option from the compiler
  258. proper&rsquo;s command line, because the compiler then knows if the device
  259. or architecture has an 8-bit stack pointer and thus no <code>SPH</code>
  260. register or not.
  261. </p>
  262. </dd>
  263. <dt><code>-mstrict-X</code></dt>
  264. <dd><a name="index-mstrict_002dX"></a>
  265. <p>Use address register <code>X</code> in a way proposed by the hardware. This means
  266. that <code>X</code> is only used in indirect, post-increment or
  267. pre-decrement addressing.
  268. </p>
  269. <p>Without this option, the <code>X</code> register may be used in the same way
  270. as <code>Y</code> or <code>Z</code> which then is emulated by additional
  271. instructions.
  272. For example, loading a value with <code>X+const</code> addressing with a
  273. small non-negative <code>const &lt; 64</code> to a register <var>Rn</var> is
  274. performed as
  275. </p>
  276. <div class="example">
  277. <pre class="example">adiw r26, const ; X += const
  278. ld <var>Rn</var>, X ; <var>Rn</var> = *X
  279. sbiw r26, const ; X -= const
  280. </pre></div>
  281. </dd>
  282. <dt><code>-mtiny-stack</code></dt>
  283. <dd><a name="index-mtiny_002dstack"></a>
  284. <p>Only change the lower 8&nbsp;bits of the stack pointer.
  285. </p>
  286. </dd>
  287. <dt><code>-mfract-convert-truncate</code></dt>
  288. <dd><a name="index-mfract_002dconvert_002dtruncate"></a>
  289. <p>Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
  290. </p>
  291. </dd>
  292. <dt><code>-nodevicelib</code></dt>
  293. <dd><a name="index-nodevicelib"></a>
  294. <p>Don&rsquo;t link against AVR-LibC&rsquo;s device specific library <code>lib&lt;mcu&gt;.a</code>.
  295. </p>
  296. </dd>
  297. <dt><code>-Waddr-space-convert</code></dt>
  298. <dd><a name="index-Waddr_002dspace_002dconvert"></a>
  299. <p>Warn about conversions between address spaces in the case where the
  300. resulting address space is not contained in the incoming address space.
  301. </p>
  302. </dd>
  303. <dt><code>-Wmisspelled-isr</code></dt>
  304. <dd><a name="index-Wmisspelled_002disr"></a>
  305. <p>Warn if the ISR is misspelled, i.e. without __vector prefix.
  306. Enabled by default.
  307. </p></dd>
  308. </dl>
  309. <a name="EIND-and-Devices-with-More-Than-128-Ki-Bytes-of-Flash"></a>
  310. <h4 class="subsubsection">3.18.5.1 <code>EIND</code> and Devices with More Than 128 Ki Bytes of Flash</h4>
  311. <a name="index-EIND"></a>
  312. <p>Pointers in the implementation are 16&nbsp;bits wide.
  313. The address of a function or label is represented as word address so
  314. that indirect jumps and calls can target any code address in the
  315. range of 64&nbsp;Ki words.
  316. </p>
  317. <p>In order to facilitate indirect jump on devices with more than 128&nbsp;Ki
  318. bytes of program memory space, there is a special function register called
  319. <code>EIND</code> that serves as most significant part of the target address
  320. when <code>EICALL</code> or <code>EIJMP</code> instructions are used.
  321. </p>
  322. <p>Indirect jumps and calls on these devices are handled as follows by
  323. the compiler and are subject to some limitations:
  324. </p>
  325. <ul>
  326. <li> The compiler never sets <code>EIND</code>.
  327. </li><li> The compiler uses <code>EIND</code> implicitly in <code>EICALL</code>/<code>EIJMP</code>
  328. instructions or might read <code>EIND</code> directly in order to emulate an
  329. indirect call/jump by means of a <code>RET</code> instruction.
  330. </li><li> The compiler assumes that <code>EIND</code> never changes during the startup
  331. code or during the application. In particular, <code>EIND</code> is not
  332. saved/restored in function or interrupt service routine
  333. prologue/epilogue.
  334. </li><li> For indirect calls to functions and computed goto, the linker
  335. generates <em>stubs</em>. Stubs are jump pads sometimes also called
  336. <em>trampolines</em>. Thus, the indirect call/jump jumps to such a stub.
  337. The stub contains a direct jump to the desired address.
  338. </li><li> Linker relaxation must be turned on so that the linker generates
  339. the stubs correctly in all situations. See the compiler option
  340. <samp>-mrelax</samp> and the linker option <samp>--relax</samp>.
  341. There are corner cases where the linker is supposed to generate stubs
  342. but aborts without relaxation and without a helpful error message.
  343. </li><li> The default linker script is arranged for code with <code>EIND = 0</code>.
  344. If code is supposed to work for a setup with <code>EIND != 0</code>, a custom
  345. linker script has to be used in order to place the sections whose
  346. name start with <code>.trampolines</code> into the segment where <code>EIND</code>
  347. points to.
  348. </li><li> The startup code from libgcc never sets <code>EIND</code>.
  349. Notice that startup code is a blend of code from libgcc and AVR-LibC.
  350. For the impact of AVR-LibC on <code>EIND</code>, see the
  351. <a href="http://nongnu.org/avr-libc/user-manual/"><span class="nolinebreak">AVR-LibC</span>&nbsp;user&nbsp;manual</a><!-- /@w -->.
  352. </li><li> It is legitimate for user-specific startup code to set up <code>EIND</code>
  353. early, for example by means of initialization code located in
  354. section <code>.init3</code>. Such code runs prior to general startup code
  355. that initializes RAM and calls constructors, but after the bit
  356. of startup code from AVR-LibC that sets <code>EIND</code> to the segment
  357. where the vector table is located.
  358. <div class="example">
  359. <pre class="example">#include &lt;avr/io.h&gt;
  360. static void
  361. __attribute__((section(&quot;.init3&quot;),naked,used,no_instrument_function))
  362. init3_set_eind (void)
  363. {
  364. __asm volatile (&quot;ldi r24,pm_hh8(__trampolines_start)\n\t&quot;
  365. &quot;out %i0,r24&quot; :: &quot;n&quot; (&amp;EIND) : &quot;r24&quot;,&quot;memory&quot;);
  366. }
  367. </pre></div>
  368. <p>The <code>__trampolines_start</code> symbol is defined in the linker script.
  369. </p>
  370. </li><li> Stubs are generated automatically by the linker if
  371. the following two conditions are met:
  372. <ul class="no-bullet">
  373. <li>- The address of a label is taken by means of the <code>gs</code> modifier
  374. (short for <em>generate stubs</em>) like so:
  375. <div class="example">
  376. <pre class="example">LDI r24, lo8(gs(<var>func</var>))
  377. LDI r25, hi8(gs(<var>func</var>))
  378. </pre></div>
  379. </li><li>- The final location of that label is in a code segment
  380. <em>outside</em> the segment where the stubs are located.
  381. </li></ul>
  382. </li><li> The compiler emits such <code>gs</code> modifiers for code labels in the
  383. following situations:
  384. <ul class="no-bullet">
  385. <li>- Taking address of a function or code label.
  386. </li><li>- Computed goto.
  387. </li><li>- If prologue-save function is used, see <samp>-mcall-prologues</samp>
  388. command-line option.
  389. </li><li>- Switch/case dispatch tables. If you do not want such dispatch
  390. tables you can specify the <samp>-fno-jump-tables</samp> command-line option.
  391. </li><li>- C and C++ constructors/destructors called during startup/shutdown.
  392. </li><li>- If the tools hit a <code>gs()</code> modifier explained above.
  393. </li></ul>
  394. </li><li> Jumping to non-symbolic addresses like so is <em>not</em> supported:
  395. <div class="example">
  396. <pre class="example">int main (void)
  397. {
  398. /* Call function at word address 0x2 */
  399. return ((int(*)(void)) 0x2)();
  400. }
  401. </pre></div>
  402. <p>Instead, a stub has to be set up, i.e. the function has to be called
  403. through a symbol (<code>func_4</code> in the example):
  404. </p>
  405. <div class="example">
  406. <pre class="example">int main (void)
  407. {
  408. extern int func_4 (void);
  409. /* Call function at byte address 0x4 */
  410. return func_4();
  411. }
  412. </pre></div>
  413. <p>and the application be linked with <samp>-Wl,--defsym,func_4=0x4</samp>.
  414. Alternatively, <code>func_4</code> can be defined in the linker script.
  415. </p></li></ul>
  416. <a name="Handling-of-the-RAMPD_002c-RAMPX_002c-RAMPY-and-RAMPZ-Special-Function-Registers"></a>
  417. <h4 class="subsubsection">3.18.5.2 Handling of the <code>RAMPD</code>, <code>RAMPX</code>, <code>RAMPY</code> and <code>RAMPZ</code> Special Function Registers</h4>
  418. <a name="index-RAMPD"></a>
  419. <a name="index-RAMPX"></a>
  420. <a name="index-RAMPY"></a>
  421. <a name="index-RAMPZ"></a>
  422. <p>Some AVR devices support memories larger than the 64&nbsp;KiB range
  423. that can be accessed with 16-bit pointers. To access memory locations
  424. outside this 64&nbsp;KiB range, the content of a <code>RAMP</code>
  425. register is used as high part of the address:
  426. The <code>X</code>, <code>Y</code>, <code>Z</code> address register is concatenated
  427. with the <code>RAMPX</code>, <code>RAMPY</code>, <code>RAMPZ</code> special function
  428. register, respectively, to get a wide address. Similarly,
  429. <code>RAMPD</code> is used together with direct addressing.
  430. </p>
  431. <ul>
  432. <li> The startup code initializes the <code>RAMP</code> special function
  433. registers with zero.
  434. </li><li> If a <a href="Named-Address-Spaces.html#AVR-Named-Address-Spaces">named address space</a> other than
  435. generic or <code>__flash</code> is used, then <code>RAMPZ</code> is set
  436. as needed before the operation.
  437. </li><li> If the device supports RAM larger than 64&nbsp;KiB and the compiler
  438. needs to change <code>RAMPZ</code> to accomplish an operation, <code>RAMPZ</code>
  439. is reset to zero after the operation.
  440. </li><li> If the device comes with a specific <code>RAMP</code> register, the ISR
  441. prologue/epilogue saves/restores that SFR and initializes it with
  442. zero in case the ISR code might (implicitly) use it.
  443. </li><li> RAM larger than 64&nbsp;KiB is not supported by GCC for AVR targets.
  444. If you use inline assembler to read from locations outside the
  445. 16-bit address range and change one of the <code>RAMP</code> registers,
  446. you must reset it to zero after the access.
  447. </li></ul>
  448. <a name="AVR-Built_002din-Macros"></a>
  449. <h4 class="subsubsection">3.18.5.3 AVR Built-in Macros</h4>
  450. <p>GCC defines several built-in macros so that the user code can test
  451. for the presence or absence of features. Almost any of the following
  452. built-in macros are deduced from device capabilities and thus
  453. triggered by the <samp>-mmcu=</samp> command-line option.
  454. </p>
  455. <p>For even more AVR-specific built-in macros see
  456. <a href="Named-Address-Spaces.html#AVR-Named-Address-Spaces">AVR Named Address Spaces</a> and <a href="AVR-Built_002din-Functions.html#AVR-Built_002din-Functions">AVR Built-in Functions</a>.
  457. </p>
  458. <dl compact="compact">
  459. <dt><code>__AVR_ARCH__</code></dt>
  460. <dd><p>Build-in macro that resolves to a decimal number that identifies the
  461. architecture and depends on the <samp>-mmcu=<var>mcu</var></samp> option.
  462. Possible values are:
  463. </p>
  464. <p><code>2</code>, <code>25</code>, <code>3</code>, <code>31</code>, <code>35</code>,
  465. <code>4</code>, <code>5</code>, <code>51</code>, <code>6</code>
  466. </p>
  467. <p>for <var>mcu</var>=<code>avr2</code>, <code>avr25</code>, <code>avr3</code>, <code>avr31</code>,
  468. <code>avr35</code>, <code>avr4</code>, <code>avr5</code>, <code>avr51</code>, <code>avr6</code>,
  469. </p>
  470. <p>respectively and
  471. </p>
  472. <p><code>100</code>, <code>102</code>, <code>104</code>,
  473. <code>105</code>, <code>106</code>, <code>107</code>
  474. </p>
  475. <p>for <var>mcu</var>=<code>avrtiny</code>, <code>avrxmega2</code>, <code>avrxmega4</code>,
  476. <code>avrxmega5</code>, <code>avrxmega6</code>, <code>avrxmega7</code>, respectively.
  477. If <var>mcu</var> specifies a device, this built-in macro is set
  478. accordingly. For example, with <samp>-mmcu=atmega8</samp> the macro is
  479. defined to <code>4</code>.
  480. </p>
  481. </dd>
  482. <dt><code>__AVR_<var>Device</var>__</code></dt>
  483. <dd><p>Setting <samp>-mmcu=<var>device</var></samp> defines this built-in macro which reflects
  484. the device&rsquo;s name. For example, <samp>-mmcu=atmega8</samp> defines the
  485. built-in macro <code>__AVR_ATmega8__</code>, <samp>-mmcu=attiny261a</samp> defines
  486. <code>__AVR_ATtiny261A__</code>, etc.
  487. </p>
  488. <p>The built-in macros&rsquo; names follow
  489. the scheme <code>__AVR_<var>Device</var>__</code> where <var>Device</var> is
  490. the device name as from the AVR user manual. The difference between
  491. <var>Device</var> in the built-in macro and <var>device</var> in
  492. <samp>-mmcu=<var>device</var></samp> is that the latter is always lowercase.
  493. </p>
  494. <p>If <var>device</var> is not a device but only a core architecture like
  495. &lsquo;<samp>avr51</samp>&rsquo;, this macro is not defined.
  496. </p>
  497. </dd>
  498. <dt><code>__AVR_DEVICE_NAME__</code></dt>
  499. <dd><p>Setting <samp>-mmcu=<var>device</var></samp> defines this built-in macro to
  500. the device&rsquo;s name. For example, with <samp>-mmcu=atmega8</samp> the macro
  501. is defined to <code>atmega8</code>.
  502. </p>
  503. <p>If <var>device</var> is not a device but only a core architecture like
  504. &lsquo;<samp>avr51</samp>&rsquo;, this macro is not defined.
  505. </p>
  506. </dd>
  507. <dt><code>__AVR_XMEGA__</code></dt>
  508. <dd><p>The device / architecture belongs to the XMEGA family of devices.
  509. </p>
  510. </dd>
  511. <dt><code>__AVR_HAVE_ELPM__</code></dt>
  512. <dd><p>The device has the <code>ELPM</code> instruction.
  513. </p>
  514. </dd>
  515. <dt><code>__AVR_HAVE_ELPMX__</code></dt>
  516. <dd><p>The device has the <code>ELPM R<var>n</var>,Z</code> and <code>ELPM
  517. R<var>n</var>,Z+</code> instructions.
  518. </p>
  519. </dd>
  520. <dt><code>__AVR_HAVE_MOVW__</code></dt>
  521. <dd><p>The device has the <code>MOVW</code> instruction to perform 16-bit
  522. register-register moves.
  523. </p>
  524. </dd>
  525. <dt><code>__AVR_HAVE_LPMX__</code></dt>
  526. <dd><p>The device has the <code>LPM R<var>n</var>,Z</code> and
  527. <code>LPM R<var>n</var>,Z+</code> instructions.
  528. </p>
  529. </dd>
  530. <dt><code>__AVR_HAVE_MUL__</code></dt>
  531. <dd><p>The device has a hardware multiplier.
  532. </p>
  533. </dd>
  534. <dt><code>__AVR_HAVE_JMP_CALL__</code></dt>
  535. <dd><p>The device has the <code>JMP</code> and <code>CALL</code> instructions.
  536. This is the case for devices with at least 16&nbsp;KiB of program
  537. memory.
  538. </p>
  539. </dd>
  540. <dt><code>__AVR_HAVE_EIJMP_EICALL__</code></dt>
  541. <dt><code>__AVR_3_BYTE_PC__</code></dt>
  542. <dd><p>The device has the <code>EIJMP</code> and <code>EICALL</code> instructions.
  543. This is the case for devices with more than 128&nbsp;KiB of program memory.
  544. This also means that the program counter
  545. (PC) is 3&nbsp;bytes wide.
  546. </p>
  547. </dd>
  548. <dt><code>__AVR_2_BYTE_PC__</code></dt>
  549. <dd><p>The program counter (PC) is 2&nbsp;bytes wide. This is the case for devices
  550. with up to 128&nbsp;KiB of program memory.
  551. </p>
  552. </dd>
  553. <dt><code>__AVR_HAVE_8BIT_SP__</code></dt>
  554. <dt><code>__AVR_HAVE_16BIT_SP__</code></dt>
  555. <dd><p>The stack pointer (SP) register is treated as 8-bit respectively
  556. 16-bit register by the compiler.
  557. The definition of these macros is affected by <samp>-mtiny-stack</samp>.
  558. </p>
  559. </dd>
  560. <dt><code>__AVR_HAVE_SPH__</code></dt>
  561. <dt><code>__AVR_SP8__</code></dt>
  562. <dd><p>The device has the SPH (high part of stack pointer) special function
  563. register or has an 8-bit stack pointer, respectively.
  564. The definition of these macros is affected by <samp>-mmcu=</samp> and
  565. in the cases of <samp>-mmcu=avr2</samp> and <samp>-mmcu=avr25</samp> also
  566. by <samp>-msp8</samp>.
  567. </p>
  568. </dd>
  569. <dt><code>__AVR_HAVE_RAMPD__</code></dt>
  570. <dt><code>__AVR_HAVE_RAMPX__</code></dt>
  571. <dt><code>__AVR_HAVE_RAMPY__</code></dt>
  572. <dt><code>__AVR_HAVE_RAMPZ__</code></dt>
  573. <dd><p>The device has the <code>RAMPD</code>, <code>RAMPX</code>, <code>RAMPY</code>,
  574. <code>RAMPZ</code> special function register, respectively.
  575. </p>
  576. </dd>
  577. <dt><code>__NO_INTERRUPTS__</code></dt>
  578. <dd><p>This macro reflects the <samp>-mno-interrupts</samp> command-line option.
  579. </p>
  580. </dd>
  581. <dt><code>__AVR_ERRATA_SKIP__</code></dt>
  582. <dt><code>__AVR_ERRATA_SKIP_JMP_CALL__</code></dt>
  583. <dd><p>Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
  584. instructions because of a hardware erratum. Skip instructions are
  585. <code>SBRS</code>, <code>SBRC</code>, <code>SBIS</code>, <code>SBIC</code> and <code>CPSE</code>.
  586. The second macro is only defined if <code>__AVR_HAVE_JMP_CALL__</code> is also
  587. set.
  588. </p>
  589. </dd>
  590. <dt><code>__AVR_ISA_RMW__</code></dt>
  591. <dd><p>The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
  592. </p>
  593. </dd>
  594. <dt><code>__AVR_SFR_OFFSET__=<var>offset</var></code></dt>
  595. <dd><p>Instructions that can address I/O special function registers directly
  596. like <code>IN</code>, <code>OUT</code>, <code>SBI</code>, etc. may use a different
  597. address as if addressed by an instruction to access RAM like <code>LD</code>
  598. or <code>STS</code>. This offset depends on the device architecture and has
  599. to be subtracted from the RAM address in order to get the
  600. respective I/O&nbsp;address.
  601. </p>
  602. </dd>
  603. <dt><code>__WITH_AVRLIBC__</code></dt>
  604. <dd><p>The compiler is configured to be used together with AVR-Libc.
  605. See the <samp>--with-avrlibc</samp> configure option.
  606. </p>
  607. </dd>
  608. </dl>
  609. <hr>
  610. <div class="header">
  611. <p>
  612. Next: <a href="Blackfin-Options.html#Blackfin-Options" accesskey="n" rel="next">Blackfin Options</a>, Previous: <a href="ARM-Options.html#ARM-Options" accesskey="p" rel="prev">ARM Options</a>, Up: <a href="Submodel-Options.html#Submodel-Options" accesskey="u" rel="up">Submodel Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  613. </div>
  614. </body>
  615. </html>