1 /* TomsFastMath, a fast ISO C bignum library.
3 * This project is meant to fill in where LibTomMath
4 * falls short. That is speed ;-)
6 * This project is public domain and free for all purposes.
8 * Tom St Denis, tomstdenis@gmail.com
11 /* Generates squaring comba code... it learns it knows our secrets! */
14 int main(int argc, char **argv)
19 "#define TFM_DEFINES\n"
20 "#include \"fp_sqr_comba.c\"\n"
22 "#if defined(TFM_SMALL_SET)\n"
23 "void fp_sqr_comba_small(fp_int *A, fp_int *B)\n"
25 " fp_digit *a, b[32], c0, c1, c2, sc0, sc1, sc2;\n"
31 printf(" switch (A->used) { \n");
33 for (N = 1; N <= 16; N++) {
39 " /* clear carries */\n"
43 " SQRADD(a[0],a[0]);\n"
44 " COMBA_STORE(b[0]);\n", N);
46 for (x = 1; x < N+N-1; x++) {
48 "\n /* output %d */\n"
49 " CARRY_FORWARD;\n ", x);
51 for (f = y = 0; y < N; y++) {
52 for (z = 0; z < N; z++) {
53 if (z != y && z + y == x && y <= z) {
60 for (y = 0; y < N; y++) {
61 for (z = 0; z < N; z++) {
62 if (y<=z && (y+z)==x) {
64 printf(" SQRADD(a[%d], a[%d]); ", y, y);
66 printf(" SQRADD2(a[%d], a[%d]); ", y, z);
75 for (y = 0; y < N; y++) {
76 for (z = 0; z < N; z++) {
77 if (z != y && z + y == x && y <= z) {
80 printf("SQRADDSC(a[%d], a[%d]); ", y, z);
83 printf("SQRADDAC(a[%d], a[%d]); ", y, z);
92 printf("SQRADD(a[%d], a[%d]); ", x/2, x/2);
95 printf("\n COMBA_STORE(b[%d]);\n", x);
97 printf(" COMBA_STORE2(b[%d]);\n", N+N-1);
103 " B->sign = FP_ZPOS;\n"
104 " memcpy(B->dp, b, %d * sizeof(fp_digit));\n"
106 " break;\n\n", N+N, N+N);
109 printf("}\n}\n\n#endif /* TFM_SMALL_SET */\n\n"