Make calcrom data info optional

This commit is contained in:
GriffinR 2021-10-14 09:52:33 -04:00
parent b9f6dd128d
commit 2f6928f016
1 changed files with 14 additions and 12 deletions

View File

@ -1,12 +1,18 @@
#!/usr/bin/perl
use IPC::Cmd qw[ run ];
use Getopt::Long;
(@ARGV == 1)
or die "ERROR: no map file specified.\n";
my $usage = "Usage: calcrom.pl file.map [--data]\n";
(@ARGV >= 1)
or die $usage;
open(my $file, $ARGV[0])
or die "ERROR: could not open file '$ARGV[0]'.\n";
my $showData;
GetOptions("data" => \$showData) or die $usage;
my $src = 0;
my $asm = 0;
my $srcdata = 0;
@ -149,17 +155,13 @@ else
print "$undocumented symbols undocumented ($undocPct%)\n";
}
print "\n";
my $dataTotal = $srcdata + $data;
my $srcDataPct = sprintf("%.4f", 100 * $srcdata / $dataTotal);
my $dataPct = sprintf("%.4f", 100 * $data / $dataTotal);
if ($showData)
{
print "\n";
my $dataTotal = $srcdata + $data;
my $srcDataPct = sprintf("%.4f", 100 * $srcdata / $dataTotal);
my $dataPct = sprintf("%.4f", 100 * $data / $dataTotal);
if ($data == 0)
{
print "Data porting to C is 100% complete\n"
}
else
{
print "$dataTotal total bytes of data\n";
print "$srcdata bytes of data in src ($srcDataPct%)\n";
print "$data bytes of data in data ($dataPct%)\n";