Created
October 13, 2014 10:28
-
-
Save bjoern-r/b16b96f25c0e94f29bb1 to your computer and use it in GitHub Desktop.
simple hexdump function borrowed from (boundarydevices/imx_usb_loader)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void hexdump_bytes(unsigned char *src, unsigned cnt, unsigned addr) | |
{ | |
unsigned char *p = src; | |
int i; | |
while (cnt >= 16) { | |
printf("%08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", addr, | |
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); | |
p += 16; | |
cnt -= 16; | |
addr += 16; | |
} | |
if (cnt) { | |
printf("%08x:", addr); | |
i = 0; | |
while (cnt) { | |
printf(" %02x", p[0]); | |
p++; | |
cnt--; | |
i++; | |
if (cnt) if (i == 4) { | |
i = 0; | |
printf(" "); | |
} | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment