1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include "icmun.h"
void process ()
{
register
OPCODE_ op;
register unsigned
i;
INT32
oldoffs;
static char
buf [200];
printf ("Binary file statistics:\n"
"\tstrings at offset\t%s\n" ,
hexstring ( (UNS16) headerp->offset[0], 4 ));
printf ("\tvariables at offset\t%s\n",
hexstring ( (UNS16) headerp->offset[1], 4 ));
printf ("\tfilenames at offset\t%s\n",
hexstring ( (UNS16) headerp->offset[2], 4 ));
printf ("\tfirst instruction at offset\t%s\n\n",
hexstring ( (UNS16) headerp->offset[3], 4 ));
if (nvar)
{
puts ("Variable section dump:");
for (i = 0; i < nvar; i++)
printf ("\tvariable %s: %s\n",
hexstring (i, 4),
varname (var [i].type));
putchar ('\n');
}
if (headerp->offset[0] < headerp->offset[1])
{
oldoffs = ftell (infile);
puts ("String constants dump:");
fseek (infile, headerp->offset[0], SEEK_SET);
while (ftell (infile) < headerp->offset[1])
{
fgetz (buf, 199, infile);
printf ("\t\"");
dumpstring (buf);
printf ("\"\n");
}
putchar ('\n');
fseek (infile, oldoffs, SEEK_SET);
}
puts ("Disassembled code:");
while ( (curoffs = (UNS16) ftell (infile)) < (UNS16) headerp->offset[0] )
{
if ( (op = getopcode (infile)) < op_hlt &&
op != -1
)
{
printf ("\t[%s] ", hexstring (curoffs, 4));
printf ("%s ", hexstring (op, 2));
procfun [op] ();
}
else
{
fprintf (stderr, "bad opcode at %s", hexstring (curoffs, 4));
error ("(opcode %s)", hexstring (op, 2));
}
}
putchar ('\n');
}
|