Commented makeasm.pl
[uccvend-snackrom.git] / ROM / makeasm.pl
1 #!/usr/local/bin/perl -w
2
3 print "\tORG\t\$8000\n";
4
5 LINE: while (<>) {
6
7 # if blank line, print blank line
8   if (/^\s*$/) { print "\n"; next LINE; }
9
10 # if comment line, pass straight through
11   if (/^\s*;/) { print; next LINE; }
12
13 # if duplicate label - rename uniquely
14   if (/^\s*((loop|jump82|goto91):)/) { print "${1}_$.\n"; next LINE; }
15
16 # if it's a label, print label
17   if (/^\s*(\w*:)/) { print "$1\n"; next LINE; }
18
19 # if it's a vector table, print words
20   if (/^\t\.word\t([a-f0-9]{4})$/) { print "\tFDB\t\$\U$1\n"; next LINE; }
21
22 # otherwise, catch all, print bytes
23   if (/^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) {
24     print ";$_";
25     @_=split(' ',$2);
26     print "\tFCB\t\$".join(', $',@_)."\n";
27     next LINE;
28   }
29
30 # if control Z, remove it
31   if (/^\cZ$/) { next LINE; }
32
33 # FINAL print commented out
34   print ";$_";
35 }

UCC git Repository :: git.ucc.asn.au