- added PrintBuffer8() and memdump()
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@441 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -140,3 +140,75 @@ void print_word(int word)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
// PrintBuffer8()
|
||||||
|
// Prints byte buffer as hex and ascii interpretation
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
// _Parameters :
|
||||||
|
// pBuf: : IN: Buffer to display
|
||||||
|
// nbpr : Number of bytes per row to display
|
||||||
|
// len : Length of input buffer
|
||||||
|
// _Return: none
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len)
|
||||||
|
{
|
||||||
|
memdump(pBuf, 1, nbpr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len)
|
||||||
|
{
|
||||||
|
int i, j, cnt_hex, cnt_asc, base;
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
i = j = 0;
|
||||||
|
cnt_hex = len;
|
||||||
|
cnt_asc = len;
|
||||||
|
base = 0;
|
||||||
|
if (!print_offset_only)
|
||||||
|
base = (int)pBuf;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
print_word(base + i);
|
||||||
|
sputs(": ");
|
||||||
|
for (j=0; j < num_bytes_per_row; j++)
|
||||||
|
{
|
||||||
|
if (cnt_hex)
|
||||||
|
{
|
||||||
|
print_byte(pBuf[i+j]);
|
||||||
|
sputs(" ");
|
||||||
|
cnt_hex--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sputs(" ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sputs(" ");
|
||||||
|
for (j=0; j < num_bytes_per_row; j++)
|
||||||
|
{
|
||||||
|
if (cnt_asc)
|
||||||
|
{
|
||||||
|
c = pBuf[i+j];
|
||||||
|
if((c < 0x20) || (c > 0x7F))
|
||||||
|
c = '.';
|
||||||
|
|
||||||
|
_putchar(c);
|
||||||
|
cnt_asc--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sputs(" ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sputs("\n");
|
||||||
|
i += num_bytes_per_row;
|
||||||
|
|
||||||
|
} while (cnt_hex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ int write(int file, char *ptr, int len);
|
|||||||
int sputs(char *pStr);
|
int sputs(char *pStr);
|
||||||
void print_byte(char byte);
|
void print_byte(char byte);
|
||||||
void print_word(int word);
|
void print_word(int word);
|
||||||
|
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len);
|
||||||
|
void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len);
|
||||||
|
|
||||||
#endif // LIBSYS_H
|
#endif // LIBSYS_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user