6 local($a,$ai,$b,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_;
8 # pos == -1 if eax and edx are pre-loaded, 0 to load from next
9 # words, and 1 if load return value
11 &comment
("mul a[$ai]*b[$bi]");
13 # "eax" and "edx" will always be pre-loaded.
14 # &mov("eax",&DWP($ai*4,$a,"",0)) ;
15 # &mov("edx",&DWP($bi*4,$b,"",0));
19 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 0; # laod next a
20 &mov
("eax",&wparam
(0)) if $pos > 0; # load r[]
23 &mov
("edx",&DWP
(($nb)*4,$b,"",0)) if $pos == 0; # laod next b
24 &mov
("edx",&DWP
(($nb)*4,$b,"",0)) if $pos == 1; # laod next b
27 # is pos > 1, it means it is the last loop
28 &mov
(&DWP
($i*4,"eax","",0),$c0) if $pos > 0; # save r[];
29 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 1; # laod next a
34 local($r,$a,$ai,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_;
36 # pos == -1 if eax and edx are pre-loaded, 0 to load from next
37 # words, and 1 if load return value
39 &comment
("sqr a[$ai]*a[$bi]");
41 # "eax" and "edx" will always be pre-loaded.
42 # &mov("eax",&DWP($ai*4,$a,"",0)) ;
43 # &mov("edx",&DWP($bi*4,$b,"",0));
50 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 0; # load next a
53 &mov
("edx",&DWP
(($nb)*4,$a,"",0)) if ($pos == 1) && ($na != $nb);
56 # is pos > 1, it means it is the last loop
57 &mov
(&DWP
($i*4,$r,"",0),$c0) if $pos > 0; # save r[];
58 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 1; # load next b
63 local($r,$a,$ai,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_;
65 # pos == -1 if eax and edx are pre-loaded, 0 to load from next
66 # words, and 1 if load return value
68 &comment
("sqr a[$ai]*a[$bi]");
70 # "eax" and "edx" will always be pre-loaded.
71 # &mov("eax",&DWP($ai*4,$a,"",0)) ;
72 # &mov("edx",&DWP($bi*4,$a,"",0));
85 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 0; # load next a
86 &mov
("eax",&DWP
(($na)*4,$a,"",0)) if $pos == 1; # load next b
88 &mov
(&DWP
($i*4,$r,"",0),$c0) if $pos > 0; # save r[];
89 &mov
("edx",&DWP
(($nb)*4,$a,"",0)) if ($pos <= 1) && ($na != $nb);
96 local($a,$b,$c0,$c1,$c2);
97 local($i,$as,$ae,$bs,$be,$ai,$bi);
100 &function_begin_B
($name,"");
122 &mov
("eax",&DWP
(0,$a,"",0)); # load the first word
124 &mov
("edx",&DWP
(0,$b,"",0)); # load the first second
126 for ($i=0; $i<$tot; $i++)
132 &comment
("################## Calculate word $i");
134 for ($j=$bs; $j<$end; $j++)
136 &xor($c2,$c2) if ($j == $bs);
140 $v=2 if (($i+1) == $tot);
151 $na=$as+($i < ($num-1));
152 $nb=$bs+($i >= ($num-1));
154 #printf STDERR "[$ai,$bi] -> [$na,$nb]\n";
155 &mul_add_c
($a,$ai,$b,$bi,$c0,$c1,$c2,$v,$i,$na,$nb);
158 &comment
("saved r[$i]");
159 # &mov("eax",&wparam(0));
160 # &mov(&DWP($i*4,"eax","",0),$c0);
161 ($c0,$c1,$c2)=($c1,$c2,$c0);
166 $as++ if ($i < ($num-1));
167 $ae++ if ($i >= ($num-1));
169 $bs++ if ($i >= ($num-1));
170 $be++ if ($i < ($num-1));
172 &comment
("save r[$i]");
173 # &mov("eax",&wparam(0));
174 &mov
(&DWP
($i*4,"eax","",0),$c0);
181 &function_end_B
($name);
186 local($name,$num)=@_;
187 local($r,$a,$c0,$c1,$c2)=@_;
188 local($i,$as,$ae,$bs,$be,$ai,$bi);
189 local($b,$tot,$end,$half);
191 &function_begin_B
($name,"");
207 &mov
("eax",&DWP
(0,$a,"",0)); # load the first word
215 for ($i=0; $i<$tot; $i++)
221 &comment
("############### Calculate word $i");
222 for ($j=$bs; $j<$end; $j++)
224 &xor($c2,$c2) if ($j == $bs);
225 if (($ai-1) < ($bi+1))
228 $v=2 if ($i+1) == $tot;
239 $na=$as+($i < ($num-1));
240 $nb=$bs+($i >= ($num-1));
244 &sqr_add_c
($r,$a,$ai,$bi,
245 $c0,$c1,$c2,$v,$i,$na,$nb);
249 &sqr_add_c2
($r,$a,$ai,$bi,
250 $c0,$c1,$c2,$v,$i,$na,$nb);
254 &comment
("saved r[$i]");
255 #&mov(&DWP($i*4,$r,"",0),$c0);
256 ($c0,$c1,$c2)=($c1,$c2,$c0);
262 $as++ if ($i < ($num-1));
263 $ae++ if ($i >= ($num-1));
265 $bs++ if ($i >= ($num-1));
266 $be++ if ($i < ($num-1));
268 &mov
(&DWP
($i*4,$r,"",0),$c0);
274 &function_end_B
($name);