I tried to code a 32bit by 32 bit multiply. This would normally yield a 64 bit result, in my case I can throw away the least sig. 24 bits since I am assuming that the multiplier is a fixed point number as XXXXXXXX.FFFFFFFFFFFFFFFFFFFFFFFF, and the multiplicand is a 32 bit integer. The answer need only contain the integer part, not the fraction.

So I wrote

uint32_t CalNumber(uint32_t F, uint32_t K)

{

uint64_t R;

R = F * K;

return R >> 24;

}

The resulting assembler is:

155 .global CalNumber

156 .type CalNumber, @function

157 CalNumber:

158 /* prologue: frame size=0 */

159 0100 8F92 push r8

160 0102 9F92 push r9

161 0104 AF92 push r10

162 0106 BF92 push r11

163 0108 CF92 push r12

164 010a DF92 push r13

165 010c EF92 push r14

166 010e FF92 push r15

167 0110 0F93 push r16

168 0112 1F93 push r17

169 /* prologue end (size=10) */

170 0114 DC01 movw r26,r24

171 0116 CB01 movw r24,r22

GAS LISTING C:\DOCUME~1\kscharf\LOCALS~1\Temp/ccmqaaaa.s page 4

172 0118 BC01 movw r22,r24

173 011a CD01 movw r24,r26

174 011c 0E94 0000 call __mulsi3

175 0120 DC01 movw r26,r24

176 0122 CB01 movw r24,r22

177 0124 4C01 movw r8,r24

178 0126 5D01 movw r10,r26

179 0128 CC24 clr r12

180 012a 08E1 ldi r16,lo8(24)

181 012c 282F mov r18,r24

182 012e 392D mov r19,r9

183 0130 4A2D mov r20,r10

184 0132 5B2D mov r21,r11

185 0134 6C2D mov r22,r12

186 0136 7C2D mov r23,r12

187 0138 8C2D mov r24,r12

188 013a 9C2D mov r25,r12

189 013c 0E94 0000 call __lshrdi3

190 0140 A22E mov r10,r18

191 0142 B32E mov r11,r19

192 0144 C42E mov r12,r20

193 0146 D52E mov r13,r21

194 0148 C601 movw r24,r12

195 014a B501 movw r22,r10

196 /* epilogue: frame size=0 */

197 014c 1F91 pop r17

198 014e 0F91 pop r16

199 0150 FF90 pop r15

200 0152 EF90 pop r14

201 0154 DF90 pop r13

202 0156 CF90 pop r12

203 0158 BF90 pop r11

204 015a AF90 pop r10

205 015c 9F90 pop r9

206 015e 8F90 pop r8

207 0160 0895 ret

208 /* epilogue end (size=11) */

209 /* function CalNumber size 49 (28) */

210 .size CalNumber, .-CalNumber

211 .comm stable,132,1

Not having the source to mulsi3 or lshrdi3 I'm not sure this is what I wanted as 24 bits of return seem to be copied. Maybe someone more familiar with the avr assembler might comment on this.