package x86nasm;
$label="L000";
+$under=($main'netware)?'':'_';
%lb=( 'eax', 'al',
'ebx', 'bl',
{
push(@labels,@_);
foreach (@_) {
- push(@out, "extern\t_$_\n");
+ push(@out,".") if ($main'mwerks);
+ push(@out, "extern\t${under}$_\n");
}
}
sub main'QWP
{
- &get_mem("QWORD",@_);
+ &get_mem("",@_);
}
sub main'BC
{
- return "BYTE @_";
+ return (($main'mwerks)?"":"BYTE ")."@_";
}
sub main'DWC
{
- return "DWORD @_";
+ return (($main'mwerks)?"":"DWORD ")."@_";
}
sub main'stack_push
{
my($size,$addr,$reg1,$reg2,$idx)=@_;
my($t,$post);
- my($ret)="[";
+ my($ret)=$size;
+ if ($ret ne "")
+ {
+ $ret .= " PTR" if ($main'mwerks);
+ $ret .= " ";
+ }
+ $ret .= "[";
$addr =~ s/^\s+//;
if ($addr =~ /^(.+)\+(.+)$/)
{
$reg2=&conv($1);
- $addr="_$2";
+ $addr="$under$2";
}
elsif ($addr =~ /^[_a-zA-Z]/)
{
- $addr="_$addr";
+ $addr="$under$addr";
}
if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
sub main'jmp_ptr { &out1p("jmp",@_); }
# This is a bit of a kludge: declare all branches as NEAR.
-sub main'je { &out1("je NEAR",@_); }
-sub main'jle { &out1("jle NEAR",@_); }
-sub main'jz { &out1("jz NEAR",@_); }
-sub main'jge { &out1("jge NEAR",@_); }
-sub main'jl { &out1("jl NEAR",@_); }
-sub main'ja { &out1("ja NEAR",@_); }
-sub main'jae { &out1("jae NEAR",@_); }
-sub main'jb { &out1("jb NEAR",@_); }
-sub main'jbe { &out1("jbe NEAR",@_); }
-sub main'jc { &out1("jc NEAR",@_); }
-sub main'jnc { &out1("jnc NEAR",@_); }
-sub main'jnz { &out1("jnz NEAR",@_); }
-sub main'jne { &out1("jne NEAR",@_); }
-sub main'jno { &out1("jno NEAR",@_); }
+$near=($main'mwerks)?'':'NEAR';
+sub main'je { &out1("je $near",@_); }
+sub main'jle { &out1("jle $near",@_); }
+sub main'jz { &out1("jz $near",@_); }
+sub main'jge { &out1("jge $near",@_); }
+sub main'jl { &out1("jl $near",@_); }
+sub main'ja { &out1("ja $near",@_); }
+sub main'jae { &out1("jae $near",@_); }
+sub main'jb { &out1("jb $near",@_); }
+sub main'jbe { &out1("jbe $near",@_); }
+sub main'jc { &out1("jc $near",@_); }
+sub main'jnc { &out1("jnc $near",@_); }
+sub main'jnz { &out1("jnz $near",@_); }
+sub main'jne { &out1("jne $near",@_); }
+sub main'jno { &out1("jno $near",@_); }
sub main'push { &out1("push",@_); $stack+=4; }
sub main'pop { &out1("pop",@_); $stack-=4; }
sub main'popf { &out0("popf"); $stack-=4; }
sub main'bswap { &out1("bswap",@_); &using486(); }
sub main'not { &out1("not",@_); }
-sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
+sub main'call { &out1("call",($_[0]=~/^\@L/?'':$under).$_[0]); }
sub main'ret { &out0("ret"); }
sub main'nop { &out0("nop"); }
sub main'test { &out2("test",@_); }
my($l,$t);
push(@out,"\t$name\t");
+ if (!$main'mwerks and $name eq "lea")
+ {
+ $p1 =~ s/^[^\[]*\[/\[/;
+ $p2 =~ s/^[^\[]*\[/\[/;
+ }
$t=&conv($p1).",";
$l=length($t);
push(@out,$t);
sub main'file
{
- push(@out, "segment .text use32\n");
+ push(@out,".") if ($main'mwerks);
+ push(@out,"section\t.text\n");
}
sub main'function_begin
push(@labels,$func);
my($tmp)=<<"EOF";
-global _$func
-_$func:
+global $under$func
+$under$func:
push ebp
push ebx
push esi
{
my($func,$extra)=@_;
my($tmp)=<<"EOF";
-global _$func
-_$func:
+global $under$func
+$under$func:
EOF
push(@out,$tmp);
$stack=4;
{
if (!defined($label{$_[0]}))
{
- $label{$_[0]}="\$${label}${_[0]}";
+ $label{$_[0]}="\@${label}${_[0]}";
$label++;
}
return($label{$_[0]});
{
if (!defined($label{$_[0]}))
{
- $label{$_[0]}="\$${label}${_[0]}";
+ $label{$_[0]}="\@${label}${_[0]}";
$label++;
}
push(@out,"$label{$_[0]}:\n");
sub main'data_word
{
- push(@out,"\tDD\t".join(',',@_)."\n");
+ push(@out,(($main'mwerks)?".long\t":"DD\t").join(',',@_)."\n");
}
sub main'align
{
- push(@out,"\tALIGN\t$_[0]\n");
+ push(@out,".") if ($main'mwerks);
+ push(@out,"align\t$_[0]\n");
}
sub out1p
}
sub main'blindpop { &out1("pop",@_); }
+
+sub main'initseg
+ {
+ local($f)=@_;
+ if ($main'win32)
+ {
+ local($tmp)=<<___;
+segment .CRT\$XIU data
+extern $under$f
+DD $under$f
+___
+ push(@out,$tmp);
+ }
+ }
+
+1;