aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-08 04:54:04 +0000
committerlloyd <[email protected]>2006-06-08 04:54:04 +0000
commitc9a2d46d4a67168c8aece9e2f5a45454fe68ede9 (patch)
treecfdefcfb93a18018665e0942caaec6182f7add66
parentd2cfbe00f3c5291f7eaf971cf19aa3266431c0af (diff)
Move the word3_muladd routines from mp_asm.h to mp_asmi.h, so they
can make use of word_add Update mp_comba.cpp to include the needed header.
-rw-r--r--include/mp_asm.h29
-rw-r--r--include/mp_asmi.h28
-rw-r--r--src/mp_comba.cpp2
3 files changed, 32 insertions, 27 deletions
diff --git a/include/mp_asm.h b/include/mp_asm.h
index 5f0747d88..a450ac47a 100644
--- a/include/mp_asm.h
+++ b/include/mp_asm.h
@@ -20,6 +20,9 @@
#error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64
#endif
+#include <stdio.h>
+#include <assert.h>
+
namespace Botan {
extern "C" {
@@ -44,32 +47,6 @@ inline word word_madd3(word a, word b, word c, word d, word* carry)
return (word)z;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
-inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
- {
- *w0 = word_madd2(a, b, *w0, &b);
- *w1 += b;
- *w2 += (*w1 < b) ? 1 : 0;
- }
-
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
-inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b)
- {
- a = word_madd2(a, b, 0, &b);
-
- *w0 += a;
- *w1 += b + ((*w0 < a) ? 1 : 0);
- *w2 += (*w1 < b) ? 1 : 0;
-
- *w0 += a;
- *w1 += b + ((*w0 < a) ? 1 : 0);
- *w2 += (*w1 < b) ? 1 : 0;
- }
-
}
}
diff --git a/include/mp_asmi.h b/include/mp_asmi.h
index b05199d0a..46a0696de 100644
--- a/include/mp_asmi.h
+++ b/include/mp_asmi.h
@@ -150,6 +150,34 @@ inline word word8_madd3(word z[8], const word x[8], word y, word carry)
return carry;
}
+/*************************************************
+* Multiply-Add Accumulator *
+*************************************************/
+inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
+ {
+ *w0 = word_madd2(a, b, *w0, &b);
+ *w1 += b;
+ *w2 += (*w1 < b) ? 1 : 0;
+ }
+
+/*************************************************
+* Multiply-Add Accumulator *
+*************************************************/
+inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b)
+ {
+ a = word_madd2(a, b, 0, &b);
+
+ word top = (b >> (BOTAN_MP_WORD_BITS-1));
+ b <<= 1;
+ b |= (a >> (BOTAN_MP_WORD_BITS-1));
+ a <<= 1;
+
+ word carry = 0;
+ *w0 = word_add(*w0, a, &carry);
+ *w1 = word_add(*w1, b, &carry);
+ *w2 = word_add(*w2, top, &carry);
+ }
+
}
}
diff --git a/src/mp_comba.cpp b/src/mp_comba.cpp
index 450d955a7..0e6dbd259 100644
--- a/src/mp_comba.cpp
+++ b/src/mp_comba.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/mp_core.h>
-#include <botan/mp_asm.h>
+#include <botan/mp_asmi.h>
namespace Botan {