3 # PowerPC assembler distiller by <appro>.
6 open STDOUT,">$output" || die "can't open $output: $!";
10 my $dotinlocallabels=0;
12 ################################################################
13 # directives which need special treatment on different platforms
14 ################################################################
18 my $global = \$GLOBALS{$name};
23 SWITCH: for ($flavour) {
24 /aix/ && do { $name = ".$name";
27 /osx/ && do { $name = "_$name";
30 /linux.*32/ && do { $ret .= ".globl $name\n";
31 $ret .= ".type $name,\@function";
32 $dotinlocallabels = 1;
35 /linux.*64/ && do { $ret .= ".globl .$name\n";
36 $ret .= ".type .$name,\@function\n";
37 $ret .= ".section \".opd\",\"aw\"\n";
38 $ret .= ".globl $name\n";
41 $ret .= ".quad .$name,.TOC.\@tocbase,0\n";
42 $ret .= ".size $name,24\n";
43 $ret .= ".previous\n";
46 $dotinlocallabels = 1;
51 $ret = ".globl $name" if (!$ret);
56 ($flavour =~ /aix/) ? ".csect" : ".text";
61 $arch = "ppc970" if ($arch eq "any" and $flavour =~ /osx/);
65 ################################################################
66 # simplified mnemonics not handled by at least one assembler
67 ################################################################
70 my $cr = 0; $cr = shift if ($#_>1);
71 " cmpl$f ".join(',',$cr,0,@_);
75 my $cr = 0; $cr = shift if ($#_>1);
76 " cmpl$f ".join(',',$cr,1,@_);
80 my $bo = $f=~/[\+\-]/ ? 17 : 16;
86 $line =~ s|[#!;].*$||; # get rid of asm-style comments...
87 $line =~ s|/\*.*\*/||; # ... and C-style comments...
88 $line =~ s|^\s+||; # ... and skip white spaces in beginning...
89 $line =~ s|\s+$||; # ... and at the end
92 $line =~ s|\b\.L(\w+)|L$1|g; # common denominator for Locallabel
93 $line =~ s|\bL(\w+)|\.L$1|g if ($dotinlocallabels);
97 $line =~ s|(^[\.\w]+)\:\s*||;
99 printf "%s:",($GLOBALS{$label} or $label) if ($label);
103 $line =~ s|^\s*(\.?)(\w+)([\.\+\-]?)\s*||;
104 my $c = $1; $c = "\t" if ($c eq "");
107 my $opcode = eval("\$$mnemonic");
108 $line =~ s|\br([0-9]+)\b|$1|g if ($c ne "." and $flavour !~ /osx/);
109 if (ref($opcode) eq 'CODE') { $line = &$opcode($f,split(',',$line)); }
110 elsif ($mnemonic) { $line = $c.$mnemonic.$f."\t".$line; }
113 print $line if ($line);