📄 mult68k.lib
字号:
*
* mult68k.lib 32x32 signed and unsigned multiply
*
*
* Upon entry, D0 holds multiplier, D1 holds multiplicand.
* Upon exit, D0 holds product.
*
_mult32u
movem.l d2-d7,-(a7) save some regs
clr.l d7 always positive
bra _mult1 do the multiply
_mult32s
movem.l d2-d7,-(a7) save some regs
clr.l d7 start positive
tst d0 negative?
bpl _mult0 branch if not
not.l d7 show negative
neg.l d0 force positive value
_mult0
tst d1 negative?
bpl _mult1 branch if not
not.l d7 reverse flag
neg.l d1 force positive value
_mult1
move.l d0,d2 set up first product
move.l d1,d4
mulu.w d4,d2 d2 = lsw(d0) * lsw(d1)
move.l d1,d4 set up second product
swap d4
mulu.w d0,d4 d4 = lsw(d0) * msw(d1)
move.l d0,d3 set up third product
swap d3
mulu.w d1,d3 d3 = msw(d0) * lsw(d1)
add.l d3,d4 d4 = d3 + d4
swap d4 move lsw to msw
clr.w d4 force low word zero
add.l d2,d4 add to product
move.l d4,d0 save as result
tst d7 check negative flag
beq _multx branch if done
neg.l d0 make product negative
_multx
movem.l (a7)+,d2-d7 restore regs
rts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -