aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-10 21:30:21 +0000
committerlloyd <[email protected]>2006-06-10 21:30:21 +0000
commit60822d6d59408f8836909c2c70a04055c3f81e67 (patch)
tree3d3c9ce467ff36bd6d5a9e345369dd0ebf2f836b
parent5e2cb71908f2ad7e9bdac787b37ff69590e125ab (diff)
Have the amd64 assembler code also be linked as C and use the
stringify preprocessor operator.
-rw-r--r--modules/mp_amd64/mp_asmi.h66
1 files changed, 38 insertions, 28 deletions
diff --git a/modules/mp_amd64/mp_asmi.h b/modules/mp_amd64/mp_asmi.h
index 5366e6d50..c0f041068 100644
--- a/modules/mp_amd64/mp_asmi.h
+++ b/modules/mp_amd64/mp_asmi.h
@@ -10,6 +10,8 @@
namespace Botan {
+extern "C" {
+
/*************************************************
* Helper Macros for amd64 Assembly *
*************************************************/
@@ -17,36 +19,42 @@ namespace Botan {
#define ASM(x) x "\n\t"
#endif
-#define ADDSUB2_OP(OPERATION, INDEX) \
- ASM("movq 8*" INDEX "(%[y]), %[carry]") \
- ASM(OPERATION " %[carry], 8*" INDEX "(%[x])") \
-
-#define ADDSUB3_OP(OPERATION, INDEX) \
- ASM("movq 8*" INDEX "(%[x]), %[carry]") \
- ASM(OPERATION " 8*" INDEX "(%[y]), %[carry]") \
- ASM("movq %[carry], 8*" INDEX "(%[z])") \
-
-#define LINMUL_OP(WRITE_TO, INDEX) \
- ASM("movq 8*" INDEX "(%[x]),%%rax") \
- ASM("mulq %[y]") \
- ASM("addq %[carry],%%rax") \
- ASM("adcq $0,%%rdx") \
- ASM("movq %%rdx,%[carry]") \
- ASM("movq %%rax, 8*" INDEX "(%[" WRITE_TO "])")
-
-#define MULADD_OP(IGNORED, INDEX) \
- ASM("movq 8*" INDEX "(%[x]),%%rax") \
- ASM("mulq %[y]") \
- ASM("addq %[carry],%%rax") \
- ASM("adcq $0,%%rdx") \
- ASM("addq 8*" INDEX "(%[z]),%%rax") \
- ASM("adcq $0,%%rdx") \
- ASM("movq %%rdx,%[carry]") \
- ASM("movq %%rax, 8*" INDEX " (%[z])")
+#define ADDSUB2_OP(OPERATION, INDEX) \
+ ASM("movq 8*" #INDEX "(%[y]), %[carry]") \
+ ASM(OPERATION " %[carry], 8*" #INDEX "(%[x])") \
+
+#define ADDSUB3_OP(OPERATION, INDEX) \
+ ASM("movq 8*" #INDEX "(%[x]), %[carry]") \
+ ASM(OPERATION " 8*" #INDEX "(%[y]), %[carry]") \
+ ASM("movq %[carry], 8*" #INDEX "(%[z])") \
+
+#define LINMUL_OP(WRITE_TO, INDEX) \
+ ASM("movq 8*" #INDEX "(%[x]),%%rax") \
+ ASM("mulq %[y]") \
+ ASM("addq %[carry],%%rax") \
+ ASM("adcq $0,%%rdx") \
+ ASM("movq %%rdx,%[carry]") \
+ ASM("movq %%rax, 8*" #INDEX "(%[" WRITE_TO "])")
+
+#define MULADD_OP(IGNORED, INDEX) \
+ ASM("movq 8*" #INDEX "(%[x]),%%rax") \
+ ASM("mulq %[y]") \
+ ASM("addq %[carry],%%rax") \
+ ASM("adcq $0,%%rdx") \
+ ASM("addq 8*" #INDEX "(%[z]),%%rax") \
+ ASM("adcq $0,%%rdx") \
+ ASM("movq %%rdx,%[carry]") \
+ ASM("movq %%rax, 8*" #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("rorq %[carry]") \
@@ -211,4 +219,6 @@ inline void word3_muladd_2(word* w2, word* w1, word* w0, word x, word y)
}
+}
+
#endif