unsigned long c=0,x=0,y=0;
/*ensure address and size are word-aligned */
address+=3;
address&=-4;
size+=3;
size&=-4;
if (SendCommand(AR_MEM_DUMP)) return 1;
ReadWrite32(address);
ReadWrite32(size);
printf("Writing to file... 0%%");
for (c=0; c < size; c+=4) {
y=ReadWrite32(0);
y=byteswap(y);
fwrite(&y,4,1,infile);
x+=y;
if (c & 0x400) printf("\b\b\b%2d%%",c*100/size);
}
printf("\b\b\bDone.\n");
/*confirm data valid*/
x&=0xFF;
y=ReadWriteByte(0);
if(x!=y) printf("Checksum invalid!\t%02X\t%02X\n",x,y);
return x!=y;
}
Bookmarks