9 "#ifdef TFM_SMALL_SET\n"
10 "/* computes x/R == x (mod N) via Montgomery Reduction */\n"
11 "void fp_montgomery_reduce_small(fp_int *a, fp_int *m, fp_digit mp)\n"
13 " fp_digit c[FP_SIZE], *_c, *tmpm, mu, cy;\n"
14 " int oldused, x, y, pa;\n"
16 "#if defined(USE_MEMSET)\n"
17 " /* now zero the buff */\n"
18 " memset(c, 0, sizeof c);\n"
22 " /* copy the input */\n"
23 " oldused = a->used;\n"
24 " for (x = 0; x < oldused; x++) {\n"
27 "#if !defined(USE_MEMSET)\n"
28 " for (; x < 2*pa+3; x++) {\n"
37 for (x = 1; x <= 16; x++) {
38 if (x > 16 && (x != 32 && x != 48 && x != 64)) continue;
39 if (x > 16) printf("#ifdef TFM_HUGE\n");
43 printf(" case %d:\n", x);
45 for (y = 0; y < x; y++) {
47 printf(" x = %d; cy = 0;\n"
50 " tmpm = m->dp;\n", y, y);
52 printf("#ifdef INNERMUL8\n");
53 for (z = 0; z+8 <= x; z += 8) {
54 printf(" INNERMUL8; _c += 8; tmpm += 8;\n");
57 printf(" INNERMUL; ++_c;\n");
60 for (z = 0; z < x; z++) {
61 printf(" INNERMUL; ++_c;\n");
75 #define LOOP_MACRO(stride) \
76 for (x = 0; x < stride; x++) { \
78 /* get Mu for this round */ \
82 for (y = 0; y < stride; y++) { \
97 if (x > 16) printf("#endif /* TFM_HUGE */\n");
106 " /* now copy out */\n"
109 " for (x = 0; x < pa+1; x++) {\n"
110 " *tmpm++ = *_c++;\n"
113 " for (; x < oldused; x++) {\n"
122 " /* if A >= m then A = A - m */\n"
123 " if (fp_cmp_mag (a, m) != FP_LT) {\n"
124 " s_fp_sub (a, m, a);\n"