#!/usr/bin/perl # # Read a Motorola format dump (from ../dumps), and emit the decoded # binary bytes into the specified file. # # Nuances of Motorola format, such as records other than S1, checksums, # etc. are not explored here. # open(INPUT, "../dumps/$ARGV[0].mot") || die "../dumps/$ARGV[0].mot: $!"; open(OUTPUT, ">$ARGV[0]") || die "$ARGV[0]: $!"; binmode(OUTPUT); while () { next unless s/^S1(..)(....)//; ($len, $addr) = (hex($1)-3, hex($2)); # Got an S1 record. while ($len--) { die "format $len: $_" unless s/^(..)//; printf OUTPUT "%c", hex($1); } }