smartworkbr / optiboot

Automatically exported from code.google.com/p/optiboot
0 stars 0 forks source link

Save about 20 bytes by using a smarter version of LPM/ELPM. #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If we use the version of the LPM or ELPM instruction that post-increments the Z 
register, we can use that as the local variable address increment, saving a 
substantial amount of space:

Old code:
      do putch(pgm_read_byte_near(address++));
      while (--length);

New code:
     do {
        // read a Flash byte and increment the address
        __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
        putch(ch);
      } while (--length);

(as per "dkinzer": http://code.google.com/p/arduino/issues/detail?id=794 )

Original issue reported on code.google.com by wes...@gmail.com on 5 Jan 2013 at 4:41

GoogleCodeExporter commented 9 years ago
committed: 
http://code.google.com/p/optiboot/source/detail?r=16a7ff5da3735623c8c6395fd6941f
95e554997f

Original comment by wes...@gmail.com on 5 Jan 2013 at 5:25