#!/usr/bin/perl
#
# print header stuff
#
print "Content-type: text/html", "\n\n";
print "<html>\n";
@bin=('0000','0001','0010','0011',
'0100','0101','0110','0111',
'1000','1001','1010','1011',
'1100','1101','1110','1111');
$preferred="preffered";
$illegal="ILLEGAL";
$empty_cell=' ';
print "<table border=\"1\">\n";
#print "<tr>\n";
#print "<td colspan=\"8\"><center>Packed Decimal Numbers</center></td>";
#print "</tr>\n";
print "<tr>\n";
#print "<td>n</td>\n";
#
#print the nibbles for debugging
#
print "<td>any<br>packed<br>number</td>";
print "<td>packed<br>number<br>sign</td>";
print "<td>packed<br>number<br>number</td>";
#print "<td colspan=\"4\"><center>Value</center></td></tr>";
#print "</tr>";
#print "<td>Decimal</td>";
#print "<td>Hex</td>";
#print "<td>Binary</td>";
#print "<td>Octal</td></tr>";
print "</tr>\n";
for ($i=0;$i<=15;$i++) {
for ($j=0;$j<=15;$j++) {
$n=($i*16)+$j;
print "<tr>\n";
if ( 1 == 1 ) {
$debug="($n)";
}
#print "<td>$n</td>";
#
#print the nibbles for debugging
#
#print "<td>$i</td><td>$j</td>\n";
$packed="$empty_cell";
$packednn="$empty_cell";
$packedns="$empty_cell";
if ($i < 10 && $j < 10 ) {
$packed="$i$j";
$packednn=$packed;
}
else {
if ($i < 10 && $j >= 10 ) {
$zsign="+";
if ($j == 11 || $j == 13) {
$zsign="-";
}
$packed="$i$zsign";
$packedns=$packed;
}
else {
$packed="$illegal";
$packednn="$illegal";
$packedns="$illegal";
}
}
print "<td>$debug $packed</td>";
print "<td>$packedns</td>";
print "<td>$packednn</td>";
$x = sprintf("%02X", $n);
$octal = sprintf("%02o", $n);
#print "<td>$n</td>\n";
#print "<td>$x</td>\n";
#print "<td>$bin[$i]$bin[$j]</td>\n";
#print "<td>$octal</td>\n";
print "</tr>\n";
}
}
print "</table>\n";
#print "<td align=\"right\">$i</td>\n";
#$x = sprintf("%02X", $i);
#$octal = sprintf("%02o", $i);
#print "<td>$x</td>\n";
#print "<td>$bin[$i]</td>\n";
#print "<td>$octal</td>\n";
#print "</tr>\n";
print "<body background=\"nevada.gif\">\n";
#
#define stuff to grab data entered on form
#
require TripodCGI;
use CGI;
$cgi = new CGI;
#
# get the file name they want to list
#
$name=$cgi->param('name');
#
#
#open the file so we can read it and print it
#
exit;