aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-10 21:28:38 +0000
committerlloyd <[email protected]>2006-06-10 21:28:38 +0000
commit5e2cb71908f2ad7e9bdac787b37ff69590e125ab (patch)
tree82d86bada6b457502e9e3dacc20763016614b575 /modules
parent4a019b4ec71933e4ff24d145fdab3edaf55d6fc3 (diff)
Have the x86 assembler functions be linked as C, to match the plain C++
versions. Also, make use of the C preprocessor stringify operation.
Diffstat (limited to 'modules')
-rw-r--r--modules/mp_ia32/mp_asmi.h72
1 files changed, 38 insertions, 34 deletions
diff --git a/modules/mp_ia32/mp_asmi.h b/modules/mp_ia32/mp_asmi.h
index 6d458a315..1320482f6 100644
--- a/modules/mp_ia32/mp_asmi.h
+++ b/modules/mp_ia32/mp_asmi.h
@@ -10,6 +10,8 @@
namespace Botan {
+extern "C" {
+
/*************************************************
* Helper Macros for x86 Assembly *
*************************************************/
@@ -17,42 +19,42 @@ namespace Botan {
#define ASM(x) x "\n\t"
#endif
-#define ADDSUB2_OP(OPERATION, INDEX) \
- ASM("movl 4*" INDEX "(%[y]), %[carry]") \
- ASM(OPERATION " %[carry], 4*" INDEX "(%[x])") \
-
-#define ADDSUB3_OP(OPERATION, INDEX) \
- ASM("movl 4*" INDEX "(%[x]), %[carry]") \
- ASM(OPERATION " 4*" INDEX "(%[y]), %[carry]") \
- ASM("movl %[carry], 4*" INDEX "(%[z])") \
-
-#define LINMUL_OP(WRITE_TO, INDEX) \
- ASM("movl 4*" INDEX "(%[x]),%%eax") \
- ASM("mull %[y]") \
- ASM("addl %[carry],%%eax") \
- ASM("adcl $0,%%edx") \
- ASM("movl %%edx,%[carry]") \
- ASM("movl %%eax, 4*" INDEX "(%[" WRITE_TO "])")
-
-#define MULADD_OP(IGNORED, INDEX) \
- ASM("movl 4*" INDEX "(%[x]),%%eax") \
- ASM("mull %[y]") \
- ASM("addl %[carry],%%eax") \
- ASM("adcl $0,%%edx") \
- ASM("addl 4*" INDEX "(%[z]),%%eax") \
- ASM("adcl $0,%%edx") \
- ASM("movl %%edx,%[carry]") \
- ASM("movl %%eax, 4*" INDEX " (%[z])")
+#define ADDSUB2_OP(OPERATION, INDEX) \
+ ASM("movl 4*" #INDEX "(%[y]), %[carry]") \
+ ASM(OPERATION " %[carry], 4*" #INDEX "(%[x])") \
+
+#define ADDSUB3_OP(OPERATION, INDEX) \
+ ASM("movl 4*" #INDEX "(%[x]), %[carry]") \
+ ASM(OPERATION " 4*" #INDEX "(%[y]), %[carry]") \
+ ASM("movl %[carry], 4*" #INDEX "(%[z])") \
+
+#define LINMUL_OP(WRITE_TO, INDEX) \
+ ASM("movl 4*" #INDEX "(%[x]),%%eax") \
+ ASM("mull %[y]") \
+ ASM("addl %[carry],%%eax") \
+ ASM("adcl $0,%%edx") \
+ ASM("movl %%edx,%[carry]") \
+ ASM("movl %%eax, 4*" #INDEX "(%[" WRITE_TO "])")
+
+#define MULADD_OP(IGNORED, INDEX) \
+ ASM("movl 4*" #INDEX "(%[x]),%%eax") \
+ ASM("mull %[y]") \
+ ASM("addl %[carry],%%eax") \
+ ASM("adcl $0,%%edx") \
+ ASM("addl 4*" #INDEX "(%[z]),%%eax") \
+ ASM("adcl $0,%%edx") \
+ ASM("movl %%edx,%[carry]") \
+ ASM("movl %%eax, 4*" #INDEX " (%[z])")
#define DO_8_TIMES(MACRO, ARG) \
- MACRO(ARG, "0") \
- MACRO(ARG, "1") \
- MACRO(ARG, "2") \
- MACRO(ARG, "3") \
- MACRO(ARG, "4") \
- MACRO(ARG, "5") \
- MACRO(ARG, "6") \
- MACRO(ARG, "7")
+ MACRO(ARG, 0) \
+ MACRO(ARG, 1) \
+ MACRO(ARG, 2) \
+ MACRO(ARG, 3) \
+ MACRO(ARG, 4) \
+ MACRO(ARG, 5) \
+ MACRO(ARG, 6) \
+ MACRO(ARG, 7)
#define ADD_OR_SUBTRACT(CORE_CODE) \
ASM("rorl %[carry]") \
@@ -217,4 +219,6 @@ inline void word3_muladd_2(word* w2, word* w1, word* w0, word x, word y)
}
+}
+
#endif