home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 471 / rccl187 < prev    next >
Text File  |  1987-03-02  |  983b  |  41 lines

  1. /*
  2.  * BOOT                       Author :  Vincent Hayward
  3.  *                                      School of Electrical Engineering
  4.  *                                      Purdue University
  5.  *      Dir     : boot
  6.  *      File    : mkabo.c
  7.  *      Remarks : Read the stripped a.out file from the lsi11 loader and make
  8.  *                it downloadable, compute word count and checksum
  9.  *      Usage   : cc mkabo.c -o mybindir/mkabo
  10.  */
  11.  
  12. #include <stdio.h>
  13.  
  14. unsigned short header[8];
  15.  
  16. char buffer[28000];
  17.  
  18. main()
  19. {
  20.     short wc, *p;
  21.     short chks = 0;
  22.     register int bc;
  23.  
  24.     read(0, header, sizeof(header));
  25.     if(header[0] != 0407 || !header[7]) {
  26.         fprintf(stderr,"mkabo : bad input\n");
  27.         exit(1);
  28.     }
  29.     bc = read(0, buffer, 28000);
  30.     wc = bc / 2;
  31.     write(1, &wc, 2);
  32.     write(1, buffer, bc);
  33.     p = (short *)buffer;
  34.     while(wc--) {
  35.         chks += *p++;
  36.     }
  37.     write(1, &chks, 2);
  38.     fprintf(stderr, "size = %d (oct 0%o), chks 0%o\n", bc, bc, chks & 0xffff);
  39.     exit(0);
  40. }
  41.