|
32-Bit Integer Multiplication ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This routine multiplies two 32-bit signed integers ; resulting; in a 64-bit product. The operands are fetched ; from data memory and the result is written back to data ; memory. ; Data Storage: ; X1,X0 32-bit operand ; Y1,Y0 32-bit operand ; W3,W2,W1,W0 64-bit product ; Entry Conditions: ; SXM = 1, OVM = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STM #X0,AR2 ;AR2 = X0 addr STM #Y0,AR3 ;AR3 = Y0 addr LD *AR2,T ;T = X0 MPYU *AR3+,A ;A = X0*Y0 STL A,@W0 ;save W0 LD A,–16,A ;A = A >> 16 MACSU *AR2+,*AR3–,A ;A = X0*Y0>>16 + X0*Y1 MACSU *AR3+,*AR2,A ;A = X0*Y0>>16 + X0*Y1 + X1*Y0 STL A,@W1 ;save W1 LD A,–16,A ;A = A >> 16 MAC *AR2,*AR3,A ;A = (X0*Y1 + X1*Y0)>>16 + X1*Y1 STL A,@W2 ;save W2 STH A,@W3 ;save W3
|