1*0Sstevel@tonic-gate#!/usr/local/bin/perl 2*0Sstevel@tonic-gate# x86 assember 3*0Sstevel@tonic-gate 4*0Sstevel@tonic-gatesub bn_sqr_words 5*0Sstevel@tonic-gate { 6*0Sstevel@tonic-gate local($name)=@_; 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate &function_begin($name,""); 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate &comment(""); 11*0Sstevel@tonic-gate $r="esi"; 12*0Sstevel@tonic-gate $a="edi"; 13*0Sstevel@tonic-gate $num="ebx"; 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate &mov($r,&wparam(0)); # 16*0Sstevel@tonic-gate &mov($a,&wparam(1)); # 17*0Sstevel@tonic-gate &mov($num,&wparam(2)); # 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gate &and($num,0xfffffff8); # num / 8 20*0Sstevel@tonic-gate &jz(&label("sw_finish")); 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate &set_label("sw_loop",0); 23*0Sstevel@tonic-gate for ($i=0; $i<32; $i+=4) 24*0Sstevel@tonic-gate { 25*0Sstevel@tonic-gate &comment("Round $i"); 26*0Sstevel@tonic-gate &mov("eax",&DWP($i,$a,"",0)); # *a 27*0Sstevel@tonic-gate # XXX 28*0Sstevel@tonic-gate &mul("eax"); # *a * *a 29*0Sstevel@tonic-gate &mov(&DWP($i*2,$r,"",0),"eax"); # 30*0Sstevel@tonic-gate &mov(&DWP($i*2+4,$r,"",0),"edx");# 31*0Sstevel@tonic-gate } 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate &comment(""); 34*0Sstevel@tonic-gate &add($a,32); 35*0Sstevel@tonic-gate &add($r,64); 36*0Sstevel@tonic-gate &sub($num,8); 37*0Sstevel@tonic-gate &jnz(&label("sw_loop")); 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate &set_label("sw_finish",0); 40*0Sstevel@tonic-gate &mov($num,&wparam(2)); # get num 41*0Sstevel@tonic-gate &and($num,7); 42*0Sstevel@tonic-gate &jz(&label("sw_end")); 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate for ($i=0; $i<7; $i++) 45*0Sstevel@tonic-gate { 46*0Sstevel@tonic-gate &comment("Tail Round $i"); 47*0Sstevel@tonic-gate &mov("eax",&DWP($i*4,$a,"",0)); # *a 48*0Sstevel@tonic-gate # XXX 49*0Sstevel@tonic-gate &mul("eax"); # *a * *a 50*0Sstevel@tonic-gate &mov(&DWP($i*8,$r,"",0),"eax"); # 51*0Sstevel@tonic-gate &dec($num) if ($i != 7-1); 52*0Sstevel@tonic-gate &mov(&DWP($i*8+4,$r,"",0),"edx"); 53*0Sstevel@tonic-gate &jz(&label("sw_end")) if ($i != 7-1); 54*0Sstevel@tonic-gate } 55*0Sstevel@tonic-gate &set_label("sw_end",0); 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate &function_end($name); 58*0Sstevel@tonic-gate } 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate1; 61