118
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
adc r17, r1
adc r18, r2
adc r19, r2
fmulsu r23, r20
; ( (signed)ah * bl ) << 1
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
fmulsu r21, r22
; ( (signed)bh * al ) << 1
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
ret
fmac16x16_32_method_B ; uses two temporary registers (r4,r5), speed/Size
optimized
; but reduces cycles/words by 2
clr r2
fmuls r23, r21
; ( (signed)ah * (signed)bh ) << 1
movw r5:r4,r1:r0
fmul r22, r20
; ( al * bl ) << 1
adc r4, r2
add r16, r0
adc r17, r1
adc r18, r4
adc r19, r5
fmulsu r23, r20
; ( (signed)ah * bl ) << 1
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
fmulsu r21, r22
; ( (signed)bh * al ) << 1
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
ret
Comment on
Implementations
All 16-bit x 16-bit = 32-bit functions implemented here start by clearing the R2 register, which
is just used as a “dummy” register with the “add with carry” (ADC) and “subtract with carry”
(SBC) operations. These operations do not alter the contents of the R2 register. If the R2 reg-
ister is not used elsewhere in the code, it is not necessary to clear the R2 register each time
these functions are called, but only once prior to the first call to one of the functions.