From def018d301a3e9365665630ffc5db860d0168f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 7 Jan 2014 17:50:46 +0100 Subject: [PATCH] Fix bignum ASM format for X86-64 --- include/polarssl/bn_mul.h | 54 +++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/include/polarssl/bn_mul.h b/include/polarssl/bn_mul.h index 1c2da136a..cbfc64ada 100644 --- a/include/polarssl/bn_mul.h +++ b/include/polarssl/bn_mul.h @@ -167,30 +167,40 @@ #if defined(__amd64__) || defined (__x86_64__) -#define MULADDC_INIT \ - asm( "movq %0, %%rsi " :: "m" (s)); \ - asm( "movq %0, %%rdi " :: "m" (d)); \ - asm( "movq %0, %%rcx " :: "m" (c)); \ - asm( "movq %0, %%rbx " :: "m" (b)); \ - asm( "xorq %r8, %r8 " ); +#define MULADDC_INIT \ + asm( \ + " \ + movq %3, %%rsi; \ + movq %4, %%rdi; \ + movq %5, %%rcx; \ + movq %6, %%rbx; \ + xorq %%r8, %%r8; \ + " -#define MULADDC_CORE \ - asm( "movq (%rsi),%rax " ); \ - asm( "mulq %rbx " ); \ - asm( "addq $8, %rsi " ); \ - asm( "addq %rcx, %rax " ); \ - asm( "movq %r8, %rcx " ); \ - asm( "adcq $0, %rdx " ); \ - asm( "nop " ); \ - asm( "addq %rax, (%rdi) " ); \ - asm( "adcq %rdx, %rcx " ); \ - asm( "addq $8, %rdi " ); +#define MULADDC_CORE \ + " \ + movq (%%rsi), %%rax; \ + mulq %%rbx; \ + addq $8, %%rsi; \ + addq %%rcx, %%rax; \ + movq %%r8, %%rcx; \ + adcq $0, %%rdx; \ + nop; \ + addq %%rax, (%%rdi); \ + adcq %%rdx, %%rcx; \ + addq $8, %%rdi; \ + " -#define MULADDC_STOP \ - asm( "movq %%rcx, %0 " : "=m" (c)); \ - asm( "movq %%rdi, %0 " : "=m" (d)); \ - asm( "movq %%rsi, %0 " : "=m" (s) :: \ - "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" ); +#define MULADDC_STOP \ + " \ + movq %%rcx, %0; \ + movq %%rdi, %1; \ + movq %%rsi, %2; \ + " \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \ + ); #endif /* AMD64 */