3 # define for pentium pro friendly version
5 push(@INC,"perlasm","../../perlasm");
8 &asm_init($ARGV[0],"rc4-586.pl");
24 local($n,$p,$char)=@_;
34 &jle(&label("finished"));
42 &jl(&label("finished"));
47 # &mov( $tx, &DWP(0,$d,$x,4)) if $p < 0;
51 &inc( $x); # NEXT ROUND
52 &mov( $ty, &DWP(0,$d,$y,4));
54 &mov( &DWP(-4,$d,$x,4),$ty); # AGI
56 &and( $x, 0xff); # NEXT ROUND
58 &mov( &DWP(0,$d,$y,4),$tx);
60 &mov( $ty, &DWP(0,$d,$ty,4));
61 &mov( $tx, &DWP(0,$d,$x,4)) if $p < 1; # NEXT ROUND
66 #moved up into last round
71 &movb( &BP($n,"esp","",0), &LB($ty));
75 # Note in+=8 has occured
76 &movb( &HB($ty), &BP(-1,$in,"",0));
78 &xorb(&LB($ty), &HB($ty));
80 &movb(&BP($n,$out,"",0),&LB($ty));
89 &function_begin_B($name,"");
95 &mov( $d, &wparam(0)); # key
96 &mov( $ty, &wparam(1)); # num
100 &mov( $x, &DWP(0,$d,"",1));
101 &mov( $y, &DWP(4,$d,"",1));
103 &mov( $in, &wparam(2));
106 &stack_push(3); # 3 temp variables
110 &lea( $ty, &DWP(-8,$ty,$in));
112 # check for 0 length input
114 &mov( $out, &wparam(3));
115 &mov( &swtmp(2), $ty); # this is now address to exit at
116 &mov( $tx, &DWP(0,$d,$x,4));
119 &jl( &label("end")); # less than 8 bytes
135 &comment("apply the cipher text");
136 # xor the cipher data with input
138 #&add( $out, 8); #moved up into last round
140 &mov( $tx, &swtmp(0));
141 &mov( $ty, &DWP(-8,$in,"",0));
143 &mov( $ty, &DWP(-4,$in,"",0));
144 &mov( &DWP(-8,$out,"",0), $tx);
145 &mov( $tx, &swtmp(1));
147 &mov( $ty, &swtmp(2)); # load end ptr;
148 &mov( &DWP(-4,$out,"",0), $tx);
149 &mov( $tx, &DWP(0,$d,$x,4));
151 &jle(&label("start"));
155 # There is quite a bit of extra crap in RC4_loop() for this
165 &set_label("finished");
168 &mov( &DWP(-4,$d,"",0),$y);
169 &movb( &BP(-8,$d,"",0),&LB($x));
171 &function_end($name);