#!perl -w
use strict;
use IO::File;
if (@ARGV!=2) {
    die "Usage: perl x520.pl  osimage520.dat  osimage512.dat\n"
}
my $ifn=shift;
my $ifh=IO::File->new($ifn, "r") or die "$ifn:$!\n";
binmode $ifh;

my $ofn=shift;
my $ofh=IO::File->new($ofn, "w") or die "$ofn:$!\n";
binmode $ofh;

my $ofn8=$ofn.".8bytes";
my $ofh8=IO::File->new($ofn8, "w") or die "$ofn8:$!\n";
binmode $ofh8;

my $ofs=0;
while (!$ifh->eof) {
    my $data;
    $ifh->read($data, 512);
    $ofh->print($data);
    $ofs+=512;
    $ifh->read($data, 8);
    $ofh8->print($data);
    $ofs+=8;
}
$ifh->close;
$ofh->close;
$ofh8->close;

