comparison tomsfastmath/src/generators/comba_mult_smallgen.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 /* program emits a NxN comba multiplier for 1x1 to 16x16 */
2 #include <stdio.h>
3
4 int main(int argc, char **argv)
5 {
6 int N, x, y, z;
7
8 /* print out preamble */
9 printf(
10 "void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\n"
11 "{\n"
12 " fp_digit c0, c1, c2, at[32];\n"
13 " switch (MAX(A->used, B->used)) { \n"
14 );
15
16 for (N = 1; N <= 16; N++) {
17
18 printf(
19 "\n"
20 " case %d:\n"
21 " memcpy(at, A->dp, %d * sizeof(fp_digit));\n"
22 " memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\n"
23 " COMBA_START;\n"
24 "\n"
25 " COMBA_CLEAR;\n", N, N, N, N);
26
27 /* now do the rows */
28 for (x = 0; x < (N+N-1); x++) {
29 printf(
30 " /* %d */\n", x);
31 if (x > 0) {
32 printf(
33 " COMBA_FORWARD;\n");
34 }
35 for (y = 0; y < N; y++) {
36 for (z = 0; z < N; z++) {
37 if ((y+z)==x) {
38 printf(" MULADD(at[%d], at[%d]); ", y, z+N);
39 }
40 }
41 }
42 printf(
43 "\n"
44 " COMBA_STORE(C->dp[%d]);\n", x);
45 }
46 printf(
47 " COMBA_STORE2(C->dp[%d]);\n"
48 " C->used = %d;\n"
49 " C->sign = A->sign ^ B->sign;\n"
50 " fp_clamp(C);\n"
51 " COMBA_FINI;\n"
52 " break;\n", N+N-1, N+N);
53 }
54 printf(" }\n}\n\n");
55
56 return 0;
57 }
58
59 /* $Source$ */
60 /* $Revision$ */
61 /* $Date$ */