Chapter 3 General 64-Bit Optimizations 65
Software Optimization Guide for AMD64 Processors
25112 Rev. 3.06 September 2005
mov eax,[esi+4] ; EAX = a1
mov edx,[edi] ; EDX = b0
mul edx ; EDX:EAX = a1*b0 = e1:e0
add ebx,eax ; EBX = d1 + e0
adc ebp,edx ; EBP = e1 + possible carry from d1+e0
adc esp,0 ; Collect possible carry into c3.
mov eax,[esi] ; EAX = a0
mov edx,[edx+4] ; EDX = b1
mul edx ; EDX:EAX = a0*b1 = f1:f0
add ebx,eax ; EBX = d1 + e0 + f0
adc ebp,edx ; EBP = e1 + f1 + carry
adc esp,0 ; Collect possible carry into c3.
mov [ecx+4],ebx ; c1 = d1 + e0 + f0
mov eax,[esi+4] ; EAX = a1
mov edx,[edi+4] ; EDX = b1
mul edx ; EDX:EAX = a1*b1 = g1:g0
add ebp,eax ; EBP = e1 + f1 + g0 + carry
adc esp,edx ; ESP = g1 + carry
mov [ecx+8],ebp ; c2 = e1 + f1 + g0 + carry
mov [ecx+12],esp ; c3 = g1 + carry
;==============================================================================
; Restore the register state.
mov esp, [tempESP]
pop ebp
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
;==============================================================================
ret
_32bitalu_64x64 ENDP
_TEXT ENDS
END