2013-01-16 22:36:23 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
2013-01-17 02:49:25 +00:00
|
|
|
int byte,offset=0;
|
2013-01-16 22:36:23 +00:00
|
|
|
unsigned int total=0;
|
|
|
|
unsigned short checksum;
|
2013-01-17 02:49:25 +00:00
|
|
|
int debug=0;
|
2013-01-16 22:36:23 +00:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
byte=fgetc(stdin);
|
|
|
|
if (byte<0) break;
|
|
|
|
|
2013-01-17 02:49:25 +00:00
|
|
|
if (debug) {
|
|
|
|
if (offset==0xffdc) printf("%x\n",byte);
|
|
|
|
if (offset==0xffdd) printf("%x\n",byte);
|
|
|
|
if (offset==0xffde) printf("%x\n",byte);
|
|
|
|
if (offset==0xffdf) printf("%x\n",byte);
|
|
|
|
}
|
|
|
|
|
2013-01-16 22:36:23 +00:00
|
|
|
total+=byte;
|
2013-01-17 02:49:25 +00:00
|
|
|
offset++;
|
2013-01-16 22:36:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
checksum=total&0xffff;
|
|
|
|
|
2013-01-17 02:49:25 +00:00
|
|
|
printf("\t.word\t$%hx\t\t; Complement of checksum\n",~checksum);
|
|
|
|
printf("\t.word\t$%hx\t\t; Unsigned 16-bit sum of ROM\n",checksum);
|
|
|
|
|
2013-01-16 22:36:23 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-17 02:49:25 +00:00
|
|
|
|