Skip to content

Commit

Permalink
Merge branch 'master' of github.com:neu-rah/Dump
Browse files Browse the repository at this point in the history
  • Loading branch information
neu-rah committed Mar 30, 2018
2 parents 17f13d8 + 977f500 commit f355143
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Dump
version=1.0.0
version=1.0.1
author=Rui Azevedo, [email protected]
maintainer=neu-rah, [email protected]
sentence=AVR dump RAM and Flash
Expand Down
12 changes: 9 additions & 3 deletions src/Dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ unsigned char memBytePgm(const void* x) {return pgm_read_byte(x);}
void dump(Print& out,void const*at,int sz,unsigned char (*memByte)(const void*)) {
while(sz>0) {
out.print("0x");
out.print(at<0x10?"000":at<0x100?"00":at<0x1000?"0":"");
out.print((unsigned long)at < 0x10 ? "000" : (unsigned long)at<0x100 ? "00" : (unsigned long)at<0x1000 ? "0" : "");
out.print((unsigned long)at,HEX);
out.print(": ");
for(int c=0;c<16;c++) {
if (c==8) out.write(' ');
if (sz-c>0) {
unsigned char v=memByte(at+c);
// Because ISO C forbids `void*` arithmetic, we have to do some funky casting
void *memAddress = (void *)((int)at + c);

unsigned char v = memByte(memAddress);
out.write(v>=32&&v<='z'?v:'.');
} else out.write(' ');
}
out.write(' ');
for(int c=0;c<16&&sz;c++,sz--,at+=1) {
for (int c=0; c<16 && sz; c++, sz--) {
// Because ISO C forbids `void*` arithmetic, we have to do some funky casting
at = (void *)((int)at + 1);

if (c==8) out.write(' ');
unsigned char v=memByte(at);
out.print(v<16?"0":"");
Expand Down

0 comments on commit f355143

Please sign in to comment.