I'm reading Computer Systems: A Programmer's Perspective and the homework was to describe how this algorithm works.
C function:
void store_prod(__int128 *dest, int64_t x, int64_t y) {
*dest = x * (__int128)y;
}
Assembly:
movq %rdx, %rax
cqto
movq %rsi, %rcx
sarq $63, %rcx
imulq %rax, %rcx
imulq %rsi, %rdx
addq %rdx, %rcx
mulq %rsi
addq %rcx, %rdx
movq %rax, (%rdi)
movq %rdx, 8(%rdi)
ret
I don't know why it performs: xh * yl + yh * xl = value which we add after unsigned multiplication