640 lines
32 KiB
HTML
640 lines
32 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- Copyright (C) 1988-2016 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with the
|
||
|
Invariant Sections being "Funding Free Software", the Front-Cover
|
||
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
||
|
(see below). A copy of the license is included in the section entitled
|
||
|
"GNU Free Documentation License".
|
||
|
|
||
|
(a) The FSF's Front-Cover Text is:
|
||
|
|
||
|
A GNU Manual
|
||
|
|
||
|
(b) The FSF's Back-Cover Text is:
|
||
|
|
||
|
You have freedom to copy and modify this GNU Manual, like GNU
|
||
|
software. Copies published by the Free Software Foundation raise
|
||
|
funds for GNU development. -->
|
||
|
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>Using the GNU Compiler Collection (GCC): AVR Options</title>
|
||
|
|
||
|
<meta name="description" content="Using the GNU Compiler Collection (GCC): AVR Options">
|
||
|
<meta name="keywords" content="Using the GNU Compiler Collection (GCC): AVR Options">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<link href="index.html#Top" rel="start" title="Top">
|
||
|
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Submodel-Options.html#Submodel-Options" rel="up" title="Submodel Options">
|
||
|
<link href="Blackfin-Options.html#Blackfin-Options" rel="next" title="Blackfin Options">
|
||
|
<link href="ARM-Options.html#ARM-Options" rel="prev" title="ARM Options">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.indentedblock {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
|
||
|
div.smalllisp {margin-left: 3.2em}
|
||
|
kbd {font-style:oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
||
|
pre.smallexample {font-size: smaller}
|
||
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
||
|
pre.smalllisp {font-size: smaller}
|
||
|
span.nocodebreak {white-space:nowrap}
|
||
|
span.nolinebreak {white-space:nowrap}
|
||
|
span.roman {font-family:serif; font-weight:normal}
|
||
|
span.sansserif {font-family:sans-serif; font-weight:normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
|
||
|
<a name="AVR-Options"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
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> [<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>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<a name="AVR-Options-1"></a>
|
||
|
<h4 class="subsection">3.18.5 AVR Options</h4>
|
||
|
<a name="index-AVR-Options"></a>
|
||
|
|
||
|
<p>These options are defined for AVR implementations:
|
||
|
</p>
|
||
|
<dl compact="compact">
|
||
|
<dt><code>-mmcu=<var>mcu</var></code></dt>
|
||
|
<dd><a name="index-mmcu"></a>
|
||
|
<p>Specify Atmel AVR instruction set architectures (ISA) or MCU type.
|
||
|
</p>
|
||
|
<p>The default for this option is ‘<samp>avr2</samp>’.
|
||
|
</p>
|
||
|
<p>GCC supports the following AVR devices and ISAs:
|
||
|
</p>
|
||
|
|
||
|
|
||
|
|
||
|
<dl compact="compact">
|
||
|
<dt><code>avr2</code></dt>
|
||
|
<dd><p>“Classic” devices with up to 8 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr25</code></dt>
|
||
|
<dd><p>“Classic” devices with up to 8 KiB of program memory and with the <code>MOVW</code> instruction.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr3</code></dt>
|
||
|
<dd><p>“Classic” devices with 16 KiB up to 64 KiB of program memory.
|
||
|
<br><var>mcu</var> = <code>at43usb355</code>, <code>at76c711</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr31</code></dt>
|
||
|
<dd><p>“Classic” devices with 128 KiB of program memory.
|
||
|
<br><var>mcu</var> = <code>atmega103</code>, <code>at43usb320</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr35</code></dt>
|
||
|
<dd><p>“Classic” devices with 16 KiB up to 64 KiB of program memory and with the <code>MOVW</code> instruction.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr4</code></dt>
|
||
|
<dd><p>“Enhanced” devices with up to 8 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr5</code></dt>
|
||
|
<dd><p>“Enhanced” devices with 16 KiB up to 64 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr51</code></dt>
|
||
|
<dd><p>“Enhanced” devices with 128 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr6</code></dt>
|
||
|
<dd><p>“Enhanced” devices with 3-byte PC, i.e. with more than 128 KiB of program memory.
|
||
|
<br><var>mcu</var> = <code>atmega256rfr2</code>, <code>atmega2560</code>, <code>atmega2561</code>, <code>atmega2564rfr2</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrxmega2</code></dt>
|
||
|
<dd><p>“XMEGA” devices with more than 8 KiB and up to 64 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrxmega4</code></dt>
|
||
|
<dd><p>“XMEGA” devices with more than 64 KiB and up to 128 KiB of program memory.
|
||
|
<br><var>mcu</var> = <code>atxmega64a3</code>, <code>atxmega64a3u</code>, <code>atxmega64a4u</code>, <code>atxmega64b1</code>, <code>atxmega64b3</code>, <code>atxmega64c3</code>, <code>atxmega64d3</code>, <code>atxmega64d4</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrxmega5</code></dt>
|
||
|
<dd><p>“XMEGA” devices with more than 64 KiB and up to 128 KiB of program memory and more than 64 KiB of RAM.
|
||
|
<br><var>mcu</var> = <code>atxmega64a1</code>, <code>atxmega64a1u</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrxmega6</code></dt>
|
||
|
<dd><p>“XMEGA” devices with more than 128 KiB of program memory.
|
||
|
<br><var>mcu</var> = <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>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrxmega7</code></dt>
|
||
|
<dd><p>“XMEGA” devices with more than 128 KiB of program memory and more than 64 KiB of RAM.
|
||
|
<br><var>mcu</var> = <code>atxmega128a1</code>, <code>atxmega128a1u</code>, <code>atxmega128a4u</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avrtiny</code></dt>
|
||
|
<dd><p>“TINY” Tiny core devices with 512 B up to 4 KiB of program memory.
|
||
|
<br><var>mcu</var> = <code>attiny10</code>, <code>attiny20</code>, <code>attiny4</code>, <code>attiny40</code>, <code>attiny5</code>, <code>attiny9</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>avr1</code></dt>
|
||
|
<dd><p>This ISA is implemented by the minimal AVR core and supported for assembler only.
|
||
|
<br><var>mcu</var> = <code>attiny11</code>, <code>attiny12</code>, <code>attiny15</code>, <code>attiny28</code>, <code>at90s1200</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
</dd>
|
||
|
<dt><code>-maccumulate-args</code></dt>
|
||
|
<dd><a name="index-maccumulate_002dargs"></a>
|
||
|
<p>Accumulate outgoing function arguments and acquire/release the needed
|
||
|
stack space for outgoing function arguments once in function
|
||
|
prologue/epilogue. Without this option, outgoing arguments are pushed
|
||
|
before calling a function and popped afterwards.
|
||
|
</p>
|
||
|
<p>Popping the arguments after the function call can be expensive on
|
||
|
AVR so that accumulating the stack space might lead to smaller
|
||
|
executables because arguments need not to be removed from the
|
||
|
stack after such a function call.
|
||
|
</p>
|
||
|
<p>This option can lead to reduced code size for functions that perform
|
||
|
several calls to functions that get their arguments on the stack like
|
||
|
calls to printf-like functions.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mbranch-cost=<var>cost</var></code></dt>
|
||
|
<dd><a name="index-mbranch_002dcost-1"></a>
|
||
|
<p>Set the branch costs for conditional branch instructions to
|
||
|
<var>cost</var>. Reasonable values for <var>cost</var> are small, non-negative
|
||
|
integers. The default branch cost is 0.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mcall-prologues</code></dt>
|
||
|
<dd><a name="index-mcall_002dprologues"></a>
|
||
|
<p>Functions prologues/epilogues are expanded as calls to appropriate
|
||
|
subroutines. Code size is smaller.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mint8</code></dt>
|
||
|
<dd><a name="index-mint8"></a>
|
||
|
<p>Assume <code>int</code> to be 8-bit integer. This affects the sizes of all types: a
|
||
|
<code>char</code> is 1 byte, an <code>int</code> is 1 byte, a <code>long</code> is 2 bytes,
|
||
|
and <code>long long</code> is 4 bytes. Please note that this option does not
|
||
|
conform to the C standards, but it results in smaller code
|
||
|
size.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mn-flash=<var>num</var></code></dt>
|
||
|
<dd><a name="index-mn_002dflash"></a>
|
||
|
<p>Assume that the flash memory has a size of
|
||
|
<var>num</var> times 64 KiB.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mno-interrupts</code></dt>
|
||
|
<dd><a name="index-mno_002dinterrupts"></a>
|
||
|
<p>Generated code is not compatible with hardware interrupts.
|
||
|
Code size is smaller.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mrelax</code></dt>
|
||
|
<dd><a name="index-mrelax"></a>
|
||
|
<p>Try to replace <code>CALL</code> resp. <code>JMP</code> instruction by the shorter
|
||
|
<code>RCALL</code> resp. <code>RJMP</code> instruction if applicable.
|
||
|
Setting <samp>-mrelax</samp> just adds the <samp>--mlink-relax</samp> option to
|
||
|
the assembler’s command line and the <samp>--relax</samp> option to the
|
||
|
linker’s command line.
|
||
|
</p>
|
||
|
<p>Jump relaxing is performed by the linker because jump offsets are not
|
||
|
known before code is located. Therefore, the assembler code generated by the
|
||
|
compiler is the same, but the instructions in the executable may
|
||
|
differ from instructions in the assembler code.
|
||
|
</p>
|
||
|
<p>Relaxing must be turned on if linker stubs are needed, see the
|
||
|
section on <code>EIND</code> and linker stubs below.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mrmw</code></dt>
|
||
|
<dd><a name="index-mrmw"></a>
|
||
|
<p>Assume that the device supports the Read-Modify-Write
|
||
|
instructions <code>XCH</code>, <code>LAC</code>, <code>LAS</code> and <code>LAT</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-msp8</code></dt>
|
||
|
<dd><a name="index-msp8"></a>
|
||
|
<p>Treat the stack pointer register as an 8-bit register,
|
||
|
i.e. assume the high byte of the stack pointer is zero.
|
||
|
In general, you don’t need to set this option by hand.
|
||
|
</p>
|
||
|
<p>This option is used internally by the compiler to select and
|
||
|
build multilibs for architectures <code>avr2</code> and <code>avr25</code>.
|
||
|
These architectures mix devices with and without <code>SPH</code>.
|
||
|
For any setting other than <samp>-mmcu=avr2</samp> or <samp>-mmcu=avr25</samp>
|
||
|
the compiler driver adds or removes this option from the compiler
|
||
|
proper’s command line, because the compiler then knows if the device
|
||
|
or architecture has an 8-bit stack pointer and thus no <code>SPH</code>
|
||
|
register or not.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-mstrict-X</code></dt>
|
||
|
<dd><a name="index-mstrict_002dX"></a>
|
||
|
<p>Use address register <code>X</code> in a way proposed by the hardware. This means
|
||
|
that <code>X</code> is only used in indirect, post-increment or
|
||
|
pre-decrement addressing.
|
||
|
</p>
|
||
|
<p>Without this option, the <code>X</code> register may be used in the same way
|
||
|
as <code>Y</code> or <code>Z</code> which then is emulated by additional
|
||
|
instructions.
|
||
|
For example, loading a value with <code>X+const</code> addressing with a
|
||
|
small non-negative <code>const < 64</code> to a register <var>Rn</var> is
|
||
|
performed as
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="example">adiw r26, const ; X += const
|
||
|
ld <var>Rn</var>, X ; <var>Rn</var> = *X
|
||
|
sbiw r26, const ; X -= const
|
||
|
</pre></div>
|
||
|
|
||
|
</dd>
|
||
|
<dt><code>-mtiny-stack</code></dt>
|
||
|
<dd><a name="index-mtiny_002dstack"></a>
|
||
|
<p>Only change the lower 8 bits of the stack pointer.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-nodevicelib</code></dt>
|
||
|
<dd><a name="index-nodevicelib"></a>
|
||
|
<p>Don’t link against AVR-LibC’s device specific library <code>libdev.a</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>-Waddr-space-convert</code></dt>
|
||
|
<dd><a name="index-Waddr_002dspace_002dconvert"></a>
|
||
|
<p>Warn about conversions between address spaces in the case where the
|
||
|
resulting address space is not contained in the incoming address space.
|
||
|
</p></dd>
|
||
|
</dl>
|
||
|
|
||
|
<a name="EIND-and-Devices-with-More-Than-128-Ki-Bytes-of-Flash"></a>
|
||
|
<h4 class="subsubsection">3.18.5.1 <code>EIND</code> and Devices with More Than 128 Ki Bytes of Flash</h4>
|
||
|
<a name="index-EIND"></a>
|
||
|
<p>Pointers in the implementation are 16 bits wide.
|
||
|
The address of a function or label is represented as word address so
|
||
|
that indirect jumps and calls can target any code address in the
|
||
|
range of 64 Ki words.
|
||
|
</p>
|
||
|
<p>In order to facilitate indirect jump on devices with more than 128 Ki
|
||
|
bytes of program memory space, there is a special function register called
|
||
|
<code>EIND</code> that serves as most significant part of the target address
|
||
|
when <code>EICALL</code> or <code>EIJMP</code> instructions are used.
|
||
|
</p>
|
||
|
<p>Indirect jumps and calls on these devices are handled as follows by
|
||
|
the compiler and are subject to some limitations:
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li> The compiler never sets <code>EIND</code>.
|
||
|
|
||
|
</li><li> The compiler uses <code>EIND</code> implicitly in <code>EICALL</code>/<code>EIJMP</code>
|
||
|
instructions or might read <code>EIND</code> directly in order to emulate an
|
||
|
indirect call/jump by means of a <code>RET</code> instruction.
|
||
|
|
||
|
</li><li> The compiler assumes that <code>EIND</code> never changes during the startup
|
||
|
code or during the application. In particular, <code>EIND</code> is not
|
||
|
saved/restored in function or interrupt service routine
|
||
|
prologue/epilogue.
|
||
|
|
||
|
</li><li> For indirect calls to functions and computed goto, the linker
|
||
|
generates <em>stubs</em>. Stubs are jump pads sometimes also called
|
||
|
<em>trampolines</em>. Thus, the indirect call/jump jumps to such a stub.
|
||
|
The stub contains a direct jump to the desired address.
|
||
|
|
||
|
</li><li> Linker relaxation must be turned on so that the linker generates
|
||
|
the stubs correctly in all situations. See the compiler option
|
||
|
<samp>-mrelax</samp> and the linker option <samp>--relax</samp>.
|
||
|
There are corner cases where the linker is supposed to generate stubs
|
||
|
but aborts without relaxation and without a helpful error message.
|
||
|
|
||
|
</li><li> The default linker script is arranged for code with <code>EIND = 0</code>.
|
||
|
If code is supposed to work for a setup with <code>EIND != 0</code>, a custom
|
||
|
linker script has to be used in order to place the sections whose
|
||
|
name start with <code>.trampolines</code> into the segment where <code>EIND</code>
|
||
|
points to.
|
||
|
|
||
|
</li><li> The startup code from libgcc never sets <code>EIND</code>.
|
||
|
Notice that startup code is a blend of code from libgcc and AVR-LibC.
|
||
|
For the impact of AVR-LibC on <code>EIND</code>, see the
|
||
|
<a href="http://nongnu.org/avr-libc/user-manual/"><span class="nolinebreak">AVR-LibC</span> user manual</a><!-- /@w -->.
|
||
|
|
||
|
</li><li> It is legitimate for user-specific startup code to set up <code>EIND</code>
|
||
|
early, for example by means of initialization code located in
|
||
|
section <code>.init3</code>. Such code runs prior to general startup code
|
||
|
that initializes RAM and calls constructors, but after the bit
|
||
|
of startup code from AVR-LibC that sets <code>EIND</code> to the segment
|
||
|
where the vector table is located.
|
||
|
<div class="example">
|
||
|
<pre class="example">#include <avr/io.h>
|
||
|
|
||
|
static void
|
||
|
__attribute__((section(".init3"),naked,used,no_instrument_function))
|
||
|
init3_set_eind (void)
|
||
|
{
|
||
|
__asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
|
||
|
"out %i0,r24" :: "n" (&EIND) : "r24","memory");
|
||
|
}
|
||
|
</pre></div>
|
||
|
|
||
|
<p>The <code>__trampolines_start</code> symbol is defined in the linker script.
|
||
|
</p>
|
||
|
</li><li> Stubs are generated automatically by the linker if
|
||
|
the following two conditions are met:
|
||
|
<ul class="no-bullet">
|
||
|
<li>- The address of a label is taken by means of the <code>gs</code> modifier
|
||
|
(short for <em>generate stubs</em>) like so:
|
||
|
<div class="example">
|
||
|
<pre class="example">LDI r24, lo8(gs(<var>func</var>))
|
||
|
LDI r25, hi8(gs(<var>func</var>))
|
||
|
</pre></div>
|
||
|
</li><li>- The final location of that label is in a code segment
|
||
|
<em>outside</em> the segment where the stubs are located.
|
||
|
</li></ul>
|
||
|
|
||
|
</li><li> The compiler emits such <code>gs</code> modifiers for code labels in the
|
||
|
following situations:
|
||
|
<ul class="no-bullet">
|
||
|
<li>- Taking address of a function or code label.
|
||
|
</li><li>- Computed goto.
|
||
|
</li><li>- If prologue-save function is used, see <samp>-mcall-prologues</samp>
|
||
|
command-line option.
|
||
|
</li><li>- Switch/case dispatch tables. If you do not want such dispatch
|
||
|
tables you can specify the <samp>-fno-jump-tables</samp> command-line option.
|
||
|
</li><li>- C and C++ constructors/destructors called during startup/shutdown.
|
||
|
</li><li>- If the tools hit a <code>gs()</code> modifier explained above.
|
||
|
</li></ul>
|
||
|
|
||
|
</li><li> Jumping to non-symbolic addresses like so is <em>not</em> supported:
|
||
|
|
||
|
<div class="example">
|
||
|
<pre class="example">int main (void)
|
||
|
{
|
||
|
/* Call function at word address 0x2 */
|
||
|
return ((int(*)(void)) 0x2)();
|
||
|
}
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Instead, a stub has to be set up, i.e. the function has to be called
|
||
|
through a symbol (<code>func_4</code> in the example):
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="example">int main (void)
|
||
|
{
|
||
|
extern int func_4 (void);
|
||
|
|
||
|
/* Call function at byte address 0x4 */
|
||
|
return func_4();
|
||
|
}
|
||
|
</pre></div>
|
||
|
|
||
|
<p>and the application be linked with <samp>-Wl,--defsym,func_4=0x4</samp>.
|
||
|
Alternatively, <code>func_4</code> can be defined in the linker script.
|
||
|
</p></li></ul>
|
||
|
|
||
|
<a name="Handling-of-the-RAMPD_002c-RAMPX_002c-RAMPY-and-RAMPZ-Special-Function-Registers"></a>
|
||
|
<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>
|
||
|
<a name="index-RAMPD"></a>
|
||
|
<a name="index-RAMPX"></a>
|
||
|
<a name="index-RAMPY"></a>
|
||
|
<a name="index-RAMPZ"></a>
|
||
|
<p>Some AVR devices support memories larger than the 64 KiB range
|
||
|
that can be accessed with 16-bit pointers. To access memory locations
|
||
|
outside this 64 KiB range, the contentent of a <code>RAMP</code>
|
||
|
register is used as high part of the address:
|
||
|
The <code>X</code>, <code>Y</code>, <code>Z</code> address register is concatenated
|
||
|
with the <code>RAMPX</code>, <code>RAMPY</code>, <code>RAMPZ</code> special function
|
||
|
register, respectively, to get a wide address. Similarly,
|
||
|
<code>RAMPD</code> is used together with direct addressing.
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li> The startup code initializes the <code>RAMP</code> special function
|
||
|
registers with zero.
|
||
|
|
||
|
</li><li> If a <a href="Named-Address-Spaces.html#AVR-Named-Address-Spaces">named address space</a> other than
|
||
|
generic or <code>__flash</code> is used, then <code>RAMPZ</code> is set
|
||
|
as needed before the operation.
|
||
|
|
||
|
</li><li> If the device supports RAM larger than 64 KiB and the compiler
|
||
|
needs to change <code>RAMPZ</code> to accomplish an operation, <code>RAMPZ</code>
|
||
|
is reset to zero after the operation.
|
||
|
|
||
|
</li><li> If the device comes with a specific <code>RAMP</code> register, the ISR
|
||
|
prologue/epilogue saves/restores that SFR and initializes it with
|
||
|
zero in case the ISR code might (implicitly) use it.
|
||
|
|
||
|
</li><li> RAM larger than 64 KiB is not supported by GCC for AVR targets.
|
||
|
If you use inline assembler to read from locations outside the
|
||
|
16-bit address range and change one of the <code>RAMP</code> registers,
|
||
|
you must reset it to zero after the access.
|
||
|
|
||
|
</li></ul>
|
||
|
|
||
|
<a name="AVR-Built_002din-Macros"></a>
|
||
|
<h4 class="subsubsection">3.18.5.3 AVR Built-in Macros</h4>
|
||
|
|
||
|
<p>GCC defines several built-in macros so that the user code can test
|
||
|
for the presence or absence of features. Almost any of the following
|
||
|
built-in macros are deduced from device capabilities and thus
|
||
|
triggered by the <samp>-mmcu=</samp> command-line option.
|
||
|
</p>
|
||
|
<p>For even more AVR-specific built-in macros see
|
||
|
<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>.
|
||
|
</p>
|
||
|
<dl compact="compact">
|
||
|
<dt><code>__AVR_ARCH__</code></dt>
|
||
|
<dd><p>Build-in macro that resolves to a decimal number that identifies the
|
||
|
architecture and depends on the <samp>-mmcu=<var>mcu</var></samp> option.
|
||
|
Possible values are:
|
||
|
</p>
|
||
|
<p><code>2</code>, <code>25</code>, <code>3</code>, <code>31</code>, <code>35</code>,
|
||
|
<code>4</code>, <code>5</code>, <code>51</code>, <code>6</code>
|
||
|
</p>
|
||
|
<p>for <var>mcu</var>=<code>avr2</code>, <code>avr25</code>, <code>avr3</code>, <code>avr31</code>,
|
||
|
<code>avr35</code>, <code>avr4</code>, <code>avr5</code>, <code>avr51</code>, <code>avr6</code>,
|
||
|
</p>
|
||
|
<p>respectively and
|
||
|
</p>
|
||
|
<p><code>100</code>, <code>102</code>, <code>104</code>,
|
||
|
<code>105</code>, <code>106</code>, <code>107</code>
|
||
|
</p>
|
||
|
<p>for <var>mcu</var>=<code>avrtiny</code>, <code>avrxmega2</code>, <code>avrxmega4</code>,
|
||
|
<code>avrxmega5</code>, <code>avrxmega6</code>, <code>avrxmega7</code>, respectively.
|
||
|
If <var>mcu</var> specifies a device, this built-in macro is set
|
||
|
accordingly. For example, with <samp>-mmcu=atmega8</samp> the macro is
|
||
|
defined to <code>4</code>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_<var>Device</var>__</code></dt>
|
||
|
<dd><p>Setting <samp>-mmcu=<var>device</var></samp> defines this built-in macro which reflects
|
||
|
the device’s name. For example, <samp>-mmcu=atmega8</samp> defines the
|
||
|
built-in macro <code>__AVR_ATmega8__</code>, <samp>-mmcu=attiny261a</samp> defines
|
||
|
<code>__AVR_ATtiny261A__</code>, etc.
|
||
|
</p>
|
||
|
<p>The built-in macros’ names follow
|
||
|
the scheme <code>__AVR_<var>Device</var>__</code> where <var>Device</var> is
|
||
|
the device name as from the AVR user manual. The difference between
|
||
|
<var>Device</var> in the built-in macro and <var>device</var> in
|
||
|
<samp>-mmcu=<var>device</var></samp> is that the latter is always lowercase.
|
||
|
</p>
|
||
|
<p>If <var>device</var> is not a device but only a core architecture like
|
||
|
‘<samp>avr51</samp>’, this macro is not defined.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_DEVICE_NAME__</code></dt>
|
||
|
<dd><p>Setting <samp>-mmcu=<var>device</var></samp> defines this built-in macro to
|
||
|
the device’s name. For example, with <samp>-mmcu=atmega8</samp> the macro
|
||
|
is defined to <code>atmega8</code>.
|
||
|
</p>
|
||
|
<p>If <var>device</var> is not a device but only a core architecture like
|
||
|
‘<samp>avr51</samp>’, this macro is not defined.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_XMEGA__</code></dt>
|
||
|
<dd><p>The device / architecture belongs to the XMEGA family of devices.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_ELPM__</code></dt>
|
||
|
<dd><p>The device has the <code>ELPM</code> instruction.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_ELPMX__</code></dt>
|
||
|
<dd><p>The device has the <code>ELPM R<var>n</var>,Z</code> and <code>ELPM
|
||
|
R<var>n</var>,Z+</code> instructions.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_MOVW__</code></dt>
|
||
|
<dd><p>The device has the <code>MOVW</code> instruction to perform 16-bit
|
||
|
register-register moves.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_LPMX__</code></dt>
|
||
|
<dd><p>The device has the <code>LPM R<var>n</var>,Z</code> and
|
||
|
<code>LPM R<var>n</var>,Z+</code> instructions.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_MUL__</code></dt>
|
||
|
<dd><p>The device has a hardware multiplier.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_JMP_CALL__</code></dt>
|
||
|
<dd><p>The device has the <code>JMP</code> and <code>CALL</code> instructions.
|
||
|
This is the case for devices with at least 16 KiB of program
|
||
|
memory.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_EIJMP_EICALL__</code></dt>
|
||
|
<dt><code>__AVR_3_BYTE_PC__</code></dt>
|
||
|
<dd><p>The device has the <code>EIJMP</code> and <code>EICALL</code> instructions.
|
||
|
This is the case for devices with more than 128 KiB of program memory.
|
||
|
This also means that the program counter
|
||
|
(PC) is 3 bytes wide.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_2_BYTE_PC__</code></dt>
|
||
|
<dd><p>The program counter (PC) is 2 bytes wide. This is the case for devices
|
||
|
with up to 128 KiB of program memory.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_8BIT_SP__</code></dt>
|
||
|
<dt><code>__AVR_HAVE_16BIT_SP__</code></dt>
|
||
|
<dd><p>The stack pointer (SP) register is treated as 8-bit respectively
|
||
|
16-bit register by the compiler.
|
||
|
The definition of these macros is affected by <samp>-mtiny-stack</samp>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_SPH__</code></dt>
|
||
|
<dt><code>__AVR_SP8__</code></dt>
|
||
|
<dd><p>The device has the SPH (high part of stack pointer) special function
|
||
|
register or has an 8-bit stack pointer, respectively.
|
||
|
The definition of these macros is affected by <samp>-mmcu=</samp> and
|
||
|
in the cases of <samp>-mmcu=avr2</samp> and <samp>-mmcu=avr25</samp> also
|
||
|
by <samp>-msp8</samp>.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_HAVE_RAMPD__</code></dt>
|
||
|
<dt><code>__AVR_HAVE_RAMPX__</code></dt>
|
||
|
<dt><code>__AVR_HAVE_RAMPY__</code></dt>
|
||
|
<dt><code>__AVR_HAVE_RAMPZ__</code></dt>
|
||
|
<dd><p>The device has the <code>RAMPD</code>, <code>RAMPX</code>, <code>RAMPY</code>,
|
||
|
<code>RAMPZ</code> special function register, respectively.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__NO_INTERRUPTS__</code></dt>
|
||
|
<dd><p>This macro reflects the <samp>-mno-interrupts</samp> command-line option.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_ERRATA_SKIP__</code></dt>
|
||
|
<dt><code>__AVR_ERRATA_SKIP_JMP_CALL__</code></dt>
|
||
|
<dd><p>Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
|
||
|
instructions because of a hardware erratum. Skip instructions are
|
||
|
<code>SBRS</code>, <code>SBRC</code>, <code>SBIS</code>, <code>SBIC</code> and <code>CPSE</code>.
|
||
|
The second macro is only defined if <code>__AVR_HAVE_JMP_CALL__</code> is also
|
||
|
set.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_ISA_RMW__</code></dt>
|
||
|
<dd><p>The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__AVR_SFR_OFFSET__=<var>offset</var></code></dt>
|
||
|
<dd><p>Instructions that can address I/O special function registers directly
|
||
|
like <code>IN</code>, <code>OUT</code>, <code>SBI</code>, etc. may use a different
|
||
|
address as if addressed by an instruction to access RAM like <code>LD</code>
|
||
|
or <code>STS</code>. This offset depends on the device architecture and has
|
||
|
to be subtracted from the RAM address in order to get the
|
||
|
respective I/O address.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>__WITH_AVRLIBC__</code></dt>
|
||
|
<dd><p>The compiler is configured to be used together with AVR-Libc.
|
||
|
See the <samp>--with-avrlibc</samp> configure option.
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
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> [<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>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|