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

Botan 1.10.16

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 != 32)
15 #error The mp_x86_32 module requires that BOTAN_MP_WORD_BITS == 32
16 #endif
17
18 namespace Botan {
19
20 extern "C" {
21
22 /*
23 * Helper Macros for x86 Assembly
24 */
25 #define ASM(x) x "\n\t"
26
27 /*
28 * Word Multiply
29 */
30 inline word word_madd2(word a, word b, word* c)
31 {
32 asm(
33 ASM("mull %[b]")
34 ASM("addl %[c],%[a]")
35 ASM("adcl $0,%[carry]")
36
37 : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*c)
38 : "0"(a), "1"(b), [c]"g"(*c) : "cc");
39
40 return a;
41 }
42
43 /*
44 * Word Multiply/Add
45 */
46 inline word word_madd3(word a, word b, word c, word* d)
47 {
48 asm(
49 ASM("mull %[b]")
50
51 ASM("addl %[c],%[a]")
52 ASM("adcl $0,%[carry]")
53
54 ASM("addl %[d],%[a]")
55 ASM("adcl $0,%[carry]")
56
57 : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*d)
58 : "0"(a), "1"(b), [c]"g"(c), [d]"g"(*d) : "cc");
59
60 return a;
61 }
62
63 }
64
65 }
66
67 #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
ASM
#define ASM(x)
Definition: mp_asm.h:25