co-586.pl revision 7c478bd95313f5f23a4c958a745db2134aa03244
require "x86asm.pl";
&asm_finish();
sub mul_add_c
{
# pos == -1 if eax and edx are pre-loaded, 0 to load from next
# words, and 1 if load return value
&comment("mul a[$ai]*b[$bi]");
# "eax" and "edx" will always be pre-loaded.
# &mov("eax",&DWP($ai*4,$a,"",0)) ;
# &mov("edx",&DWP($bi*4,$b,"",0));
&mul("edx");
###
###
# is pos > 1, it means it is the last loop
}
sub sqr_add_c
{
# pos == -1 if eax and edx are pre-loaded, 0 to load from next
# words, and 1 if load return value
&comment("sqr a[$ai]*a[$bi]");
# "eax" and "edx" will always be pre-loaded.
# &mov("eax",&DWP($ai*4,$a,"",0)) ;
# &mov("edx",&DWP($bi*4,$b,"",0));
{ &mul("eax");}
else
{ &mul("edx");}
###
###
# is pos > 1, it means it is the last loop
}
sub sqr_add_c2
{
# pos == -1 if eax and edx are pre-loaded, 0 to load from next
# words, and 1 if load return value
&comment("sqr a[$ai]*a[$bi]");
# "eax" and "edx" will always be pre-loaded.
# &mov("eax",&DWP($ai*4,$a,"",0)) ;
# &mov("edx",&DWP($bi*4,$a,"",0));
{ &mul("eax");}
else
{ &mul("edx");}
###
###
###
}
sub bn_mul_comba
{
$c0="ebx";
$c1="ecx";
$c2="ebp";
$a="esi";
$b="edi";
$as=0;
$ae=0;
$bs=0;
$be=0;
&push("esi");
&push("edi");
&push("ebp");
&push("ebx");
for ($i=0; $i<$tot; $i++)
{
&comment("################## Calculate word $i");
{
if (($j+1) == $end)
{
$v=1;
}
else
{ $v=0; }
if (($j+1) != $end)
{
}
else
{
}
#printf STDERR "[$ai,$bi] -> [$na,$nb]\n";
if ($v)
{
&comment("saved r[$i]");
# &mov("eax",&wparam(0));
# &mov(&DWP($i*4,"eax","",0),$c0);
}
$ai--;
$bi++;
}
}
&comment("save r[$i]");
# &mov("eax",&wparam(0));
&pop("ebx");
&pop("ebp");
&pop("edi");
&pop("esi");
&ret();
&function_end_B($name);
}
sub bn_sqr_comba
{
$c0="ebx";
$c1="ecx";
$c2="ebp";
$a="esi";
$r="edi";
&push("esi");
&push("edi");
&push("ebp");
&push("ebx");
$as=0;
$ae=0;
$bs=0;
$be=0;
for ($i=0; $i<$tot; $i++)
{
&comment("############### Calculate word $i");
{
{
$v=1;
}
else
{ $v=0; }
if (!$v)
{
}
else
{
}
{
}
else
{
}
if ($v)
{
&comment("saved r[$i]");
#&mov(&DWP($i*4,$r,"",0),$c0);
last;
}
$ai--;
$bi++;
}
}
&pop("ebx");
&pop("ebp");
&pop("edi");
&pop("esi");
&ret();
&function_end_B($name);
}