/* File compacter.  This will compact files with multiple load segments. *//* It is useful for .COM files produced by C, and assembly language object files. *//* Binary file must not exceed 6K! (about 49 sectors) */char *buf,*begin,*end,*place,*endbuf,name[20];main() $(int iocb,tmp;  iocb=getread(name,"COM");  buf=0x5000;  endbuf=bgets(buf,0x6000,iocb)+buf;  if(getint(buf) != 0xFFFF) $(    printf("Not a binary file!\n");    getkey();    exit();  $)  buf+=2; /* get past the header */  place=buf;  while(1) $(    if((begin=getint(place))<0) break; /* end of file? */    end=getint(place+2); /* end of first module */    printf("\n%x - %x",begin,end);    tmp=(end-begin)+5+place;    if(tmp>=endbuf) break; /* end of file */    if(getint(tmp)==(end+1)) $( /* compact it */      printf("   Compacted");      *(place+2)=*(tmp+2);      *(place+3)=*(tmp+3);      move(tmp+4,tmp,endbuf-tmp);      endbuf-=4;    $)    else place=tmp;  $)  close(iocb);  copen(name,'w');  buf-=2; /* this is to get the header we discarde at the beginning */  iocb=bputs(buf,endbuf-buf,iocb);  close(iocb);  putchar(155);  slow();$)getint(where)char *where;$(  if(where>endbuf) return -1; /* end of the file */  return *where+(*(where+1)<<8);$)