xxxxxxxxxx
import std;
struct m128 { ulong lo, hi; }
// REX.W + F7 /4 MUL r/m64 (RDX:RAX ← RAX ∗ r/m64).
// https://en.wikipedia.org/wiki/X86_calling_conventions#x86-64_calling_conventions
// Windows RCX, RDX, R8, R9. returns RAX only
// Linux RDI, RSI, RDX, RCX, R8, R9. returns RDX:RAX
m128 mul128( ulong a, ulong b ) pure nothrow {
asm pure nothrow {
naked;
mov RAX, RDI;
mul RSI;
ret;
}
}
// probably u can do it inline
void main()
{
ulong a = 0x0102030405060708, b = 0x0101010101010101;
auto r = mul128( a, b );
"%016x %016x".writefln( r.hi, r.lo );
BigInt ba = a, bb = b, bc = ba * bb;
"%016x %016x".writefln( bc.getDigit( 1), bc.getDigit( 0));
}