/* load.c load S-records */ #include "defs.h" void load(void) { /* L */ /* The LOAD command moves object in "S" record format */ /* from an external device to either map of memory. */ /* Any line not beginning with an "S" is ignored. */ /* Loader terminates on 'SX' records */ int count, check, i, c, tmp, error,addrbyte; char *addr; error = 0; smallprintf("\nLoading"); while (1) { while (_inchar() != 'S') ; // drop c = _inchar(); switch (c) { case '0': case 'X': break; case '1': case '2': case '3': if (error) break; _outchar('.'); /* make something happen at tty */ addrbyte = c - (int)'1'+ 2; count = atohex(_inchar()) << 4; count += atohex(_inchar()); check = count; tmp = 0; for (i=0; i 0) { c = atohex(_inchar()) << 4; c += atohex(_inchar()); check += c; *addr++ = c; count--; } c = atohex(_inchar()) << 4; c += atohex(_inchar()); if (c != (~check & 0xFF)) { smallprintf("\nLoad checksum error at %X\n" ,tmp); error = 1; } break; case '7': case '8': case '9': while(1){ c = _inchar(); if((c=='\n')||(c=='\r') ) break ; /* skip */ } if (! error){ smallprintf("\nLoad Complete\n"); } return; } } }