-
Notifications
You must be signed in to change notification settings - Fork 0
/
timing.pl
121 lines (110 loc) · 2.04 KB
/
timing.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/perl
sub decode($) {
my $arg = shift @_;
if($arg =~ /ld[axy] .*,X/) {
#return 5; # TODO FIX, assumes always crosses page
return 4;
}
elsif($arg =~ /ld[axy] \(.*\),X/) {
return 6;
}
elsif($arg =~ /ld[axy] \(/) {
return 5;
}
elsif($arg =~ /ld[axy] #/) {
return 2;
}
elsif($arg =~ /ld[axy] /) {
return 3;
}
if($arg =~ /st[axy] .*,X/) {
#return 5; # TODO FIX, assumes always crosses page
return 4;
}
elsif($arg =~ /st[axy] \(.*\),X/) {
return 6;
}
elsif($arg =~ /st[axy] \(/) {
return 5;
}
elsif($arg =~ /st[axy] #/) {
return 2;
}
elsif($arg =~ /st[axy] /) {
return 3;
}
if($arg =~ /cmp \(/) {
return 5;
}
elsif($arg =~ /cmp #/) {
return 2;
}
elsif($arg =~ /cmp /) {
return 3;
}
if($arg =~ /adc \(/) {
return 5;
}
elsif($arg =~ /adc #/) {
return 2;
}
elsif($arg =~ /adc /) {
return 3;
}
if($arg =~ /sbc \(/) {
return 5;
}
elsif($arg =~ /sbc #/) {
return 2;
}
elsif($arg =~ /sbc /) {
return 3;
}
if ($arg =~ /dec/) {
return 5;
}
if ($arg =~ /jmp \(/) {
return 5;
}
elsif ($arg =~ /jmp/) {
return 3;
}
if ($arg =~ / b/) {
$tmp = $arg;
$tmp =~ s/^[ ]+//g;
($tmp1, $tmp2) = split / /, $tmp;
$labels{$tmp2} = $now + 4;
}
return 2;
}
$now = 0;
while (<>) {
@parts = split /;;/;
if ($#parts <= 0) {
print $_;
}
elsif (!(/^ /)) {
$label = $_;
$label =~ s/[ \x0a\x0d].*//g;
if (defined($labels{$label})) {
$now = $labels{$label};
}
print $_;
}
else {
if ($parts[1] =~ /\[0\]/) { $now = 0; }
$count = decode($parts[0]);
$sum = $now + $count;
while (length($parts[0]) < 40) {
$parts[0] .= " ";
}
print "$parts[0];; [$now] + $count = *$sum*";
if ($#parts == 2) {
print " ;;$parts[2]";
}
else {
print "\n";
}
$now = $sum;
}
}