Bunch of silly errors & debugging stuff.
[uccvend-snackrom.git] / ROM / fixvendbra.pl
1 my %commands;
2
3 $commands{'bra'}=1;
4 $commands{'bcc'}=1;
5 $commands{'bcs'}=1;
6 $commands{'beq'}=1;
7
8 $commands{'bge'}=1;
9 $commands{'bgt'}=1;
10 $commands{'bhi'}=1;
11 $commands{'ble'}=1;
12
13 $commands{'bls'}=1;
14 $commands{'blt'}=1;
15 $commands{'bmi'}=1;
16 $commands{'bne'}=1;
17
18 $commands{'bhs'}=1;
19 $commands{'blo'}=1;
20 $commands{'bsr'}=1;
21
22 $commands{'bpl'}=1;
23 $commands{'brn'}=1;
24 $commands{'bvc'}=1;
25 $commands{'bvs'}=1;
26
27 sub convert {
28         ($onum) = @_;
29
30         $num = hex $onum;
31
32         if ($num & 128) {
33                 $num = $num - 256;
34         }
35
36         return $num;
37
38 }
39
40 #printf "%X", convert("E1");
41 #printf "\n";
42 #printf "%X", convert("71");
43 #printf "\n";
44
45
46 while(<>) {     
47         chomp;
48         $l = length;
49         if ($l == 42) {
50                 print "$_\n";
51                 next;
52         } elsif ($l != 33) {
53                 print "$_\n";
54                 next;
55         } else {
56
57         $addr = substr($_,0,4);
58         $inst = substr($_,27,3);
59         $val = substr($_,31,2);
60
61         #print "$val\n";
62         $daddr = (hex $addr) + 2 + convert($val);
63
64         
65         if (defined $commands{$inst}) {
66                 print "$_\t\t;";
67                 printf "%4X", $daddr;
68                 #print " $addr $inst $val\n";
69                 print "\n";
70         } 
71         }
72 }

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