1 #!/usr/bin/env perl
2
3 package x86gas;
4
5 *out=\@::out;
6
7 $::lbdecor=$::aout?"L":".L"; # local label decoration
8 $nmdecor=($::aout or $::coff)?"_":""; # external name decoration
9
10 $initseg="";
11
12 $align=16;
13 $align=log($align)/log(2) if ($::aout);
14 $com_start="#" if ($::aout or $::coff);
15
16 sub opsize()
17 { my $reg=shift;
18 if ($reg =~ m/^%e/o) { "l"; }
19 elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; }
20 elsif ($reg =~ m/^%[xm]/o) { undef; }
21 else { "w"; }
22 }
23
24 # swap arguments;
25 # expand opcode with size suffix;
26 # prefix numeric constants with $;
27 sub ::generic
28 { my($opcode,@arg)=@_;
232 .mod_init_func
233 .align 2
234 .long $f
235 ___
236 }
237 elsif ($::aout)
238 { my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
239 $initseg.=".text\n";
240 $initseg.=".type $ctor,\@function\n" if ($::pic);
241 $initseg.=<<___; # OpenBSD way...
242 .globl $ctor
243 .align 2
244 $ctor:
245 jmp $f
246 ___
247 }
248 }
249
250 sub ::dataseg
251 { push(@out,".data\n"); }
252
253 1;
|
1 #!/usr/bin/env perl
2
3 package x86gas;
4
5 *out=\@::out;
6
7 $::lbdecor=$::aout?"L":".L"; # local label decoration
8 $nmdecor=($::aout or $::coff)?"_":"sunw_"; # external name decoration
9
10 $initseg="";
11
12 $align=16;
13 $align=log($align)/log(2) if ($::aout);
14 $com_start="#" if ($::aout or $::coff);
15
16 sub opsize()
17 { my $reg=shift;
18 if ($reg =~ m/^%e/o) { "l"; }
19 elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; }
20 elsif ($reg =~ m/^%[xm]/o) { undef; }
21 else { "w"; }
22 }
23
24 # swap arguments;
25 # expand opcode with size suffix;
26 # prefix numeric constants with $;
27 sub ::generic
28 { my($opcode,@arg)=@_;
232 .mod_init_func
233 .align 2
234 .long $f
235 ___
236 }
237 elsif ($::aout)
238 { my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
239 $initseg.=".text\n";
240 $initseg.=".type $ctor,\@function\n" if ($::pic);
241 $initseg.=<<___; # OpenBSD way...
242 .globl $ctor
243 .align 2
244 $ctor:
245 jmp $f
246 ___
247 }
248 }
249
250 sub ::dataseg
251 { push(@out,".data\n"); }
252
253 *::hidden = sub { push(@out,".hidden\t$nmdecor$_[0]\n"); } if ($::elf);
254
255 1;
|