X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM%2Fmakeasm.pl;h=dde0d0d648402931e335641642b40086365f5703;hb=f32e21ae0470e823770cca4dd264b353201bfe64;hp=98faa9e5be8637467aed22b63ff38b6c8b5b72a9;hpb=8f6482741a7f1a1945776acf1d1910ca492bd897;p=uccvend-snackrom.git diff --git a/ROM/makeasm.pl b/ROM/makeasm.pl index 98faa9e..dde0d0d 100755 --- a/ROM/makeasm.pl +++ b/ROM/makeasm.pl @@ -11,6 +11,7 @@ my %transtable = ( '02' => 'IDIV' , '0E' => 'CLI', '0F' => 'SEI', '19' => 'DAA', + '1B' => 'ABA', '30' => 'TSX', '31' => 'INS', '32' => 'PULA', @@ -21,6 +22,7 @@ my %transtable = ( '02' => 'IDIV' , '37' => 'PSHB', '3C' => 'PSHX', '38' => 'PULX', + '3A' => 'ABX', '3B' => 'RTI', '3E' => 'WAI', '43' => 'COMA', @@ -40,6 +42,43 @@ my %transtable = ( '02' => 'IDIV' , # '10' => 'SBA', +my %twobytefirst = ( '18' => '1' ); + +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 @@ -85,40 +124,38 @@ sub instruction { return; } - # FIXME: parse instruction - #if (defined($transtable{$instruction})) { - # print "\t$transtable{$instruction}"; -# if (defined($comment)) { print "; $comment"; } -# print "\n"; -# return; -# } - -# chomp; -# $l = length; -# if ($l == 42) { -# print "$_\n"; -# next; -# } elsif ($l != 33) { -# print "$_\n"; -# next; -# } else { -# -# $addr = substr($_,0,4); -# $inst = substr($_,27,3); -# $val = substr($_,31,2); -# -# #print "$val\n"; -# $daddr = (hex $addr) + 2 + convert($val); -# -# -# if (defined $commands{$inst}) { -# print "$_\t\t;"; -# printf "%4X", $daddr; -# #print " $addr $inst $val\n"; -# print "\n"; -# } -# } - + if (defined $twobytefirst{$instruction}) { + $thing = substr($line,5,5); + if (defined $twobytesecond{$thing}) { + print "\t" . $twobytesecond{$thing}; + $line =~ /$twobytesecond{$thing}(.*)$/i; + print "$1\n"; + 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); print "\tFCB\t\$".join(', $',@_)."\n";