Botan: src/math/mp/mp_generic/mp_asm.h Source File

Botan 1.10.17

mp_asm.h
Go to the documentation of this file.
1 /*
2 * Lowest Level MPI Algorithms
3 * (C) 1999-2008 Jack Lloyd
4 * 2006 Luca Piccarreta
5 *
6 * Distributed under the terms of the Botan license
7 */
8
9 #ifndef BOTAN_MP_ASM_H__
10 #define BOTAN_MP_ASM_H__
11
12 #include <botan/mp_types.h>
13
14 #if (BOTAN_MP_WORD_BITS == 8)
15 typedef Botan::u16bit dword;
16 #elif (BOTAN_MP_WORD_BITS == 16)
17 typedef Botan::u32bit dword;
18 #elif (BOTAN_MP_WORD_BITS == 32)
19 typedef Botan::u64bit dword;
20 #elif (BOTAN_MP_WORD_BITS == 64)
21 #error BOTAN_MP_WORD_BITS can be 64 only with assembly support
22 #else
23 #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64
24 #endif
25
26 namespace Botan {
27
28 extern "C" {
29
30 /*
31 * Word Multiply/Add
32 */
33 inline word word_madd2(word a, word b, word* c)
34 {
35 dword z = (dword)a * b + *c;
36 *c = (word)(z >> BOTAN_MP_WORD_BITS);
37 return (word)z;
38 }
39
40 /*
41 * Word Multiply/Add
42 */
43 inline word word_madd3(word a, word b, word c, word* d)
44 {
45 dword z = (dword)a * b + c + *d;
46 *d = (word)(z >> BOTAN_MP_WORD_BITS);
47 return (word)z;
48 }
49
50 }
51
52 }
53
54 #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::u64bit
unsigned long long u64bit
Definition: types.h:49
Botan::u16bit
unsigned short u16bit
Definition: types.h:27
Botan
Definition: algo_base.h:14
Botan::u32bit
unsigned int u32bit
Definition: types.h:32