title: How can I bind a variable to an unused AVR I/O register using avr-gcc?
body: <p>I would like to bind a global variable to an unused I/O register (e.g. PORTB) using avr-gcc, to reduce code size. I learned this trick in AVR's application note <a href="http://www.atmel.com/Images/doc1497.pdf" rel="nofollow">AVR035</a> (page 14).</p>
  
  <p>In the application note, they use the IAR compiler and bind the variable to an I/O register like this:</p>
  
  <pre><code>__no_init volatile uint8_t counter@0x35;
  </code></pre>
  
  <p>With avr-gcc, I can bind a variable to a standard register (r3 in this case) using this line:</p>
  
  <pre><code>register uint8_t counter asm("r3");
  </code></pre>
  
  <p>This does not work for I/O registers though. Is there a way to do this for I/O registers?</p>