9 $under=($::netware)?'':'_';
17 { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps
18 { $_[0] = "NEAR $_[0]"; }
19 elsif ($opcode eq "lea" && $#_==1)# wipe storage qualifier from lea
20 { $_[1] =~ s/^[^\[]*\[/\[/o; }
26 # opcodes not covered by ::generic above, mostly inconsistent namings...
28 sub ::movz { &::movzx(@_); }
29 sub ::pushf { &::pushfd; }
30 sub ::popf { &::popfd; }
32 sub ::call { &::emit("call",(&islabel($_[0]) or "$under$_[0]")); }
33 sub ::call_ptr { &::emit("call",@_); }
34 sub ::jmp_ptr { &::emit("jmp",@_); }
36 # chosen SSE instructions
38 { my($p1,$p2,$optimize)=@_;
40 if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
41 # movq between mmx registers can sink Intel CPUs
42 { &::pshufw($p1,$p2,0xe4); }
44 { &::emit("movq",@_); }
46 sub ::pshufw { &::emit("pshufw",@_); }
49 { my($size,$addr,$reg1,$reg2,$idx)=@_;
54 $ret .= " PTR" if ($::mwerks);
60 # prepend global references with optional underscore
61 $addr =~ s/^([^\+\-0-9][^\+\-]*)/islabel($1) or "$under$1"/ige;
62 # put address arithmetic expression in parenthesis
63 $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
65 if (($addr ne "") && ($addr ne 0))
66 { if ($addr !~ /^-/) { $ret .= "$addr+"; }
73 $ret .= "+$reg1" if ($reg1 ne "");
79 $ret =~ s/\+\]/]/; # in case $addr was the only argument
83 sub ::BP { &get_mem("BYTE",@_); }
84 sub ::DWP { &get_mem("DWORD",@_); }
85 sub ::QWP { &get_mem("",@_); }
86 sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; }
87 sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; }
90 { if ($::mwerks) { push(@out,".section\t.text\n"); }
94 section code use32 class=code align=64
96 section .text code align=64
103 sub ::function_begin_B
105 my $begin="${lprfx}_${func}_begin";
112 $label{$func}=$begin;
118 foreach $i (keys %label) { delete $label{$i} if ($label{$i} =~ /^${lprfx}[0-9]{3}/); }
123 { # try to detect if SSE2 or MMX extensions were used on Win32...
124 if ($::win32 && grep {/\b[x]?mm[0-7]\b|OPENSSL_ia32cap_P\b/i} @out)
125 { # $1<<10 sets a reserved bit to signal that variable
126 # was initialized already...
129 ${lprfx}OPENSSL_ia32cap_init:
130 lea edx,[${under}OPENSSL_ia32cap_P]
132 jne NEAR ${lprfx}nocpuid
133 mov DWORD [edx],1<<10
144 jnc NEAR ${lprfx}nocpuid
184 segment .CRT\$XCU data align=4
185 dd ${lprfx}OPENSSL_ia32cap_init
189 common ${under}OPENSSL_ia32cap_P 4
192 #<not needed in OpenSSL context>#push (@out,$code);
194 # comment out OPENSSL_ia32cap_P declarations
195 grep {s/(^extern\s+${under}OPENSSL_ia32cap_P)/\;$1/} @out;
198 push (@out,$initseg) if ($initseg);
201 sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
203 sub islabel # see is argument is known label
205 foreach $i (values %label) { return $i if ($i eq $_[0]); }
206 $label{$_[0]}; # can be undef
212 { push(@out,".") if ($::mwerks);
213 push(@out, "extern\t${under}$_\n");
218 { $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
219 push(@out,"global\t$label{$_[0]}\n");
223 { if (!defined($label{$_[0]}))
224 { $label{$_[0]}="${lprfx}${label}${_[0]}"; $label++; }
229 { my $label=&::label($_[0]);
230 &::align($_[1]) if ($_[1]>1);
231 push(@out,"$label{$_[0]}:\n");
235 { push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); }
238 { push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); }
241 { push(@out,".") if ($::mwerks); push(@out,"align\t$_[0]\n"); }
245 &::lea($dst,&::DWP($sym));
249 { my($f)=$under.shift;
252 segment .CRT\$XCU data align=4