3 # x86 CodeWarrior assembler for NetWare
5 # This file is a slightly modified version of x86nasm.pl. The Metrowerks
6 # compiler for NetWare doesn't prefix symbols with an underscore.
31 sub main'asm_init_output
34 &comment("NetWare: assembly for CodeWarrior assembler (mwasmnlm)");
36 sub main'asm_get_output { return(@out); }
37 sub main'get_labels { return(@labels); }
39 sub main'external_label
43 push(@out, ".extern\t$_\n");
49 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
55 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
83 &main'sub("esp",$num*4);
90 &main'add("esp",$num*4);
95 my($size,$addr,$reg1,$reg2,$idx)=@_;
97 my($ret)="$size PTR [";
99 if ($addr =~ /^(.+)\+(.+)$/)
104 elsif ($addr =~ /^[_a-zA-Z]/)
109 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
111 $reg1="$regs{$reg1}" if defined($regs{$reg1});
112 $reg2="$regs{$reg2}" if defined($regs{$reg2});
113 if (($addr ne "") && ($addr ne 0))
116 { $ret.="${addr}+"; }
117 else { $post=$addr; }
122 $t="*$idx" if ($idx != 0);
123 $reg1="+".$reg1 if ("$reg1$post" ne "");
124 $ret.="$reg2$t$reg1$post]";
130 $ret =~ s/\+\]/]/; # in case $addr was the only argument
134 sub main'mov { &out2("mov",@_); }
135 sub main'movb { &out2("mov",@_); }
136 sub main'and { &out2("and",@_); }
137 sub main'or { &out2("or",@_); }
138 sub main'shl { &out2("shl",@_); }
139 sub main'shr { &out2("shr",@_); }
140 sub main'xor { &out2("xor",@_); }
141 sub main'xorb { &out2("xor",@_); }
142 sub main'add { &out2("add",@_); }
143 sub main'adc { &out2("adc",@_); }
144 sub main'sub { &out2("sub",@_); }
145 sub main'rotl { &out2("rol",@_); }
146 sub main'rotr { &out2("ror",@_); }
147 sub main'exch { &out2("xchg",@_); }
148 sub main'cmp { &out2("cmp",@_); }
149 sub main'lea { &out2("lea",@_); }
150 sub main'mul { &out1("mul",@_); }
151 sub main'div { &out1("div",@_); }
152 sub main'dec { &out1("dec",@_); }
153 sub main'inc { &out1("inc",@_); }
154 sub main'jmp { &out1("jmp",@_); }
155 sub main'jmp_ptr { &out1p("jmp",@_); }
157 sub main'je { &out1("je ",@_); }
158 sub main'jle { &out1("jle ",@_); }
159 sub main'jz { &out1("jz ",@_); }
160 sub main'jge { &out1("jge ",@_); }
161 sub main'jl { &out1("jl ",@_); }
162 sub main'ja { &out1("ja ",@_); }
163 sub main'jae { &out1("jae ",@_); }
164 sub main'jb { &out1("jb ",@_); }
165 sub main'jbe { &out1("jbe ",@_); }
166 sub main'jc { &out1("jc ",@_); }
167 sub main'jnc { &out1("jnc ",@_); }
168 sub main'jnz { &out1("jnz ",@_); }
169 sub main'jne { &out1("jne ",@_); }
170 sub main'jno { &out1("jno ",@_); }
172 sub main'push { &out1("push",@_); $stack+=4; }
173 sub main'pop { &out1("pop",@_); $stack-=4; }
174 sub main'bswap { &out1("bswap",@_); &using486(); }
175 sub main'not { &out1("not",@_); }
176 sub main'call { &out1("call",$_[0]); }
177 sub main'ret { &out0("ret"); }
178 sub main'nop { &out0("nop"); }
182 my($name,$p1,$p2)=@_;
185 push(@out,"\t$name\t");
190 push(@out,"\t" x $l);
191 push(@out,&conv($p2));
199 push(@out,"\t$name\n");
206 push(@out,"\t$name\t".&conv($p1)."\n");
212 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
220 grep(s/\.386/\.486/,@out);
225 push(@out, ".section .text\n");
228 sub main'function_begin
245 sub main'function_begin_B
256 sub main'function_end
272 sub main'function_end_B
278 sub main'function_end_A
300 return(&main'DWP($stack+$num*4,"esp","",0));
305 return(&main'DWP($_[0]*4,"esp","",0));
308 # Should use swtmp, which is above esp. Linix can trash the stack above esp
313 # return(&main'DWP(-(($num+1)*4),"esp","",0));
320 push(@out,"\t; $_\n");
326 if (!defined($label{$_[0]}))
328 $label{$_[0]}="${label}${_[0]}";
331 return($label{$_[0]});
336 if (!defined($label{$_[0]}))
338 $label{$_[0]}="${label}${_[0]}";
341 push(@out,"$label{$_[0]}:\n");
346 push(@out,"\t.long\t$_[0]\n");
354 push(@out,"\t$name\t ".&conv($p1)."\n");
360 &main'lea($dst,&main'DWP($sym));
363 sub main'blindpop { &out1("pop",@_); }