// makesym.c                       1121                          7/25/98

// Get and combine addresses from "cleaned" "dis" file with assembly code
// from "cod" file.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

FILE *codefile;
FILE *disfile;
FILE *symfile;

char basename[10], filename[15], instring[100], numstring[6];
int n;

void main(int argc, char *argv[])
     {
     if(argc < 2) exit(1);
     
     strcpy(basename, argv[1]);
     
     sprintf(filename, "%s.dis", basename);
     disfile = fopen(filename, "rt");
     if(!disfile) exit(1);

     sprintf(filename, "%s.cod", basename);
     codefile = fopen(filename, "rt");
     if(!codefile)
          {
          fclose(disfile);     
          exit(1);
          }
     
     sprintf(filename, "%s.sym", basename);
     symfile = fopen(filename, "wt");     
     if(!symfile)
          {
          fclose(disfile);
          fclose(codefile);
          exit(1);
          }
     
     while(!feof(codefile))
          {
          fgets(instring, 100, disfile);
          for(n = 0; n < 4; n++)
               {
               numstring[n] = instring[n];
               }
               
          fgets(instring, 100, codefile);               
          fprintf(symfile, "%s %s", numstring, instring);
          }
          
     fclose(codefile);
     fclose(disfile);
     fclose(symfile);
     }
               