aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mp_amd64/mp_asmi.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mp_amd64/mp_asmi.h')
-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