diff options
Diffstat (limited to 'src/math/bigint/mp_amd64_msvc')
-rw-r--r-- | src/math/bigint/mp_amd64_msvc/info.txt | 17 | ||||
-rw-r--r-- | src/math/bigint/mp_amd64_msvc/mp_asm.h | 61 |
2 files changed, 78 insertions, 0 deletions
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..56ae05927 --- /dev/null +++ b/src/math/bigint/mp_amd64_msvc/info.txt @@ -0,0 +1,17 @@ +load_on dep + +mp_bits 64 + +<header:internal> +mp_asm.h +mp_generic:mp_asmi.h +</header:internal> + +<arch> +amd64 +ia64 +</arch> + +<cc> +msvc +</cc> 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..3acbe11bb --- /dev/null +++ b/src/math/bigint/mp_amd64_msvc/mp_asm.h @@ -0,0 +1,61 @@ +/* +* 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 <botan/mp_types.h> +#include <intrin.h> + +#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 |