Here's a 68000 assembly function to multiply two 32-bit unsigned values and produce a 64-bit result using the approach you specified:
; Multiply two 32-bit unsigned values to produce a 64-bit result
; Input: D0 = multiplier, D1 = multiplicand
; Output: D0 = high 32 bits of result, D1 = low 32 bits of result
; Registers modified: D0, D1, D2, D3, D4
Multiply32:
; Save D2-D4 as we'll use them for intermediate calculations
MOVEM.L D2-D4,-(SP)
; Split D0 and D1 into high and low words
MOVE.W D0,D2 ; D2 = low word of D0
SWAP D0 ; D0 = high word of D0 (in low position)
MOVE.W D1,D3 ; D3 = low word of D1
SWAP D1 ; D1 = high word of D1 (in low position)
; Calculate the four partial products
; D4 = low word of D0 * low word of D1 (LL)
MULU D3,D2 ; D2 = LL
; D3 = high word of D0 * low word of D1 (HL)
MULU D3,D0 ; D0 = HL
; D4 = low word of D0 * high word of D1 (LH)
MOVE.W D2,D4 ; Save LL temporarily
MOVE.L D1,D3 ; Restore D1's high word to D3
SWAP D2 ; Get original low word of D0
MULU D3,D2 ; D2 = LH
MOVE.W D4,D2 ; Restore LL to D2
; D1 = high word of D0 * high word of D1 (HH)
SWAP D0 ; Get original high word of D0
MULU D3,D0 ; D0 = HH
; Combine the partial products
; First, add the two middle terms (HL + LH)
MOVE.L D2,D4 ; D4 = LL
CLR.W D2 ; Clear low word of D2
SWAP D2 ; D2 = LL << 16
ADD.L D2,D1 ; D1 = HL + (LL << 16)
; Check for carry from middle terms addition
BCC .no_carry
ADDQ.L #1,D0 ; Add carry to high result
.no_carry:
; Combine to form the final 64-bit result
MOVE.L D4,D1 ; D1 = low 32 bits (LL)
; Restore registers and return
MOVEM.L (SP)+,D2-D4
RTS
Would you like me to explain or break down this code?