comparison tomsfastmath/src/sqr/fp_sqr_comba_8.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_SQR8
5 void fp_sqr_comba8(fp_int *A, fp_int *B)
6 {
7 fp_digit *a, b[16], 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[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[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 SQRADD2(a[3], a[7]); SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]);
70 COMBA_STORE(b[10]);
71
72 /* output 11 */
73 CARRY_FORWARD;
74 SQRADD2(a[4], a[7]); SQRADD2(a[5], a[6]);
75 COMBA_STORE(b[11]);
76
77 /* output 12 */
78 CARRY_FORWARD;
79 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[6], a[7]);
85 COMBA_STORE(b[13]);
86
87 /* output 14 */
88 CARRY_FORWARD;
89 SQRADD(a[7], a[7]);
90 COMBA_STORE(b[14]);
91 COMBA_STORE2(b[15]);
92 COMBA_FINI;
93
94 B->used = 16;
95 B->sign = FP_ZPOS;
96 memcpy(B->dp, b, 16 * sizeof(fp_digit));
97 memset(B->dp + 16, 0, (FP_SIZE - 16) * sizeof(fp_digit));
98 fp_clamp(B);
99 }
100 #endif
101
102