comparison tomsfastmath/src/sqr/fp_sqr_comba_9.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 #define TFM_DEFINES
2 #include "fp_sqr_comba.c"
3
4 #ifdef TFM_SQR9
5 void fp_sqr_comba9(fp_int *A, fp_int *B)
6 {
7 fp_digit *a, b[18], c0, c1, c2, sc0, sc1, sc2;
8 #ifdef TFM_ISO
9 fp_word tt;
10 #endif
11
12 a = A->dp;
13 COMBA_START;
14
15 /* clear carries */
16 CLEAR_CARRY;
17
18 /* output 0 */
19 SQRADD(a[0],a[0]);
20 COMBA_STORE(b[0]);
21
22 /* output 1 */
23 CARRY_FORWARD;
24 SQRADD2(a[0], a[1]);
25 COMBA_STORE(b[1]);
26
27 /* output 2 */
28 CARRY_FORWARD;
29 SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]);
30 COMBA_STORE(b[2]);
31
32 /* output 3 */
33 CARRY_FORWARD;
34 SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]);
35 COMBA_STORE(b[3]);
36
37 /* output 4 */
38 CARRY_FORWARD;
39 SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]);
40 COMBA_STORE(b[4]);
41
42 /* output 5 */
43 CARRY_FORWARD;
44 SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB;
45 COMBA_STORE(b[5]);
46
47 /* output 6 */
48 CARRY_FORWARD;
49 SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]);
50 COMBA_STORE(b[6]);
51
52 /* output 7 */
53 CARRY_FORWARD;
54 SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB;
55 COMBA_STORE(b[7]);
56
57 /* output 8 */
58 CARRY_FORWARD;
59 SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]);
60 COMBA_STORE(b[8]);
61
62 /* output 9 */
63 CARRY_FORWARD;
64 SQRADDSC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB;
65 COMBA_STORE(b[9]);
66
67 /* output 10 */
68 CARRY_FORWARD;
69 SQRADDSC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]);
70 COMBA_STORE(b[10]);
71
72 /* output 11 */
73 CARRY_FORWARD;
74 SQRADDSC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB;
75 COMBA_STORE(b[11]);
76
77 /* output 12 */
78 CARRY_FORWARD;
79 SQRADD2(a[4], a[8]); SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]);
80 COMBA_STORE(b[12]);
81
82 /* output 13 */
83 CARRY_FORWARD;
84 SQRADD2(a[5], a[8]); SQRADD2(a[6], a[7]);
85 COMBA_STORE(b[13]);
86
87 /* output 14 */
88 CARRY_FORWARD;
89 SQRADD2(a[6], a[8]); SQRADD(a[7], a[7]);
90 COMBA_STORE(b[14]);
91
92 /* output 15 */
93 CARRY_FORWARD;
94 SQRADD2(a[7], a[8]);
95 COMBA_STORE(b[15]);
96
97 /* output 16 */
98 CARRY_FORWARD;
99 SQRADD(a[8], a[8]);
100 COMBA_STORE(b[16]);
101 COMBA_STORE2(b[17]);
102 COMBA_FINI;
103
104 B->used = 18;
105 B->sign = FP_ZPOS;
106 memcpy(B->dp, b, 18 * sizeof(fp_digit));
107 memset(B->dp + 18, 0, (FP_SIZE - 18) * sizeof(fp_digit));
108 fp_clamp(B);
109 }
110 #endif
111
112