view 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 (2020-03-07)
parents a0b770fab355
children
line wrap: on
line source
#!/usr/bin/perl

# Copyright 2014  Tormod Volden
#
# Digests assembly listings generated by lwasm, and stores the
# module body listing in a file named by the module CRC.
# Example: for f in *.lst; do ../scripts/list2crc.pl $f; done

open(CRCFILE, ">", "crc.tmp") or die "cannot create crc.tmp: $!";

while (<>) {
	($hoffset, $opbytes, $filepath, $lineno,  $label, $opcode, $operand, $comment) =
		( $_ =~ /^(\w+) (\w+)\s+\((.*)\):(\d+) (\S+)?\s+(\w+)\s*(\S+)?\s*(.*)?/ );

	# print $hoffset, "\t", $opcode, "\t", $comment, "\n";
	if (lc($opcode) eq "mod") {
		$in_module = 1;
	}

	if (lc($opcode) eq "emod") {
		die "double emod" if $found_emod;
		$found_emod = 1;
		$crc = $opbytes;
		$in_module = 0;
	}

#	if ($in_module && $hoffset) {
#		$offset = hex($hoffset);
#		print CRCFILE "$offset\t$filepath\t$lineno\n";
#	}
	if ($in_module) {
		print CRCFILE $_
	}
}
close(CRCFILE);
if ($crc) {
	print "writing $crc.crc\n";
	rename "crc.tmp", $crc . ".crc";
}