This commit is contained in:
[GGSuchao]
2017-07-06 17:23:17 +08:00
committed by GGSuchao
parent 96dc55edb1
commit 7f55f996cd
3 changed files with 81 additions and 58 deletions

View File

@@ -4,4 +4,4 @@ SOURCE[../../libcrypto]=sm2_err.c sm2_asn1.c sm2_id.c sm2_sign.c sm2_enc.c \
sm2_standard_sign.c ./miracl/mralloc.c ./miracl/mrarth0.c \
./miracl/mrarth1.c ./miracl/mrarth2.c ./miracl/mrarth3.c ./miracl/mrbits.c \
./miracl/mrcore.c ./miracl/mrcurve.c ./miracl/mrjack.c ./miracl/mrlucas.c\
./miracl/mrmonty.c ./miracl/mrmuldv.c ./miracl/mrsroot.c ./miracl/mrxgcd.c
./miracl/mrmonty.c ./miracl/mrmuldv.g64 ./miracl/mrsroot.c ./miracl/mrxgcd.c

View File

@@ -1,57 +0,0 @@
/*
* Borland C++ 32-bit compiler (BCC32). Use with mirdef.h32
* Uses inline assembly feature. Suitable for Win32 Apps
* Also compatible with Microsoft Visual C++ 32-bit compiler
*/
#define ASM __asm__
int muldiv(a,b,c,m,rp)
int a,b,c,m,*rp;
{
ASM ("movl a,%eax");
ASM ("mull b");
ASM ("addl c,%eax");
ASM ("adcl $0x00,%edx");
ASM ("divl m");
ASM ("movl rp,%ebx");
ASM ("movl %edx,(%ebx)");
}
int muldvm(a,c,m,rp)
int a,c,m,*rp;
{
ASM ("movl a,%edx");
ASM ("movl c,%eax");
ASM ("divl m");
ASM ("movl rp,%ebx");
ASM ("movl %edx,(%ebx)");
}
int muldvd(a,b,c,rp)
int a,b,c,*rp;
{
ASM ("movl a,%eax");
ASM ("mull b");
ASM ("addl c,%eax");
ASM ("adcl $0x00,%edx");
ASM ("movl rp,%ebx");
ASM ("movl %eax,(%ebx)");
ASM ("movl %edx,%eax");
}
void muldvd2(a,b,c,rp)
int a,b,*c,*rp;
{
ASM ("movl a,%eax");
ASM ("mull b");
ASM ("movl c,%ebx");
ASM ("addl (%ebx),%eax");
ASM ("adcl $0x00,%edx");
ASM ("movl rp,%esi");
ASM ("addl (%esi),%eax");
ASM ("adcl $0x00,%edx");
ASM ("movl %eax,(%esi)");
ASM ("movl %edx,(%ebx)");
}

View File

@@ -0,0 +1,80 @@
/* GCC inline assembly version for Linux64 */
#include "miracl.h"
mr_small muldiv(mr_small a,mr_small b,mr_small c,mr_small m,mr_small *rp)
{
mr_small q;
__asm__ __volatile__ (
"movq %1,%%rax\n"
"mulq %2\n"
"addq %3,%%rax\n"
"adcq $0,%%rdx\n"
"divq %4\n"
"movq %5,%%rbx\n"
"movq %%rdx,(%%rbx)\n"
"movq %%rax,%0\n"
: "=m"(q)
: "m"(a),"m"(b),"m"(c),"m"(m),"m"(rp)
: "rax","rbx","memory"
);
return q;
}
mr_small muldvm(mr_small a,mr_small c,mr_small m,mr_small *rp)
{
mr_small q;
__asm__ __volatile__ (
"movq %1,%%rdx\n"
"movq %2,%%rax\n"
"divq %3\n"
"movq %4,%%rbx\n"
"movq %%rdx,(%%rbx)\n"
"movq %%rax,%0\n"
: "=m"(q)
: "m"(a),"m"(c),"m"(m),"m"(rp)
: "rax","rbx","memory"
);
return q;
}
mr_small muldvd(mr_small a,mr_small b,mr_small c,mr_small *rp)
{
mr_small q;
__asm__ __volatile__ (
"movq %1,%%rax\n"
"mulq %2\n"
"addq %3,%%rax\n"
"adcq $0,%%rdx\n"
"movq %4,%%rbx\n"
"movq %%rax,(%%rbx)\n"
"movq %%rdx,%0\n"
: "=m"(q)
: "m"(a),"m"(b),"m"(c),"m"(rp)
: "rax","rbx","memory"
);
return q;
}
void muldvd2(mr_small a,mr_small b,mr_small *c,mr_small *rp)
{
__asm__ __volatile__ (
"movq %0,%%rax\n"
"mulq %1\n"
"movq %2,%%rbx\n"
"addq (%%rbx),%%rax\n"
"adcq $0,%%rdx\n"
"movq %3,%%rsi\n"
"addq (%%rsi),%%rax\n"
"adcq $0,%%rdx\n"
"movq %%rax,(%%rsi)\n"
"movq %%rdx,(%%rbx)\n"
:
: "m"(a),"m"(b),"m"(c),"m"(rp)
: "rax","rbx","rsi","memory"
);
}