out2IMEM
1.18 KB
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
#!/usr/sbin/perl
#
$alt = 0;
$addr = 0;
$cnt = 0;
while (<>) {
chop;
split;
if ($_[1] ne "") { $inst[$cnt++] = $_[1]; }
if ($_[2] ne "") { $inst[$cnt++] = $_[2]; }
if ($_[3] ne "") { $inst[$cnt++] = $_[3]; }
if ($_[4] ne "") { $inst[$cnt++] = $_[4]; }
}
for ($i = 0; $i<$cnt; $i++) {
if ($alt==0) {
printf "@%3.3X %8.8lX", $addr, hex($inst[$i]);
}
else {
printf "_%8.8lX", hex($inst[$i]);
printf "\t//addrs: 0x%3.3X 0x%3.3X",$addr*8, ($addr*8) + 4;
}
if ($alt) {
printf "\n";
$addr = $addr+1;
}
$alt = !$alt;
}
if ($addr == 0) {
exit;
}
if ($alt==1) {
printf "_%8.8lX", hex(0);
printf "\t//addrs: 0x%3.3X 0x%3.3X \n",$addr*8, ($addr*8) + 4;
}
else {
$addr = $addr -1;
}
# fill with noops
if ($addr < 509) {
$addr = $addr+1;
printf "@%3.3X 00000000_00000000 \t//addrs: 0x%3.3X 0x%3.3X \n",
$addr, $addr*8, ($addr*8) + 4;
}
if ($addr < 510) {
$addr = $addr+1;
printf "@%3.3X 00000000_00000000 \t//addrs: 0x%3.3X 0x%3.3X \n",
$addr, $addr*8, ($addr*8) + 4;
}
if ($addr < 511) {
$addr = $addr+1;
printf "@%3.3X 00000000_00000000 \t//addrs: 0x%3.3X 0x%3.3X \n",
$addr, $addr*8, ($addr*8) + 4;
}