home *** CD-ROM | disk | FTP | other *** search
-
-
- *****Listing 6*****
-
-
-
- #define DOS_IMAGE 1024
- unsigned char dos_low_memory[DOS_IMAGE];
-
- unsigned short compute_image_checksum(start,length,copy)
- unsigned char * start;
- unsigned short length;
- unsigned char * copy;
- {
- unsigned char * end = start + length;
- unsigned short sum = 0;
-
- while(start < end)
- {
- if(copy)
- *copy = *start;
- sum += *start++;
- }
- return sum;
- }
-
- unsigned short check_image_checksum
- (where,start,length,oldsum,copy)
- {
- unsigned short sum;
- unsigned char * end = start + length;
-
- sum = compute_image_checksum(start,length,NULL);
- if(sum == oldsum)
- return 1;
- fprintf(stderr,
- "Checksum error at %s: "
- "%p/%ud(0x%4x), "
- "old %ux, new %ux\n",
- where, start, length,
- oldsum, sum);
-
- while(start < end)
- {
- if(*start != *copy)
- {
- fprintf(stderr,
- " %p: old: %02x, new: %02x\n",
- start, *copy, *start);
- }
- }
- }
-
- **********
-
-