From 9c333239e691d9a80368fc2068c1c3956299ec00 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 11 Jun 2010 12:22:11 +0000 Subject: Add (untested) support for VC++'s _umul128 intrinsic, which apparently works on both x86-64 and ia64. Will allow using 64-bit limbs on Windows. --- src/math/bigint/mp_amd64_msvc/info.txt | 16 +++++++++ src/math/bigint/mp_amd64_msvc/mp_asm.h | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/math/bigint/mp_amd64_msvc/info.txt create mode 100644 src/math/bigint/mp_amd64_msvc/mp_asm.h (limited to 'src/math/bigint') diff --git a/src/math/bigint/mp_amd64_msvc/info.txt b/src/math/bigint/mp_amd64_msvc/info.txt new file mode 100644 index 000000000..b6f322b83 --- /dev/null +++ b/src/math/bigint/mp_amd64_msvc/info.txt @@ -0,0 +1,16 @@ +load_on dep + +mp_bits 64 + + +mp_asm.h + + + +amd64 +ia64 + + + +msvc + diff --git a/src/math/bigint/mp_amd64_msvc/mp_asm.h b/src/math/bigint/mp_amd64_msvc/mp_asm.h new file mode 100644 index 000000000..09ca303df --- /dev/null +++ b/src/math/bigint/mp_amd64_msvc/mp_asm.h @@ -0,0 +1,60 @@ +/* +* Multiply-Add for 64-bit MSVC +* (C) 2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MP_ASM_H__ +#define BOTAN_MP_ASM_H__ + +#include + +#if (BOTAN_MP_WORD_BITS != 64) + #error The mp_amd64_msvc module requires that BOTAN_MP_WORD_BITS == 64 +#endif + +#pragma intrinsic(_umul128) + +namespace Botan { + +extern "C" { + +/* +* Word Multiply +*/ +inline word word_madd2(word a, word b, word* c) + { + word hi, lo; + lo = _umul128(a, b, &hi); + + lo += *c; + hi += (lo < *c); // carry? + + *c = hi; + return lo; + } + +/* +* Word Multiply/Add +*/ +inline word word_madd3(word a, word b, word c, word* d) + { + word hi, lo; + lo = _umul128(a, b, &hi); + + lo += c; + hi += (lo < c); // carry? + + lo += *d; + hi += (lo < *d); // carry? + + *d = hi; + return lo; + } + +} + +} + +#endif -- cgit v1.2.3