4 push(@INC,"perlasm","../../perlasm");
8 &asm_init($ARGV[0],"bf-686.pl");
11 $BF_OFF=($BF_ROUNDS+2)*4;
20 &des_encrypt("BF_encrypt",1);
21 &des_encrypt("BF_decrypt",0);
22 &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1);
32 &function_begin($name,"");
35 &comment("Load the 2 words");
36 &mov("eax",&wparam(0));
37 &mov($L,&DWP(0,"eax","",0));
38 &mov($R,&DWP(4,"eax","",0));
41 &comment("P pointer, s and enc flag");
51 &xor($L,&DWP(0,$P,"",0));
52 for ($i=0; $i<$BF_ROUNDS; $i+=2)
56 &BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
59 &comment("Round ".sprintf("%d",$i+1));
60 &BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
62 &xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
64 &mov("eax",&wparam(0));
65 &mov(&DWP(0,"eax","",0),$R);
66 &mov(&DWP(4,"eax","",0),$L);
67 &function_end_A($name);
71 &xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
72 for ($i=$BF_ROUNDS; $i>0; $i-=2)
76 &BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
78 &comment("Round ".sprintf("%d",$i-1));
79 &BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
81 &xor($R,&DWP(0,$P,"",0));
83 &mov("eax",&wparam(0));
84 &mov(&DWP(0,"eax","",0),$R);
85 &mov(&DWP(4,"eax","",0),$L);
86 &function_end_A($name);
89 &function_end_B($name);
94 local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_;
97 &mov( $tot, &DWP(&n2a($i*4),$P,"",0));
99 &movb( &LB($tmp1), &HB($R));
100 &movb( &LB($tmp2), &LB($R));
105 &mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4));
106 &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4));
108 &movb( &LB($tmp1), &HB($R));
109 &movb( &LB($tmp2), &LB($R));
112 &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay
115 &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4));