Skip to content

Commit

Permalink
Merge pull request #2514 from douniwan5788/hexdump
Browse files Browse the repository at this point in the history
refactor: Optimize Dbhexdump
  • Loading branch information
iceman1001 authored Sep 16, 2024
2 parents e46024e + 0de7864 commit c9b1cc1
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions armsrc/dbprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,27 @@ void Dbprintf(const char *fmt, ...) {
// prints HEX & ASCII
void Dbhexdump(int len, const uint8_t *d, bool bAsci) {
#if DEBUG
char ascii[17];

while (len > 0) {

int l = (len > 16) ? 16 : len;

memcpy(ascii, d, l);
ascii[l] = 0;
if (bAsci) {
char ascii[17];

memcpy(ascii, d, l);
ascii[l] = 0;

// filter safe ascii
for (int i = 0; i < l; i++) {
if (ascii[i] < 32 || ascii[i] > 126) {
ascii[i] = '.';
// filter safe ascii
for (int i = 0; i < l; i++) {
if (ascii[i] < 32 || ascii[i] > 126) {
ascii[i] = '.';
}
}
}

if (bAsci)
Dbprintf("%-8s %*D", ascii, l, d, " ");
else
} else {
Dbprintf("%*D", l, d, " ");
}

len -= 16;
d += 16;
Expand Down

0 comments on commit c9b1cc1

Please sign in to comment.