Botan 1.10.17

mp_asm.h
Go to the documentation of this file.
1 /*
2 * Multiply-Add for 64-bit MSVC
3 * (C) 2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_MP_ASM_H__
9 #define BOTAN_MP_ASM_H__
10
11 #include <botan/mp_types.h>
12 #include <intrin.h>
13
14 #if (BOTAN_MP_WORD_BITS != 64)
15 #error The mp_msvc64 module requires that BOTAN_MP_WORD_BITS == 64
16 #endif
17
18 #pragma intrinsic(_umul128)
19
20 namespace Botan {
21
22 extern "C" {
23
24 /*
25 * Word Multiply
26 */
27 inline word word_madd2(word a, word b, word* c)
28 {
29 word hi, lo;
30 lo = _umul128(a, b, &hi);
31
32 lo += *c;
33 hi += (lo < *c); // carry?
34
35 *c = hi;
36 return lo;
37 }
38
39 /*
40 * Word Multiply/Add
41 */
42 inline word word_madd3(word a, word b, word c, word* d)
43 {
44 word hi, lo;
45 lo = _umul128(a, b, &hi);
46
47 lo += c;
48 hi += (lo < c); // carry?
49
50 lo += *d;
51 hi += (lo < *d); // carry?
52
53 *d = hi;
54 return lo;
55 }
56
57 }
58
59 }
60
61 #endif
Botan::word_madd3
word word_madd3(word a, word b, word c, word *d)
Definition: mp_asm.h:102
Botan::word_madd2
word word_madd2(word a, word b, word *c)
Definition: mp_asm.h:86
Botan
Definition: algo_base.h:14