lst2IMEM
1.15 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
# SCCS: @(#)MAKE_IHEX 1.1 07 Sep 1994
#
#
# This program extracts the instructions in ascii hex format from
# the .lst file which is an output of the rspasm.
#
$alt = 0;
$addr = 0;
while (<>) {
chop;
split;
if ($_ ne "") {
if ($_[0] ne "***") {
if ($alt==0) {
printf "@%3.3X %8.8lX", $addr, hex($_[2]);
}
else {
printf "_%8.8lX", hex($_[2]);
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;
}