home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * ut_dmem.c - dump memory in hex and ASCII.
- *
- * Purpose: This file contains a function to dump memory in hex and
- * ASCII.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include <stdio.h>
- #include "blackstr.h"
-
-
- /********
- *
- * ut_dump(memptr,nbytes) - dump memory to std output
- *
- **/
-
- void ut_dump(
- char *memptr, /* Pointer to start of memory to dump */
- int nbytes) /* Number of bytes to dump */
-
- {
- int i; /* Line counter */
- int j; /* Bytes on line (<= 16) counter */
- int k; /* Byte counter = 16*i + j */
- int n; /* Number of lines to output */
-
- n = nbytes/16 + 1;
-
- for (i = 0; i < n; i++) {
- for (j = 0; j < 16; j++) {
- k = 16*i + j;
- if (k < nbytes)
- printf("%02x ", memptr[k]);
- else
- printf(" ");
- }
- printf(" ");
- for (j = 0; j < 16; j++) {
- k = 16*i + j;
- if (k < nbytes) {
- if (memptr[k] >= 0x20 && memptr[k] <= 0x7e)
- printf("%c", memptr[k]);
- else
- printf(".");
- }
- }
- printf("\n");
- }
- }
-