add memdump()

This commit is contained in:
Laurent Vivier 2004-05-26 21:41:20 +00:00
parent 7d8654276a
commit c680062e0c
2 changed files with 30 additions and 0 deletions

View File

@ -56,3 +56,32 @@ void error(char *x)
while(1); /* Halt */
}
void memdump(unsigned char* addr, unsigned long size)
{
int i = 0;
int j;
while ( i < size)
{
printf("%08lx ", (unsigned long)addr + i);
for (j = 0; (j < 8) && (i + j < size); j++)
printf("%02x ", addr[i+j]);
printf(" ");
for (j = 8; (j < 16) && (i + j < size); j++)
printf("%02x ", addr[i+j]);
printf(" |");
for (j = 0; (j < 16) && (i + j < size); j++)
{
if ( (addr[i+j] > 31) && (addr[i+j] < 128) )
printf("%c", addr[i+j]);
else
printf(".");
}
printf("|\n");
i += j;
}
}

View File

@ -4,4 +4,5 @@
*
*/
extern void memdump(unsigned char* addr, unsigned long size);
extern void error(char *x);