Mercurial > dropbear
comparison tomsfastmath/src/generators/comba_mult_gen.c @ 643:a362b62d38b2 dropbear-tfm
Add tomsfastmath from git rev bfa4582842bc3bab42e4be4aed5703437049502a
with Makefile.in renamed
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 23 Nov 2011 18:10:20 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
642:33fd2f3499d2 | 643:a362b62d38b2 |
---|---|
1 /* TomsFastMath, a fast ISO C bignum library. | |
2 * | |
3 * This project is meant to fill in where LibTomMath | |
4 * falls short. That is speed ;-) | |
5 * | |
6 * This project is public domain and free for all purposes. | |
7 * | |
8 * Tom St Denis, [email protected] | |
9 */ | |
10 | |
11 /* program emits a NxN comba multiplier */ | |
12 #include <stdio.h> | |
13 | |
14 int main(int argc, char **argv) | |
15 { | |
16 int N, x, y, z; | |
17 N = atoi(argv[1]); | |
18 | |
19 /* print out preamble */ | |
20 printf( | |
21 "void fp_mul_comba%d(fp_int *A, fp_int *B, fp_int *C)\n" | |
22 "{\n" | |
23 " fp_digit c0, c1, c2, at[%d];\n" | |
24 "\n" | |
25 " memcpy(at, A->dp, %d * sizeof(fp_digit));\n" | |
26 " memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\n" | |
27 " COMBA_START;\n" | |
28 "\n" | |
29 " COMBA_CLEAR;\n", N, N+N, N, N, N); | |
30 | |
31 /* now do the rows */ | |
32 for (x = 0; x < (N+N-1); x++) { | |
33 printf( | |
34 " /* %d */\n", x); | |
35 if (x > 0) { | |
36 printf( | |
37 " COMBA_FORWARD;\n"); | |
38 } | |
39 for (y = 0; y < N; y++) { | |
40 for (z = 0; z < N; z++) { | |
41 if ((y+z)==x) { | |
42 printf(" MULADD(at[%d], at[%d]); ", y, z+N); | |
43 } | |
44 } | |
45 } | |
46 printf( | |
47 "\n" | |
48 " COMBA_STORE(C->dp[%d]);\n", x); | |
49 } | |
50 printf( | |
51 " COMBA_STORE2(C->dp[%d]);\n" | |
52 " C->used = %d;\n" | |
53 " C->sign = A->sign ^ B->sign;\n" | |
54 " fp_clamp(C);\n" | |
55 " COMBA_FINI;\n" | |
56 "}\n\n\n", N+N-1, N+N); | |
57 | |
58 return 0; | |
59 } | |
60 | |
61 /* $Source$ */ | |
62 /* $Revision$ */ | |
63 /* $Date$ */ |