annotate scripts/list2crc.pl @ 3277:33d539c123cf

d64: Add mb.ddisk script for making Dragon boot floppy At least it works in XRoar when running off a 80d floppy and preparing a new 40d boot floppy in the second drive. The "format" must be run manually for now since there is not enough memory to run it from inside the script...
author Tormod Volden <debian.tormod@gmail.com>
date Sat, 07 Mar 2020 23:15:05 +0100
parents a0b770fab355
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2955
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
1 #!/usr/bin/perl
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
2
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
3 # Copyright 2014 Tormod Volden
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
4 #
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
5 # Digests assembly listings generated by lwasm, and stores the
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
6 # module body listing in a file named by the module CRC.
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
7 # Example: for f in *.lst; do ../scripts/list2crc.pl $f; done
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
8
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
9 open(CRCFILE, ">", "crc.tmp") or die "cannot create crc.tmp: $!";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
10
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
11 while (<>) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
12 ($hoffset, $opbytes, $filepath, $lineno, $label, $opcode, $operand, $comment) =
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
13 ( $_ =~ /^(\w+) (\w+)\s+\((.*)\):(\d+) (\S+)?\s+(\w+)\s*(\S+)?\s*(.*)?/ );
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
14
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
15 # print $hoffset, "\t", $opcode, "\t", $comment, "\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
16 if (lc($opcode) eq "mod") {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
17 $in_module = 1;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
18 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
19
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
20 if (lc($opcode) eq "emod") {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
21 die "double emod" if $found_emod;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
22 $found_emod = 1;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
23 $crc = $opbytes;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
24 $in_module = 0;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
25 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
26
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
27 # if ($in_module && $hoffset) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
28 # $offset = hex($hoffset);
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
29 # print CRCFILE "$offset\t$filepath\t$lineno\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
30 # }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
31 if ($in_module) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
32 print CRCFILE $_
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
33 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
34 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
35 close(CRCFILE);
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
36 if ($crc) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
37 print "writing $crc.crc\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
38 rename "crc.tmp", $crc . ".crc";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
39 }