Fixed STX extended addressing
[uccvend-snackrom.git] / ROM / makeasm.pl
index bdc48a9..dde0d0d 100755 (executable)
@@ -48,6 +48,37 @@ my %twobytesecond = ( '18 38' => 'PULY',
                        '18 3A' => 'ABY',
                        '18 3C' => 'PSHY');
 
+my %onewitharg = ('63' => "COM\t\$%s,X",
+                       '6A' => "DEC\t\$%s,X",
+                       '6C' => "INC\t\$%s,X",
+                       '6D' => "TST\t\$%s,X",
+                       '6E' => "JMP\t\$%s,X",
+                       '6F' => "CLR\t\$%s,X",
+                       '80' => "SUBA\t#\$%s",
+                       '81' => "CMPA\t#\$%s",
+                       '82' => "SBCA\t#\$%s",
+                       '84' => "ANDA\t#\$%s",
+                       '85' => "BITA\t#\$%s",
+                       '86' => "LDAA\t#\$%s",
+                       '88' => "EORA\t#\$%s",
+                       '8A' => "ORA\t#\$%s",
+                       'A3' => "SUBD\t\$%s,X",
+                       'A7' => "STA\t\$%s,X",
+                       'C0' => "SUBB\t#\$%s",
+                       'C1' => "CMPB\t#\$%s",
+                       'C2' => "SBCB\t#\$%s",
+                       'C4' => "ANDB\t#\$%s",
+                       'C5' => "BITB\t#\$%s",
+                       'C6' => "LDAB\t#\$%s",
+                       'C8' => "EORB\t#\$%s",
+                       'CA' => "ORB\t#\$%s",
+                       'E3' => "ADDD\t\$%s,X",
+                       'EC' => "LDD\t\$%s,X",
+                       'ED' => "STAD\t\$%s,X" );
+
+
+my %onewithword = ('FF' => "STX\t%s");
+
 LINE: while (<>) {
 
 # if blank line, print blank line
@@ -102,6 +133,28 @@ sub instruction {
                return;
        }
     }
+    
+    if (defined $onewitharg{$instruction}) {
+       $thing = substr($line,8,2);
+       
+       printf "\t$onewitharg{$instruction}", $thing;
+       $line =~ /$onewitharg{$instruction} [0-9A-F][0-9A-F](.*)$/i;
+       print "\t;$1\n";
+       return;
+    }
+   
+    if (defined $onewithword{$instruction}) {
+       $thing = substr($line,8,2);
+       $thing2 = substr($line,11,2);
+       if (!($thing2 =~ /\s+/)) {
+       $curraddr = substr($line,0,4);
+       printf "FOO%s\tEQU\t\$%s%s\n", $curraddr,$thing,$thing2;
+       printf "\t$onewithword{$instruction}", ">FOO$curraddr";
+       $line =~ /$onewithword{$instruction} [0-9A-F][0-9A-F][0-9A-F][0-9A-F](.*)$/i;
+       print "\t;$1\n";
+       return;
+       }
+    }
    
     if ($line =~ /^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) {
         @_=split(' ',$2);

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