summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/perlasm/x86ms.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/perlasm/x86ms.pl')
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl122
1 files changed, 15 insertions, 107 deletions
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
index a0be2934c2..b6bd744057 100644
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ b/src/lib/libcrypto/perlasm/x86ms.pl
@@ -27,13 +27,7 @@ $label="L000";
27sub main'asm_init_output { @out=(); } 27sub main'asm_init_output { @out=(); }
28sub main'asm_get_output { return(@out); } 28sub main'asm_get_output { return(@out); }
29sub main'get_labels { return(@labels); } 29sub main'get_labels { return(@labels); }
30sub main'external_label 30sub main'external_label { push(@labels,@_); }
31{
32 push(@labels,@_);
33 foreach (@_) {
34 push(@out, "EXTRN\t_$_:DWORD\n");
35 }
36}
37 31
38sub main'LB 32sub main'LB
39 { 33 {
@@ -57,11 +51,6 @@ sub main'DWP
57 &get_mem("DWORD",@_); 51 &get_mem("DWORD",@_);
58 } 52 }
59 53
60sub main'QWP
61 {
62 &get_mem("QWORD",@_);
63 }
64
65sub main'BC 54sub main'BC
66 { 55 {
67 return @_; 56 return @_;
@@ -98,7 +87,7 @@ sub get_mem
98 $reg2=&conv($1); 87 $reg2=&conv($1);
99 $addr="_$2"; 88 $addr="_$2";
100 } 89 }
101 elsif ($addr =~ /^[_a-z][_a-z0-9]*$/i) 90 elsif ($addr =~ /^[_a-zA-Z]/)
102 { 91 {
103 $addr="_$addr"; 92 $addr="_$addr";
104 } 93 }
@@ -139,14 +128,12 @@ sub main'xorb { &out2("xor",@_); }
139sub main'add { &out2("add",@_); } 128sub main'add { &out2("add",@_); }
140sub main'adc { &out2("adc",@_); } 129sub main'adc { &out2("adc",@_); }
141sub main'sub { &out2("sub",@_); } 130sub main'sub { &out2("sub",@_); }
142sub main'sbb { &out2("sbb",@_); }
143sub main'rotl { &out2("rol",@_); } 131sub main'rotl { &out2("rol",@_); }
144sub main'rotr { &out2("ror",@_); } 132sub main'rotr { &out2("ror",@_); }
145sub main'exch { &out2("xchg",@_); } 133sub main'exch { &out2("xchg",@_); }
146sub main'cmp { &out2("cmp",@_); } 134sub main'cmp { &out2("cmp",@_); }
147sub main'lea { &out2("lea",@_); } 135sub main'lea { &out2("lea",@_); }
148sub main'mul { &out1("mul",@_); } 136sub main'mul { &out1("mul",@_); }
149sub main'imul { &out2("imul",@_); }
150sub main'div { &out1("div",@_); } 137sub main'div { &out1("div",@_); }
151sub main'dec { &out1("dec",@_); } 138sub main'dec { &out1("dec",@_); }
152sub main'inc { &out1("inc",@_); } 139sub main'inc { &out1("inc",@_); }
@@ -168,54 +155,26 @@ sub main'jne { &out1("jne",@_); }
168sub main'jno { &out1("jno",@_); } 155sub main'jno { &out1("jno",@_); }
169sub main'push { &out1("push",@_); $stack+=4; } 156sub main'push { &out1("push",@_); $stack+=4; }
170sub main'pop { &out1("pop",@_); $stack-=4; } 157sub main'pop { &out1("pop",@_); $stack-=4; }
171sub main'pushf { &out0("pushfd"); $stack+=4; }
172sub main'popf { &out0("popfd"); $stack-=4; }
173sub main'bswap { &out1("bswap",@_); &using486(); } 158sub main'bswap { &out1("bswap",@_); &using486(); }
174sub main'not { &out1("not",@_); } 159sub main'not { &out1("not",@_); }
175sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); } 160sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
176sub main'call_ptr { &out1p("call",@_); }
177sub main'ret { &out0("ret"); } 161sub main'ret { &out0("ret"); }
178sub main'nop { &out0("nop"); } 162sub main'nop { &out0("nop"); }
179sub main'test { &out2("test",@_); }
180sub main'bt { &out2("bt",@_); }
181sub main'leave { &out0("leave"); }
182sub main'cpuid { &out0("DW\t0A20Fh"); }
183sub main'rdtsc { &out0("DW\t0310Fh"); }
184sub main'halt { &out0("hlt"); }
185sub main'movz { &out2("movzx",@_); } 163sub main'movz { &out2("movzx",@_); }
186sub main'neg { &out1("neg",@_); }
187sub main'cld { &out0("cld"); }
188
189# SSE2
190sub main'emms { &out0("emms"); }
191sub main'movd { &out2("movd",@_); }
192sub main'movq { &out2("movq",@_); }
193sub main'movdqu { &out2("movdqu",@_); }
194sub main'movdqa { &out2("movdqa",@_); }
195sub main'movdq2q{ &out2("movdq2q",@_); }
196sub main'movq2dq{ &out2("movq2dq",@_); }
197sub main'paddq { &out2("paddq",@_); }
198sub main'pmuludq{ &out2("pmuludq",@_); }
199sub main'psrlq { &out2("psrlq",@_); }
200sub main'psllq { &out2("psllq",@_); }
201sub main'pxor { &out2("pxor",@_); }
202sub main'por { &out2("por",@_); }
203sub main'pand { &out2("pand",@_); }
204 164
205sub out2 165sub out2
206 { 166 {
207 local($name,$p1,$p2)=@_; 167 local($name,$p1,$p2)=@_;
208 local($l,$t,$line); 168 local($l,$t);
209 169
210 $line="\t$name\t"; 170 push(@out,"\t$name\t");
211 $t=&conv($p1).","; 171 $t=&conv($p1).",";
212 $l=length($t); 172 $l=length($t);
213 $line.="$t"; 173 push(@out,$t);
214 $l=4-($l+9)/8; 174 $l=4-($l+9)/8;
215 $line.="\t" x $l; 175 push(@out,"\t" x $l);
216 $line.=&conv($p2); 176 push(@out,&conv($p2));
217 if ($line=~/\bxmm[0-7]\b/i) { $line=~s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i; } 177 push(@out,"\n");
218 push(@out,$line."\n");
219 } 178 }
220 179
221sub out0 180sub out0
@@ -255,9 +214,7 @@ sub main'file
255 local($tmp)=<<"EOF"; 214 local($tmp)=<<"EOF";
256 TITLE $file.asm 215 TITLE $file.asm
257 .386 216 .386
258.model FLAT 217.model FLAT
259_TEXT\$ SEGMENT PAGE 'CODE'
260
261EOF 218EOF
262 push(@out,$tmp); 219 push(@out,$tmp);
263 } 220 }
@@ -269,6 +226,7 @@ sub main'function_begin
269 push(@labels,$func); 226 push(@labels,$func);
270 227
271 local($tmp)=<<"EOF"; 228 local($tmp)=<<"EOF";
229_TEXT SEGMENT
272PUBLIC _$func 230PUBLIC _$func
273$extra 231$extra
274_$func PROC NEAR 232_$func PROC NEAR
@@ -286,6 +244,7 @@ sub main'function_begin_B
286 local($func,$extra)=@_; 244 local($func,$extra)=@_;
287 245
288 local($tmp)=<<"EOF"; 246 local($tmp)=<<"EOF";
247_TEXT SEGMENT
289PUBLIC _$func 248PUBLIC _$func
290$extra 249$extra
291_$func PROC NEAR 250_$func PROC NEAR
@@ -305,6 +264,7 @@ sub main'function_end
305 pop ebp 264 pop ebp
306 ret 265 ret
307_$func ENDP 266_$func ENDP
267_TEXT ENDS
308EOF 268EOF
309 push(@out,$tmp); 269 push(@out,$tmp);
310 $stack=0; 270 $stack=0;
@@ -317,6 +277,7 @@ sub main'function_end_B
317 277
318 local($tmp)=<<"EOF"; 278 local($tmp)=<<"EOF";
319_$func ENDP 279_$func ENDP
280_TEXT ENDS
320EOF 281EOF
321 push(@out,$tmp); 282 push(@out,$tmp);
322 $stack=0; 283 $stack=0;
@@ -339,20 +300,6 @@ EOF
339 300
340sub main'file_end 301sub main'file_end
341 { 302 {
342 # try to detect if SSE2 or MMX extensions were used...
343 my $xmmheader=<<___;
344.686
345.XMM
346IF \@Version LT 800
347XMMWORD STRUCT 16
348 DQ 2 dup (?)
349XMMWORD ENDS
350ENDIF
351___
352 if (grep {/\b[x]?mm[0-7]\b/i} @out) {
353 grep {s/\.[3-7]86/$xmmheader/} @out;
354 }
355 push(@out,"_TEXT\$ ENDS\n");
356 push(@out,"END\n"); 303 push(@out,"END\n");
357 } 304 }
358 305
@@ -384,12 +331,6 @@ sub main'comment
384 } 331 }
385 } 332 }
386 333
387sub main'public_label
388 {
389 $label{$_[0]}="_$_[0]" if (!defined($label{$_[0]}));
390 push(@out,"PUBLIC\t$label{$_[0]}\n");
391 }
392
393sub main'label 334sub main'label
394 { 335 {
395 if (!defined($label{$_[0]})) 336 if (!defined($label{$_[0]}))
@@ -407,37 +348,19 @@ sub main'set_label
407 $label{$_[0]}="\$${label}${_[0]}"; 348 $label{$_[0]}="\$${label}${_[0]}";
408 $label++; 349 $label++;
409 } 350 }
410 if ($_[1]!=0 && $_[1]>1)
411 {
412 main'align($_[1]);
413 }
414 if((defined $_[2]) && ($_[2] == 1)) 351 if((defined $_[2]) && ($_[2] == 1))
415 { 352 {
416 push(@out,"$label{$_[0]}::\n"); 353 push(@out,"$label{$_[0]}::\n");
417 } 354 }
418 elsif ($label{$_[0]} !~ /^\$/)
419 {
420 push(@out,"$label{$_[0]}\tLABEL PTR\n");
421 }
422 else 355 else
423 { 356 {
424 push(@out,"$label{$_[0]}:\n"); 357 push(@out,"$label{$_[0]}:\n");
425 } 358 }
426 } 359 }
427 360
428sub main'data_byte
429 {
430 push(@out,"\tDB\t".join(',',@_)."\n");
431 }
432
433sub main'data_word 361sub main'data_word
434 { 362 {
435 push(@out,"\tDD\t".join(',',@_)."\n"); 363 push(@out,"\tDD\t$_[0]\n");
436 }
437
438sub main'align
439 {
440 push(@out,"\tALIGN\t$_[0]\n");
441 } 364 }
442 365
443sub out1p 366sub out1p
@@ -445,7 +368,7 @@ sub out1p
445 local($name,$p1)=@_; 368 local($name,$p1)=@_;
446 local($l,$t); 369 local($l,$t);
447 370
448 push(@out,"\t$name\t".&conv($p1)."\n"); 371 push(@out,"\t$name\t ".&conv($p1)."\n");
449 } 372 }
450 373
451sub main'picmeup 374sub main'picmeup
@@ -455,18 +378,3 @@ sub main'picmeup
455 } 378 }
456 379
457sub main'blindpop { &out1("pop",@_); } 380sub main'blindpop { &out1("pop",@_); }
458
459sub main'initseg
460 {
461 local($f)=@_;
462 local($tmp)=<<___;
463OPTION DOTNAME
464.CRT\$XCU SEGMENT DWORD PUBLIC 'DATA'
465EXTRN _$f:NEAR
466DD _$f
467.CRT\$XCU ENDS
468___
469 push(@out,$tmp);
470 }
471
4721;