27 sub main'asm_init_output { @out=(); }
28 sub main'asm_get_output { return(@out); }
29 sub main'get_labels { return(@labels); }
30 sub main'external_label { push(@labels,@_); }
34 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
40 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
68 &main'sub("esp",$num*4);
75 &main'add("esp",$num*4);
80 local($size,$addr,$reg1,$reg2,$idx)=@_;
82 local($ret)="$size PTR ";
85 if ($addr =~ /^(.+)\+(.+)$/)
90 elsif ($addr =~ /^[_a-zA-Z]/)
95 $reg1="$regs{$reg1}" if defined($regs{$reg1});
96 $reg2="$regs{$reg2}" if defined($regs{$reg2});
97 if (($addr ne "") && ($addr ne 0))
101 else { $post=$addr; }
106 $t="*$idx" if ($idx != 0);
107 $reg1="+".$reg1 if ("$reg1$post" ne "");
108 $ret.="[$reg2$t$reg1$post]";
117 sub main'mov { &out2("mov",@_); }
118 sub main'movb { &out2("mov",@_); }
119 sub main'and { &out2("and",@_); }
120 sub main'or { &out2("or",@_); }
121 sub main'shl { &out2("shl",@_); }
122 sub main'shr { &out2("shr",@_); }
123 sub main'xor { &out2("xor",@_); }
124 sub main'xorb { &out2("xor",@_); }
125 sub main'add { &out2("add",@_); }
126 sub main'adc { &out2("adc",@_); }
127 sub main'sub { &out2("sub",@_); }
128 sub main'rotl { &out2("rol",@_); }
129 sub main'rotr { &out2("ror",@_); }
130 sub main'exch { &out2("xchg",@_); }
131 sub main'cmp { &out2("cmp",@_); }
132 sub main'lea { &out2("lea",@_); }
133 sub main'mul { &out1("mul",@_); }
134 sub main'div { &out1("div",@_); }
135 sub main'dec { &out1("dec",@_); }
136 sub main'inc { &out1("inc",@_); }
137 sub main'jmp { &out1("jmp",@_); }
138 sub main'jmp_ptr { &out1p("jmp",@_); }
139 sub main'je { &out1("je",@_); }
140 sub main'jle { &out1("jle",@_); }
141 sub main'jz { &out1("jz",@_); }
142 sub main'jge { &out1("jge",@_); }
143 sub main'jl { &out1("jl",@_); }
144 sub main'jb { &out1("jb",@_); }
145 sub main'jc { &out1("jc",@_); }
146 sub main'jnc { &out1("jnc",@_); }
147 sub main'jnz { &out1("jnz",@_); }
148 sub main'jne { &out1("jne",@_); }
149 sub main'jno { &out1("jno",@_); }
150 sub main'push { &out1("push",@_); $stack+=4; }
151 sub main'pop { &out1("pop",@_); $stack-=4; }
152 sub main'bswap { &out1("bswap",@_); &using486(); }
153 sub main'not { &out1("not",@_); }
154 sub main'call { &out1("call",'_'.$_[0]); }
155 sub main'ret { &out0("ret"); }
156 sub main'nop { &out0("nop"); }
160 local($name,$p1,$p2)=@_;
163 push(@out,"\t$name\t");
168 push(@out,"\t" x $l);
169 push(@out,&conv($p2));
177 push(@out,"\t$name\n");
185 push(@out,"\t$name\t".&conv($p1)."\n");
192 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
200 grep(s/\.386/\.486/,@out);
215 sub main'function_begin
217 local($func,$extra)=@_;
235 sub main'function_begin_B
237 local($func,$extra)=@_;
249 sub main'function_end
267 sub main'function_end_B
280 sub main'function_end_A
303 return(&main'DWP($stack+$num*4,"esp","",0));
308 return(&main'DWP($_[0]*4,"esp","",0));
311 # Should use swtmp, which is above esp. Linix can trash the stack above esp
316 # return(&main'DWP(-(($num+1)*4),"esp","",0));
323 push(@out,"\t; $_\n");
329 if (!defined($label{$_[0]}))
331 $label{$_[0]}="\$${label}${_[0]}";
334 return($label{$_[0]});
339 if (!defined($label{$_[0]}))
341 $label{$_[0]}="${label}${_[0]}";
344 if((defined $_[2]) && ($_[2] == 1))
346 push(@out,"$label{$_[0]}::\n");
350 push(@out,"$label{$_[0]}:\n");
356 push(@out,"\tDD\t$_[0]\n");
364 push(@out,"\t$name\t ".&conv($p1)."\n");