X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM%2Fmakeasm.pl;h=ad25bbae7702eca3f76838997a047a8e4b1e8d61;hb=ad9b95abe0f7009f44d98de5264eb526e1987664;hp=98faa9e5be8637467aed22b63ff38b6c8b5b72a9;hpb=8f6482741a7f1a1945776acf1d1910ca492bd897;p=uccvend-snackrom.git diff --git a/ROM/makeasm.pl b/ROM/makeasm.pl index 98faa9e..ad25bba 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,30 @@ my %transtable = ( '02' => 'IDIV' , # '10' => 'SBA', +my %twobytefirst = ( '18' => '1' ); + +my %twobytesecond = ( '18 38' => 'PULY', + '18 3A' => 'ABY', + '18 3C' => 'PSHY'); + +my %onewitharg = ( '80' => 'SUBA', + '81' => 'CMPA', + '82' => 'SBCA', + '84' => 'ANDA', + '85' => 'BITA', + '86' => 'LDAA', + '88' => 'EORA', + '8A' => 'ORA', + 'C0' => 'SUBB', + 'C1' => 'CMPB', + 'C2' => 'SBCB', + 'C4' => 'ANDB', + 'C5' => 'BITB', + 'C6' => 'LDAB', + 'C8' => 'EORB', + 'CA' => 'ORB' ); + + LINE: while (<>) { # if blank line, print blank line @@ -85,40 +111,24 @@ 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); + print "\t$onewitharg{$instruction}\t#\$$thing"; + $line =~ /$onewitharg{$instruction} [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";