Arduino inline assembly: 16 bit x 8 bit multiplication!

There's quite a bit of stuff on AVR assembler at http://www.avr-asm-tutorial.net/avr_en/

westfw:
Are you sure now? i *= 5 compiles to:

12e:   9c 01           movw    r18, r24

130:   22 0f           add     r18, r18
132:   33 1f           adc     r19, r19
134:   22 0f           add     r18, r18
136:   33 1f           adc     r19, r19
138:   28 0f           add     r18, r24
13a:   39 1f           adc     r19, r25



(that's (i+i)+(i+i)+i )

I can't see a way of beating that. Just for fun I tried a few other factors too, and GCC always comes up with extremely efficient code.

Ah, how I don't miss the days of writing assembler. :slight_smile: