1996 微芯 技术 公司 ds30412c-页 51
PIC17C4X
例子 8-4 显示 这 sequence 至 做 一个 16 x 16
signed 乘以. 等式 8-2 显示 这 algorithm 那
使用. 这 32-位 结果 是 贮存 在 四 寄存器
res3:res0. 至 账户 为 这 sign 位 的 这 argu-
ments, 各自 argument pairs 大多数 significant 位 (msb)
是 测试 和 这 适合的 subtractions 是 完毕.
等式 8-2: 16 x 16 signed
MULTIPLICATION
ALGORITHM
res3:res0
= arg1h:arg1l * arg2h:arg2l
= (arg1h * arg2h * 2
16
)+
(arg1h * arg2l * 2
8
)+
(arg1l * arg2h * 2
8
)+
(arg1l * arg2l) +
(-1 * arg2h<7> * arg1h:arg1l * 2
16
)+
(-1 * arg1h<7> * arg2h:arg2l * 2
16
)
例子 8-4: 16 x 16 signed 乘以
ROUTINE
movfp arg1l, wreg
mulwf arg2l ; arg1l * arg2l ->
; prodh:prodl
movpf prodh, res1 ;
movpf prodl, res0 ;
;
movfp arg1h, wreg
mulwf arg2h ; arg1h * arg2h ->
; prodh:prodl
movpf prodh, res3 ;
movpf prodl, res2 ;
;
movfp arg1l, wreg
mulwf arg2h ; arg1l * arg2h ->
; prodh:prodl
movfp prodl, wreg ;
addwf res1, f ; 增加 交叉
movfp prodh, wreg ; 产品
addwfc res2, f ;
clrf wreg, f ;
addwfc res3, f ;
;
movfp arg1h, wreg ;
mulwf arg2l ; arg1h * arg2l ->
; prodh:prodl
movfp prodl, wreg ;
addwf res1, f ; 增加 交叉
movfp prodh, wreg ; 产品
addwfc res2, f ;
clrf wreg, f ;
addwfc res3, f ;
;
btfss arg2h, 7 ; arg2h:arg2l neg?
goto sign_arg1 ; 非, 审查 arg1
movfp arg1l, wreg ;
subwf res2 ;
movfp arg1h, wreg ;
subwfb res3
;
sign_arg1
btfss arg1h, 7 ; arg1h:arg1l neg?
goto 内容_代号 ; 非, 完毕
movfp arg2l, wreg ;
subwf res2 ;
movfp arg2h, wreg ;
subwfb res3
;
内容_代号
: