7 $::lbdecor="L\$"; # local label decoration
8 $nmdecor=$::netware?"":"_"; # external name decoration
9 $drdecor=$::mwerks?".":""; # directive decoration
18 { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps
19 { $_[0] = "NEAR $_[0]"; }
20 elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea
21 { $_[1] =~ s/^[^\[]*\[/\[/o; }
22 elsif ($opcode eq "clflush" && $#_==0)
23 { $_[0] =~ s/^[^\[]*\[/\[/o; }
29 # opcodes not covered by ::generic above, mostly inconsistent namings...
31 sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
32 sub ::call_ptr { &::emit("call",@_); }
33 sub ::jmp_ptr { &::emit("jmp",@_); }
36 { my($size,$addr,$reg1,$reg2,$idx)=@_;
39 if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; }
43 $ret .= " PTR" if ($::mwerks);
49 # prepend global references with optional underscore
50 $addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige;
51 # put address arithmetic expression in parenthesis
52 $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
54 if (($addr ne "") && ($addr ne 0))
55 { if ($addr !~ /^-/) { $ret .= "$addr+"; }
62 $ret .= "+$reg1" if ($reg1 ne "");
68 $ret =~ s/\+\]/]/; # in case $addr was the only argument
72 sub ::BP { &get_mem("BYTE",@_); }
73 sub ::DWP { &get_mem("DWORD",@_); }
74 sub ::WP { &get_mem("WORD",@_); }
75 sub ::QWP { &get_mem("",@_); }
76 sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; }
77 sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; }
80 { if ($::mwerks) { push(@out,".section\t.text,64\n"); }
83 %ifidn __OUTPUT_FORMAT__,obj
84 section code use32 class=code align=64
85 %elifidn __OUTPUT_FORMAT__,win32
87 section .text code align=64
96 sub ::function_begin_B
98 my $global=($func !~ /^_/);
99 my $begin="${::lbdecor}_${func}_begin";
101 $begin =~ s/^\@/./ if ($::mwerks); # the torture never stops
103 &::LABEL($func,$global?"$begin":"$nmdecor$func");
104 $func=$nmdecor.$func;
106 push(@out,"${drdecor}global $func\n") if ($global);
107 push(@out,"${drdecor}align 16\n");
108 push(@out,"$func:\n");
109 push(@out,"$begin:\n") if ($global);
119 { if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
121 ${drdecor}segment .bss
122 ${drdecor}common ${nmdecor}OPENSSL_ia32cap_P 16
124 # comment out OPENSSL_ia32cap_P declarations
125 grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
128 push (@out,$initseg) if ($initseg);
131 sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
135 { push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); }
139 { push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
142 { push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); }
144 { push(@out,(($::mwerks)?".word\t":"dw\t").join(',',@_)."\n"); }
146 { push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); }
149 { push(@out,"${drdecor}align\t$_[0]\n"); }
153 &::lea($dst,&::DWP($sym));
157 { my $f=$nmdecor.shift;
160 segment .CRT\$XCU data align=4
168 { if ($mwerks) { push(@out,".section\t.data,4\n"); }
169 else { push(@out,"section\t.data align=4\n"); }
174 push(@out,"%if __NASM_VERSION_ID__ >= 0x02030000\n");
175 push(@out,"safeseh ".&::LABEL($nm,$nmdecor.$nm)."\n");
176 push(@out,"%endif\n");