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

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