Adding 64 bit numbers using 32 bit arithmetic

Light_handle picture Light_handle · Oct 30, 2009 · Viewed 26.8k times · Source

How do we add two 64 bit numbers using 32 bit arithmetic??

Answer

mmx picture mmx · Oct 30, 2009

Add the least significant bytes first, keep the carry. Add the most significant bytes considering the carry from LSBs:

; x86 assembly, Intel syntax
; adds ecx:ebx to edx:eax
add eax, ebx
adc edx, ecx