Arduino inline assembly: 16 bit x 8 bit multiplication!

robtillaart:
I would code x = x* 5 as x = x + x <<2; if I wanted to optimize

don't know the assembly for that but it uses no multiply at all..

Superb!

Are you sure now?  i *= 5 compiles to:
 
Code:
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 )

Nice one!!

Really appreciate for your help!! :smiley: