Skip to content

Commit f355143

Browse files
committed
Merge branch 'master' of github.com:neu-rah/Dump
2 parents 17f13d8 + 977f500 commit f355143

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Dump
2-
version=1.0.0
2+
version=1.0.1
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=AVR dump RAM and Flash

src/Dump.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ unsigned char memBytePgm(const void* x) {return pgm_read_byte(x);}
66
void dump(Print& out,void const*at,int sz,unsigned char (*memByte)(const void*)) {
77
while(sz>0) {
88
out.print("0x");
9-
out.print(at<0x10?"000":at<0x100?"00":at<0x1000?"0":"");
9+
out.print((unsigned long)at < 0x10 ? "000" : (unsigned long)at<0x100 ? "00" : (unsigned long)at<0x1000 ? "0" : "");
1010
out.print((unsigned long)at,HEX);
1111
out.print(": ");
1212
for(int c=0;c<16;c++) {
1313
if (c==8) out.write(' ');
1414
if (sz-c>0) {
15-
unsigned char v=memByte(at+c);
15+
// Because ISO C forbids `void*` arithmetic, we have to do some funky casting
16+
void *memAddress = (void *)((int)at + c);
17+
18+
unsigned char v = memByte(memAddress);
1619
out.write(v>=32&&v<='z'?v:'.');
1720
} else out.write(' ');
1821
}
1922
out.write(' ');
20-
for(int c=0;c<16&&sz;c++,sz--,at+=1) {
23+
for (int c=0; c<16 && sz; c++, sz--) {
24+
// Because ISO C forbids `void*` arithmetic, we have to do some funky casting
25+
at = (void *)((int)at + 1);
26+
2127
if (c==8) out.write(' ');
2228
unsigned char v=memByte(at);
2329
out.print(v<16?"0":"");

0 commit comments

Comments
 (0)