7 $::lbdecor="\$L"; # local label decoration
8 $nmdecor="_"; # external name decoration
13 { my ($opcode,@arg)=@_;
15 # fix hexadecimal constants
16 $arg[0] =~ s/0x([0-9a-f]+)/0$1h/oi if (defined($arg[0]));
17 $arg[1] =~ s/0x([0-9a-f]+)/0$1h/oi if (defined($arg[1]));
19 &::emit($opcode,@arg);
23 # opcodes not covered by ::generic above, mostly inconsistent namings...
25 sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
26 sub ::call_ptr { &::emit("call",@_); }
27 sub ::jmp_ptr { &::emit("jmp",@_); }
30 { my($size,$addr,$reg1,$reg2,$idx)=@_;
33 $ret .= "$size PTR " if ($size ne "");
36 # prepend global references with optional underscore
37 $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige;
38 # put address arithmetic expression in parenthesis
39 $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
41 if (($addr ne "") && ($addr ne 0))
42 { if ($addr !~ /^-/) { $ret .= "$addr"; }
50 $ret .= "+$reg1" if ($reg1 ne "");
56 $ret =~ s/\+\]/]/; # in case $addr was the only argument
61 sub ::BP { &get_mem("BYTE",@_); }
62 sub ::DWP { &get_mem("DWORD",@_); }
63 sub ::QWP { &get_mem("QWORD",@_); }
73 .TEXT\$ SEGMENT PAGE 'CODE'
78 sub ::function_begin_B
80 my $global=($func !~ /^_/);
81 my $begin="${::lbdecor}_${func}_begin";
83 &::LABEL($func,$global?"$begin":"$nmdecor$func");
84 $func=$nmdecor.$func."\tPROC";
86 if ($global) { $func.=" PUBLIC\n${begin}::\n"; }
87 else { $func.=" PRIVATE\n"; }
94 push(@out,"$nmdecor$func ENDP\n");
100 { my $xmmheader=<<___;
109 if (grep {/\b[x]?mm[0-7]\b/i} @out) {
110 grep {s/\.[3-7]86/$xmmheader/} @out;
113 push(@out,".TEXT\$ ENDS\n");
115 if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
118 COMM ${nmdecor}OPENSSL_ia32cap_P:DWORD
121 # comment out OPENSSL_ia32cap_P declarations
122 grep {s/(^EXTERN\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
125 push (@out,$initseg) if ($initseg);
129 sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
132 { my $l=shift; push(@out,$l.($l=~/^\Q${::lbdecor}\E[0-9]{3}/?":\n":"::\n")); };
135 { push(@out, "EXTERN\t".&::LABEL($_[0],$nmdecor.$_[0]).":NEAR\n"); }
138 { push(@out,"PUBLIC\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
141 { push(@out,("DB\t").join(',',@_)."\n"); }
144 { push(@out,("DD\t").join(',',@_)."\n"); }
147 { push(@out,"ALIGN\t$_[0]\n"); }
151 &::lea($dst,&::DWP($sym));
155 { my $f=$nmdecor.shift;
158 .CRT\$XCU SEGMENT DWORD PUBLIC DATA