Fix bignum ASM format for X86-64

This commit is contained in:
Manuel Pégourié-Gonnard 2014-01-07 17:50:46 +01:00
parent c78c8422c2
commit def018d301

View file

@ -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 */