5 # Calculate sectors and save to loaderSectors
13 open MAP
, "<$map" or die "Unable to open $map: $!";
14 while (my $line = <MAP
>) {
15 if ($line =~ m/(0x[0-9a-f]+)\s+loaderSectors/) {
16 $off = hex($1) - 0x7c00;
21 my $bytes = (stat('boot'))[7];
22 my $sectors = int(($bytes + 512) / 512) - 1;
24 my $image = "boot.img";
26 open IMG
, "+<$image" or die "Unable to open $image: $!";
30 my $n = syswrite IMG
, pack('S', $sectors), 2;
34 print sprintf(" ==> Writing 0x%04x to loaderSectors at offset 0x%x\n",