1 #!/usr/local/bin/perl -w
3 print "\tORG\t\$8000\n";
5 my %transtable = ( '02' => 'IDIV' ,
45 my %twobytefirst = ( '18' => '1' );
47 my %twobytesecond = ( '18 38' => 'PULY',
51 my %onewitharg = ( '80' => 'SUBA',
71 # if blank line, print blank line
72 if (/^\s*$/) { print "\n"; next LINE; }
74 # if comment line, pass straight through
75 if (/^\s*;/) { print; next LINE; }
77 # if duplicate label - rename uniquely
78 if (/^\s*((loop|jump82|goto91):)/) { print "${1}_$.\n"; next LINE; }
80 # if it's a label, print label
81 if (/^\s*(\w*:)/) { print "$1\n"; next LINE; }
83 # if it's a vector table, print words
84 if (/^\t\.word\t([a-f0-9]{4})$/) { print "\tFDB\t\$\U$1\n"; next LINE; }
86 # otherwise, catch all, print bytes
87 if (/^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) {
92 # if control Z, remove it
93 if (/^\cZ$/) { next LINE; }
95 # FINAL print commented out
99 # Process one instruction
100 # Usage: instruction line
105 $instruction = substr($line,5,2);
107 if (defined $transtable{$instruction}) {
108 print "\t$transtable{$instruction}";
109 $line =~ /$transtable{$instruction}(.*)$/i;
114 if (defined $twobytefirst{$instruction}) {
115 $thing = substr($line,5,5);
116 if (defined $twobytesecond{$thing}) {
117 print "\t" . $twobytesecond{$thing};
118 $line =~ /$twobytesecond{$thing}(.*)$/i;
124 if (defined $onewitharg{$instruction}) {
125 $thing = substr($line,8,2);
126 print "\t$onewitharg{$instruction}\t#\$$thing";
127 $line =~ /$onewitharg{$instruction} [0-9A-F][0-9A-F](.*)$/i;
132 if ($line =~ /^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) {
134 print "\tFCB\t\$".join(', $',@_)."\n";