117
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
fmuls16x16_32
Description
Signed fractional multiply of two 16-bit numbers with a 32-bit result.
Usage
R19:R18:R17:R16 = (R23:R22 • R21:R20) << 1
Statistics
Cycles: 20 + ret
Words: 16 + ret
Register usage: R0 to R2 and R16 to R23 (11 registers)
Note:
1. The routine is non-destructive to the operands.
fmuls16x16_32:
clr r2
fmuls r23, r21
; ( (signed)ah * (signed)bh ) << 1
movw r19:r18, r1:r0
fmul r22, r20
; ( al * bl ) << 1
adc r18, r2
movw r17:r16, r1:r0
fmulsu r23, r20
; ( (signed)ah * bl ) << 1
sbc r19, r2
; Sign extend
add r17, r0
adc r18, r1
adc r19, r2
fmulsu r21, r22
; ( (signed)bh * al ) << 1
sbc r19, r2
; Sign extend
add r17, r0
adc r18, r1
adc r19, r2
ret
fmac16x16_32
Description
Signed fractional multiply-accumulate of two 16-bit numbers with a 32-bit result.
Usage
R19:R18:R17:R16 += (R23:R22 • R21:R20) << 1
Statistics
Cycles: 25 + ret
Words: 21 + ret
Register usage: R0 to R2 and R16 to R23 (11 registers)
fmac16x16_32:
; Register usage optimized
clr r2
fmuls r23, r21
; ( (signed)ah * (signed)bh ) << 1
add r18, r0
adc r19, r1
fmul r22, r20
; ( al * bl ) << 1
adc r18, r2
adc r19, r2
add r16, r0