# HYVERS.PL V002 from 03-SEP-2004
# Dipl.-Inf. Herbert Oppmann
# Extracts assembler module version texts from uncompressed NexGen Nx586
# hyper code image.

open(PRD,"<$ARGV[0]") || die "can't open $ARGV[0]";
binmode(PRD);

print "File $ARGV[0]:\n\n";
$state =0;
while (not eof PRD) {
   $r = getc(PRD);
   if ($state == 0) {
      if ($r eq '@') {$state =1;} # else {$state =0;}
   } elsif ($state == 1) {
      if ($r eq '(') {$state =2;} else {$state =0;}
   } elsif ($state == 2) {
      if ($r eq '#') {$state =3;} else {$state =0;}
   } elsif ($state == 3) {
      if ($r eq ')') {
         $state =4;
         printf("%05X \"",tell(PRD)-4);
         print '@(#)';
      } else {$state =0;}
   } elsif ($state == 4) {
      if ($r eq "\t") {print '\t';}
      elsif (($r eq "\0") || ($r ge "~")) {$state =0; print "\"\n";}
      else {print "$r";}
   }
}
if ($state ==4) {print "\"\n";}

close PRD;
