X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM%2Fmakeasm.pl;h=98faa9e5be8637467aed22b63ff38b6c8b5b72a9;hb=8f6482741a7f1a1945776acf1d1910ca492bd897;hp=786dfef014168dc0e1f915dc3c7d3d2409d1ff7f;hpb=9368b346431ba73c5c34f5361d7681d6d71430f9;p=uccvend-snackrom.git diff --git a/ROM/makeasm.pl b/ROM/makeasm.pl index 786dfef..98faa9e 100755 --- a/ROM/makeasm.pl +++ b/ROM/makeasm.pl @@ -2,6 +2,44 @@ print "\tORG\t\$8000\n"; +my %transtable = ( '02' => 'IDIV' , + '03' => 'FDIV' , + '08' => 'INX' , + '09' => 'DEX', + '0A' => 'CLV', + '0D' => 'SEC', + '0E' => 'CLI', + '0F' => 'SEI', + '19' => 'DAA', + '30' => 'TSX', + '31' => 'INS', + '32' => 'PULA', + '33' => 'PULB', + '34' => 'DES', + '35' => 'TXS', + '36' => 'PSHA', + '37' => 'PSHB', + '3C' => 'PSHX', + '38' => 'PULX', + '3B' => 'RTI', + '3E' => 'WAI', + '43' => 'COMA', + '46' => 'RORA', + '49' => 'ROLA', + '4A' => 'DECA', + '4C' => 'INCA', + '4F' => 'CLRA', + '53' => 'COMB', + '56' => 'RORB', + '59' => 'ROLB', + '5A' => 'DECB', + '5F' => 'CLRB', + '8F' => 'XGDX', + '39' => 'RTS' ); + + # '10' => 'SBA', + + LINE: while (<>) { # if blank line, print blank line @@ -21,9 +59,7 @@ LINE: while (<>) { # otherwise, catch all, print bytes if (/^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) { - print ";$_"; - @_=split(' ',$2); - print "\tFCB\t\$".join(', $',@_)."\n"; + instruction($_); next LINE; } @@ -33,3 +69,58 @@ LINE: while (<>) { # FINAL print commented out print ";$_"; } + +# Process one instruction +# Usage: instruction line +sub instruction { + my ($line) = @_; + print ";$line"; + + $instruction = substr($line,5,2); + + if (defined $transtable{$instruction}) { + print "\t$transtable{$instruction}"; + $line =~ /$transtable{$instruction}(.*)$/i; + print "$1\n"; + 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 ($line =~ /^([A-F0-9]{4}) ((([A-F0-9]{2}) )*[A-F0-9]{2})/) { + @_=split(' ',$2); + print "\tFCB\t\$".join(', $',@_)."\n"; + } +}